[None][fix] Fix disaggregated draft token accounting#16805
Conversation
Generation-only requests created from disaggregated context-phase handoff can carry draft tokens alongside first-generation tokens. Adopt those draft tokens into LlmRequest so decoder capacity and Python-visible request state account for every generation token handed off by prefill. Add C++ and Python unit coverage for constructor-time and late context-phase parameter handoff paths. Tests added: - LlmRequestTest.generationOnlyRequestAdoptsContextPhaseDraftTokens - tests/unittest/_torch/executor/test_request_utils.py::test_executor_request_to_llm_request_adopts_context_phase_draft_tokens - tests/unittest/bindings/test_bindings_ut.py::test_generation_only_llm_request_adopts_draft_tokens Signed-off-by: Simeng Liu <simengl@nvidia.com>
WalkthroughGeneric LLM requests now adopt draft tokens from context-phase parameters during construction or later updates, expose combined context-phase generation-token counts, and use that count in decoder sequence-length calculations. C++ and Python tests cover these paths. ChangesContext-phase draft tokens
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ExecutorRequest
participant GenericLlmRequest
participant ContextPhaseParams
participant DecoderRequestCreation
ExecutorRequest->>GenericLlmRequest: construct with context-phase parameters
GenericLlmRequest->>ContextPhaseParams: read draft tokens
ContextPhaseParams-->>GenericLlmRequest: return draft tokens
GenericLlmRequest->>GenericLlmRequest: adopt draft tokens
DecoderRequestCreation->>GenericLlmRequest: get context-phase generation-token count
GenericLlmRequest-->>DecoderRequestCreation: return first-generation plus draft-token count
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cpp/tests/unit_tests/batch_manager/llmRequestTest.cpp (1)
793-826: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftExercise decoder sequence-length initialization.
This validates adoption and counting, but never runs decoder setup. A regression in decoder sequence-length accounting can still pass. Add coverage asserting
prompt + generated + first-gen + draftis written to decoder sequence lengths.🤖 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 `@cpp/tests/unit_tests/batch_manager/llmRequestTest.cpp` around lines 793 - 826, Extend generationOnlyRequestAdoptsContextPhaseDraftTokens to exercise decoder setup after adopting the context-phase tokens, then assert the decoder sequence length equals prompt tokens plus generated tokens plus first-generation tokens plus draft tokens. Reuse the existing token vectors and request symbols, and verify the recorded decoder sequence lengths through the relevant LlmRequest/decoder setup API.
🤖 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.
Nitpick comments:
In `@cpp/tests/unit_tests/batch_manager/llmRequestTest.cpp`:
- Around line 793-826: Extend generationOnlyRequestAdoptsContextPhaseDraftTokens
to exercise decoder setup after adopting the context-phase tokens, then assert
the decoder sequence length equals prompt tokens plus generated tokens plus
first-generation tokens plus draft tokens. Reuse the existing token vectors and
request symbols, and verify the recorded decoder sequence lengths through the
relevant LlmRequest/decoder setup API.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: adca7be2-268b-402f-80ef-be390c225a2c
📒 Files selected for processing (5)
cpp/include/tensorrt_llm/batch_manager/llmRequest.hcpp/tensorrt_llm/batch_manager/createNewDecoderRequests.cppcpp/tests/unit_tests/batch_manager/llmRequestTest.cpptests/unittest/_torch/executor/test_request_utils.pytests/unittest/bindings/test_bindings_ut.py
|
/bot run --disable-fail-fast |
|
PR_Github #61360 [ run ] triggered by Bot. Commit: |
|
/bot run --disable-fail-fast |
|
PR_Github #61379 [ run ] triggered by Bot. Commit: |
|
PR_Github #61360 [ run ] completed with state |
|
PR_Github #61379 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
schetlur-nv
left a comment
There was a problem hiding this comment.
Approving for pending groups.
|
PR_Github #61466 [ run ] triggered by Bot. Commit: |
|
PR_Github #61466 [ run ] completed with state
|
|
/bot run |
|
PR_Github #61592 [ run ] triggered by Bot. Commit: |
|
PR_Github #61592 [ run ] completed with state
|
|
The previous CI failed at DGX_H100-4_GPUs-PyTorch-GptOss-1 / DGX_H100-4_GPUs-PyTorch-GptOss-1.accuracy.test_llm_api_pytorch.TestGPTOSS.test_w4_4gpus[v2_kv_cache-dp4-triton-auto] which I cannot reproduce on computelab machines. |
|
/bot run |
|
PR_Github #61652 [ run ] triggered by Bot. Commit: |
|
PR_Github #61652 [ run ] completed with state
|
|
/bot run |
|
PR_Github #61656 [ run ] triggered by Bot. Commit: |
|
PR_Github #61656 [ run ] completed with state |
Generation-only requests created from disaggregated context-phase handoff can carry draft tokens alongside first-generation tokens. Adopt those draft tokens into LlmRequest so decoder capacity and Python-visible request state account for every generation token handed off by prefill.
Add C++ and Python unit coverage for constructor-time and late context-phase parameter handoff paths.
Tests added:
Dev Engineer Review
GenericLlmRequestto adopt context-phase draft tokens during construction and when context-phase parameters are set later.getNumContextPhaseGenerationTokens()and integrated it into decoder sequence-length accounting.QA Engineer Review
generationOnlyRequestAdoptsContextPhaseDraftTokensincpp/tests/unit_tests/batch_manager/llmRequestTest.cpp.test_generation_only_llm_request_adopts_draft_tokensintests/unittest/bindings/test_bindings_ut.py.tests/unittest/_torch/executor/test_request_utils.pyforexecutor_request_to_llm_request.tests/integration/test_lists/,test-db/, orqa/entries were found for these unit tests, so CI/manual-QA listing coverage is not explicitly recorded.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-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin 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.