Repository navigation
feat(vllm): support generation-prefix cuts with multiple HTTP frontends - #5267
Conversation
955c92c to
dd52a6e
Compare
dd52a6e to
67c4c0c
Compare
terrykong
left a comment
There was a problem hiding this comment.
Re-review after the rebase onto main. The earlier comments are rewritten for this head.
This PR lets prefix-level rollout recovery run with several HTTP frontends. Gym's generation-cut call reaches one frontend, which runs the cut on its own calls, asks every other frontend over a loopback control port to do the same, and merges the answers into one receipt. The setup-time refusal for multiple frontends is gone, and each child frontend now gets the cut settings.
Thanks for moving the shared pieces into one module used by both the native frontends and Dynamo (merge_cut_receipts, durable_prefixes, local_deadline), for sharing the token check between both routes (_refusal), and for the late-frontend test. The earlier C3 (stalled peer frontend) is now covered by test_generation_cut_fan_out_merges_without_a_late_frontend.
- (C1) Child frontends never get
media_family, so VLM capture with more than one frontend fails at setup; no test checks this dict. - (C2) No CI run does prefix recovery with more than one frontend; add 2 HTTP servers to the existing L1 prefix-recovery run and make it prove another frontend restored a call.
- (C5) Each cut logs a false "cannot cut completed model call" warning for every call another frontend holds.
- (C6) The PR description still describes the earlier claims design and its benchmark numbers; rewrite it and rerun the numbers.
- (C7) One frontend slower than aiohttp's 300 s timeout fails the whole cut, because this copy of Dynamo's fan-out loop catches fewer errors; share one helper.
Visual explainer: https://terrykong.github.io/gh-pages-poc/terryk/pr-5267-many-frontends-cut.html
nemo-rl-review: kind=expert harness=claude-code/2.1.332 model=claude-opus-5-5 effort=medium review-pr-team=v3 reviewed=67c4c0c
With http_api_server_count > 1, every frontend accepts from one shared socket, and a model call's decoding state lives only in the frontend that accepted its request. Gym's single cut call reached one frontend, which could not cut the others' calls, so #5074 rejected prefix cuts there. Cut across frontends the way the Dynamo frontend cuts across engines. Each frontend also listens on a loopback control port. The frontend Gym's call reaches runs FrontendCutFanOut: it runs its own run_cut and posts the inventory, with one wall-clock deadline, to every other frontend's new /ng-control/v1/generation-cut/frontend route. Each answers with the durable acks of the calls it cut, and merge_cut_receipts fails any call no frontend cut, so it regenerates after a restore. A frontend that does not answer by the deadline claims nothing. merge_cut_receipts and CUT_REPLY_MARGIN_S move from the Dynamo cut module to generation_cut_route.py, beside new durable_prefixes and local_deadline helpers that the Dynamo engine adapter now uses too. The owner hands every frontend the others' control URLs after start-up, forwards the cut settings and prefix write/read limits to children with the capture command, and fans out obsolete-row flushes and per-frontend prefix counts. Each frontend runs its own write pipeline and writer actor. A single frontend keeps the existing cut path. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Anish Mahishi <[email protected]>
- Send child frontends every setup_token_capture keyword argument, including media_family, which a VLM capture needs; a test now checks the forwarded settings against the method's signature. - Cut with held_only on every fan-out participant (HTTP frontends and Dynamo engines): each answers only for the calls it holds, cut or not, so frontends no longer warn about each other's calls. The merge prefers a cut ack, fails any call no engine holds, and warns once per cut about those calls only. - Share one fan_out_cut between FrontendCutFanOut and Dynamo's EngineCutFanOut: one deadline, late targets named, merge in target order. A peer frontend's request no longer has aiohttp's 300 s timeout and catches any error, so one slow or failing frontend costs only its own calls instead of failing the whole cut. - Log the calls each peer frontend cut. The L1 prefix-recovery run now uses two HTTP frontends, and its snapshot selection requires a restored call that the other frontend cut. - Document the per-frontend prefix-writer actor's CPU cost. Signed-off-by: Anish Mahishi <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
67c4c0c to
1bdac8e
Compare
|
/ok to test 1bdac8e |
main d040a22 brings NVIDIA-NeMo#4801 (Megatron prefill/decode behind Dynamo), which adds its own disagg_layout.py with a subset of this branch's helpers, plus NVIDIA-NeMo#5267 (prefix counts per HTTP frontend) and NVIDIA-NeMo#5158 (multi-harness). - disagg_layout.py: this branch's module, with main's replica_width_from and main's plan_engines (ValueError instead of assert, role-count check). validate_disagg_entrypoint lets megatron + dynamo through to its own checks. - trtllm/config.py, trtllm_generation.py, grpo.py: keep the shared-module wrappers of this branch. - vllm_generation.py: fan the per-frontend prefix counts out per engine. - nemo_gym.py: pass both forward_session_id_as_conversation_id and multi_harness. Signed-off-by: Shiki Wu <[email protected]>
What and why
Problem. #5074 added several vLLM HTTP frontends per worker (
vllm_cfg.http_api_server_count > 1) but rejected them with prefix-level rollout recovery (rollout_recovery.target_level: prefix). All frontends accept from one shared socket, and a model call's decoding state lives only in the frontend that accepted its request. Gym sends one generation-cut request per backend per checkpoint, which reaches one frontend, so every call on the other frontends would regenerate after a restore.Change. The frontend that Gym's cut reaches fans it out to the others and returns one merged receipt, as the Dynamo frontend already does across engines (
EngineCutFanOut).sequenceDiagram participant Gym participant C1 as child 1 (reached by Gym) participant Own as owner participant C2 as child 2 Gym->>C1: POST /ng-control/v1/generation-cut (inventory) par one deadline for every frontend C1->>C1: run_cut(held_only=True) and C1->>Own: POST /generation-cut/frontend (inventory, deadline), loopback Own->>Own: run_cut(held_only=True) Own-->>C1: acks of the calls it holds and C1->>C2: POST /generation-cut/frontend (inventory, deadline), loopback C2->>C2: run_cut(held_only=True) C2-->>C1: acks of the calls it holds end C1->>C1: merge_cut_receipts (a call no frontend holds fails) C1-->>Gym: one GenerationCutReceipt127.0.0.1:0. The owner collects every frontend's URL (children return theirs fromstart) and sends the list to all of them (peers). The port opens wheneverhttp_api_server_count > 1, even with cuts off, because frontends start beforesetup_token_capturedecides on cuts.FrontendCutFanOut(generation_cut_route.py) runs this frontend's cut and POSTs the inventory and one wall-clock deadline to every peer's new/ng-control/v1/generation-cut/frontendroute, which takes the same control bearer. A peer that errors or misses the deadline answers nothing, so its calls regenerate; the checkpoint never fails on it. It sharesfan_out_cutwith Dynamo'sEngineCutFanOut: wait to one deadline, cancel and name late targets, merge in target order.held_only. Every frontend gets the whole inventory. Withrun_cut(..., held_only=True), a frontend cuts only the calls it runs or has a finished record of, answers with an ack for each of them (cut, or a failure it logged itself) and says nothing about the rest.merge_cut_receipts, shared with Dynamo, prefers a cut ack over a failure for the same call, gives any call no frontend holds a failure ack, and logs one warning per cut naming the first few. A call that has not started decoding is held, so it does not trip that warning. Dynamo engines now passheld_only=Truetoo, so they no longer warn once per call held by another engine.setup_token_capture's keyword arguments to each child (media_family, the cut settings, the prefix batch limits).flushreaches the children, and the driver sums prefix counts per frontend (get_generation_prefix_counts_per_frontend). Restores need no coordination: any frontend reads the prefix from TQ.PrefixWritePipelineand, on a TransferQueue data plane, its own prefix-writer actor, which needs 1 free CPU on the generation node: N frontends use N writer CPUs per worker. Each frontend also looks up every inventory call, including the ones it does not hold.A single frontend keeps the existing path: Gym's cut runs
run_cuton it directly. No Gym change and no new config keys.CI coverage. The L1 prefix-recovery run (
L1_Functional_Tests_SingleController_3.sh, score-centering variant) now runs withhttp_api_server_count=2. Its snapshot selection requires a restored call that the other frontend cut, read from the fan-out's per-peer log line, so the test cannot pass with every call on one frontend.Issues
Follows #5074. Supersedes #5261.
Convergence / perf / functionality proof
The earlier numbers were measured on the previous design and are removed.
test_vllm_token_capture_hosting.py,test_prefix_write_pipeline.pyandtest_prefix_writer_actor.py205 passed; cut-route tests intest_vllm_generation.py16 passed;test_vllm_multi_api.pyandtest_gym_prefix_recovery_parity.py50 passed;test_vllm_captured_call_progress.py19 passed;test_dynamo_vllm_adapter_capture.py13 passed;test_dynamo_generation_cut.py2 passed.grpo_async_gym_single_controller_prefix_recovery.shwith its score-centering overrides andhttp_api_server_count=2, passed in 447 s:gym_parked_seconds, average of the four snapshots that cut the most callsgym_parked_secondsis Gym's prepare/commit and the TQ save, not the cut. The 1-frontend run's 1.17 s cut is one outlier; its other large cuts took 0.19–0.26 s.Needs upstream changes
None
PR commands and CI
CI:Lfast: the default for most PRs. Runs a fast test subset.CI:L1: dependency or container changes (pyproject.toml,uv.lock,Dockerfile) or broad core changes. Builds a new image and runs unit and functional tests.CI:docs: docs-only changes. Runs doc tests only./ok to test <full-commit-sha>: start CI for that commit. Post again after each push./review: automated review comments. Addmode=strictfor a stricter review,reset=truefor a fresh full review./resolve-conflict: Autobot mergesmaininto this PR and resolves the conflicts. PRs from forks must allow edits by maintainers./review-pr-team <pr-number>for a team review before you ask for human review.🤖 Generated with Claude Code