Skip to content

Conversation

@ChristinaZ
Copy link
Collaborator

@ChristinaZ ChristinaZ commented Oct 13, 2025

Description

Fix the bug related to the FP8 post-quant allgather for MoE TRTLLM backend (https://nvbugs/5537738)
Merge this commit to the release 1.1

Test Coverage

pytest -s -o log_cli=true "tests/integration/defs/accuracy/test_llm_api_pytorch.py::TestDeepSeekR1::test_fp8_blockscale[throughput_mtp_trtllm]"

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.

Details

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.

Summary by CodeRabbit

  • New Features

    • Simplified gating for post-quantization allgather and added conditional padding/no-op branches for specific quant modes.
    • Propagated top-k weights/ids into MoE runtime paths and adjusted runtime calls when post-quant allgather is active.
  • Bug Fixes

    • Standardized handling of padding and finalization so routing/finalize steps are skipped or adjusted when allgather is used.
  • Tests

    • Re-enabled a DeepSeek FP8 blockscale throughput test.

✏️ Tip: You can customize this high-level summary in your review settings.

@ChristinaZ ChristinaZ requested a review from a team as a code owner October 13, 2025 12:52
@ChristinaZ
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #21218 [ run ] triggered by Bot

@ChristinaZ
Copy link
Collaborator Author

/bot run

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 13, 2025

📝 Walkthrough

Walkthrough

Simplifies post-quant allgather gating to depend on data parallelism, adds handling for DeepSeek FP8 block scales and W4A16 MXFP4 padding, propagates top-k metadata into MoE runners, and conditionally omits router outputs when post-quant allgather is enabled. A single test-waive entry was removed.

Changes

Cohort / File(s) Summary
Fused MoE runtime & quant paths
tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py
Replaces dtype/feature-based gating with run_post_quant_allgather = use_dp && parallel_size > 1; adds DeepSeek FP8 block-scale branch (no-op) and W4A16 MXFP4 input padding when post-quant allgather is disabled; passes router_logits/routing_bias as None when post-quant allgather is enabled; propagates topk_weights/topk_ids into FP8 and non-FP8 MoE runners; retains unsupported-mode errors.
Integration test waives list
tests/integration/test_lists/waives.txt
Removed a single skip entry for TestDeepSeekR1::test_fp8_blockscale[throughput_mtp_trtllm]; no other edits to public APIs.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Caller
  participant G as FusedMoeGen
  participant R as Router
  participant RT as MoE Runtime
  participant DP as DataParallel

  C->>G: forward(x, config, use_dp, parallel_size, quant_flags)
  Note over G: run_post_quant_allgather = use_dp && parallel_size > 1

  alt run_post_quant_allgather
    G->>DP: post-quant AllGather(x)
    Note right of G: omit router outputs (router_logits=None, routing_bias=None)
  else no allgather
    G->>R: compute router_logits, routing_bias (may produce topk_ids/weights)
    Note right of G: pad x if W4A16 MXFP4 and required
  end

  G->>RT: invoke runner(x[, topk_ids, topk_weights][, router_logits, routing_bias])
  RT-->>G: moe outputs
  G-->>C: return hidden_state/results
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • Pay attention to branching where router_logits/routing_bias become None — verify downstream callers handle missing routing info.
  • Validate padding logic for W4A16 MXFP4 to avoid shape-mismatch or unnecessary copies.
  • Confirm topk metadata propagation covers all FP8 and non-FP8 runner invocation sites.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding FP8 post-quant allgather support to release 1.1, which aligns with the core modification in the fused_moe_trtllm_gen.py file.
Description check ✅ Passed The PR description identifies the bug (nvbugs/5537738), explains the purpose (merge fix to release 1.1), and includes test coverage and a completed checklist, meeting the template requirements.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • 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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 13, 2025

📝 Walkthrough

Walkthrough

Refactors fused MoE generation logic to standardize post-quant allgather based on data parallelism, expands handling for additional quantization modes (DeepSeek FP8, W4A16 MXFP4), propagates top-k metadata through finalization paths, adjusts routing parameter passing under allgather, and updates tests by un-skipping a DeepSeek FP8 blockscale case.

Changes

Cohort / File(s) Summary
Fused MoE generation logic
tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py
Simplified run_post_quant_allgather condition to depend on DP and parallel size; added branches for DeepSeek FP8 block scales and W4A16 MXFP4; introduced conditional padding; propagated top-k metadata (weights, ids, token_final_scales, token_selected_experts); adjusted runner calls to pass router params as None when allgathering; aligned x/x_sf handling across quant modes; gated finalize ops during post-quant allgather.
Integration test waivers
tests/integration/test_lists/waives.txt
Removed two SKIP entries for accuracy/test_llm_api_pytorch.py::TestDeepSeekR1.test_fp8_blockscale[throughput_mtp_trtllm].

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as Caller
  participant G as FusedMoEGen
  participant R as Router
  participant Q as Quantizer
  participant AG as DP AllGather
  participant MR as MoE Runner

  U->>G: generate(x, config, topk_args?)
  G->>Q: quantize(x) / prepare x_sf
  alt run_post_quant_allgather (use_dp && parallel_size>1)
    G->>AG: allgather(x[, x_sf])
    note right of AG: Routing params set to None<br/>Finalize ops skipped
  else
    G->>R: compute routing (router_logits, routing_bias, topk_ids, topk_weights)
  end

  rect rgba(230,240,255,0.5)
    note over G,MR: Quant mode branches
    alt DeepSeek FP8 block scales
      G->>MR: fp8_block_scale_moe_runner(..., router=None if allgather)
    else NVFP4 / W4A8 MXFP4 FP8 / MXFP8
      G->>MR: corresponding moe_runner(..., padding?, top-k propagated)
    else W4A16 MXFP4
      G->>MR: bf16_mxe2m1_block_scale_moe_runner(..., padding?, top-k)
    end
  end

  MR-->>G: outputs (+ token_final_scales, token_selected_experts as applicable)
  G-->>U: final tokens / states
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title follows the repository convention by including the NVBugs ID, the fix type, and a concise summary of the primary change (adding FP8 post-quant allgather support), accurately reflecting the PR’s content.
Description Check ✅ Passed The description adheres to the repository template by providing a clear “## Description” section explaining the issue and fix, a “## Test Coverage” section listing the relevant pytest command, and a “## PR Checklist” with review items, making it sufficiently complete.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • 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: 1

🧹 Nitpick comments (1)
tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py (1)

343-347: Simplify by removing no-op assignment.

The else branch at line 347 contains a no-op assignment x = x. Since the padding was already applied before allgather (lines 243-244) when run_post_quant_allgather is True, you can simplify this code.

Apply this diff:

-            if not run_post_quant_allgather:
-                pad_size = self.w3_w1_weight.shape[-1] * 2 - x.shape[-1]
-                x = torch.nn.functional.pad(x, (0, pad_size))
-            else:
-                x = x
+            if not run_post_quant_allgather:
+                pad_size = self.w3_w1_weight.shape[-1] * 2 - x.shape[-1]
+                x = torch.nn.functional.pad(x, (0, pad_size))
📜 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 598e885 and f644017.

📒 Files selected for processing (2)
  • tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py (6 hunks)
  • tests/integration/test_lists/waives.txt (0 hunks)
💤 Files with no reviewable changes (1)
  • tests/integration/test_lists/waives.txt
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{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/modules/fused_moe/fused_moe_trtllm_gen.py
**/*.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/modules/fused_moe/fused_moe_trtllm_gen.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/modules/fused_moe/fused_moe_trtllm_gen.py
🧬 Code graph analysis (1)
tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py (2)
tensorrt_llm/_torch/modules/fused_moe/interface.py (2)
  • has_deepseek_fp8_block_scales (293-296)
  • has_w4a16_mxfp4 (317-320)
tensorrt_llm/_torch/custom_ops/trtllm_gen_custom_ops.py (1)
  • bf16_mxe2m1_block_scale_moe_runner (1355-1434)
⏰ 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 (6)
tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py (6)

240-244: Verify that DeepSeek FP8 requires no pre-allgather quantization.

The empty pass statement for has_deepseek_fp8_block_scales indicates that no quantization is performed before allgather for this mode. The FP8 quantization occurs later at line 269. Confirm this is the intended behavior and that the input x in bfloat16 format can be safely allgathered without prior quantization.


272-273: LGTM: Correct parameter passing for post-quant allgather mode.

When run_post_quant_allgather is True, routing is performed beforehand (lines 211-212), so the runner receives None for router_logits and routing_bias but gets pre-computed topk_weights and topk_ids. This correctly avoids duplicate routing computation.

Also applies to: 290-291


332-333: LGTM: Consistent top-k metadata propagation.

The addition of topk_weights and topk_ids parameters ensures consistent handling of pre-computed routing information across all MoE runner calls when post-quant allgather is enabled.


352-353: LGTM: Consistent routing parameter handling.

The conditional passing of routing parameters and top-k metadata follows the same pattern as other MoE runners, ensuring uniform behavior across all quantization modes.

Also applies to: 376-377


420-421: LGTM: Top-k metadata properly propagated.

The addition of token_final_scales and token_selected_experts parameters to the remaining MoE runner calls completes the consistent propagation of routing metadata across all quantization modes.

Also applies to: 463-464


202-481: Overall assessment: Well-structured implementation of FP8 post-quant allgather support.

The changes systematically enable post-quant allgather for DeepSeek FP8 block scales and other quantization modes by:

  1. Simplifying the allgather condition (line 202) to apply universally when data parallelism is enabled
  2. Adding quantization-specific branches (lines 240-244) to handle different modes appropriately before allgather
  3. Propagating pre-computed routing metadata (topk_weights/topk_ids) throughout all MoE runner calls
  4. Conditionally bypassing redundant routing by passing None for router_logits/routing_bias when routing was already performed

The implementation is consistent across all five quantization modes (DeepSeek FP8, NVFP4, W4A16 MXFP4, W4A8 MXFP4 FP8, W4A8 MXFP4 MXFP8), ensuring uniform behavior. The changes align with the PR objective to fix the FP8 post-quant allgather bug for MoE.

Minor suggestions:

  • Remove the no-op assignment at line 347 (addressed in separate comment)
  • Verify the simplified allgather logic works correctly for all modes (verification script provided)

@tensorrt-cicd
Copy link
Collaborator

PR_Github #21219 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #21218 [ run ] completed with state ABORTED
LLM/release-1.1/L0_MergeRequest_PR #118 (Blue Ocean) completed with status: ABORTED

@tensorrt-cicd
Copy link
Collaborator

PR_Github #21219 [ run ] completed with state SUCCESS
/LLM/release-1.1/L0_MergeRequest_PR pipeline #119 completed with status: 'FAILURE'

Signed-off-by: Christina Zhang <83400082+ChristinaZ@users.noreply.github.com>
@ChristinaZ
Copy link
Collaborator Author

/bot run

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: 0

♻️ Duplicate comments (1)
tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py (1)

240-248: Correct handling for DeepSeek FP8 and W4A16 MXFP4 modes in post-quant allgather.

The pass for has_deepseek_fp8_block_scales is intentional—bf16 data is allgathered first, then quantized via fp8_quantize_1x128 at line 269. The padding for has_w4a16_mxfp4 ensures proper tensor alignment before the allgather. This completes the coverage for all five quantization modes in the if-elif chain, addressing the concern from the previous review.

🧹 Nitpick comments (1)
tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py (1)

343-348: Minor: redundant assignment x = x.

Line 347 is a no-op since padding was already applied at lines 243-244 when run_post_quant_allgather is true. The logic is correct, but the else branch could be omitted entirely.

         if not run_post_quant_allgather:
             pad_size = self.w3_w1_weight.shape[-1] * 2 - x.shape[-1]
             x = torch.nn.functional.pad(x, (0, pad_size))
-        else:
-            x = x
+        # else: padding was already applied in the run_post_quant_allgather block
📜 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 6f5e8a3 and b11f3a3.

📒 Files selected for processing (2)
  • tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py (6 hunks)
  • tests/integration/test_lists/waives.txt (0 hunks)
💤 Files with no reviewable changes (1)
  • tests/integration/test_lists/waives.txt
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.py: The code developed for TensorRT-LLM should conform to Python 3.8+
Indent Python code with 4 spaces; do not use tabs
Always maintain the namespace when importing in Python, even if only one class or function from a module is used (e.g., use from package.subpackage import foo and then foo.SomeClass() instead of from package.subpackage.foo import SomeClass)
Python filenames should use snake_case (e.g., some_file.py)
Python class names should use PascalCase (e.g., class SomeClass)
Python function and method names should use snake_case (e.g., def my_awesome_function():)
Python local variable names should use snake_case, with prefix k for variable names that start with a number (e.g., k_99th_percentile = ...)
Python global variables should use upper snake_case with prefix G (e.g., G_MY_GLOBAL = ...)
Python constants should use upper snake_case (e.g., MY_CONSTANT = ...)
Avoid shadowing variables declared in an outer scope in Python
Initialize all externally visible members of a Python class in the constructor
For Python interfaces that may be used outside a file, prefer docstrings over comments
Python comments should be reserved for code within a function, or interfaces that are local to a file
Use Google style docstrings for Python classes and functions, which can be parsed by Sphinx
Python attributes and variables can be documented inline with type and description (e.g., self.x = 5 followed by """<type>: Description of 'x'""" )
Avoid using reflection in Python when functionality can be easily achieved without reflection
When using try-except blocks in Python, limit the except clause to the smallest set of specific errors possible instead of catching all exceptions
When using try-except blocks in Python to handle multiple possible variable types (duck-typing), keep the body of the try as small as possible and use the else block to implement the logic

Files:

  • tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py
**/*.{cpp,h,cu,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

All TensorRT-LLM Open Source Software code files should contain an NVIDIA copyright header that includes the current year at the top

Files:

  • tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py
🧠 Learnings (11)
📓 Common learnings
Learnt from: djns99
Repo: NVIDIA/TensorRT-LLM PR: 6915
File: cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu:4010-4012
Timestamp: 2025-08-14T23:23:27.449Z
Learning: For MOE (Mixture of Experts) code reviews in TensorRT-LLM, avoid repeatedly suggesting finalize fusion validation checks and safety assertions. The user djns99 has indicated these suggestions are repetitive and unwanted across multiple MOE-related changes.
Learnt from: jhaotingc
Repo: NVIDIA/TensorRT-LLM PR: 7856
File: cpp/tensorrt_llm/thop/fp8BlockScaleMoe.cpp:159-166
Timestamp: 2025-09-19T21:28:13.751Z
Learning: In TensorRT-LLM blockScaleMoe routing (cpp/tensorrt_llm/kernels/trtllmGenKernels/blockScaleMoe/runner.cu), the DeepSeek routing method performs reinterpret_cast<float*>(routingLogits) at line 89, which could cause issues if routing_logits are BF16. However, Qwen3-FP8 models use RenormalizeNaive routing method and are not affected by this dtype casting issue.
Learnt from: sklevtsov-nvidia
Repo: NVIDIA/TensorRT-LLM PR: 3294
File: cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu:1198-1209
Timestamp: 2025-08-08T22:03:40.707Z
Learning: In the CUTLASS MoE kernels (cpp/tensorrt_llm/cutlass_extensions), when `layout_info.fusion` is set to `TmaWarpSpecializedGroupedGemmInput::EpilogueFusion::FINALIZE`, the `router_scales` parameter must be non-null by design. The fused finalize kernel epilogue does not perform nullptr checks and requires valid router scales to function correctly. This is an implicit contract that callers must satisfy when enabling the FINALIZE fusion mode.
📚 Learning: 2025-09-19T21:28:13.751Z
Learnt from: jhaotingc
Repo: NVIDIA/TensorRT-LLM PR: 7856
File: cpp/tensorrt_llm/thop/fp8BlockScaleMoe.cpp:159-166
Timestamp: 2025-09-19T21:28:13.751Z
Learning: In TensorRT-LLM blockScaleMoe routing (cpp/tensorrt_llm/kernels/trtllmGenKernels/blockScaleMoe/runner.cu), the DeepSeek routing method performs reinterpret_cast<float*>(routingLogits) at line 89, which could cause issues if routing_logits are BF16. However, Qwen3-FP8 models use RenormalizeNaive routing method and are not affected by this dtype casting issue.

Applied to files:

  • tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py
📚 Learning: 2025-09-23T15:12:38.312Z
Learnt from: nv-lschneider
Repo: NVIDIA/TensorRT-LLM PR: 7910
File: cpp/tensorrt_llm/thop/allreduceOp.cpp:352-446
Timestamp: 2025-09-23T15:12:38.312Z
Learning: In TensorRT-LLM NCCL device allreduce implementation (cpp/tensorrt_llm/thop/allreduceOp.cpp), the goto pattern in runNCCLAllReduceDeviceFusion is intentionally used for future extensibility, allowing multiple switch cases to fallback to the default handler. While not aesthetically ideal, this pattern supports adding more fusion cases later that can reuse the same fallback logic.

Applied to files:

  • tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py
📚 Learning: 2025-08-08T22:03:40.707Z
Learnt from: sklevtsov-nvidia
Repo: NVIDIA/TensorRT-LLM PR: 3294
File: cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu:1198-1209
Timestamp: 2025-08-08T22:03:40.707Z
Learning: In the CUTLASS MoE kernels (cpp/tensorrt_llm/cutlass_extensions), when `layout_info.fusion` is set to `TmaWarpSpecializedGroupedGemmInput::EpilogueFusion::FINALIZE`, the `router_scales` parameter must be non-null by design. The fused finalize kernel epilogue does not perform nullptr checks and requires valid router scales to function correctly. This is an implicit contract that callers must satisfy when enabling the FINALIZE fusion mode.

Applied to files:

  • tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py
📚 Learning: 2025-08-14T23:23:27.449Z
Learnt from: djns99
Repo: NVIDIA/TensorRT-LLM PR: 6915
File: cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu:4010-4012
Timestamp: 2025-08-14T23:23:27.449Z
Learning: For MOE (Mixture of Experts) code reviews in TensorRT-LLM, avoid repeatedly suggesting finalize fusion validation checks and safety assertions. The user djns99 has indicated these suggestions are repetitive and unwanted across multiple MOE-related changes.

Applied to files:

  • tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py
📚 Learning: 2025-08-09T20:57:04.084Z
Learnt from: sklevtsov-nvidia
Repo: NVIDIA/TensorRT-LLM PR: 3294
File: cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_gemm_tma_warp_specialized_input.cu:118-127
Timestamp: 2025-08-09T20:57:04.084Z
Learning: In the CUTLASS MoE finalize fusion implementation (cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_gemm_tma_warp_specialized_input.cu), when setting `fused_finalize_epilogue.stride_final_output` with shape `(hidden_size, num_output_tokens, 1)`, the `num_rows_in_final_output` should be set to `num_output_tokens` (not `hidden_size`) because of a swap+transpose operation that maps rows of the output tensor to `hidden_size` and columns to `num_output_tokens`.

Applied to files:

  • tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py
📚 Learning: 2025-10-20T17:07:18.745Z
Learnt from: nvchenghaoz
Repo: NVIDIA/TensorRT-LLM PR: 8469
File: tensorrt_llm/_torch/auto_deploy/models/patches/nemotron_h.py:98-116
Timestamp: 2025-10-20T17:07:18.745Z
Learning: In NemotronH models (tensorrt_llm/_torch/auto_deploy/models/patches/nemotron_h.py), the gate (self.gate) returns topk_indices and topk_weights that are already in the correct shape to be passed directly to torch_ops.auto_deploy.torch_moe without needing to reshape them when hidden_states is flattened.

Applied to files:

  • tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py
📚 Learning: 2025-08-21T02:39:12.009Z
Learnt from: djns99
Repo: NVIDIA/TensorRT-LLM PR: 7104
File: cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu:1475-1480
Timestamp: 2025-08-21T02:39:12.009Z
Learning: The min latency mode functionality in TensorRT-LLM MOE kernels (cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu) is deprecated and no longer being maintained/updated, as confirmed by djns99. Bug reports and optimization suggestions for the computeStridesTmaWarpSpecializedLowLatencyKernel and related min latency code paths should be deprioritized.

Applied to files:

  • tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py
📚 Learning: 2025-08-19T03:35:20.866Z
Learnt from: djns99
Repo: NVIDIA/TensorRT-LLM PR: 6915
File: cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu:4616-4626
Timestamp: 2025-08-19T03:35:20.866Z
Learning: In the MOE profiler TMA workspace preparation (cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu), the overlapping of TMA WS regions for NONE and FINALIZE variants is deliberate design to save memory space, as confirmed by djns99. The comment "reuse the same pointers to save space" reflects this intentional behavior.

Applied to files:

  • tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py
📚 Learning: 2025-08-19T12:45:11.997Z
Learnt from: amitz-nv
Repo: NVIDIA/TensorRT-LLM PR: 7033
File: tensorrt_llm/_torch/pyexecutor/model_engine.py:0-0
Timestamp: 2025-08-19T12:45:11.997Z
Learning: In tensorrt_llm/_torch/pyexecutor/model_engine.py, DoRA (Delta Orthogonal Rank Adaptation) functionality was removed from the PyTorch flow to eliminate issues with inverted DoRA detection logic. The original is_dora condition was checking if scaling_vec_pointer == 0, which was potentially incorrect.

Applied to files:

  • tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py
📚 Learning: 2025-08-14T06:36:40.701Z
Learnt from: timlee0212
Repo: NVIDIA/TensorRT-LLM PR: 6886
File: tensorrt_llm/_torch/models/modeling_deepseekv3.py:0-0
Timestamp: 2025-08-14T06:36:40.701Z
Learning: In DeepSeek V3 model (tensorrt_llm/_torch/models/modeling_deepseekv3.py), the disagreement between AllReduce.__init__ guard and _compute_mlp_tp_size logic for MNNVL usage is expected by design. The AllReduce component and MLP TP-size computation intentionally use different criteria for MNNVL availability decisions.

Applied to files:

  • tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py
🧬 Code graph analysis (1)
tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py (2)
tensorrt_llm/_torch/modules/fused_moe/interface.py (2)
  • has_deepseek_fp8_block_scales (293-296)
  • has_w4a16_mxfp4 (317-320)
tensorrt_llm/_torch/custom_ops/trtllm_gen_custom_ops.py (1)
  • bf16_mxe2m1_block_scale_moe_runner (1355-1434)
⏰ 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 (4)
tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py (4)

202-202: Simplified gating logic for post-quant allgather looks correct.

The condition now correctly enables post-quant allgather for all quantization modes when data parallelism is active (use_dp) and multiple ranks are involved (parallel_size > 1). The subsequent if-elif chain (lines 217-248) properly handles each quantization mode.


271-292: FP8 block scale MoE runner correctly receives pre-computed routing metadata.

When run_post_quant_allgather is enabled, routing has already been computed (lines 211-215). Passing router_logits=None and routing_bias=None while providing topk_weights and topk_ids allows the runner to skip redundant routing computation and use the pre-gathered routing results. This is the key fix for the FP8 post-quant allgather support.


332-334: LGTM!

The topk_ids parameter is now correctly passed to the nvfp4 runner, completing the routing metadata propagation for this quantization path.


351-378: LGTM!

The bf16_mxe2m1_block_scale_moe_runner call correctly handles the post-quant allgather scenario by conditionally passing None for routing inputs and propagating the pre-computed token_final_scales and token_selected_experts as the final positional arguments.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #27117 [ run ] triggered by Bot. Commit: b11f3a3

@tensorrt-cicd
Copy link
Collaborator

PR_Github #27117 [ run ] completed with state SUCCESS. Commit: b11f3a3
/LLM/release-1.1/L0_MergeRequest_PR pipeline #559 completed with status: 'SUCCESS'
Pipeline passed with automatic retried tests. Check the rerun report for details.

@ChristinaZ ChristinaZ merged commit 9aa4795 into NVIDIA:release/1.1 Dec 6, 2025
7 checks passed
mikeiovine pushed a commit to mikeiovine/TensorRT-LLM that referenced this pull request Dec 12, 2025
… release 1.1 (NVIDIA#8322)

Signed-off-by: Christina Zhang <83400082+ChristinaZ@users.noreply.github.com>
mikeiovine pushed a commit to mikeiovine/TensorRT-LLM that referenced this pull request Dec 12, 2025
… release 1.1 (NVIDIA#8322)

Signed-off-by: Christina Zhang <83400082+ChristinaZ@users.noreply.github.com>
mikeiovine pushed a commit to mikeiovine/TensorRT-LLM that referenced this pull request Dec 12, 2025
… release 1.1 (NVIDIA#8322)

Signed-off-by: Christina Zhang <83400082+ChristinaZ@users.noreply.github.com>
Signed-off-by: Mike Iovine <6158008+mikeiovine@users.noreply.github.com>
mikeiovine pushed a commit to mikeiovine/TensorRT-LLM that referenced this pull request Dec 13, 2025
… release 1.1 (NVIDIA#8322)

Signed-off-by: Christina Zhang <83400082+ChristinaZ@users.noreply.github.com>
Signed-off-by: Mike Iovine <6158008+mikeiovine@users.noreply.github.com>
mikeiovine pushed a commit to mikeiovine/TensorRT-LLM that referenced this pull request Dec 13, 2025
… release 1.1 (NVIDIA#8322)

Signed-off-by: Christina Zhang <83400082+ChristinaZ@users.noreply.github.com>
Signed-off-by: Mike Iovine <6158008+mikeiovine@users.noreply.github.com>
Signed-off-by: Mike Iovine <miovine@nvidia.com>
mikeiovine pushed a commit to mikeiovine/TensorRT-LLM that referenced this pull request Dec 13, 2025
… release 1.1 (NVIDIA#8322)

Signed-off-by: Christina Zhang <83400082+ChristinaZ@users.noreply.github.com>
Signed-off-by: Mike Iovine <6158008+mikeiovine@users.noreply.github.com>
Signed-off-by: Mike Iovine <miovine@nvidia.com>
mikeiovine pushed a commit to mikeiovine/TensorRT-LLM that referenced this pull request Dec 14, 2025
… release 1.1 (NVIDIA#8322)

Signed-off-by: Christina Zhang <83400082+ChristinaZ@users.noreply.github.com>
Signed-off-by: Mike Iovine <6158008+mikeiovine@users.noreply.github.com>
Signed-off-by: Mike Iovine <miovine@nvidia.com>
mikeiovine pushed a commit to mikeiovine/TensorRT-LLM that referenced this pull request Dec 15, 2025
… release 1.1 (NVIDIA#8322)

Signed-off-by: Christina Zhang <83400082+ChristinaZ@users.noreply.github.com>
Signed-off-by: Mike Iovine <6158008+mikeiovine@users.noreply.github.com>
Signed-off-by: Mike Iovine <miovine@nvidia.com>
mikeiovine pushed a commit to mikeiovine/TensorRT-LLM that referenced this pull request Dec 15, 2025
… release 1.1 (NVIDIA#8322)

Signed-off-by: Christina Zhang <83400082+ChristinaZ@users.noreply.github.com>
Signed-off-by: Mike Iovine <6158008+mikeiovine@users.noreply.github.com>
Signed-off-by: Mike Iovine <miovine@nvidia.com>
mikeiovine pushed a commit to mikeiovine/TensorRT-LLM that referenced this pull request Dec 16, 2025
… release 1.1 (NVIDIA#8322)

Signed-off-by: Christina Zhang <83400082+ChristinaZ@users.noreply.github.com>
Signed-off-by: Mike Iovine <6158008+mikeiovine@users.noreply.github.com>
Signed-off-by: Mike Iovine <miovine@nvidia.com>
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.

3 participants