[TRTLLM-12807][feat] Wrap CuteDSL MLA decode as FMHA lib#15333
Draft
yuxianq wants to merge 8 commits into
Draft
Conversation
Signed-off-by: Yuxian Qiu <142763828+yuxianq@users.noreply.github.com>
Signed-off-by: Yuxian Qiu <142763828+yuxianq@users.noreply.github.com>
Signed-off-by: Yuxian Qiu <142763828+yuxianq@users.noreply.github.com>
Signed-off-by: Yuxian Qiu <142763828+yuxianq@users.noreply.github.com>
Signed-off-by: Yuxian Qiu <142763828+yuxianq@users.noreply.github.com>
Add a CuteDSL attention backend that intercepts the MLA decode-only path
and dispatches to Blackwell CuTe DSL kernels (FP8 e4m3 / FP16), falling
back to TrtllmAttention for all other paths.
- attention_backend/cute_dsl.py: CuteDslAttention(TrtllmAttention)
- cute_dsl_kernels/blackwell/attention/mla: decode fp8/fp16 kernels + helpers
- custom_ops: register cute_dsl_mla_decode_{fp8,fp16}_blackwell ops
- utils/__init__: wire up CUTEDSL backend selection
- tests: CUTEDSL coverage in test_attention_mla + dedicated decode test
Signed-off-by: haow <haow@nvidia.com>
…ayer paged-KV, multi-layer test - attention_backend/cute_dsl.py: feed the scaled quant_q_buffer (not q.to(fp8)) and fold the fp8 dequant + de-folded log2(e) softmax scale into the bmm1/bmm2 scales; resolve the per-layer KV pool / page-table for layer_idx>0; gate the non-causal fast path off CUSTOM masks and speculative decoding; add a once-per-process ENGAGED log (symmetric to the fallback warning) confirming the decode kernel actually ran. - custom_ops/cute_dsl_custom_ops.py: add BF16 to the decode runner and the fp16 op with dtype dispatch + validation; pass workspace=None for split_kv==1 to avoid a zero-sized-buffer global write. - cute_dsl_kernels/.../mla_decode_fp8.py: allow a widened BF16 attention output. - cute_dsl_kernels/.../mla_decode_fp16.py: accept BF16 input/output in can_implement. - tests/.../test_cute_dsl_mla_decode.py: parametrize over num_layers to exercise the layer_idx>0 paged-KV path (reproduces the real DeepSeek-V3 E2E case). Signed-off-by: haow <haow@nvidia.com>
Signed-off-by: Yuxian Qiu <142763828+yuxianq@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.
@coderabbitai summary
Description
Wrap the CuteDSL FP8/FP16 MLA decode kernels as a TRTLLM FMHA library so they participate in the new FMHA library selection path.
This PR:
tensorrt_llm/_torch/attention_backend/fmha/.cute_dsl_mlainFMHA_LIBS.TLLM_FMHA_LIBSordering.generation_seq_len_q=[1, 4]coverage by replaying the single-token CuteDSL kernel per intra-step query with adjusted effective KV lengths.Test Coverage
B200:
python3 -m pytest -p no:threadleak -q tests/unittest/_torch/attention/test_cute_dsl_mla_decode.py --timeout=600 --tb=short(16 passed)python3 -m pytest -p no:threadleak -q tests/unittest/_torch/attention/test_attention_mla.py --timeout=600 --tb=short(87 passed)Local:
python3 -m py_compile tensorrt_llm/_torch/attention_backend/fmha/cute_dsl.py tests/unittest/_torch/attention/test_cute_dsl_mla_decode.py tensorrt_llm/_torch/custom_ops/cute_dsl_custom_ops.pyruff check --config ruff-legacy.toml tensorrt_llm/_torch/attention_backend/fmha/cute_dsl.py tests/unittest/_torch/attention/test_cute_dsl_mla_decode.py tensorrt_llm/_torch/custom_ops/cute_dsl_custom_ops.pygit diff --checkPR 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.