[None][fix] disagg-gen-init: pass context_current_position as history… - #14377
Merged
Tabrizian merged 1 commit intoMay 21, 2026
Conversation
…_length
The V2 scheduler's `_try_schedule_disagg_gen_init` was passing
`req.context_remaining_length` as `history_length` to
`kv_cache_manager.resize_context`. That field is the prompt
suffix still to be processed, not the historic prefix already
in the cache.
When GEN-side block reuse hits a long matching prefix,
`prepare_context` sets `req.context_current_position` to the
number of reused tokens and the cache's `_history_length` to the
same value. The subsequent `resize_context(...,
history_length=req.context_remaining_length)` then violates the
"history length cannot be decreased" invariant in
`_KVCache.resize()` and aborts the GEN event loop.
Pass `req.context_current_position` instead, matching the cache's
established history boundary in both reuse-hit and reuse-miss
paths. The block comment above the call already states the right
intent ("Prompt is already historic ... history_length so SWA
layers skip pre-window block allocation"); only the field was
wrong.
Reproduced on DSV4-Pro disagg smoke (1×CTX TEP8 + 1×GEN TEP8 on
GB300, concurrency 2). With this fix the GEN side no longer
raises "History length cannot be decreased".
Signed-off-by: Iman Tabrizian <10105175+tabrizian@users.noreply.github.com>
Member
Author
|
/bot run --disable-fail-fast |
Collaborator
|
PR_Github #49505 [ run ] triggered by Bot. Commit: |
Shixiaowei02
approved these changes
May 21, 2026
Collaborator
|
PR_Github #49505 [ run ] completed with state |
1 task
Shixiaowei02
added a commit
to Shixiaowei02/TensorRT-LLM
that referenced
this pull request
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 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>
lfr-0531
pushed a commit
to lfr-0531/TensorRT-LLM
that referenced
this pull request
Jun 10, 2026
NVIDIA#14377) Signed-off-by: Iman Tabrizian <10105175+tabrizian@users.noreply.github.com>
lfr-0531
pushed a commit
to lfr-0531/TensorRT-LLM
that referenced
this pull request
Jun 11, 2026
NVIDIA#14377) Signed-off-by: Iman Tabrizian <10105175+tabrizian@users.noreply.github.com>
lfr-0531
pushed a commit
to lfr-0531/TensorRT-LLM
that referenced
this pull request
Jun 12, 2026
NVIDIA#14377) Signed-off-by: Iman Tabrizian <10105175+tabrizian@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The V2 scheduler's
_try_schedule_disagg_gen_initwas passingreq.context_remaining_lengthashistory_lengthtokv_cache_manager.resize_context. That field is the prompt suffix still to be processed, not the historic prefix already in the cache.When GEN-side block reuse hits a long matching prefix,
prepare_contextsetsreq.context_current_positionto the number of reused tokens and the cache's_history_lengthto the same value. The subsequentresize_context(..., history_length=req.context_remaining_length)then violates the "history length cannot be decreased" invariant in_KVCache.resize()and aborts the GEN event loop.Pass
req.context_current_positioninstead, matching the cache's established history boundary in both reuse-hit and reuse-miss paths. The block comment above the call already states the right intent ("Prompt is already historic ... history_length so SWA layers skip pre-window block allocation"); only the field was wrong.Reproduced on DSV4-Pro disagg smoke (1×CTX TEP8 + 1×GEN TEP8 on GB300, concurrency 2). With this fix the GEN side no longer raises "History length cannot be decreased".
@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-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.