[None][perf] Address decode-first assumption in MSA - #16923
Merged
pcicotti merged 1 commit intoJul 28, 2026
Conversation
Signed-off-by: Balaram Buddharaju <169953907+brb-nv@users.noreply.github.com>
brb-nv
force-pushed
the
user/brb/split-mixed-batch
branch
from
July 28, 2026 03:00
af3e4dc to
fa7279f
Compare
brb-nv
marked this pull request as ready for review
July 28, 2026 03:01
brb-nv
requested review from
PerkzZheng,
pcicotti,
peihu-nv,
yunruis and
zheyuf
and removed request for
a team,
PerkzZheng and
yunruis
July 28, 2026 03:01
Collaborator
Author
|
/bot run --disable-fail-fast |
Collaborator
|
PR_Github #62080 [ run ] triggered by Bot. Commit: |
pcicotti
approved these changes
Jul 28, 2026
2 tasks
ZhanruiSunCh
pushed a commit
that referenced
this pull request
Jul 29, 2026
Signed-off-by: Balaram Buddharaju <169953907+brb-nv@users.noreply.github.com>
Collaborator
|
PR_Github #62080 [ run ] completed with state |
1 task
brb-nv
added a commit
to brb-nv/TensorRT-LLM
that referenced
this pull request
Aug 20, 2026
In a mixed batch (context plus generation requests in one step) fmha_sm100_plan recognized only decode-first ordering, but TensorRT-LLM always orders context requests first. has_mixed was therefore always false and the whole batch was planned as a single sparse-prefill call, dragging every generation row through the MM-SA-Nv prefill kernel. _mixed_batch_split now also recognizes prefill-first ordering, restricted to sparse plans so the proxy and dense plans stay byte-identical (the proxy's max-score output drives top-k block selection). The sparse GQA plan then covers only the context rows and generation rows route to the paged decode kernel. Since each half of a split plan now writes its own rows of the caller's output buffer, out= is plumbed through sparse_fmha, sparse_atten_func and _sparse_atten_csr_varlen_forward, which removes a full-size concatenate plus copy from every split call. Cherry-picked from NVIDIA#16923 on feat/m3_with_msa, whose changes outside the submodule patch do not apply here: the msa_backend.py hunk is a comment inside an on_update_kv_lens override main's MSA metadata does not have, and main carries no MSA patch-marker check for the new fmha_sm100.api symbol to extend. Rebased onto main's copy of the patch, which carries a later revision of the _prepare_paged_hnd_input hunk and its tests; the interface.py hunk offsets are adjusted for those three extra lines. Verified with `patch -p1 --forward --batch` against MSA e2ebe76 (the pinned submodule commit): all four files apply with no fuzz or offset, the reverse dry run still succeeds, and the patched sources parse. (cherry picked from commit 6e9c670) Signed-off-by: Balaram Buddharaju <169953907+brb-nv@users.noreply.github.com>
brb-nv
added a commit
to brb-nv/TensorRT-LLM
that referenced
this pull request
Aug 21, 2026
In a mixed batch (context plus generation requests in one step) fmha_sm100_plan recognized only decode-first ordering, but TensorRT-LLM always orders context requests first. has_mixed was therefore always false and the whole batch was planned as a single sparse-prefill call, dragging every generation row through the MM-SA-Nv prefill kernel. _mixed_batch_split now also recognizes prefill-first ordering, restricted to sparse plans so the proxy and dense plans stay byte-identical (the proxy's max-score output drives top-k block selection). The sparse GQA plan then covers only the context rows and generation rows route to the paged decode kernel. Since each half of a split plan now writes its own rows of the caller's output buffer, out= is plumbed through sparse_fmha, sparse_atten_func and _sparse_atten_csr_varlen_forward, which removes a full-size concatenate plus copy from every split call. Cherry-picked from NVIDIA#16923 on feat/m3_with_msa, whose changes outside the submodule patch do not apply here: the msa_backend.py hunk is a comment inside an on_update_kv_lens override main's MSA metadata does not have, and main carries no MSA patch-marker check for the new fmha_sm100.api symbol to extend. Rebased onto main's copy of the patch, which carries a later revision of the _prepare_paged_hnd_input hunk and its tests; the interface.py hunk offsets are adjusted for those three extra lines. Verified with `patch -p1 --forward --batch` against MSA e2ebe76 (the pinned submodule commit): all four files apply with no fuzz or offset, the reverse dry run still succeeds, and the patched sources parse. (cherry picked from commit 6e9c670) Signed-off-by: Balaram Buddharaju <169953907+brb-nv@users.noreply.github.com>
brb-nv
added a commit
to brb-nv/TensorRT-LLM
that referenced
this pull request
Aug 24, 2026
In a mixed batch (context plus generation requests in one step) fmha_sm100_plan recognized only decode-first ordering, but TensorRT-LLM always orders context requests first. has_mixed was therefore always false and the whole batch was planned as a single sparse-prefill call, dragging every generation row through the MM-SA-Nv prefill kernel. _mixed_batch_split now also recognizes prefill-first ordering, restricted to sparse plans so the proxy and dense plans stay byte-identical (the proxy's max-score output drives top-k block selection). The sparse GQA plan then covers only the context rows and generation rows route to the paged decode kernel. Since each half of a split plan now writes its own rows of the caller's output buffer, out= is plumbed through sparse_fmha, sparse_atten_func and _sparse_atten_csr_varlen_forward, which removes a full-size concatenate plus copy from every split call. Cherry-picked from NVIDIA#16923 on feat/m3_with_msa, whose changes outside the submodule patch do not apply here: the msa_backend.py hunk is a comment inside an on_update_kv_lens override main's MSA metadata does not have, and main carries no MSA patch-marker check for the new fmha_sm100.api symbol to extend. Rebased onto main's copy of the patch, which carries a later revision of the _prepare_paged_hnd_input hunk and its tests; the interface.py hunk offsets are adjusted for those three extra lines. Verified with `patch -p1 --forward --batch` against MSA e2ebe76 (the pinned submodule commit): all four files apply with no fuzz or offset, the reverse dry run still succeeds, and the patched sources parse. (cherry picked from commit 6e9c670) Signed-off-by: Balaram Buddharaju <169953907+brb-nv@users.noreply.github.com>
brb-nv
added a commit
to brb-nv/TensorRT-LLM
that referenced
this pull request
Aug 25, 2026
Signed-off-by: Balaram Buddharaju <169953907+brb-nv@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
Problem:
In a mixed batch (context + generation requests in one step),
fmha_sm100_planrecognized only decode-first ordering, but TensorRT-LLM always orders context requests first; sohas_mixedwas always false and the whole batch was planned as a single sparse-prefill call.Fix:
_mixed_batch_splitnow also recognizes prefill-first ordering, restricted to sparse plans so the proxy and dense plans stay byte-identical (the proxy's max-score output drives top-k block selection). The sparse GQA plan then covers only the context rows, and generation rows route to the paged decode kernel.For ISL=8192, OSL=128, c=320, request latency in ms:
Before:
After:
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.