Skip to content

[None][fix] Disagg: keep the KV handshake id on generation retries; do not let one wedged receive park a rank - #19802

Merged
zongfeijing merged 1 commit into
NVIDIA:feat/rl_rcfrom
zongfeijing:user/zongfeij/disagg-gen-retry-handshake-fix
Oct 2, 2026
Merged

zongfeijing merged 1 commit into
NVIDIA:feat/rl_rcfrom
zongfeijing:user/zongfeij/disagg-gen-retry-handshake-fix

Conversation

@zongfeijing

Copy link
Copy Markdown
Collaborator

Description

Two production disaggregated runs (2P4+1D16, attention-DP generation engine, Python/NIXL transceiver) each lost about ten minutes of training to the same chain, visible in the Gym timeline as 30-35 generation requests on one rank waiting 300-600 s in the "generation queue" and all being scheduled in the same iteration.

  1. The frontend's generation leg hit a transient Server disconnected and was retried. OpenAIHttpClient._post_with_retry regenerated disagg_request_id on every retry, for both legs. For a generation leg that id is the KV handshake the context worker registered its send session under when prefill finished, so the retried request asked for KV under an id nobody held: the sender parked the REQUEST_DATA for a session that never came (_respond_with_kv -> _save_peer_req_info, the gen-first path), the generation request sat in DISAGG_GENERATION_TRANS_IN_PROGRESS, and both sides waited out kv_transfer_timeout_ms (600 s): Observed timeout on context request ... elapsed 601353ms, Observed timeout on generation request ... elapsed 600006ms, HTTP 500 Request timed out (KV transfer).
  2. Meanwhile the stuck receive kept its blocks in DisaggTransferAdmissionController's budget (max_tokens_in_buffer, by default max_seq_len). Admission is FCFS, so the first gen-init candidate on that rank that no longer fit next to it stopped admission for every candidate behind it, however small, until the timeout cancelled the head. In both runs the first parked request is exactly the first candidate larger than the remaining budget (22896 + 44297 and 31435 + 35588 prompt tokens against a 65536-token window).

Changes:

  • serve/openai_client.py: regenerate disagg_request_id only for context_only retries (they re-run prefill and need a fresh id); a generation retry keeps the handshake id.
  • _torch/disaggregation/orchestration/admission.py: a generation receive in flight for longer than TRTLLM_DISAGG_ADMISSION_STALE_TRANSFER_S (default 30 s, 0 disables) stops counting toward the transfer window and is reported separately; the first exclusion is logged once with the receive's age. It still ends through kv_transfer_timeout_ms. 30 s sits above the slowest healthy receives seen (first contact between a context and a generation rank at cold start, 10-20 s without a warm-up phase) and far below the timeout.
  • _torch/disaggregation/transceiver.py: a second generation request for a handshake that already has a live receive is failed through the transfer-error path instead of being left in DISAGG_GENERATION_INIT, where it would be re-admitted every iteration with no transfer to time out. Re-submitting the request that owns the receive stays a no-op.
  • _torch/disaggregation/native/transfer.py: the context sender remembers retired send-session ids for 120 s (bounded) and answers a REQUEST_DATA naming one of them with FAILED instead of parking it, so the requester fails fast. Ids it has never seen are still parked for the gen-first flows that ask before the session exists.

Test Coverage

Run in the production image with these four modules overlaid:

  • tests/unittest/_torch/disaggregation/test_disagg_coordinator_admission.py, tests/unittest/disaggregated/test_disagg_openai_client.py, tests/unittest/disaggregated/test_transfer_ownership_regressions.py, tests/unittest/disaggregated/test_transceiver_bounded_polling.py, tests/unittest/disaggregated/test_openai_disagg_service.py, and the disagg/admission/transfer subset of tests/unittest/_torch/executor/test_py_executor.py: all passing.
  • A 2P4+1D16 generation-only rollout smoke (NeMo Gym / OpenHands agents, 30 turns, two rollout steps) passes with no transfer errors.

PR Checklist

Please review the following before submitting your PR:

  • PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.

  • PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.

  • Test cases are provided for new code paths (see test instructions)

  • If PR introduces API changes, an appropriate PR label is added - either api-compatible or api-breaking. For api-breaking, include BREAKING in the PR title.

  • Any new dependencies have been scanned for license and vulnerabilities

  • CODEOWNERS updated if ownership changes

  • Documentation updated as needed

  • Update tava architecture diagram if there is a significant design change in PR.

  • The reviewers assigned automatically/manually are appropriate for the PR.

  • Please check this after reviewing the above items as appropriate for this PR.

…o not let one wedged receive park a rank

Two production runs (2P4+1D16, attention-DP generation engine) each lost ~10 minutes
of training to the same chain:

1. The frontend's generation leg hit a transient "Server disconnected" and was retried.
   OpenAIHttpClient._post_with_retry regenerated disagg_request_id on every retry, for
   both legs. For a generation leg that id is the KV handshake the context worker
   registered its send session under when prefill finished, so the retried request
   asked the context side for KV under an id nobody held: the sender parked the
   REQUEST_DATA for a session that never came, the generation request sat in
   DISAGG_GENERATION_TRANS_IN_PROGRESS, and both sides waited out
   kv_transfer_timeout_ms (600 s). Regenerate the id only for context_only retries,
   which re-run prefill and need a fresh one.

2. The stuck receive kept its blocks in DisaggTransferAdmissionController's budget
   (max_tokens_in_buffer, by default max_seq_len). Admission is FCFS, so the first
   gen-init candidate on that rank that no longer fit next to it stopped admission
   for every candidate behind it, however small, until the timeout cancelled the
   head: 30-35 requests queued 300-600 s and were released in one iteration. A
   receive in flight longer than TRTLLM_DISAGG_ADMISSION_STALE_TRANSFER_S (default
   10 s, 0 disables) now stops counting toward the window; it still ends through
   kv_transfer_timeout_ms, and the first exclusion is logged once.

3. Two safety nets for a duplicate attempt that does reach both sides: a second
   generation request for a handshake that already has a live receive is failed
   through the transfer-error path instead of being left in
   DISAGG_GENERATION_INIT, where it would be re-admitted every iteration with no
   transfer to time out; and the context sender answers a REQUEST_DATA naming a
   send session that already ended with FAILED instead of parking it (retired ids
   are remembered for 120 s, bounded), so the requester fails fast. Unknown ids
   are still parked for the gen-first flows that ask before the session exists.

Signed-off-by: Zongfei Jing <[email protected]>
@zongfeijing
zongfeijing force-pushed the user/zongfeij/disagg-gen-retry-handshake-fix branch from c81308c to 8c3bd3c Compare October 2, 2026 07:56
@zongfeijing
zongfeijing merged commit 6c6303b into NVIDIA:feat/rl_rc Oct 2, 2026
jepio added a commit to NVIDIA-NeMo/RL that referenced this pull request Oct 2, 2026
shuyixiong pushed a commit to shuyixiong/TensorRT-LLM that referenced this pull request Oct 6, 2026
…o not let one wedged receive park a rank (NVIDIA#19802)

Signed-off-by: Zongfei Jing <[email protected]>
@zongfeijing
zongfeijing deleted the user/zongfeij/disagg-gen-retry-handshake-fix branch October 27, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant