Skip to content

[None][fix] Fix gen-only async kvtransfer hang - #17107

Open
reasonsolo wants to merge 4 commits into
NVIDIA:mainfrom
reasonsolo:fix/python-mamba-cache-headroom
Open

[None][fix] Fix gen-only async kvtransfer hang#17107
reasonsolo wants to merge 4 commits into
NVIDIA:mainfrom
reasonsolo:fix/python-mamba-cache-headroom

Conversation

@reasonsolo

@reasonsolo reasonsolo commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Description

When no requests are scheduled, the PyExecutor forward pass is skipped. Previously, this could also skip checking completed context-side KV transfers, leaving the context request incomplete and its cache resources unreleased. With
max_batch_size=1 and concurrency 2, the second request then remains blocked, causing a deadlock.

This change detects idle iterations from the scheduled batch and polls context transfer status regardless of TRTLLM_DISABLE_KV_CACHE_TRANSFER_OVERLAP. The regression test runs context and generation workers on one GPU with batch size
1 and two concurrent Mamba requests.

Test Coverage

  • Without idle polling: request times out and the test fails.
  • With the fix: both requests complete and the test passes.

PR Checklist

  • PR description clearly explains what and why.
  • PR follows TensorRT-LLM coding guidelines.
  • Test cases cover new code paths.
  • No API changes or new dependencies.

Dev Engineer Review

  • Updated PyExecutor to poll completed context-side KV transfers during idle iterations.
  • Preserved synchronous generation-transfer behavior.
  • Added idle-state handling to PP and non-PP scheduling paths.
  • Added a disaggregated Mamba configuration for context and generation workers sharing one GPU.
  • Added support for separate context and generation environments.
  • Added GPU allocation reset between worker groups.
  • Updated idle-transfer unit-test expectations.
  • Added the mamba_bs1_concurrency2 QA entry.
  • No public API declarations changed.
  • No unrelated scope changes were identified.

QA Engineer Review

  • Added test_disaggregated_mamba_bs1_concurrency2.
  • Updated synchronous idle-transfer tests.
  • Added return annotations to two benchmark disaggregation tests.
  • The Mamba regression test sends two concurrent completion requests with batch size 1.
  • The test uses separate context and generation workers on one GPU.
  • The Mamba test is covered in tests/integration/test_lists/qa/llm_function_core.txt.
  • Verdict: sufficient.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The executor now receives scheduled-batch idle state for disaggregated transfer checks. Integration coverage adds separate worker environments, optional GPU sharing, and a concurrent Mamba test with its YAML configuration and QA registration.

Changes

Disaggregated transfer and Mamba concurrency flow

Layer / File(s) Summary
Context-transfer progress handling
tensorrt_llm/_torch/pyexecutor/py_executor.py, tests/unittest/_torch/executor/test_py_executor.py, tests/unittest/_torch/executor/test_benchmark_disagg.py
PP and non-overlap execution paths pass idle state to transfer checks. Context transfers are checked during idle iterations. Synchronous generation transfers continue to skip generation progress collectives. Unit tests verify the expected collectives and polling behavior.
Separate worker environments and GPU allocation
tests/integration/defs/disaggregated/test_disaggregated.py
Cluster setup accepts context and generation environments. Optional GPU sharing resets generation allocation to device zero.
Mamba concurrency regression coverage
tests/integration/defs/disaggregated/test_configs/disagg_config_mamba_bs1_concurrency2.yaml, tests/integration/defs/disaggregated/test_disaggregated.py, tests/integration/test_lists/qa/llm_function_core.txt
Adds the Mamba disaggregated configuration, concurrent completion test, response checks, and QA test-list entry.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Executor
  participant TransferProgressHelper
  participant ContextTransfer
  Executor->>TransferProgressHelper: pass scheduled-batch idle state
  TransferProgressHelper->>ContextTransfer: poll context-transfer progress during idle iteration
  ContextTransfer-->>TransferProgressHelper: report completed transfers
  TransferProgressHelper-->>Executor: return transfer-progress result
Loading

Possibly related PRs

Suggested reviewers: qijune, yiqingy0

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description explains the hang, the fix, regression coverage, and checklist status; it is mostly complete despite omitting some non-critical checklist items.
Title check ✅ Passed The title follows the required format and clearly identifies the fix for the generation-only asynchronous KV-transfer hang.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/unittest/_torch/executor/test_mamba_cache_manager.py (1)

58-86: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add annotations to the changed test functions.

Annotate all changed test functions and fixture parameters. Use enable_attention_dp: bool and -> None for the unit tests. Add a precise type for monkeypatch and -> None for the integration test.

  • tests/unittest/_torch/executor/test_mamba_cache_manager.py#L58-L86: annotate enable_attention_dp and both test return types.
  • tests/unittest/_torch/executor/test_mamba_cache_manager.py#L153-L157: add the test return type.
  • tests/integration/defs/accuracy/test_disaggregated_serving.py#L2170-L2170: annotate monkeypatch and the test return type.

As per coding guidelines, “Annotate every function.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unittest/_torch/executor/test_mamba_cache_manager.py` around lines 58 -
86, Annotate the changed test functions: in
tests/unittest/_torch/executor/test_mamba_cache_manager.py lines 58-86, add
enable_attention_dp: bool and -> None to both tests; at lines 153-157, add ->
None to the test. In
tests/integration/defs/accuracy/test_disaggregated_serving.py line 2170, add the
precise type for monkeypatch and -> None to the integration test.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/integration/defs/accuracy/test_disaggregated_serving.py`:
- Around line 2178-2179: Update the test setup around the existing monkeypatch
environment configuration before launch_disaggregated_llm() to remove inherited
UCX_NET_DEVICES and set TRTLLM_NIXL_NUM_THREADS to "1"; apply the same
deterministic settings to both server-role setup blocks, including the
corresponding lines around 2211-2219.

---

Nitpick comments:
In `@tests/unittest/_torch/executor/test_mamba_cache_manager.py`:
- Around line 58-86: Annotate the changed test functions: in
tests/unittest/_torch/executor/test_mamba_cache_manager.py lines 58-86, add
enable_attention_dp: bool and -> None to both tests; at lines 153-157, add ->
None to the test. In
tests/integration/defs/accuracy/test_disaggregated_serving.py line 2170, add the
precise type for monkeypatch and -> None to the integration test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 80a49c2d-a76f-46fa-ad4a-c0caa76f6988

📥 Commits

Reviewing files that changed from the base of the PR and between 8e602fa and 5cfad04.

📒 Files selected for processing (5)
  • tensorrt_llm/_torch/pyexecutor/mamba_cache_manager.py
  • tests/integration/defs/accuracy/test_disaggregated_serving.py
  • tests/integration/test_lists/test-db/l0_dgx_b200.yml
  • tests/unittest/_torch/executor/test_mamba_cache_manager.py
  • tests/unittest/disaggregated/test_mamba_transfer.py

Comment thread tests/integration/defs/accuracy/test_disaggregated_serving.py Outdated
@reasonsolo
reasonsolo force-pushed the fix/python-mamba-cache-headroom branch from 5cfad04 to f9fa76c Compare July 31, 2026 04:48
@reasonsolo

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62982 [ run ] triggered by Bot. Commit: f9fa76c Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62982 [ run ] completed with state FAILURE. Commit: f9fa76c
/LLM/main/L0_MergeRequest_PR pipeline #51090 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@longlee0622

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64593 [ run ] triggered by Bot. Commit: 431fc0a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64593 [ run ] completed with state SUCCESS. Commit: 431fc0a
/LLM/main/L0_MergeRequest_PR pipeline #52454 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@reasonsolo

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64622 [ run ] triggered by Bot. Commit: 431fc0a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64622 [ run ] completed with state SUCCESS. Commit: 431fc0a
/LLM/main/L0_MergeRequest_PR pipeline #52482 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@reasonsolo

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64746 [ run ] triggered by Bot. Commit: 431fc0a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64746 [ run ] completed with state SUCCESS. Commit: 431fc0a
/LLM/main/L0_MergeRequest_PR pipeline #52593 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

Signed-off-by: Lizhi Zhou <1432185+reasonsolo@users.noreply.github.com>
Signed-off-by: Lizhi Zhou <1432185+reasonsolo@users.noreply.github.com>
Signed-off-by: Lizhi Zhou <1432185+reasonsolo@users.noreply.github.com>
@reasonsolo
reasonsolo force-pushed the fix/python-mamba-cache-headroom branch from 431fc0a to 91da83a Compare August 8, 2026 04:26
@reasonsolo

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64757 [ run ] triggered by Bot. Commit: 91da83a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64757 [ run ] completed with state FAILURE. Commit: 91da83a
/LLM/main/L0_MergeRequest_PR pipeline #52606 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@reasonsolo

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64775 [ run ] triggered by Bot. Commit: 91da83a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64775 [ run ] completed with state FAILURE. Commit: 91da83a
/LLM/main/L0_MergeRequest_PR pipeline #52619 completed with status: 'UNSTABLE'

CI Report

⚠️ Multi-GPU Label Required:
Multi-GPU tests require the ci: full pre-merge approved label on this PR. Ask a member of NVIDIA/trt-llm-ci-approvers to add the label, then re-trigger CI with the same bot command (no rebase needed).

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@reasonsolo

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64789 [ run ] triggered by Bot. Commit: 91da83a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64789 [ run ] completed with state FAILURE. Commit: 91da83a
/LLM/main/L0_MergeRequest_PR pipeline #52632 completed with status: 'UNSTABLE'

CI Report

⚠️ Multi-GPU Label Required:
Multi-GPU tests require the ci: full pre-merge approved label on this PR. Ask a member of NVIDIA/trt-llm-ci-approvers to add the label, then re-trigger CI with the same bot command (no rebase needed).

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@reasonsolo

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

Signed-off-by: Lizhi Zhou <1432185+reasonsolo@users.noreply.github.com>
@reasonsolo

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64827 [ run ] triggered by Bot. Commit: 000515e Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64827 [ run ] completed with state SUCCESS. Commit: 000515e
/LLM/main/L0_MergeRequest_PR pipeline #52669 completed with status: 'UNSTABLE'

CI Report

⚠️ Multi-GPU Label Required:
Multi-GPU tests require the ci: full pre-merge approved label on this PR. Ask a member of NVIDIA/trt-llm-ci-approvers to add the label, then re-trigger CI with the same bot command (no rebase needed).

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

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.

9 participants