fix(cluster): apply AlphaFloor in dial calibration sweep#781
Conversation
computeDialCalibration recorded mix breakpoints on unfloored alpha while live routing floors via applyDialAlpha, wasting dial travel on unreachable crossovers and flattening QualityBias on floored bundles (v0.72+). Signed-off-by: N Rohith Reddy <rohithreddy2202@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
|
PR author is not in the allowed authors list. |
Keep workweave#779 why-comments to ≤2 lines so the advisory comment-length check stays quiet. Signed-off-by: N Rohith Reddy <rohithreddy2202@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
|
Thank you so much for this contribution, @rohith500 — the fix itself is exactly right, and the floored-bundle regression coverage is genuinely thorough. 🙏 We've rewritten it to match the repo's internal conventions in #788 (your logic and tests are preserved verbatim, with credit to you). The only change: AGENTS.md's comment rule ("Concise comments, sparingly … never reference current task/PR/caller") — comments like Please don't take this as a knock on your work — these conventions are internal, evolving, and honestly not obvious from the outside. The engineering here was great: shared |
Bug
computeDialCalibrationrecords QualityBias mix-change breakpoints by sweeping unfloored uniform alpha, but live routing appliesalpha[i] = max(dialToAlpha(t), floor[i])viaapplyDialAlpha.On floored bundles (v0.72–v0.74,
latest= v0.73), roughly the first half of the dial produces an identical model mix / projected cost — the same “50% looks like 20%” failure #479 fixed, reintroduced when #501/#515 added floors without retargeting the calibration sweep.CI did not catch it:
TestRoutingDistribution_NoDeadZoneand mid-vs-low cost guards pin on v0.67, which ships noalpha_floor.Reproduction (v0.73, 21-point
RoutingDistribution)Fix
Extract shared
applyAlphaFloor(alpha[i] = max(raw, floor[i]);floor == nildisables) and call it from both:computeDialCalibration— sweep raw uniform alpha through the floor before recording mix breakpointsapplyDialAlpha— request-time / distribution path (same policy as before, now shared)After the fix on v0.73:
Bundles without
alpha_floor(v0.67) keep the previous calibration behavior.Tests
TestRoutingDistribution_NoDeadZone_FlooredBundle— v0.73: no long consecutive identical-mix runTestRoutingDistribution_MidDialIsPricierThanLowDial_FlooredBundle— v0.73: cost(0.5) ≥ 1.2× cost(0.2) (floored span is tighter than v0.67’s 1.5×)TestComputeDialCalibration_NoBreakpointsBelowMinFloor— no interior breakpoint belowmin(AlphaFloor)TestComputeDialCalibration_HeterogeneousFloorSynthetic— different per-cluster floors; no breakpoint in(0, minFloor)TestApplyAlphaFloor_NilAndHeterogeneous— nil floor + per-slot floor behaviorNoDeadZone/ mid-vs-low guards unchanged (backward-compat path)Full package:
go test ./internal/router/cluster/ -count=1green.Closes #779