fix(cache): include scheduler occupancy in owner pressure - #55
fix(cache): include scheduler occupancy in owner pressure#55DavidBellamy wants to merge 3 commits into
Conversation
Signed-off-by: David <12414531+DavidBellamy@users.noreply.github.com>
|
Canary update from the isolated two-engine Kimi K3 run:
The capacity race is tracked in #56 and fixed with deterministic regressions in draft PR #57. This PR should remain draft until a combined canary image includes #57 and the same 76-way A/B completes. The balanced-engine estimate is promising, but there is no treatment throughput claim yet. |
Signed-off-by: David <12414531+DavidBellamy@users.noreply.github.com>
This reverts commit b828e2a.
|
Canary correction (2026-08-07): the first isolated M1 A/B did not execute this change. The control and nominal treatment images contained the same compiled The later legacy I am rebuilding the original treatment with a source-specific Cargo target and will require the embedded |
|
Corrected isolated M1 canary result (job The earlier A/B artifact was invalid because its nominal treatment and control images loaded the same compiled Runtime provenance in this run:
Workload and isolation:
Matched result:
Both arms completed 228/228 turns with zero terminal failures, 429 retries, retractions, or CUDA OOMs. The treatment made 10 bounded The fail-closed analyzer intentionally exited nonzero on three caveats, so I am keeping this PR in draft and am not recommending production activation yet:
The complete analyzer is at Next gates before merge/activation: code-owner review, fixed-trace or task-quality parity, then a multi-engine canary with admission enforcement rather than shadow mode. |
|
Enforced-admission follow-up (M1 job The 182.595 successful output tok/s/node shadow result above is real, but this PR is not sufficient for the current production admission path by itself. Source audit shows that HTTP adaptive admission runs before The five-node M1 follow-up reproduced the exact live state in two consecutive one-second gateway samples using the provenance-verified treatment binary:
Snapshot artifacts:
At that state the current EngineFeedback decision is deterministically I am deliberately classifying this as source-plus-live-state evidence, not an endpoint 429 measurement. The one-shot probe wrapper rejected a zero-retry CLI argument and the fail-closed cleanup stopped the gateway before a replacement raw probe could be sent. The harness is corrected for a future rerun; no production process was touched, and all five nodes returned idle. I also prototyped a distribution-headroom admission rule in an unpublished worktree. It bypasses both the waiter gate and a skewed learned knee only with complete per-replica load/cap telemetry, a distinct clean peer, and aggregate hard-cap headroom. Formatting/diff checks and 24 targeted Rust tests pass, including hot-owner/idle-peer, learned-knee, full-saturation, and incomplete-telemetry cases. It is not merge-ready: the admission controller cannot yet prove owner-pressure routing is enabled, and a one-request relaxation can close again as soon as the waiter clears. The safe design needs an explicit routing-policy opt-in plus a bounded one-in-flight seeding lease/cooldown. This PR should remain draft. Required next gate: couple distribution-aware admission to owner-pressure routing, then rerun the corrected enforced canary before code-owner review and activation. |
|
Safety hardening checkpoint after the 1191549 result The 182.595 successful output tok/s per serving node result remains valid for the isolated two-engine warm shared-prefix canary described above. It is not a production-readiness result. A recovered stack atop the exact PR #59 head now adds three fail-closed hardenings:
Local validation on the recovered exact tree:
Production remains NO-GO. The seed permit is process-local, so overlapping blue/green gateways or any other multiple-router topology can each mint one permit against the same workers. The next production prerequisite is a canonical shared per-partition lease acquired before the local permit and held through the seeded request lifetime. The implementation must then be split into independently reviewed capacity, routing-policy, and HTTP integration changes. No new commit, branch push, image, deployment, or production mutation was made for this checkpoint. The current hardened code is preserved only as an unapplied local patch against b75db35, SHA-256 d36fed8b722944eefa5d1f2be6bfccdba70ff5c465db6785565af483343849fb. |
|
Safety correction to my previous checkpoint: a subsequent audit found the local distribution-headroom prototype is NO-GO, even for the earlier singleton canary shape. |
|
Hardened-prototype checkpoint (2026-08-08) The corrected owner-pressure design is now frozen locally but remains unpublished, disabled, and production NO-GO.
The hardened proof boundary is narrow: one fresh singleton SMG process, one exact worker partition, controlled generation traffic, stable worker URLs, cold routing state, mesh disabled, owner-tree eviction disabled, trusted partition header overwritten by Comet, and A separate The fair-share boundary remains unchanged: PR #59 is the generic scheduler-slot lease, Comet draft PR smg-project#596 owns fair-share ordering, and this throughput-side design owns per-worker issuable headroom plus target-constrained selection, verification, and refund/fail-closed. Neither dependency should be activated from this checkpoint. The 182.595 output tok/s/node result remains diagnostic only until the hardened route is rebuilt and rerun. No production mutation occurred. |
|
Final exact-source validation checkpoint (2026-08-08) The hardened prototype remains unpublished as a PR and disabled by default.
Independent review found no fair-share bypass. The special path requires an exact one-shot PR #59 authorization, then independently constrains and revalidates worker URL, generation, revision, telemetry, cache policy, and load transfer before dispatch. Comet PR smg-project#596 therefore remains the upstream fair-share/order owner; this route is subordinate to it. Production is still NO-GO. In addition to process-local permits and missing backend-KV eviction/tombstones, review found that ordinary cold bootstrap records an owner before backend success, and standard OpenAI streams may omit the usage proof required for owner commit. A narrow canary is only conditionally eligible after a clean image build, with exactly one gateway/no overlap, a prewarmed proved owner, non-stream requests, one partition/model, The correct publication path is the documented decomposed stack, not this 6,364-line prototype as one PR. The 182.595 output tok/s/node result remains diagnostic evidence only until the exclusive design is rebuilt and rerun. No production mutation occurred. |
Description
Problem
Cache-aware engine-load routing currently defines pressure as the larger of KV token usage and utilization. A Kimi K3 engine can therefore remain a suitable cached owner while its scheduler is full and has a large waiting queue, so cache affinity keeps feeding that owner while other healthy engines stay idle.
On the observed M2 workload, hot owners reached the 37-request cap with up to 116 waiting requests while most of the 50-engine pool was idle. This PR only changes routing pressure. It does not change adaptive-admission ordering or enable the feature in production.
Solution
Include scheduler occupancy in per-worker pressure when every healthy candidate reports a positive max-running cap for every DP rank:
pressure = max(token_usage, utilization, (running + waiting) / max_running)The existing 90% high watermark, 10-point owner slack, replication ceiling, cooldown, and provisional-owner coalescing remain unchanged. If any candidate has missing, partial, or stale cap telemetry, the entire decision falls back to the existing backend pressure. This avoids false spills from incomplete multi-DP caps and from SGLang Prometheus fallback counts that may be duplicated across TP ranks.
Refs #11.
Changes
Test Plan
Local verification:
cargo +nightly fmt --all -- --checkgit diff --checkcargo test -p smg policies::cache_aware --lib(53 passed)cargo test -p smg --lib(1,477 passed, 5 ignored)The repository-wide
cargo clippy --all-targets --all-features -- -D warningsremains blocked on the unchanged base by existing Rust 1.94 lint failures and this Mac's missingpkg-config/OpenCV dependency. Repository-widecargo testalso fails compiling existingopenai-protocolbuilder tests that omit theotherfield. Neither failure touches this diff.Before production use, run an isolated M2 routing canary on the same TP16 engines and growing-prefix trace:
Checklist
cargo +nightly fmtpassescargo clippy --all-targets --all-features -- -D warningspasses (blocked by unchanged base and local OpenCV tooling, detailed above)