Repository navigation
Conversation
…ric)
load_based ranks prefill workers by request count, but prefill time follows
the uncached prompt tokens, so two workers with equal counts can carry very
different work. --load-based-metric tokens (default requests, unchanged)
ranks them by prompt tokens still to prefill.
Engine
- num_waiting_uncached_tokens counts the waiting and bootstrap queues,
discounted by the matched prefix and by the queried L3 hit
(get_pending_storage_hit_end), plus the chunked and round-robin
remainders.
The L3 hit stays discounted after the fetch completes and before
admission: cache mode keeps the parked span start even when a concurrent
fetch already inserted the whole prefix, buffer mode reads the staged
prefetch.
- New cumulative total_prefill_input_tokens: prompt tokens prefilled, cache
hits included. It advances with total_prefill_uncached_tokens under the
same step gate and is appended to the LoadStat wire array, so older
routers ignore it.
Router
- Pending tokens per worker: the engine snapshot when every candidate
reports, plus this replica's dispatches since the snapshot scaled by the
worker's cold ratio; otherwise router-tracked in-flight tokens for all.
- Cold ratio: EMA over 200k-token windows of the engine's uncached / input
counter deltas, clamped to [0.01, 1]. Both counters cover every router
replica. Engines without the input counter leave in-flight tokens raw.
- Gate: workers whose request count exceeds the fleet minimum by more than
--load-based-token-slack (default 8) are not picked. Token loads within
--load-based-token-tie-band (default 16384) tie and rank by request count.
The gate is exposed as an eligibility filter, so fused / score_policy /
Pipeline compositions cannot score a gated worker back in.
- Routing uses a text estimate of the prompt length instead of a full
encode; capacity admission keeps exact lengths. /v1/responses keeps the
body-size estimate, since the text estimate reads chat messages only.
Observability
- /metrics adds per prefill worker: sgl_router_worker_engine_load_fresh,
sgl_router_worker_engine_load_age_seconds,
sgl_router_worker_pending_prefill_tokens{source} and
sgl_router_worker_prefill_cold_ratio. Pending tokens follow the routing
source: source="engine" (engine_pending_prefill_tokens) only when every
prefill worker of the worker's models is fresh, otherwise
source="local" with router in-flight tokens. The cold ratio is
absent until the first window closes. Computed at scrape time; the
cold ratio is read without feeding the estimator.
- The pending-prefill debug log adds snapshot_age_ms.
Also fixes two stale test fixtures on dev: the idle-step Scheduler fixture
now sets enable_chunked_prefill_round_robin, read by
reset_prefill_ready_seq_if_idle(); test_load_inquirer derives its totals
from the queue list after the demotion revert dropped one queue.
chencjcj
force-pushed
the
feat/v0.5.21-router-loadbase-token-1104
branch
from
November 4, 2026 07:42
b2b996a to
a2ae340
Compare
Nozom1ff
added a commit
that referenced
this pull request
Nov 7, 2026
…vation v0.5.23 (sgl-project#44401) made get_num_allocatable_reqs give back the rows that counted requests already hold, and the admission loop now passes the continuation's row. The replayed HRRN chunk-limit reservation (#99) still asked for the cap without it and then subtracted the continuation again, so with free rows binding it reserved budget for one short request fewer than the pass admits (none at one free row). Co-Authored-By: Claude <[email protected]>
Nozom1ff
added a commit
that referenced
this pull request
Nov 7, 2026
The per-node MLA host tests (ported with the #99-#105 net diff) still passed v0.5.23's mamba_layer_mapping/use_mla and unpacked two values; the day-0 assembler takes start_layer and returns (group, controller, config). The pool-host mocks are unchanged and still need a run on GPU. Co-Authored-By: Claude <[email protected]>
Nozom1ff
added a commit
that referenced
this pull request
Nov 7, 2026
sgl-project#46977 moved PrefillAdder.rem_mamba_slots onto memory_budget.rem_state_slots, but reservable_new_reqs (our #99 HRRN chunk-limit reservation) still read the removed attribute. The merge was clean, so it surfaced only at runtime: AttributeError: 'PrefillAdder' object has no attribute 'rem_mamba_slots' the first time HRRN admits new requests next to a chunked continuation, which kills the prefill scheduler under load. Read rem_state_slots from the budget instead; budgets without state slots have no such attribute and keep no mamba cap, as before. Update the unit test that set the removed attribute. Co-Authored-By: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
load_basedranks prefill workers by request count, but prefill time follows the uncached prompt tokens, so two workers with the same count can carry very different work. This adds--load-based-metric tokens(defaultrequests, unchanged), which ranks prefill workers by prompt tokens still to prefill.Rebased from
feat/v0.5.21-router-loadbase-token(based oninfrawaves/prod/v0.5.21) ontoinfrawaves/dev/v0.5.21@4e30be7dba.Engine
num_waiting_uncached_tokenscounts the waiting and bootstrap queues, discounted by the matched prefix and the queried L3 hit, plus the chunked and round-robin remainders. The L3 hit stays discounted after the fetch completes and before admission: cache mode keeps the parked span start even when a concurrent fetch already inserted the whole prefix; buffer mode reads the staged prefetch.total_prefill_input_tokens(prompt tokens prefilled, cache hits included), appended to the LoadStat wire array so older routers ignore it.Router
--load-based-token-slack(default 8) excludes workers whose request count exceeds the fleet minimum by more than the slack.--load-based-token-tie-band(default 16384) treats token loads within the band as tied and ranks them by request count. The gate is an eligibility filter, so fused / score_policy / Pipeline compositions cannot score a gated worker back in./v1/responseskeeps the body-size estimate, since the text estimate reads chatmessagesonly.tokensrequires the legacy chat routing path; startup fails under--chat-routing reorg.Observability
New per-prefill-worker gauges on
/metrics, computed at scrape time:sgl_router_worker_engine_load_freshsgl_router_worker_engine_load_age_secondssgl_router_worker_pending_prefill_tokens{source}engineonly when every prefill worker of the model is fresh, otherwiselocalsgl_router_worker_prefill_cold_ratioRebase conflicts
chat/preparation.rs: kept dev's Responses handling, and kept Responses off the text estimate (see above). Covered byresponses_token_count_keeps_body_size_estimate.chat/reorg.rs: dev's comment plus the newprepareargument.tests/proxy/pd_bootstrap_injection.rs: took dev's version.Testing
cargo clippy --all-targets -- -D warnings: clean.cargo test --lib: 833 passed.cargo test --test component: 114 passed.render_paritywas skipped because it needs model snapshots.cargo test --test proxy: 163 passed.caller_ids_fan_out_and_rejected_streams_do_not_abortwas skipped because it hangs; it also hangs on the base branch.test_storage_prefetch_lifecycle.py,test_loadstat_wire.py,test_disagg_idle_step_counters.py,test_load_inquirer.py): 80 passed.enable_chunked_prefill_round_robin(added by feat: add round-robin scheduling for chunked PD prefill #26), and the demotion revert left two6totals for 5 queues.Not verified