Skip to content

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

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

[None][fix] Fix gen-only async kvtransfer hang#17107
reasonsolo wants to merge 1 commit 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 the existing behavior for synchronous generation-transfer workers.
  • Kept generation-progress checks for asynchronous workers.
  • Added idle-state handling to both PP and non-PP scheduling paths.
  • Added a disaggregated Mamba configuration for one context worker and one generation worker sharing one GPU.
  • Added support for separate context and generation environments and optional GPU sharing.
  • Added GPU allocation reset between worker groups.
  • Added the mamba_bs1_concurrency2 QA entry.
  • No public API declarations changed.
  • The configuration and test-list entry match the new regression scenario.
  • No unrelated scope changes were identified.

QA Engineer Review

  • Added test_disaggregated_mamba_bs1_concurrency2.
  • Added coverage for two concurrent completion requests with batch size 1.
  • The test uses separate context and generation workers on one GPU.
  • The test verifies asynchronous request completion and guards against the gen-only KV-transfer hang.
  • The test is covered by 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

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
PP and non-overlap execution paths pass idle state to transfer checks. Context transfers are checked during idle iterations, while synchronous generation transfers continue to skip progress collectives.
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

Possibly related PRs

Suggested reviewers: bowenfu, yiqingy0, yuanjingx87

🚥 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
Title check ✅ Passed The title follows the required format and clearly identifies the fix for the async KV-transfer hang.
Description check ✅ Passed The description explains the issue, solution, regression scenario, test coverage, and checklist status.
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 #63444 [ run ] triggered by Bot. Commit: 2b7ef51 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63444 [ run ] completed with state FAILURE. Commit: 2b7ef51
/LLM/main/L0_MergeRequest_PR pipeline #51415 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

Comment on lines 3524 to 3545
@@ -3533,9 +3534,12 @@ def _check_disagg_transfer_progress_when_idle(
self._check_disagg_gen_cache_transfer_status(1)
return

any_need_check = self._sync_disagg_ctx_status_entry(local_need_check)
local_need_ctx_check = is_idle or (uses_async_gen_transfer
and local_needs_progress)
any_need_check = self._sync_disagg_ctx_status_entry(
local_need_ctx_check)
if any_need_check > 0:
if local_need_check and not all_gen_first:
if local_need_ctx_check and not all_gen_first:
logger.warning(
"num_fitting_reqs=0 and fitting_disagg_gen_init_requests is empty, may not have enough kvCache"
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I have one concern about the multi-rank synchronous-transfer path.

With overlap disabled, ranks can be at different points: one rank may still be blocked in request_and_receive_sync(), while another rank has no transfer to process and reaches this allreduce. Because every rank must enter collectives in the same order, this could stall or misalign the ranks.

#15737 avoided these progress collectives for synchronous GEN transfer. Could we preserve that behavior for GEN workers while separately allowing CTX workers to poll their asynchronous sends, using a worker-role decision that is consistent across ranks?

@reasonsolo
reasonsolo force-pushed the fix/python-mamba-cache-headroom branch from 2b7ef51 to 30fdacf Compare August 4, 2026 04:45
@reasonsolo reasonsolo changed the title [None][fix] Fix context-only async kvtransfer hang [None][fix] Fix gen-only async kvtransfer hang Aug 4, 2026
@reasonsolo

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63664 [ run ] triggered by Bot. Commit: 30fdacf Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63664 [ run ] completed with state FAILURE. Commit: 30fdacf
/LLM/main/L0_MergeRequest_PR pipeline #51616 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 #63717 [ run ] triggered by Bot. Commit: 30fdacf Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63717 [ run ] completed with state SUCCESS. Commit: 30fdacf
/LLM/main/L0_MergeRequest_PR pipeline #51669 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 #63762 [ run ] triggered by Bot. Commit: 30fdacf Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63762 [ run ] completed with state FAILURE. Commit: 30fdacf
/LLM/main/L0_MergeRequest_PR pipeline #51713 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>
@reasonsolo
reasonsolo force-pushed the fix/python-mamba-cache-headroom branch from 30fdacf to 734773c Compare August 5, 2026 00:46
@reasonsolo
reasonsolo enabled auto-merge (squash) August 5, 2026 00:46
@reasonsolo

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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

🤖 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/disaggregated/test_disaggregated.py`:
- Line 1108: Update test_disaggregated_mamba_bs1_concurrency2 to set
TRTLLM_DISABLE_KV_CACHE_TRANSFER_OVERLAP to "1" for the regression scenario
instead of removing it, while preserving the two concurrent completion requests.
Ensure the test explicitly exercises the disabled-overlap branch.
🪄 Autofix

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: a9b34bd7-eb65-4ea9-909e-3ebe85dcf495

📥 Commits

Reviewing files that changed from the base of the PR and between 1982523 and 734773c.

📒 Files selected for processing (4)
  • tensorrt_llm/_torch/pyexecutor/py_executor.py
  • 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
🚧 Files skipped from review as they are similar to previous changes (1)
  • tensorrt_llm/_torch/pyexecutor/py_executor.py

Comment thread tests/integration/defs/disaggregated/test_disaggregated.py
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63880 [ run ] triggered by Bot. Commit: 734773c Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63880 [ run ] completed with state SUCCESS. Commit: 734773c
/LLM/main/L0_MergeRequest_PR pipeline #51820 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 #64471 [ run ] triggered by Bot. Commit: 734773c Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64471 [ run ] completed with state FAILURE. Commit: 734773c
/LLM/main/L0_MergeRequest_PR pipeline #52345 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

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.

8 participants