Skip to content

[None][fix] Fix context-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 context-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

  • Python Mamba cache headroom now matches the C++ behavior.
  • CUDA-graph padding uses lazy allocation for its shared cache slot.
  • The slot remains available for live requests until padding is added.
  • Failed padding allocation returns False and allows eager-mode fallback.
  • Synchronous context workers now reap completed context transfers.
  • The integration test configuration targets the intended 2-GPU B200 pre-merge scope.
  • No public API or configuration changes were found.

QA Engineer Review

  • Added Mamba cache tests for lazy allocation, exhausted headroom, and retained padding slots.
  • Added disaggregated-transfer coverage for padding fallback when headroom is occupied.
  • Added idle context-worker coverage for completed synchronous transfers.
  • Updated synchronous receive tests to verify DISAGG_GENERATION_TRANS_COMPLETE.
  • Added TestNemotronNano9BV2::test_sync_transfer_bs1_concurrency2.
  • The integration test is listed in tests/integration/test_lists/test-db/l0_dgx_b200.yml.
  • Unit and disaggregated test functions are not listed in test-db/ or qa/ files.
  • CI coverage data is unavailable for the updated unit tests.

Verdict: needs follow-up.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The Mamba cache manager now allocates the shared CUDA-graph padding slot on demand and reports allocation failure. Disaggregated transfer handling now polls context-only transfers correctly. Unit and integration tests cover cache capacity, dummy requests, and synchronous transfers.

Changes

Mamba cache and transfer flow

Layer / File(s) Summary
Lazy padding-slot allocation
tensorrt_llm/_torch/pyexecutor/mamba_cache_manager.py
The manager keeps the padding slot available for real requests until a padding sentinel requires it. Dummy insertion reports failure when no block is available, and hybrid insertion propagates that result.
Cache allocation and dummy-request validation
tests/unittest/_torch/executor/test_mamba_cache_manager.py, tests/unittest/disaggregated/test_mamba_transfer.py
Tests cover lazy capacity, batch-size-one pressure, padding-slot retention, attention-DP dummy behavior, and failed CUDA-graph dummy insertion.
Context-transfer progress handling
tensorrt_llm/_torch/pyexecutor/py_executor.py, tests/unittest/_torch/executor/test_py_executor.py
Synchronous generation workers skip progress collectives. Context-only workers continue polling context-transfer progress.
Synchronous transfer validation
tests/integration/defs/accuracy/test_disaggregated_serving.py, tests/integration/test_lists/test-db/l0_dgx_b200.yml, tests/unittest/disaggregated/test_py_cache_transceiver_mp.py
Tests cover concurrent synchronous NIXL transfers and validate completed generation-transfer states.

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

Suggested reviewers: juney-nvidia, tabrizian, thorjohnsen

🚥 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
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.
Title check ✅ Passed The title clearly identifies the primary fix for the context-only asynchronous KV-transfer hang.
Description check ✅ Passed The description includes the required sections and clearly explains the issue, solution, regression coverage, and checklist status.
✨ Finishing Touches 💡 1
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch fix/python-mamba-cache-headroom
🧪 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

@reasonsolo
reasonsolo force-pushed the fix/python-mamba-cache-headroom branch from 1c44af0 to e456a8d Compare August 3, 2026 04:52
@reasonsolo
reasonsolo requested review from a team as code owners August 3, 2026 06:33
@reasonsolo reasonsolo changed the title [None][fix] align Python Mamba cache headroom with C++ [None][fix] Fix context-only async kvtransfer hang Aug 3, 2026
@reasonsolo
reasonsolo requested review from chienchunhung and removed request for BowenFu, QiJune, allisonlim-nv and jieli-matrix August 3, 2026 08:39
@reasonsolo
reasonsolo force-pushed the fix/python-mamba-cache-headroom branch from 73906bc to dd62818 Compare August 3, 2026 08:41
@reasonsolo

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63401 [ run ] triggered by Bot. Commit: dd62818 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 dd62818 to 2b7ef51 Compare August 3, 2026 09:04
@reasonsolo
reasonsolo removed request for a team August 3, 2026 09:04
@reasonsolo

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63403 [ run ] triggered by Bot. Commit: 2b7ef51 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63401 [ run ] completed with state ABORTED. Commit: dd62818

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

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.

6 participants