Skip to content

[None][fix] reserve draft KV at disagg transition for gen-only-dspark case - #16990

Merged
reasonsolo merged 3 commits into
NVIDIA:mainfrom
reasonsolo:fix/gen_only_dspark
Jul 31, 2026
Merged

[None][fix] reserve draft KV at disagg transition for gen-only-dspark case#16990
reasonsolo merged 3 commits into
NVIDIA:mainfrom
reasonsolo:fix/gen_only_dspark

Conversation

@reasonsolo

@reasonsolo reasonsolo commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Dev Engineer Review

  • KVCacheManagerV2._effective_draft_len now reserves transferred context draft tokens and falls back to configured draft capacity for speculative decoding.
  • _pad_attention_dp_dummy_request now checks engine, sequence, and KV-cache capacity before allocating a context dummy request.
  • The capacity checks prevent dummy allocation when full generation capacity is unavailable.
  • The changes do not modify public APIs or configuration files.
  • Review the CI failures before merge. The available summary does not identify whether they relate to this change.

QA Engineer Review

  • Added test_disagg_gen_reserves_target_draft_and_required_capacity.
  • Added test_disagg_gen_disables_speculative_decoding.
  • Added test_disagg_gen_prefers_context_phase_draft_tokens.
  • Added test_disabled_dsv4_gate_checks_full_generation_capacity.
  • Extended _StubADPExecutor.__init__ with capacity-related parameters.
  • No integration test-list coverage is shown for these tests. Add or verify test-db/ coverage.
  • The duplicate test_disabled_dsv4_gate_checks_full_generation_capacity definition causes the earlier test to be overwritten. Rename or remove one definition.
  • Verdict: needs follow-up.

Description

Test Coverage

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.

GitHub Bot Help

To see a list of available CI bot commands, please comment /bot help.

@reasonsolo
reasonsolo force-pushed the fix/gen_only_dspark branch 2 times, most recently from e5630ec to 912580d Compare July 29, 2026 07:00
@reasonsolo
reasonsolo marked this pull request as ready for review July 29, 2026 07:03
@reasonsolo
reasonsolo requested review from a team as code owners July 29, 2026 07:03
@reasonsolo

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8045790d-dfea-4a97-a41a-9f00e990429e

📥 Commits

Reviewing files that changed from the base of the PR and between 6bb5556 and d463494.

📒 Files selected for processing (4)
  • tensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.py
  • tensorrt_llm/_torch/pyexecutor/py_executor.py
  • tests/unittest/_torch/executor/test_kv_cache_v2_capacity_only.py
  • tests/unittest/_torch/executor/test_py_executor.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • tensorrt_llm/_torch/pyexecutor/py_executor.py
  • tests/unittest/_torch/executor/test_kv_cache_v2_capacity_only.py
  • tensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.py
  • tests/unittest/_torch/executor/test_py_executor.py

Walkthrough

The changes update speculative-decoding draft reservation and attention-DP dummy sizing. Capacity checks now include engine, sequence, and KV-cache limits. Unit tests cover disaggregated generation transitions and disabled-dsv4 dummy allocation.

Changes

Capacity accounting

Layer / File(s) Summary
Disaggregated draft reservation
tensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.py, tests/unittest/_torch/executor/test_kv_cache_v2_capacity_only.py
_effective_draft_len reserves configured target draft capacity when needed, returns zero when speculative decoding is disabled, and prefers transferred context draft tokens.
Attention-DP dummy capacity checks
tensorrt_llm/_torch/pyexecutor/py_executor.py, tests/unittest/_torch/executor/test_py_executor.py
Dummy sizing clamps engine, sequence, and KV-cache capacity, accounts for extra speculative-decoding tokens, and skips allocation when full capacity is insufficient. Test stubs expose the required limits. The added test name duplicates a later test definition.

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

Suggested labels: api-compatible

Suggested reviewers: yingguo-trt, eopxd

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description contains the template but provides no issue, solution, or test details, and the checklist is not meaningfully completed. Add a concise issue and solution summary, list the relevant tests, and complete the applicable checklist items.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title follows the required [None][fix] format and clearly states the draft KV reservation fix at disaggregated transition.
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: 2

🤖 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/unittest/_torch/executor/test_kv_cache_v2_capacity_only.py`:
- Around line 197-198: Update the expected value in the test assertion for
manager._required_gen_capacity(request, 128) from 137 to 133, while preserving
the existing _effective_draft_len assertion.

In `@tests/unittest/_torch/executor/test_py_executor.py`:
- Around line 1507-1517: Add test-list entries for
test_disabled_dsv4_gate_checks_full_generation_capacity to the appropriate
tests/integration/test_lists/test-db and tests/integration/test_lists/qa files,
using the existing format and suite placement conventions.
🪄 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: 310c0807-d825-4df4-b337-900e7d0b216f

📥 Commits

Reviewing files that changed from the base of the PR and between 097cbc1 and 912580d.

📒 Files selected for processing (4)
  • tensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.py
  • tensorrt_llm/_torch/pyexecutor/py_executor.py
  • tests/unittest/_torch/executor/test_kv_cache_v2_capacity_only.py
  • tests/unittest/_torch/executor/test_py_executor.py

Comment thread tests/unittest/_torch/executor/test_kv_cache_v2_capacity_only.py Outdated
Comment thread tests/unittest/_torch/executor/test_py_executor.py
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62461 [ run ] triggered by Bot. Commit: 912580d Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62461 [ run ] completed with state FAILURE. Commit: 912580d
/LLM/main/L0_MergeRequest_PR pipeline #50613 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 #62671 [ run ] triggered by Bot. Commit: 912580d Link to invocation

@reasonsolo

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62695 [ run ] triggered by Bot. Commit: 5141693 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62671 [ run ] completed with state ABORTED. Commit: 912580d

Link to invocation

@nvpohanh
nvpohanh requested a review from thorjohnsen July 30, 2026 06:19
@nvpohanh

Copy link
Copy Markdown
Collaborator

[by Codex] @thorjohnsen Friendly review reminder: this PR is awaiting your review. Thanks!

@reasonsolo

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62755 [ run ] triggered by Bot. Commit: 5141693 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62695 [ run ] completed with state ABORTED. Commit: 5141693

Link to invocation

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tensorrt_llm/_torch/pyexecutor/mamba_cache_manager.py (1)

602-626: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Keep get_max_resource_count() aligned with real-request capacity.

PyExecutor uses this method only as a fallback for get_kv_cache_capacity(). Scheduler admission uses live cache checks. After _padding_slot is claimed, the method still overreports the documented maximum real-request count by one. Return _max_resource_count - 1 when _padding_slot is set.

🤖 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 `@tensorrt_llm/_torch/pyexecutor/mamba_cache_manager.py` around lines 602 -
626, Update get_max_resource_count() to return _max_resource_count - 1 once
_padding_slot has been claimed, while retaining _max_resource_count when it
remains unset. Keep the result aligned with the maximum real-request capacity
and preserve the existing lazy padding-slot behavior.
🧹 Nitpick comments (1)
tests/integration/defs/accuracy/test_disaggregated_serving.py (1)

2216-2284: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Test coverage summary for tests/integration/defs/accuracy/test_disaggregated_serving.py.

  1. Test function added: TestNemotronNano9BV2::test_sync_transfer_bs1_concurrency2 (Line 2216-2284). It launches a 1-context/1-generation disaggregated deployment with max_batch_size=1, overlap scheduler enabled, TRTLLM_DISABLE_KV_CACHE_TRANSFER_OVERLAP=1 (synchronous cache transfer), NIXL Python-runtime cache transceiver, and float16 Mamba SSM cache, then submits two concurrent prompts and asserts each returns exactly one output.
  2. Listed in test list files: confirmed present in tests/integration/test_lists/test-db/l0_dgx_b200.yml as accuracy/test_disaggregated_serving.py::TestNemotronNano9BV2::test_sync_transfer_bs1_concurrency2.
  3. Coverage verdict: sufficient for its stated purpose (regression coverage for the back-to-back batch-size-1 Mamba cache-holding scenario under synchronous transfer), though it is a structural/crash-regression check rather than an output-quality check: the assertion (len(output.outputs) == 1) does not verify generated text content. Since the test lives in accuracy/test_disaggregated_serving.py, consider a lightweight content sanity check (e.g., non-empty text) if intended to also guard against silent corruption of recurrent state, not just crashes.

As per path instructions, "Act as a QA engineer reviewing test changes and coverage for TensorRT-LLM. Always produce a test coverage summary, even if no issues are found," and confirming listing via "Whether each changed test is listed in the appropriate test list files under tests/integration/test_lists/ (test-db/ for CI, qa/ for manual QA)."

🤖 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/integration/defs/accuracy/test_disaggregated_serving.py` around lines
2216 - 2284, Strengthen
TestNemotronNano9BV2::test_sync_transfer_bs1_concurrency2 with a lightweight
output-content assertion in addition to checking one output per response. Verify
each generated output contains non-empty text while preserving the existing
concurrency, configuration, and response-count checks.

Source: Path instructions

🤖 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.

Outside diff comments:
In `@tensorrt_llm/_torch/pyexecutor/mamba_cache_manager.py`:
- Around line 602-626: Update get_max_resource_count() to return
_max_resource_count - 1 once _padding_slot has been claimed, while retaining
_max_resource_count when it remains unset. Keep the result aligned with the
maximum real-request capacity and preserve the existing lazy padding-slot
behavior.

---

Nitpick comments:
In `@tests/integration/defs/accuracy/test_disaggregated_serving.py`:
- Around line 2216-2284: Strengthen
TestNemotronNano9BV2::test_sync_transfer_bs1_concurrency2 with a lightweight
output-content assertion in addition to checking one output per response. Verify
each generated output contains non-empty text while preserving the existing
concurrency, configuration, and response-count checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a74738ea-d7cd-4524-887f-24d6c4b53cbc

📥 Commits

Reviewing files that changed from the base of the PR and between 5141693 and 6bb5556.

📒 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

@reasonsolo
reasonsolo force-pushed the fix/gen_only_dspark branch from 6bb5556 to 5141693 Compare July 31, 2026 04:34
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62936 [ run ] completed with state SUCCESS. Commit: 5141693
/LLM/main/L0_MergeRequest_PR pipeline #51054 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/gen_only_dspark branch from 5141693 to d463494 Compare July 31, 2026 04:40
@reasonsolo

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62955 [ run ] triggered by Bot. Commit: d463494 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62955 [ run ] completed with state FAILURE. Commit: d463494
/LLM/main/L0_MergeRequest_PR pipeline #51071 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 #63040 [ run ] triggered by Bot. Commit: d463494 Link to invocation

@reasonsolo
reasonsolo enabled auto-merge (squash) July 31, 2026 14:21
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63040 [ run ] completed with state SUCCESS. Commit: d463494
/LLM/main/L0_MergeRequest_PR pipeline #51145 completed with status: 'SUCCESS'
Pipeline passed with automatic retried tests. Check the rerun report for details.

CI Report

Link to invocation

Comment thread tensorrt_llm/_torch/pyexecutor/py_executor.py
@reasonsolo
reasonsolo merged commit 376d219 into NVIDIA:main Jul 31, 2026
11 checks passed
yuanjingx87 pushed a commit that referenced this pull request Aug 1, 2026
… case (#16990)

Signed-off-by: Lizhi Zhou <1432185+reasonsolo@users.noreply.github.com>
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.

7 participants