Skip to content

[TRTLLM-12807][feat] Wrap FP4 MLA as FMHA lib - #15375

Draft
yuxianq wants to merge 11 commits into
NVIDIA:mainfrom
yuxianq:feat/trtllm-12807-fp4-mla-fmha-lib
Draft

[TRTLLM-12807][feat] Wrap FP4 MLA as FMHA lib#15375
yuxianq wants to merge 11 commits into
NVIDIA:mainfrom
yuxianq:feat/trtllm-12807-fp4-mla-fmha-lib

Conversation

@yuxianq

@yuxianq yuxianq commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai summary

Description

Wrap FP4 MLA attention behind the FMHA library abstraction for the PyTorch backend. This adds FMHA interface/registry plumbing, the FP4 MLA FMHA implementation, FlashInfer/TRTLLM integration points, KV cache support updates, and speculative decoding/MTP wiring needed by the new path.

Rebased onto main after #15204 merged.

Test Coverage

  • Added unit coverage in tests/unittest/_torch/attention/test_fp4_mla.py.
  • Updated attention backend sync, FlashInfer attention, and MLA tokens-per-block unit coverage.
  • python3 -m compileall -q tensorrt_llm/_torch/attention_backend/fmha/fp4_mla.py tensorrt_llm/_torch/pyexecutor/resource_manager.py
  • git diff --check
  • DeepSeek V3 Lite FP4 MLA, triton backend: ENABLE_TILE=0 TRTLLM_FP4_MLA_ATTENTION_BACKEND=triton trtllm-eval --model /home/scratch.trt_llm_data_ci/llm-models/DeepSeek-V3-Lite/nvfp4_moe_only/ --config tmp/extra_llm_api_options.yaml gsm8k passed, average accuracy 60.46.
  • DeepSeek V3 Lite FP4 MLA, cutile backend with nv-triton==9.9.99.dev20260603+git69a952bc.cudatile: ENABLE_TILE=1 TRTLLM_FP4_MLA_ATTENTION_BACKEND=cutile trtllm-eval --model /home/scratch.trt_llm_data_ci/llm-models/DeepSeek-V3-Lite/nvfp4_moe_only/ --config tmp/extra_llm_api_options.yaml gsm8k passed, average accuracy 61.07.

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.

@yuxianq
yuxianq force-pushed the feat/trtllm-12807-fp4-mla-fmha-lib branch 3 times, most recently from e57b660 to 5c5863a Compare June 20, 2026 00:03
Tracin and others added 11 commits June 20, 2026 00:19
Allocate a standalone BF16 tensor indexed by sequence slot for recent MLA tokens when FP4 KV cache is active.

Add Triton kernels to store context and generation latent cache values into the high-precision pool before attention runs.

Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>
Add shared FP4 MLA KV-cache helpers, V-scale storage, Triton no-dequant decode, and FlashInfer integration for NVFP4 MLA cache.

Fold the offset, layout, memory, workspace, tail-scale, and scatter overflow fixes into the implementation, with focused unit coverage.

Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>
Add CuTile and CuTe DSL implementations for the FP4 MLA paged decode path and route them through the existing backend selector.

Extend the opt-in FP4 MLA decode benchmark coverage to report the selected backend and estimated memory bandwidth.

Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>
Add a standalone benchmark comparing the FP4 MLA decode backends against FlashInfer BF16 and trtllm-gen baselines.

Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>
Disable compile wrapping for the copy helper and force FLA utility device selection to CUDA for this debug path.

Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>
Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>

[None][fix] Avoid CuTe FP4 MLA large KV descriptor overflow

Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>

Support MPT. Update kernels.

Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>

Support MPT. Update kernels.

Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>

Support MPT. Update kernels.

Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>

Support MPT. Update kernels.

Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>

Support MPT. Update kernels.

Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>
Reuse FP4 MLA V-packed storage across layers

Handle partial FP4 MLA page-stat groups

Tune FP4 MLA PV block size by batch

Optimize FP4 MLA MTP decode path

Add experimental FP4 MLA MTP fused QKPV path

Optimize FP4 MLA MTP final-page path

Fix cutile bug.

Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>
Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>

Triton kernel prepack V.

Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>
Signed-off-by: Tracin <10434017+Tracin@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>
@yuxianq
yuxianq force-pushed the feat/trtllm-12807-fp4-mla-fmha-lib branch from 5c5863a to 3549726 Compare June 20, 2026 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants