Skip to content

[TRTLLM-13017][fix] disagg gen init: use prompt_len for SWA history_length#14627

Merged
pcastonguay merged 1 commit into
NVIDIA:feat/deepseek_v4from
Shixiaowei02:fix/disagg-gen-init-swa-prompt-len
May 27, 2026
Merged

[TRTLLM-13017][fix] disagg gen init: use prompt_len for SWA history_length#14627
pcastonguay merged 1 commit into
NVIDIA:feat/deepseek_v4from
Shixiaowei02:fix/disagg-gen-init-swa-prompt-len

Conversation

@Shixiaowei02
Copy link
Copy Markdown
Collaborator

@Shixiaowei02 Shixiaowei02 commented May 27, 2026

For a disagg gen init request entering the V2 scheduler, context_current_position is still 0 — it is only advanced to prompt_len in _prepare_disagg_gen_transmission_complete after KV transfer completes. Passing history_length=context_current_position degenerates to history_length=0, the SWA stale range collapses to an empty interval, and pre-window blocks are still allocated before KV transfer — defeating the over-allocation fix from #13845/#14377.

Use req.prompt_len, which is known statically at scheduler time and correctly conveys that the entire prompt is history.

@coderabbitai summary

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.

@Shixiaowei02 Shixiaowei02 requested a review from a team as a code owner May 27, 2026 09:30
@Shixiaowei02 Shixiaowei02 requested review from a team, Tabrizian and joyang-nv and removed request for a team May 27, 2026 09:30
@Shixiaowei02 Shixiaowei02 requested review from chuangz0 and jiaganc May 27, 2026 09:30
Comment thread tensorrt_llm/_torch/pyexecutor/scheduler/scheduler_v2.py
Copy link
Copy Markdown
Collaborator

@jiaganc jiaganc left a comment

Choose a reason for hiding this comment

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

LGTM

@Shixiaowei02 Shixiaowei02 changed the title [None][fix] disagg gen init: use prompt_len for SWA history_length [TRTLLM-13018][fix] disagg gen init: use prompt_len for SWA history_length May 27, 2026
@Shixiaowei02 Shixiaowei02 changed the title [TRTLLM-13018][fix] disagg gen init: use prompt_len for SWA history_length [TRTLLM-13017][fix] disagg gen init: use prompt_len for SWA history_length May 27, 2026
@lfr-0531
Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #50529 [ run ] triggered by Bot. Commit: e834dbd Link to invocation

For a disagg gen init request entering the V2 scheduler,
context_current_position is still 0 — it is only advanced to
prompt_len in _prepare_disagg_gen_transmission_complete after KV
transfer completes. Passing history_length=context_current_position
degenerates to history_length=0, the SWA stale range collapses to an
empty interval, and pre-window blocks are still allocated before KV
transfer — defeating the over-allocation fix from NVIDIA#13845/NVIDIA#14377.

Use req.prompt_len, which is known statically at scheduler time and
correctly conveys that the entire prompt is history.

Signed-off-by: Shixiaowei02 <39303645+Shixiaowei02@users.noreply.github.com>
@Shixiaowei02 Shixiaowei02 force-pushed the fix/disagg-gen-init-swa-prompt-len branch from e834dbd to 0f2294e Compare May 27, 2026 13:55
@Shixiaowei02
Copy link
Copy Markdown
Collaborator Author

/bot run --add-multi-gpu-test --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #50546 [ run ] triggered by Bot. Commit: 0f2294e Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #50529 [ run ] completed with state ABORTED. Commit: e834dbd

Link to invocation

@peihu-nv
Copy link
Copy Markdown
Collaborator

/bot run --add-multi-gpu-test --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #50570 [ run ] triggered by Bot. Commit: 0f2294e Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #50546 [ run ] completed with state ABORTED. Commit: 0f2294e

Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #50570 [ run ] completed with state SUCCESS. Commit: 0f2294e
/LLM/main/L0_MergeRequest_PR pipeline #40071 completed with status: 'SUCCESS'

CI Report

Link to invocation

@pcastonguay pcastonguay merged commit eeb09d1 into NVIDIA:feat/deepseek_v4 May 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants