[https://nvbugs/5983390][perf] Reduce host overhead in DSA MLA attention path#12691
Merged
liji-nv merged 4 commits intoNVIDIA:feat/bench_yfrom Apr 3, 2026
Merged
Conversation
…ion path Pass pre-computed num_contexts/num_ctx_tokens to thop::attention and trtllm_gen_attention to eliminate per-layer sum().item() calls that recompute batch structure from host_request_types/host_context_lengths. Move view/slice/reinterpret ops from Python _update_k_cache into the C++ indexer_k_cache_scatter_op kernel: accept original k_fp8 (FP8) and k_scale (float32) tensors directly with num_tokens, avoiding per-layer torch.empty, view, as_strided and slice overhead on the host. Signed-off-by: Jin Li <59594262+liji-nv@users.noreply.github.com>
Remove default values from num_contexts, num_generations, and num_ctx_tokens parameters in trtllm_gen_attention() so callers cannot silently omit them. Move them before the optional global_layer_idx parameter. Signed-off-by: Jin Li <59594262+liji-nv@users.noreply.github.com>
- Remove std::optional from num_contexts/num_ctx_tokens in attention op (always passed by caller, never null) - Remove num_generations param from trtllm_gen_attention interface; compute it inside as host_request_types.size(0) - num_contexts - Remove unused _parse_request_types function - Restore tensor dimension/dtype validation in IndexerKCacheScatterOp with element_size checks to guard reinterpret_cast safety Signed-off-by: Jin Li <59594262+liji-nv@users.noreply.github.com>
Collaborator
Author
|
Please hold the merge. After I address some comments from the previous PR, I haven't run E2E test. |
…ttention call Store num_contexts and num_ctx_tokens in _TrtllmPlanner during plan_host and pass them as keyword args to thop.attention, matching the updated C++ binding signature. Signed-off-by: Jin Li <59594262+liji-nv@users.noreply.github.com>
Collaborator
Author
|
previous failing test for autodeploy passed. Merge now. |
SimengLiu-nv
pushed a commit
to SimengLiu-nv/TensorRT-LLM
that referenced
this pull request
Apr 6, 2026
…ion path (NVIDIA#12691) Signed-off-by: Jin Li <59594262+liji-nv@users.noreply.github.com>
dongfengy
pushed a commit
to dongfengy/TensorRT-LLM
that referenced
this pull request
Apr 8, 2026
…ion path (NVIDIA#12691) Signed-off-by: Jin Li <59594262+liji-nv@users.noreply.github.com>
dongfengy
pushed a commit
to dongfengy/TensorRT-LLM
that referenced
this pull request
Apr 10, 2026
…ion path (NVIDIA#12691) Signed-off-by: Jin Li <59594262+liji-nv@users.noreply.github.com>
dongfengy
pushed a commit
to dongfengy/TensorRT-LLM
that referenced
this pull request
Apr 10, 2026
…ion path (NVIDIA#12691) Signed-off-by: Jin Li <59594262+liji-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.
Pass pre-computed num_contexts/num_ctx_tokens to thop::attention and
trtllm_gen_attention to eliminate per-layer sum().item() calls that
recompute batch structure from host_request_types/host_context_lengths.
Move view/slice/reinterpret ops from Python _update_k_cache into the
C++ indexer_k_cache_scatter_op kernel: accept original k_fp8 (FP8) and
k_scale (float32) tensors directly with num_tokens, avoiding per-layer
torch.empty, view, as_strided and slice overhead on the host.
@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)
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.