PR #5024 (4 of 6, reviewed against #5023) · reviewed at ea1a6e22, re-checked at 9df434a7 (the reviewed files are unchanged since d2e22762) · review still pending
Two pages on this PR, one question each. This one: what the PR changes compared with PR 3.
persist KV mode, so suspend and resume leave the KV memory, the block allocator and the pinned blocks alone. Dotted words have a short explanation: hover or tap them.Example fleet: 1 prefill engine P0 and 2 decode engines D0, D1. Each row is one operation in MegatronDynamoGeneration, PR 3 on the left, this PR on the right. Boxes in one column run at the same time; arrows mean "then".
Refit suspend · driver process
# driver, MegatronDynamoGeneration.suspend_for_refit call_engines(all engines, suspend) # PR 3: one wave call_engines(prefill, suspend) # each wave: Ray calls in parallel call_engines(decode, suspend) # no wait for pinned blocks on failure: resume every engine the suspend reached # then re-raise
Shutdown · driver process
# driver, MegatronDynamoGeneration.shutdown for engine in engines: stop(engine) # PR 3: index order owners = read handoff owner from each decode rank 0 # ≤600 s for d in decode: stop(d) # one at a time for owner in owners: # C3: one Ray call per owner prefill0.confirm_decode_terminated(owner) # ≤ 600 + 10 s each for p in prefill: stop(p) # frees every pinned block anyway stop frontend, NATS, etcd
Real code: PR 3 shutdown, PR 4 shutdown, _confirm_decode_terminated.
The 600 s is today's default dynamo_cfg.control_timeout_s. C1 removes that key (following #4801 C9), so the caller's timeout or a fixed shutdown constant takes its place. The problem does not depend on the number: each report still waits its full timeout, one after another.
🔴 review comment C3 — dynamo_generation.py:1381
An earlier commit in this PR paused prefill, waited for decode to pull every pinned block, then suspended. A later commit (ef48e301) removed the wait, because with a deep decode backlog the pins did not drain for over an hour. The worker pieces stayed: pause_for_refit, a paused flag read in four places, and pinned_handoff_block_count. Only tests call them, here and in PRs 5 and 6. The class docstring, the PR title and the PR body still describe the wait.
The fix changed after the review of PR 2. #4912 C7 asks PR 2 to rewrite the worker's _sleep/_wake: every wait for an engine state gets a timeout, and wake looks at the engine's real state instead of a saved flag. So C4 asks this PR to take PR 2's version of those four functions as it is, not to restore the older untimed one or keep this PR's own change to when the flags are set.
🔴 review comment C4 — megatron_worker.py:2492 C5 — dynamo_generation.py:307 C6 — PR body
Take 500 prefill and 500 decode engines. vLLM, plain Megatron and TRT-LLM's own prefill/decode mode on main each keep every engine's workers in one worker group, so each step is one wave: send the call to every worker, then wait once (run_all_workers_single_data, TRT-LLM P/D wake and sleep). A wave costs as long as its slowest engine, however many engines there are. This PR keeps one wave for the weight transfer, the KV rebuild and the resume: _call_engines sends every call before it waits on any. Three steps don't:
| Step | This PR | Cost at 1,000 engines | Ask (review comment) |
|---|---|---|---|
| Suspend | a prefill wave, then a decode wave (L911-L923) | slowest prefill + slowest decode: up to 2 waves, not a cascade | One wave. The order only existed so prefill could pause while decode drained the pins (PR body, "Refit ordering"), and ef48e301 removed that wait. The PR's own resume docstring says no order is needed in persist mode, and the two facts it uses hold on the way down too: a suspended prefill engine still serves pulls, and a handoff to a sleeping decode engine is queued. |
| Startup | GPU reservation and a node-IP lookup per engine, one by one (L1197); then rounds of 8 (L1246) | The PR's own comment: 64 engines one at a time took about 2 h, about 110 s each. 1,000 engines = 125 rounds × at least 110 s ≈ 3.8 h, more whenever one engine in a round is slow. | Reserve and start every engine at once, as RayWorkerGroup does for its workers, then wait once. If a limit is needed, use a pool that starts the next engine as soon as any one finishes, not rounds. |
| Shutdown | one engine at a time: decode (L1409), one report per decode engine, then prefill (L1424) | 1,000 stops back to back; a hung endpoint adds up to 600 s each | After C3 deletes the report, no role order is left to keep: stop every engine at once, as VllmGeneration.shutdown does (one cleanup call per worker, at most 30 s, then kill). On main, worker_group.shutdown stops a whole group in one wave. |
🔴 review comment C9 — suspend in one wave C10 — build at once C11 — stop every engine at once
persist mode, and records the weight version per token. For the same reason it doesn't need to be an order at all: suspend can be one wave, like resume. The PR should drop the shutdown report step (C3) and the leftover pause code (C4), and fix the docs (C5, C6). At 1,000 engines the real cost is startup (hours, in rounds of 8) and shutdown (one engine at a time); startup should be one wave, and so should shutdown, as on main.