Repository navigation
Scheduler load metrics: a server-owned load ledger in /metrics and GET /v1/load - #1655
Conversation
GB10 receiptEnvironment. One NVIDIA GB10 (DGX Spark), Ubuntu 24.04.5, kernel 6.17.0-1032-nvidia, driver 580.178.04, nvcc 13.4.92, Zig 0.17.0. Two builds with Before and afterA fresh server each round with
The branch's cold prompt is about 0.3% slower at every size, and the reversed pair shows it too, so it does not come from the run order. That is 1.5 to 18 ms on 0.4 to 6.7 s. I have not found its cause yet. The ledger on a served engineThis branch, prompt cache on as served. 12 unique 4.2K-token chat requests (a nonce first),
Parked engine
A problem this found. Not runThe paged census (GLM-5.3-Flash on two ranks) and requeues under memory pressure were not reached by this engine and load. macOS was not built. |
Follow-up: the parked fix on GB10, and the cold-prompt gapSame machine, checkpoint, settings and client host as the receipt above. Parked, with the fix (
|
| cycle | engine values gone, parked 0, /health 503 |
parked 1 |
close window | wake |
|---|---|---|---|---|
| 1 | 17.26 s | 18.09 s | 0.83 s | 0 refusals, reloaded in 14.4 s |
| 2 | 17.02 s | 17.85 s | 0.83 s | 0 refusals, reloaded in 14.6 s |
| 3 | 16.81 s | 17.64 s | 0.83 s | 0 refusals, reloaded in 14.5 s |
During the close window, /v1/load has no engine groups and parked: false, and /metrics renders no requests_running, requests_waiting or generation_tokens_running, so a shaper reads the node as unknown and does not send its wake. The wake, sent as soon as parked read true, succeeded each time with the same instance, and requests_started_total was 1 after it. In cycle 1, one 0.2 s sample read /v1/load with engine groups and /metrics already from the stub: the two routes were read a few milliseconds apart, the park in between.
The cold-prompt gap
Twelve fresh servers with --prompt-cache-gib 0, in the order base, branch, diag, diag, branch, base, base, branch, diag, branch, diag, base. diag is 2731719db with the ledger's publish at each host unlock turned off, a test build only. ttft_s from bench_cache.py --require-cold --tokens 16 on the same exact token arrays; every request had 0 cached tokens, and every reply's token_sha is the same at each size. The rounds drift up by 1.2 ms (8K) and 7.3 ms (32K) a round; the differences below are after that trend, with a permutation test over the 4 + 4 rounds:
| prompt tokens | base mean | branch mean | diag mean | branch − base | p | diag − base | p |
|---|---|---|---|---|---|---|---|
| 8,192 | 1443.5 ms | 1445.4 ms | 1447.5 ms | +2.2 ms (+0.15%) | 0.60 | +3.8 ms | 0.37 |
| 32,768 | 6667.6 ms | 6684.8 ms | 6694.8 ms | +19.0 ms (+0.28%) | 0.20 | +25.3 ms | 0.17 |
The receipt's six rounds gave +0.29% (p 0.20) and +0.21% (p 0.30) by the same method. The branch is slower in all four, but no run separates it from the round-to-round spread, and diag, with less ledger work on the prompt path, is not faster than the branch. So the gap is not the per-unlock publish. The other prompt-path updates are one host lock and a few integer updates per 4,096-row chunk call, microseconds against the 2 ms per chunk that 0.3% at 32K would take. I leave it as an unexplained difference of at most 0.3%, within the noise at this sample size.
|
Thanks @laudney. We'll take this, with Your receipts and ours so far are clean: Qwen3.6 and Qwen3.8-27B on a GB10 and Flash Next on an M3 Ultra show the same tokens and speed within noise. Two checks are left before it lands: GLM-5.3-Flash at TP=2 on two GB10s, and a quiet re-run of one Nemotron cell on the M3 Ultra (4-stream greedy chat read 3% low once while other work was running there). We'll post both here. |
|
Both checks are back, @laudney, and both are clean:
It lands in our next batch, with |
lane_host.zig sat at 596 of its 600 lines, and the load ledger needs call sites there. The warm pass moves to lane_host_warm.zig and the LaneMemory requeue joins the other job endings in lane_host_end.zig, with no change in behavior; the lane host is now 541 lines.
A traffic shaper needs scheduler load that survives engine reloads and never shows a closed host's values. The ledger holds server values, route-group activity and the groups a host publishes through an epoch-checked producer handle, which the new optional load vtable entry hands out; detach is synchronous and folds counters into a base.
A shaper must tell a parked engine from an idle one and see which model routes are busy. The server now owns the load ledger, attaches the serving engine at startup and reload, detaches before every close, counts model requests by route group, and renders identity, parked state, lanes and every ledger group beside the existing families, with engine gauges left out while the engine is parked.
A shaper needs request counts, queued prompt tokens and lane give-ups that agree in one read. Each lane host unlock now publishes its counts when they changed, with requeues after LaneMemory and background passes that yield to foreground work counted apart; the lane and Flash Next hosts no longer report a constant zero preemption count, and memory_lanes changes only under the host lock.
A shaper derives the prefill rate from adjacent counter deltas, so tokens and time must move together as the work happens. The lane host now counts computed, restored and decoded tokens and times each backend prompt call for the pass inside it; a pass moves its time into the busy counter only with its own tokens, a batch counts once, and addStreams reports which prompts completed before a failure.
A collector that computes deltas wants every value from one instant. GET /v1/load returns the whole ledger from one read, leaves out the keys of groups no host fills, and follows the /metrics access rule: read-scoped keys reach it and --metrics-open opens it. docs/api.md documents the scheduler load families and the preemption meaning.
A shaper needs lane and KV headroom, and must not read a missing pool as an empty one. The core page pool now notifies once per outermost change; the generic CUDA host reports window mode without a page plan, and paged mode with the pool a family names, in tokens. GLM names rank 0's pool, and the census reaches the ledger at attach and after every change without the lane host lock.
A reuse hint set fill_at before the backend confirmed the restore, so filling_prompt_tokens_left could fall below the work still to do, and the fallback scrape body reported generation_tokens_running as zero while a closing host still held generated tokens. A pass now records when its start is settled and counts fill progress only from then, began shows the fill under the lock whose unlock publishes it, so a blocking prefill is seen from its start, and the fallback body takes the status read's generated tokens.
On a GB10 the ledger read parked while the idle unload was still closing the engine, and a wake sent then got 503 "still unloading", so a shaper that wakes a node on engine_parked lost its request. The park now detaches with parked false before the close and marks the ledger parked only where it moves to unloaded, under the manager lock the reload also takes, and the scrape's fallback body hides the stub's zero counts during the close, so that window reads unknown, not idle. The harness attaches its fake engine as serve does, and a gated close checks both surfaces before and after it ends.
2731719 to
52aebf3
Compare
|
Thank you @laudney. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in 1.2.1, credited to you in the changelog and the release notes. |
|
Thanks @laudney! |
What this changes
/metricsand a newGET /v1/loadpublish the scheduler load a traffic shaper needs, from one ledger the server owns: the server's identity and process instance, whether--idle-unloadhas parked the engine, model requests in progress by route group, queued prompt tokens, requests requeued for memory and background passes that yielded, per-mode scheduler tokens counted as the work happens with the engine time of their prompt calls, and on CUDA the KV mode, free lanes and GLM-5.3-Flash's page pool in tokens. A group an engine cannot count is left out, never shown as zero, and while the engine is parked no engine value is shown. The lane host and the Flash Next host no longer publishpreemptions_total 0as a constant. No scheduling, admission or arithmetic changes. Closes #1558.The questions in #1558 are still open. This is one series of eight commits in the delivery order the issue gives; I can split it into a stack, move the JSON under a stable
/stats, or add vLLM-name mirrors, whichever you prefer.lane_host.zig(595 to 556) for the call sites; no behaviour changecore/load_ledger.zig: groups, producer handles that drop writes once detached, one snapshot readserver_info{model,backend,version,instance},process_start_time_seconds,engine_parked,lanes,http_requests_active{route}requests_runningandrequests_waitingfrom the ledger,waiting_prompt_tokens,filling_prompt_tokens_left,requests_started_total,requests_requeued_total,background_yields_totalscheduler_tokens_total{mode}(prefill_compute,prefill_cache,decode),prefill_busy_seconds_totalGET /v1/load, under the/metricsaccess rule, thereadscope and--metrics-openkv_capacity_mode{mode},lanes_free,kv_pool_{capacity,available,reclaimable,promised}_tokens{pool},kv_pool_run_available; the pool reports each promise, take, release and evictionfilling_prompt_tokens_leftcounts only from a settled start; the fallback body keeps the generated-token gaugeThe
docs/api.mdsection "Scheduler load" lists every family. A changelog line, if it helps:Receipt
mainatf350cd3ea, Zig 0.17.0, Linux x86_64. No GPU was used: the CUDA binary was built, not run.zig build test441/441 steps succeeded, 181/183 tests passed, 2 skipped;zig build test-golden322/335 equal to server goldens, 0 unexpected differences;zig build test-kv-poolandzig build nativesucceed;zig fmt --check zig/srcis clean;tools/zig/lean_check.pyreports 426 problems onf350cd3eaand 426 on this branch, so it adds none. TheFAILlines in thetestoutput are the same 94 lines thatmainprints. New tests: ledger (busy time as a union, counters kept across park and reload, writes through a detached handle dropped), renderer (each group whole or absent, the parked body, fixed route groups at zero), lane host (requeues, yields, shutdown cancels,running,waitingandwaiting_prompt_tokensconsistent in every snapshot), pool (available + promised + taken == capacityafter every transition) and/v1/loadaccess and scopes.flashnext_host.zig, the removed constant. Each commit built and passed the host suite on the earlier base; onf350cd3eaonly the head was tested.atc overlapfinds one textual conflict, with deepseek: fail fast on a lost CUDA context and on stalled engine operations #1646 inzig/src/core/lane_host.zig: both add aLaneHostfield afterpressure. Whichever lands second takes both lines; the merged file stays at or below 600 lines.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (Not run on a GPU; no token path changes.)SUMMARYline is in the receipt. (No kernel changed.)