mixle.inference.orchestration module¶
Learned orchestration from telemetry.
The static placement policy decides local-versus-pool execution from rules.
LearnedPolicy can improve that decision from historical telemetry rows
of the form (features, choice, outcome). For a new feature vector it looks
up nearby historical decisions, estimates which choice had lower realized cost,
and uses the learned choice only when there is enough comparable evidence.
When the nearby history is sparse or ambiguous, the policy defers to the static fallback. Promotion is a separate operation: it requires isolated realized holdout outcomes, common support, paired or propensity-aware evaluation, and an uncertainty-adjusted improvement threshold.
- class LearnedPolicy(keys, vecs, choices, costs, static, mean=<factory>, scale=<factory>, k=8, min_neighbors=4, margin=0.02)[source]
Bases:
objectA history-based placement policy that defers to a static teacher where it lacks evidence.
- Parameters:
- decide(features)[source]
Return
(choice, learned)– the learned pick when confident, else the static fallback.
- evaluate(rows, *, cost_key='cost')[source]
Compare policies on the same contexts with actually observed action costs.
A context contributes only when both the learned and static selected actions have realized outcomes in the supplied holdout panel. No training-neighbor estimate is substituted for a missing outcome.
- class LearnedAcquisition(keys, vecs, values, static, mean=<factory>, scale=<factory>, k=8, min_neighbors=4)[source]
Bases:
objectA history-based action scorer for the reasoner: learns which actions pay off, else defers.
Drop-in for
mixle.substrate.act.score_action()(call it asscorer=policyininvestigate). Fromroutetelemetry – each row a fired action’s(features={kind,cost,overlap}, value)– it estimates the expected yield of an action in a query’s feature region and scores ityield / cost. Where nearby history is too thin, it falls back to the static lexical scorer. This is an abstention rule, not a guarantee that learned decisions are never worse.- Parameters:
- learn_action_policy(rows, static_scorer=None, *, value_key='value', k=8, min_neighbors=4)[source]
Learn a reasoner acquisition policy from
routetelemetry(features, kind, outcome)rows.static_scoreris the fall-back when history is thin (defaultmixle.substrate.act.score_action()).value_keynames the outcome field to MAXIMIZE (default"value"– did the action yield evidence). Returns aLearnedAcquisitionusable directly asinvestigate(..., scorer=policy).
- learn_placement_policy(rows, static_policy, *, cost_key='cost', k=8, min_neighbors=4)[source]
Learn a placement policy from telemetry
(features, choice, outcome)rows (see module docstring).static_policymaps a feature dict to a choice and is the fall-back when history is too thin.cost_keynames the outcome field to minimize (default"cost"). Feature standardization and the neighbor index are built from the rows;LearnedPolicy.decide()andevaluatefollow.
- learn_schedule_policy(rows, static_policy, *, latency_key='latency', k=8, min_neighbors=4)[source]
Learned pool scheduling (J4): when work is pool-eligible, learn where and when it actually runs fastest.
The same evidence-gated shape as placement, keyed on realized latency instead of dollar cost: rows are
(features, choice, outcome)where features describe the moment (queue depth, job size, local load), choice is the scheduling decision (“run_local” / “queue_pool” / “defer”), and the outcome’slatencyis what the decision actually cost in wall-clock. Where nearby history is thin, the returned policy defers to the static scheduler.
- meta_improve(rows, static_policy, *, holdout_rows=None, cost_key='cost', holdout_frac=0.3, seed=0, k=8, min_neighbors=4, propensity_key='propensities', min_propensity=0.05, min_overlap=0.8, confidence_level=0.95, min_improvement=0.0)[source]
Learn from telemetry and promote only with isolated, supported holdout evidence.
Repeated outcomes for the same feature context are kept in one split. Evaluation first uses paired realized outcomes when both policies’ selected actions were observed for the same context. If a complete propensity map is logged instead, inverse-propensity evaluation is available. Promotion requires minimum overlap and the one-sided confidence bound on
learned - staticto beat the requested improvement threshold. Returns:{promoted, policy, receipt: {learned_mean_cost, static_mean_cost, mean_cost_difference, upper_confidence_bound, overlap_fraction, n}}
policyis learned only when promoted; otherwise it is exactlystatic_policy. The receipt records either decision.