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. This keeps learned orchestration an incremental optimization around a known policy rather than an unbounded replacement.
- 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:
- vecs: ndarray
- costs: ndarray
- mean: ndarray
- scale: ndarray
- k: int = 8
- min_neighbors: int = 4
- margin: float = 0.02
- decide(features)[source]
Return
(choice, learned)– the learned pick when confident, else the static fallback.
- 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: the same never-worse discipline asLearnedPolicy, now on the reasoner’s acquisition decisions (J3).- Parameters:
- vecs: ndarray
- values: ndarray
- mean: ndarray
- scale: ndarray
- k: int = 8
- min_neighbors: int = 4
- 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/WHEN it actually runs fastest.
The same never-worse 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, *, cost_key='cost', holdout_frac=0.3, seed=0, k=8, min_neighbors=4)[source]
The meta-improve loop (J5): learn from telemetry, PROMOTE only on a never-worse holdout receipt.
Splits the telemetry into train/holdout, learns a policy on the train slice, and evaluates it against the static policy on the HELD-OUT decisions (realized cost, the same currency the platform pays). The learned policy is promoted iff its held-out mean cost is <= the static policy’s – the receipt is returned either way, so a non-promotion is auditable, not silent. Returns:
{promoted, policy, receipt: {learned_mean_cost, static_mean_cost, deferred_fraction, n}}
policyis the learned policy when promoted, else the static one wrapped for the same call shape – callers can always use the result’s policy and get never-worse behavior by construction.