Skip to content

[TRTLLM-12288][fix] add the follow-up fix of nemotron nvfp4 on hopper - #14862

Closed
JadoTu wants to merge 6 commits into
NVIDIA:mainfrom
JadoTu:follow_up_fix_of_PR14775
Closed

[TRTLLM-12288][fix] add the follow-up fix of nemotron nvfp4 on hopper#14862
JadoTu wants to merge 6 commits into
NVIDIA:mainfrom
JadoTu:follow_up_fix_of_PR14775

Conversation

@JadoTu

@JadoTu JadoTu commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Refined NVFP4 hardware compatibility to support only specific GPU SM versions (100-120).
    • Enhanced input validation for dequantization operations to ensure CUDA graph safety and correct tensor properties.
    • Improved FP8 input handling with stricter condition checking.
    • Restricted EPLB support for NVFP4 quantization on older GPU architectures.
  • Chores

    • Added QA test for NVFP4 quantization on Hopper GPUs.

Description

This PR is to add the follow-up fix of supporting nemotron nvfp4 on hopper. The link of pr is here.

  1. Some syntax changes and code rearrangements
  2. Append the ci test to qa test list.

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.

Signed-off-by: jiant <107457950+JadoTu@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR refines NVFP4 W4A16 support for Hopper GPUs by tightening SM-version hardware detection to [100, 120), disabling FP4 attention output on unsupported SM versions, consolidating dequantization imports to module scope, and adding stricter input validation throughout the dequantization path.

Changes

NVFP4 W4A16 Hopper Refinement

Layer / File(s) Summary
Nemotron NVFP4 hardware gating and attention patching
tensorrt_llm/_torch/models/modeling_nemotron_h.py
Removes os import and environment-variable control. Tightens SM check from ≥100 to [100, 120) for NVFP4 enablement in NemotronHLayer. Updates _force_moe_backend_for_w4a16_on_hopper and _use_w4a16_for_nvfp4_on_hopper to treat SM <100 and SM ≥120 as "no native NVFP4 HW". Adds Attention.create_weights patching via _patched_attn_create_weights to disable per-instance FP4 output (attn.has_nvfp4 = False), with proper restoration in the context manager's finally block.
Dequantization path restructuring and input validation
tensorrt_llm/_torch/modules/fused_moe/quantization.py, tensorrt_llm/_torch/modules/linear.py, tensorrt_llm/_torch/modules/triton_dequant_nvfp4.py
Moves build_active_expert_mask and dequant_nvfp4_active_triton to module-level imports in quantization.py. Changes linear.py to import dequant_nvfp4_2d_triton from dedicated triton_dequant_nvfp4 module. Tightens FP8 input validation in W4A16NVFP4LinearMethod.apply to require both force_dynamic_quantization=false and inv_input_scale present. Adds comprehensive runtime assertions in triton_dequant_nvfp4 for tensor rank, E-dimension consistency, contiguity, innermost stride, and validates weight_scale_2.numel() == 1.
EPLB config update and NVFP4 Hopper test
tensorrt_llm/_torch/modules/fused_moe/quantization.py, tests/integration/test_lists/qa/llm_function_core.txt
Sets W4A16NVFP4CutlassFusedMoEMethod.eplb_support_status = EplbSupportStatus.NOT_SUPPORTED and updates docstring to reflect disabled online EPLB for SM<100. Adds new QA test entry TestNemotronV3Super::test_nvfp4_4gpus_hopper_w4a16 for validation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • NVIDIA/TensorRT-LLM#14775: This PR directly refines the same Hopper NVFP4-on-Hopper W4A16 fallback by updating SM version gating and dequantization path infrastructure introduced in #14775.

Suggested reviewers

  • nv-guomingz
  • Wanli-Jiang
  • tijyojwad
  • xinhe-nv
  • danielafrimi
  • HuiGao-NV
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: a follow-up fix for nemotron nvfp4 support on Hopper hardware, and includes proper JIRA ticket and type prefix.
Description check ✅ Passed The description provides context (follow-up to PR #14775) and lists changes (syntax updates, code rearrangements, CI test addition), though it lacks detailed explanation of the technical rationale and specific changes across the four modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tensorrt_llm/_torch/modules/fused_moe/quantization.py`:
- Line 2914: The class currently only sets eplb_support_status =
EplbSupportStatus.NOT_SUPPORTED (metadata) but still inherits
NVFP4FusedMoEMethod.create_weights(), which never calls
_online_eplb_not_supported(), so modules with an attached layer_load_balancer
can still take the shared-weight path; to fix, add a runtime fail-fast check by
overriding create_weights (or adding an __init__ guard) in this class to call
_online_eplb_not_supported() when eplb_support_status ==
EplbSupportStatus.NOT_SUPPORTED and a layer_load_balancer is present (or simply
raise an error), ensuring the code path that would use
NVFP4FusedMoEMethod.create_weights() cannot proceed with EPLB disabled.

In `@tensorrt_llm/_torch/modules/triton_dequant_nvfp4.py`:
- Around line 167-189: The assert-based runtime checks for packed_weight,
scale_linear, active_mask, and weight_scale_2 should be converted to explicit
runtime exceptions so they are not stripped with python -O: replace each assert
with an if condition that raises a ValueError (or a more specific exception)
using the existing error message strings (e.g., check
packed_weight.stride(-1)==1 and raise ValueError("packed_weight innermost stride
must be 1 (contiguous K dim)"), verify scale_linear.dim()==3 and stride(-1)==1
and shape[0]==E, ensure active_mask is 1D contiguous of length E, and ensure
weight_scale_2 is 1D contiguous of length E) to preserve the same validation
behavior at runtime.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 294f06bd-2220-470d-8b51-e7976f10335b

📥 Commits

Reviewing files that changed from the base of the PR and between 4cc2d8a and 82f93a0.

📒 Files selected for processing (5)
  • tensorrt_llm/_torch/models/modeling_nemotron_h.py
  • tensorrt_llm/_torch/modules/fused_moe/quantization.py
  • tensorrt_llm/_torch/modules/linear.py
  • tensorrt_llm/_torch/modules/triton_dequant_nvfp4.py
  • tests/integration/test_lists/qa/llm_function_core.txt

Comment thread tensorrt_llm/_torch/modules/fused_moe/quantization.py
Comment thread tensorrt_llm/_torch/modules/triton_dequant_nvfp4.py Outdated
JadoTu added 2 commits June 2, 2026 17:26
Signed-off-by: jiant <107457950+JadoTu@users.noreply.github.com>
Signed-off-by: jiant <107457950+JadoTu@users.noreply.github.com>
@JadoTu

JadoTu commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run -disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51763 Bot args parsing error: usage: /bot [-h]
{run,kill,skip,submit,reviewers,reuse-pipeline,reuse-review} ...
/bot: error: unrecognized arguments: -disable-fail-fast

Link to invocation

@JadoTu

JadoTu commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51766 [ run ] triggered by Bot. Commit: ff169c6 Link to invocation

# Mirrors what `TRTLLM_ENABLE_ATTENTION_NVFP4_OUTPUT=0` does.
original_attn_create_weights(self)
if hasattr(self.attn, 'use_nvfp4_output'):
self.attn.use_nvfp4_output = lambda *args, **kwargs: False

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why it is not simple False but a lambda function here?

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51766 [ run ] completed with state SUCCESS. Commit: ff169c6
/LLM/main/L0_MergeRequest_PR pipeline #41134 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@JadoTu

JadoTu commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator Author

/bot help

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

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) --high-priority]

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. Supports wildcard * for pattern matching (e.g., "*PerfSanity*" matches all stages containing PerfSanity). Examples: "A10-PyTorch-1, xxx", "PerfSanity". 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. Supports wildcard * for pattern matching. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx", --extra-stage "Post-Merge".

--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.

--high-priority (OPTIONAL) : Run the pipeline with high priority. This option is restricted to authorized users only and will route the job to a high-priority queue.

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.

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #52226 Bot args parsing error: usage: /bot [-h]
{run,kill,skip,submit,reviewers,reuse-pipeline,reuse-review} ...
/bot: error: unrecognized arguments: --help

Link to invocation

Signed-off-by: jiant <107457950+JadoTu@users.noreply.github.com>
@JadoTu

JadoTu commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #52564 [ run ] triggered by Bot. Commit: 7b30cfc Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #52564 [ run ] completed with state SUCCESS. Commit: 7b30cfc
/LLM/main/L0_MergeRequest_PR pipeline #41848 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@JadoTu

JadoTu commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #52693 [ run ] triggered by Bot. Commit: 346b2ea Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #52693 [ run ] completed with state SUCCESS. Commit: 346b2ea
/LLM/main/L0_MergeRequest_PR pipeline #41961 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@JadoTu

JadoTu commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #52929 [ run ] triggered by Bot. Commit: 1c327ce Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #52929 [ run ] completed with state SUCCESS. Commit: 1c327ce
/LLM/main/L0_MergeRequest_PR pipeline #42174 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@JadoTu JadoTu closed this Jul 17, 2026
@JadoTu

JadoTu commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator Author

Close this PR as the parent feature is reverted.

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.

4 participants