mesh: a cost model that can represent the request it is meant to refuse #70
Loading…
Reference in a new issue
No description provided.
Delete branch "mesh/context-cost-profile"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Ranked #2 by the 2026-08-29 sweep, which correctly described it as falsifying TX's own cost model.
For a backend whose per-token cost genuinely doesn't depend on the prefix, that's correct — and it stays expressible. For one that re-reads its context per token it isn't, and the error has a direction.
A linear model applied to a super-linear backend under-estimates, always, and the gap widens with context. At a gate, under-estimating means admitting work the ceiling cannot cover: the request passes, runs, and overruns — the one outcome a joule ceiling exists to prevent.
"Refuse a long-context route before it burns the budget" was a capability the docs implied and the code could not deliver. The test that now pins it shows the same backend, the same request — admitted under a flat profile, refused under a calibrated one.
The design
CostProfilecarries the shape: a fixed base, a flat per-token term, and µJ per token per 1024 tokens of context.CostProfile::linearreproduces the old arithmetic exactly.No profile ships as a default, deliberately. The context term is a property of a particular backend on particular hardware and must be calibrated by measurement there. The study that motivated this change used one model per attention condition, so architecture is confounded with model family and parameter count — lifting its slopes into a constant would inherit that confound and dress it as a fact. Same reason
BandingScaleships no canonical scale: the type expresses the shape, the operator supplies the numbers.Details worth stating
prompt_tokens. Output tokens extend the prefix as they're generated, so this stays a lower bound on a growing-context backend — deliberately, because the alternative is modelling that growth and then defending a second uncalibrated constant.is_context_aware()is inspectable, so a deployment gating long-context work can notice it's deciding with profiles that cannot represent the case.Backward compatibility is proven, not asserted
BackendSpec::newis unchanged in signature and behaviour, and re-runninggen-vectorsleaves the published vectors byte-identical on disk.The source paper is cite-only (arXiv non-exclusive licence, no code); nothing from it is reproduced here.
Verification
38 mesh-rs tests pass (6 new) · conformance passes · published vectors unchanged after regeneration · no clippy warnings in
mesh-router.