Skip to content

Conversation

yuxianq
Copy link
Collaborator

@yuxianq yuxianq commented Sep 8, 2025

Summary by CodeRabbit

  • New Features
    • Enable MLA with FP8-context attention, unlocking additional configuration options.
    • Expand FP8 MLA support to more GPU architectures.
  • Bug Fixes
    • Correct output dtype selection in FP8 MLA paths for better compatibility.
    • Add a clear assertion when prompt length exceeds the configured maximum.
  • Refactor
    • Centralize quantization flags and scale propagation for attention, improving consistency across execution paths.
  • Chores
    • Improve initialization error logs with deeper tracebacks.
    • Enrich kernel diagnostic messages with detailed dtype and architecture info.

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

  • 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

/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...

Provide a user friendly way for developers to interact with a Jenkins server.

Run /bot [-h|--help] to print this help message.

See details below for each supported subcommand.

run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]

Launch build/test pipelines. All previously running jobs will be killed.

--reuse-test (optional)pipeline-id (OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.

--disable-reuse-test (OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.

--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.

--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.

--stage-list "A10-PyTorch-1, xxx" (OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.

--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.

--test-backend "pytorch, cpp" (OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.

--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.

--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.

--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.

--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.

--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".

--detailed-log (OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.

--debug (OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in the stage-list parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.

For guidance on mapping tests to stage names, see docs/source/reference/ci-overview.md
and the scripts/test_to_stage_mapping.py helper.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip testing for latest commit on pull request. --comment "Reason for skipping build/test" is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

reuse-pipeline

reuse-pipeline

Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

@yuxianq yuxianq requested review from a team as code owners September 8, 2025 08:56
@yuxianq
Copy link
Collaborator Author

yuxianq commented Sep 8, 2025

/bot run --disable-fail-fast

@yuxianq yuxianq requested a review from jmydurant September 8, 2025 08:57
@yuxianq yuxianq changed the title Cherry-pick https://github.com/NVIDIA/TensorRT-LLM/pull/6059 from release/1.1.0rc2 [TRTLLM-6994][feat] FP8 Context MLA integration (Cherry-pick https://github.com/NVIDIA/TensorRT-LLM/pull/6059 from release/1.1.0rc2) Sep 8, 2025
@tensorrt-cicd
Copy link
Collaborator

PR_Github #18020 [ run ] triggered by Bot

@yuxianq yuxianq requested a review from QiJune September 8, 2025 09:04
Copy link
Contributor

coderabbitai bot commented Sep 8, 2025

📝 Walkthrough

Walkthrough

Enables FP8-context MLA by relaxing checks and removing forced output dtype; adds mFP8ContextMLA and KV cache quant mode plumbing; switches Runner allocations to shared_ptr; expands FMHA kernel hash info; centralizes quant scale/out_scale handling in PyTorch Attention; increases initialization traceback depth; adds a max prompt length assertion; updates tests with Hopper gating and MOE backend selection.

Changes

Cohort / File(s) Summary
AttentionOp core (MLA gating & dtype)
cpp/tensorrt_llm/common/attentionOp.cpp, cpp/tensorrt_llm/common/attentionOp.h
Allows MLA with FP8-context FMHA by only forbidding dense FMHA; removes forced E4M3 output dtype for FP8-context MLA; extends AttentionOp::data() tuple to include mFP8ContextMLA.
THOP AttentionOp wiring & allocation
cpp/tensorrt_llm/thop/attentionOp.cpp
Replaces raw new/reset with std::make_shared for Runner creation; introduces and initializes mKVCacheQuantMode; broadens mFP8ContextMLA SM gating (SM 100 or 120); removes duplicate KV quant mode in nvfp4 path.
FMHA kernel info string
cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/fmhaKernels.h
Extends hashFromRunnerParams info string to include dtypeQ, dtypeKv, dtypeOut, and sm along with qkvLayout.
PyTorch Attention quant plumbing
tensorrt_llm/_torch/modules/attention.py
Adds has_quant_scale and out_scale (Attention/MLA); ensures o_proj.create_weights() is called; centralizes FP8/NVFP4 gating via has_quant_scale; threads self.out_scale through all forward paths.
Executor engine logging
tensorrt_llm/_torch/pyexecutor/model_engine.py
Increases traceback depth in fallback init logging from 1 to 10 frames.
Worker prompt length check
tensorrt_llm/executor/worker.py
Adds assertion in _deduce_max_tokens that len(prompt_token_ids) <= executor_config.max_seq_len.
Integration tests (gating + MOE backend)
tests/integration/defs/accuracy/test_llm_api_pytorch.py
Replaces @skip_no_hopper/device-specific skips with @skip_pre_hopper; injects MoeConfig with backend "DEEPGEMM" for SM ≥ 100 else "CUTLASS" into PyTorch configs.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User
  participant TorchAttention as Attention (PyTorch)
  participant OProj as o_proj
  participant Backend as TRT-LLM AttentionOp

  Note over TorchAttention,OProj: Weight creation and quant flag discovery
  User->>TorchAttention: create_weights()
  TorchAttention->>OProj: create_weights()
  OProj-->>TorchAttention: returns (quant flags, out_scale)
  TorchAttention->>TorchAttention: has_quant_scale = (FP8/NVFP4 flags)\nout_scale = o_proj.out_scale

  Note over TorchAttention,Backend: Forward path with centralized out_scale
  User->>TorchAttention: forward(...)
  TorchAttention->>Backend: attention(..., out_scale=self.out_scale)
  Backend-->>TorchAttention: outputs
  TorchAttention-->>User: result
Loading
sequenceDiagram
  autonumber
  participant Host as Host Init
  participant AttnOp as AttentionOp
  participant Runner as FMHA/MLA Runner

  Note over AttnOp: MLA enablement with FP8-context
  Host->>AttnOp: initialize(...)
  AttnOp->>AttnOp: mFP8ContextMLA = (SM in {100,120} && KvCache supports FP8)
  AttnOp->>AttnOp: if MLA enabled ensure !DenseContextFMHA
  AttnOp->>Runner: construct (shared_ptr)
  Runner-->>AttnOp: ready
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

Release Blocker

Suggested reviewers

  • PerkzZheng
  • litaotju
  • Superjomn
  • QiJune
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tensorrt_llm/_torch/modules/attention.py (1)

317-327: Fix potential dtype mismatch under torch.compile path (custom op disables NVFP4 output).

create_output may allocate an FP8 output tensor when has_quant_scale and FP8/FP4 KV cache are enabled. However, attn_custom_op_inplace invokes _attn_impl(..., enable_attn_nvfp4_output=False) under torch.compile, which can yield BF16 output into an FP8 buffer. Make dtype selection conditional on the same enable flag.

Apply:

-    def create_output(self, q: torch.Tensor):
+    def create_output(self, q: torch.Tensor, enable_attn_nvfp4_output: bool = True):
         num_tokens = q.shape[0]
         hidden_size = self.o_proj.in_features
         out_dtype = q.dtype
 
-        if self.attn_backend == "TRTLLM":
+        if self.attn_backend == "TRTLLM" and enable_attn_nvfp4_output:
             if self.has_quant_scale and (self.attn.has_fp8_kv_cache
                                          or self.attn.has_fp4_kv_cache):
                 out_dtype = torch.float8_e4m3fn
         output = q.new_empty([num_tokens, hidden_size], dtype=out_dtype)
         return output

And update the compile path call site:

# In forward_impl(), inside if use_custom_inplace_op:
-    output = self.create_output(q)
+    output = self.create_output(q, enable_attn_nvfp4_output=False)

This keeps buffer dtype aligned with the execution path.

🧹 Nitpick comments (13)
tensorrt_llm/_torch/pyexecutor/model_engine.py (2)

1-1: Missing NVIDIA Apache-2.0 header (2025).

Per guidelines, prepend the NVIDIA Apache-2.0 header with the current year.

Apply:

+# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#     http://www.apache.org/licenses/LICENSE-2.0
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.

1009-1013: Traceback limit increased to 10: consider log level.

Good for debugging, but verbose for INFO. Suggest logging the full traceback at DEBUG, or gate by an env flag.

cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/fmhaKernels.h (2)

1-15: Update copyright year.

Header shows 2020–2023; update to include 2025.

- * Copyright (c) 2020-2023, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2020-2025, NVIDIA CORPORATION. All rights reserved.

544-547: Log readability: print dtype names instead of ints.

The info string logs dtypeQ/Kv/Out as integers. Prefer symbolic names for quicker debugging.

Example:

-        std::string info = "dtypeQ=" + std::to_string(static_cast<int>(mDtypeQ)) + ", dtypeKv="
-            + std::to_string(static_cast<int>(mDtypeKv)) + ", dtypeOut=" + std::to_string(static_cast<int>(mDtypeOut))
+        std::string info = "dtypeQ=" + toString(mDtypeQ) + ", dtypeKv="
+            + toString(mDtypeKv) + ", dtypeOut=" + toString(mDtypeOut)
             + ", sm=" + std::to_string(mSM) + ", qkvLayout=" + std::to_string(static_cast<int>(params.mQkvLayout))

(Add a small toString(Data_type) helper if not present.)

tensorrt_llm/executor/worker.py (1)

519-525: Minor: variable name typo.

Consider renaming splited_prompt_len → split_prompt_len for clarity (optional).

-            splited_prompt_len = int(len(prompt_token_ids) / cp_size)
-            default_max_tokens = max_seq_len - splited_prompt_len - query_token_len
+            split_prompt_len = int(len(prompt_token_ids) / cp_size)
+            default_max_tokens = max_seq_len - split_prompt_len - query_token_len
tests/integration/defs/accuracy/test_llm_api_pytorch.py (4)

1239-1241: Avoid repetition: factor MOE backend selection into a helper.

The "DEEPGEMM if SM>=100 else CUTLASS" logic is duplicated across tests. Suggest a small helper to keep tests DRY.

Example (place near the top of this file):

def _moe_backend_for_ci():
    return "DEEPGEMM" if get_sm_version() >= 100 else "CUTLASS"

Then here:

moe_config=MoeConfig(backend=_moe_backend_for_ci())

1329-1331: Same refactor applies here.

Use the shared helper to choose the MOE backend.


1353-1355: Same refactor applies here.

Use the shared helper to choose the MOE backend.


1397-1399: Same refactor applies here.

Use the shared helper to choose the MOE backend.

tensorrt_llm/_torch/modules/attention.py (1)

298-299: Guard against re-initialization of o_proj weights.

Attention.create_weights() now unconditionally calls self.o_proj.create_weights(). If init already created weights (default path), this may reinitialize or conflict unless Linear.create_weights is idempotent.

Please confirm Linear.create_weights is idempotent (e.g., via an internal _weights_created guard). If not, guard:

-        self.o_proj.create_weights()
+        if not getattr(self.o_proj, "_weights_created", False):
+            self.o_proj.create_weights()
cpp/tensorrt_llm/common/attentionOp.cpp (1)

2573-2574: Fix wording in user-visible error message

Change “currently not support dense fmha” to “does not currently support dense FMHA” for clarity.

-        TLLM_CHECK_WITH_INFO(!mDenseContextFMHA, "MLA(Deepseek v2) currently not support dense fmha");
+        TLLM_CHECK_WITH_INFO(!mDenseContextFMHA, "MLA (Deepseek v2) does not currently support dense FMHA");
cpp/tensorrt_llm/thop/attentionOp.cpp (2)

709-723: Validate workspace dtype and size in bytes

The check uses numel() (elements) against workspace_size (bytes). If a caller passes a non-Byte tensor, the comparison and resize logic become inconsistent. Guard for dtype Byte or compute in bytes.

-    if (workspace_.has_value())
+    if (workspace_.has_value())
     {
-        if (workspace_.value().numel() < workspace_size)
+        auto ws = workspace_.value();
+        TORCH_CHECK(ws.dtype() == torch::kByte, "workspace must be a torch.uint8 (Byte) tensor");
+        if (ws.numel() < workspace_size) // numel == bytes for Byte tensors
         {
             TLLM_LOG_WARNING("Attention workspace size is not enough, increase the size from %ld bytes to %ld bytes",
-                workspace_.value().numel(), workspace_size);
-            workspace_.value().resize_({workspace_size});
+                ws.numel(), workspace_size);
+            ws.resize_({workspace_size});
         }
-        workspace = workspace_.value();
+        workspace = ws;
     }

1-16: Header year nit

Guidelines ask to prepend the NVIDIA Apache-2.0 header with the current year; file shows 1993-2024. Consider updating to include 2025 where applicable.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 219e955 and 7961672.

📒 Files selected for processing (8)
  • cpp/tensorrt_llm/common/attentionOp.cpp (1 hunks)
  • cpp/tensorrt_llm/common/attentionOp.h (1 hunks)
  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/fmhaKernels.h (1 hunks)
  • cpp/tensorrt_llm/thop/attentionOp.cpp (3 hunks)
  • tensorrt_llm/_torch/modules/attention.py (9 hunks)
  • tensorrt_llm/_torch/pyexecutor/model_engine.py (1 hunks)
  • tensorrt_llm/executor/worker.py (1 hunks)
  • tests/integration/defs/accuracy/test_llm_api_pytorch.py (9 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{h,hpp,hh,hxx,cpp,cxx,cc,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Use only spaces, no tabs; indent with 4 spaces.

Files:

  • tensorrt_llm/_torch/pyexecutor/model_engine.py
  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/fmhaKernels.h
  • cpp/tensorrt_llm/common/attentionOp.cpp
  • tensorrt_llm/_torch/modules/attention.py
  • cpp/tensorrt_llm/thop/attentionOp.cpp
  • tensorrt_llm/executor/worker.py
  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
  • cpp/tensorrt_llm/common/attentionOp.h
**/*.py

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.py: Python code must target Python 3.8+.
Indent Python code with 4 spaces; do not use tabs.
Maintain module namespace when importing; prefer 'from package.subpackage import foo' then 'foo.SomeClass()' instead of importing the class directly.
Python filenames should be snake_case (e.g., some_file.py).
Python classes use PascalCase names.
Functions and methods use snake_case names.
Local variables use snake_case; prefix 'k' for variables that start with a number (e.g., k_99th_percentile).
Global variables use upper SNAKE_CASE prefixed with 'G' (e.g., G_MY_GLOBAL).
Constants use upper SNAKE_CASE (e.g., MY_CONSTANT).
Avoid shadowing variables from an outer scope.
Initialize all externally visible members of a class in the constructor.
Prefer docstrings for interfaces that may be used outside a file; comments for in-function or file-local interfaces.
Use Google-style docstrings for classes and functions (Sphinx-parsable).
Document attributes and variables inline so they render under the class/function docstring.
Avoid reflection when a simpler, explicit approach suffices (e.g., avoid dict(**locals()) patterns).
In try/except, catch the most specific exceptions possible.
For duck-typing try/except, keep the try body minimal and use else for the main logic.

Files:

  • tensorrt_llm/_torch/pyexecutor/model_engine.py
  • tensorrt_llm/_torch/modules/attention.py
  • tensorrt_llm/executor/worker.py
  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
**/*.{cpp,cxx,cc,h,hpp,hh,hxx,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Prepend the NVIDIA Apache-2.0 copyright header with current year to the top of all source files (e.g., .cpp, .h, .cu, .py).

Files:

  • tensorrt_llm/_torch/pyexecutor/model_engine.py
  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/fmhaKernels.h
  • cpp/tensorrt_llm/common/attentionOp.cpp
  • tensorrt_llm/_torch/modules/attention.py
  • cpp/tensorrt_llm/thop/attentionOp.cpp
  • tensorrt_llm/executor/worker.py
  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
  • cpp/tensorrt_llm/common/attentionOp.h
**/*.{h,hpp,hh,hxx,cpp,cxx,cc,cu,cuh}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.{h,hpp,hh,hxx,cpp,cxx,cc,cu,cuh}: Namespace closing braces must include a trailing comment with the namespace name (e.g., '} // namespace foo').
Prefer const or constexpr variables over #define for constants.
Declare variables that are not modified after initialization as const.
Avoid magic literals in code; except for 0, nullptr, true, false. Use named constants for comparisons and logic.
Use Allman brace style for formatting.
Place the semicolon of an empty for/while loop on a new line.
Bodies of switch/while/do-while/for must be compound statements (brace-delimited), and if/else must always be followed by brace-delimited statements.
Type names (e.g., classes) must be CamelCase starting with an uppercase letter (e.g., FooBar).
Local variables, methods, and namespaces use lowerCamelCase (e.g., localFooBar).
Non-magic-number global variables that are non-static and not in an anonymous namespace must be lowerCamelCase prefixed with 'g' (e.g., gDontUseGlobalFoos).
Non-magic-number globals that are static or in an anonymous namespace use lowerCamelCase prefixed with 's' (e.g., sMutableStaticGlobal).
Locally visible static variables use lowerCamelCase with 's' prefix (e.g., static std::once_flag sFlag).
Private/protected member variables use 'm' prefix with CamelCase (e.g., mNbFooValues). Public members may omit, but 'm' is encouraged for clarity.
Constants (enums, global constants, static constants, and function-scope magic/literal constants) use uppercase SNAKE_CASE with 'k' prefix (e.g., kDIGIT_NUM).
Function-scope constants that are not magic numbers or literals are named like non-constant variables (e.g., bool const pass = a && b).
If macros are necessary, name them in UPPER_SNAKE_CASE (e.g., FOO_VERSION) and prefer constants over #define.
Use LLVM clang-format; wrap lines at a maximum of 120 columns; use '// clang-format off/on' sparingly with justification.
Use smart pointers for heap allocations; prefer unique_ptr for sole ownership, shared_ptr for shared...

Files:

  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/fmhaKernels.h
  • cpp/tensorrt_llm/common/attentionOp.cpp
  • cpp/tensorrt_llm/thop/attentionOp.cpp
  • cpp/tensorrt_llm/common/attentionOp.h
**/*.{cpp,cxx,cc,cu,h,hpp,hh,hxx,cuh}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

C++ filenames should be lowerCamelCase (first letter lowercase) and must be case-insensitive unique within a compilation target.

Files:

  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/fmhaKernels.h
  • cpp/tensorrt_llm/common/attentionOp.cpp
  • cpp/tensorrt_llm/thop/attentionOp.cpp
  • cpp/tensorrt_llm/common/attentionOp.h
**/*.{h,hpp,hh,hxx}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Document new class interfaces and function prototypes with Doxygen; use //! for single-line and //!< for members.

Files:

  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/fmhaKernels.h
  • cpp/tensorrt_llm/common/attentionOp.h
**/*.{h,hpp,hh,hxx,cpp,cxx,cc}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.{h,hpp,hh,hxx,cpp,cxx,cc}: Prefer anonymous namespaces over 'static' for internal linkage of functions.
All templates (class/function/member/static) must be instantiated at least once; non-POD classes should have private data members.

Files:

  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/fmhaKernels.h
  • cpp/tensorrt_llm/common/attentionOp.cpp
  • cpp/tensorrt_llm/thop/attentionOp.cpp
  • cpp/tensorrt_llm/common/attentionOp.h
**/*.{h,hpp,hh,hxx,cuh}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Use include guards named 'TRTLLM_<FILE_NAME_IN_CAPS_WITH_UNDERSCORES>_H' (no leading or trailing underscore; directory names excluded).

Files:

  • cpp/tensorrt_llm/kernels/trtllmGenKernels/fmha/fmhaKernels.h
  • cpp/tensorrt_llm/common/attentionOp.h
🧠 Learnings (3)
📚 Learning: 2025-08-14T21:04:50.248Z
Learnt from: thorjohnsen
PR: NVIDIA/TensorRT-LLM#6910
File: cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp:0-0
Timestamp: 2025-08-14T21:04:50.248Z
Learning: In KV cache onboarding logic during prefill in cpp/tensorrt_llm/batch_manager/kvCacheManager.cpp, when calculating which blocks fall within the attention window, use getTokensPerBlock() to advance token indices rather than block->getUniqueTokens().size(), because the calculation needs to consider the post-prefill state where blocks will be filled to capacity, not their current token count.

Applied to files:

  • cpp/tensorrt_llm/thop/attentionOp.cpp
📚 Learning: 2025-08-26T09:37:10.463Z
Learnt from: jiaganc
PR: NVIDIA/TensorRT-LLM#7031
File: tensorrt_llm/bench/dataclasses/configuration.py:90-104
Timestamp: 2025-08-26T09:37:10.463Z
Learning: In TensorRT-LLM's bench configuration, the `get_pytorch_perf_config()` method returns `self.pytorch_config` which is a Dict[str, Any] that can contain default values including `cuda_graph_config`, making the fallback `llm_args["cuda_graph_config"]` safe to use.

Applied to files:

  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
📚 Learning: 2025-08-26T09:37:10.463Z
Learnt from: jiaganc
PR: NVIDIA/TensorRT-LLM#7031
File: tensorrt_llm/bench/dataclasses/configuration.py:90-104
Timestamp: 2025-08-26T09:37:10.463Z
Learning: In TensorRT-LLM, the `get_pytorch_perf_config()` method returns `self.pytorch_config` which can contain default `cuda_graph_config` values, so `llm_args` may already have this config before the extra options processing.

Applied to files:

  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
🧬 Code graph analysis (4)
tensorrt_llm/_torch/modules/attention.py (3)
tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py (1)
  • create_weights (157-179)
tensorrt_llm/_torch/modules/linear.py (18)
  • create_weights (219-222)
  • create_weights (274-284)
  • create_weights (317-340)
  • create_weights (484-504)
  • create_weights (585-608)
  • create_weights (717-757)
  • create_weights (904-944)
  • create_weights (1096-1119)
  • create_weights (1208-1227)
  • create_weights (1324-1351)
  • create_weights (1467-1507)
  • create_weights (1723-1726)
  • create_weights (1851-1860)
  • has_fp8_qdq (1869-1872)
  • has_nvfp4 (1887-1890)
  • has_fp8_block_scales (1881-1884)
  • has_fp8_rowwise (1875-1878)
  • has_w4a8_nvfp4_fp8 (1911-1914)
tensorrt_llm/quantization/mode.py (2)
  • has_fp8_kv_cache (166-167)
  • has_fp4_kv_cache (169-170)
cpp/tensorrt_llm/thop/attentionOp.cpp (3)
cpp/tensorrt_llm/common/attentionOp.cpp (1)
  • if (1363-1366)
cpp/tensorrt_llm/kernels/unfusedAttentionKernels.h (3)
  • if (334-337)
  • if (340-354)
  • if (374-377)
tensorrt_llm/models/modeling_utils.py (3)
  • quant_mode (156-163)
  • quant_mode (301-303)
  • quant_mode (543-544)
tensorrt_llm/executor/worker.py (1)
tensorrt_llm/executor/result.py (1)
  • prompt_token_ids (525-526)
tests/integration/defs/accuracy/test_llm_api_pytorch.py (3)
tensorrt_llm/llmapi/llm_args.py (1)
  • MoeConfig (168-196)
tensorrt_llm/layers/moe.py (1)
  • MoeConfig (104-140)
tensorrt_llm/_utils.py (1)
  • get_sm_version (689-691)
🪛 Ruff (0.12.2)
tensorrt_llm/executor/worker.py

515-515: Use of assert detected

(S101)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Pre-commit Check
🔇 Additional comments (8)
cpp/tensorrt_llm/common/attentionOp.h (1)

469-476: Drop the tuple‐layout break warning
AttentionOp::data() is only used wholesale as a key in an unordered_map—no structured bindings or std::tie unpack its elements, nor is it serialized for engine/plugins—so inserting mFP8ContextMLA in the middle has no positional‐unpack or ABI impact.

tests/integration/defs/accuracy/test_llm_api_pytorch.py (2)

1215-1215: Gating change looks good.

The Hopper gating via @skip_pre_hopper aligns with the FP8-block-scales coverage.


1485-1486: Gating change looks good.

The Hopper gating for static_eplb covers kernel availability appropriately.

tensorrt_llm/_torch/modules/attention.py (2)

848-850: LGTM: MLA keeps out_scale None (BF16 output), consistent with comment.

No issues.


1062-1062: LGTM: Pass-through of out_scale to MHA/MQA is consistent.

With out_scale=None in MLA, these calls retain BF16 outputs while enabling scale plumbing when needed later.

Also applies to: 1126-1126, 1226-1226, 1274-1274, 1376-1376

cpp/tensorrt_llm/thop/attentionOp.cpp (3)

532-533: Good switch to make_shared

Replacing raw new/reset with std::make_shared reduces verbosity and improves exception safety.

Also applies to: 536-537, 541-542, 547-548, 554-555, 558-559, 563-564


582-582: QuantMode initialization looks correct

Setting mKVCacheQuantMode early from the torch int matches the new plumbing; no issues spotted here.


630-633: Clarify SM gating for mFP8ContextMLA
mFP8ContextMLA is currently enabled only on SM100 and SM120; if Hopper (SM90) should support FP8 KV-cache MLA, broaden the check to include sm == 90 (e.g. sm == 90 || sm == 100 || sm == 120), otherwise add a brief comment explaining why SM90 is excluded. [attentionOp.cpp:630-633]

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18020 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #13506 completed with status: 'FAILURE'

@yuxianq
Copy link
Collaborator Author

yuxianq commented Sep 9, 2025

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18135 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18135 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #13591 completed with status: 'FAILURE'

@yuxianq yuxianq force-pushed the fp8-context-mla-main branch from b550a05 to 70af66a Compare September 16, 2025 09:09
@yuxianq
Copy link
Collaborator Author

yuxianq commented Sep 16, 2025

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18770 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18770 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #14071 completed with status: 'FAILURE'

@yuxianq
Copy link
Collaborator Author

yuxianq commented Sep 17, 2025

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18892 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18892 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #14162 completed with status: 'FAILURE'

@yuxianq
Copy link
Collaborator Author

yuxianq commented Sep 17, 2025

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18993 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18993 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #14242 completed with status: 'FAILURE'

Signed-off-by: Yuxian Qiu <[email protected]>
@yuxianq
Copy link
Collaborator Author

yuxianq commented Sep 18, 2025

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #19106 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #19106 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #14334 completed with status: 'FAILURE'

@yuxianq
Copy link
Collaborator Author

yuxianq commented Sep 18, 2025

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #19185 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #19185 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #14399 completed with status: 'SUCCESS'

Copy link
Collaborator

@Superjomn Superjomn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yuxianq yuxianq merged commit d6ebcf7 into NVIDIA:main Sep 19, 2025
5 checks passed
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Sep 19, 2025
Wong4j pushed a commit to Wong4j/TensorRT-LLM that referenced this pull request Sep 20, 2025
MrGeva pushed a commit to nv-auto-deploy/TensorRT-LLM that referenced this pull request Sep 21, 2025
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.

5 participants