mixle.task.economics module¶
The cost arithmetic that decides whether to spend the GPU: distill-and-serve-local vs. cascade vs. frontier.
GPU time is not free, so every routing choice is an economic one. This module turns the conformal escalation
rate (mixle.task.calibrate.CalibratedTaskModel.escalation_rate(), the empirical p_escalate) and a few
unit costs into dollars:
frontier-only – pay
c_frontierfor every request, forever.local-only – distill once (
n_labelteacher calls + training), then payc_localper request.cascade – run the cheap local model first, escalate only the ambiguous fraction: per request
c_local + p_escalate * c_frontier, with the singletons covered at1 - alpha.
break_even_volume() is the request count at which a distilled route pays back its one-time setup;
recommend_route() picks the cheapest route at a given volume (optionally constrained to a maximum tolerated
escalation rate) and reports the savings. This is the “is it worth it?” question answered with a number.
- class CostModel(c_frontier, c_local=0.0, c_label=0.0, train_cost=0.0)[source]
Bases:
objectUnit costs (any consistent currency).
c_localis the amortized local per-request cost (~0 on CPU).- c_frontier: float
- c_local: float = 0.0
- c_label: float = 0.0
- train_cost: float = 0.0
- cascade_cost_per_request(cost, p_escalate)[source]
Expected per-request cost of the cascade: always run local, escalate the
p_escalatefraction.
- break_even_volume(cost, n_label, *, p_escalate=0.0)[source]
Requests after which a distilled route undercuts frontier-only (
infif it never does).Setup is amortized against the per-request saving
c_frontier - per_request(route). Withp_escalate=0this is the local-only break-even; pass the model’s escalation rate for the cascade break-even.
- class RoutePlan(route, volume, per_request, total, savings_vs_frontier, p_escalate, break_even, options)[source]
Bases:
objectThe costed comparison of routes at a given volume, with the recommended choice and its savings.
- Parameters:
- route: str
- volume: int
- per_request: float
- total: float
- savings_vs_frontier: float
- p_escalate: float
- break_even: float
- recommend_route(cost, *, volume, n_label, p_escalate, max_escalation=None)[source]
Pick the cheapest route over
volumerequests; honor an optional cap on tolerated escalation.local_onlyis treated as a cascade with no escalation only when its quality is acceptable to the caller – here it is offered whenevermax_escalationis not exceeded byp_escalate(the cascade already answers the easy cases locally and escalates the rest, so it dominates pure local-only on accuracy; local-only is kept as the floor cost when escalation is disallowed entirely,max_escalation == 0).