eoc-route-learned: recommend the stage cheapest in expectation, not the likeliest #439

Merged
dcharlot merged 2 commits from fix/eoc-route-cheapest into main 2026-11-01 09:38:36 -05:00

2026-10-22

Transaction Science
eoc-route-learned: pin the classifier's self-reinforcement and MF's confidence
All checks were successful
standards workspaces build + test / which workspaces this change touches (pull_request) Successful in 6s
repository checks / lockfiles, tests in CI, workflow hygiene, spec and section references, public text (pull_request) Successful in 35s
standards workspaces build + test / eoc-rs (eoc/eoc-rs, -p eoc-meter --features cuda, eoc-rs, linux) (pull_request) Successful in 2m42s
standards workspaces build + test / macOS energy backends (pull_request) Successful in 8m14s
Two mutants of the previous commit survived: a correct result on the
predicted stage itself no longer reinforcing it, and MF reporting a fixed
confidence. Each now has a test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 07:19:34 -04:00
Transaction Science
eoc-route-learned: recommend the stage cheapest in expectation, not the likeliest
The crate says a learned router "predicts the cheapest stage that is likely
to satisfy the query". Three of its four routers recommended the stage
likeliest to succeed: MF and both bandits took an argmax over success, and
the bandits ignored the joule cost `observe` passed them. Neural succeeds on
everything and costs the most, so they learned to send every query there.
The synthetic LinUCB test pinned exactly that as the goal.

- router: `expected_joules` prices a skip the way LearnedCascade dispatches
  it (Kv or Graph falling through to Neural, Neural alone, Cache as the full
  walk), and `cheapest_in_expectation` picks the least. A broken probability
  prices a stage dearer, never cheaper. `observe` is the outcome of one
  stage that ran, with that stage's own joules.
- MF picks by that rule over its per-stage chances and learned costs.
- LinUCB and Thompson learn each stage's cost and pick by the rule over
  optimistic and sampled chances. Confidence is the mean belief, not the
  bound or sample used to explore. Older saved states import with the
  default costs.
- train_logreg labels each query with its cheapest successful stage; the
  classifier's online update no longer reinforces a correct stage costlier
  than the one it predicts.
- evaluate replays each recommendation over per-stage outcomes. It charged
  every row's own cost whatever the router chose and priced the walk at 4x
  that, so every router showed a lift of 3x its spend. A query it cannot
  price is counted unscored, not charged zero, and joules_per_correct is
  None when nothing was correct.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 07:16:10 -04:00