[TRTLLM-12288][fix] add the follow-up fix of nemotron nvfp4 on hopper
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.
- Some syntax changes and code rearrangements
- 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-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title. -
Any new dependencies have been scanned for license and vulnerabilities
-
CODEOWNERS updated if ownership changes
-
Documentation updated as needed
-
Update tava architecture diagram if there is a significant design change in PR.
-
The reviewers assigned automatically/manually are appropriate for the PR.
-
[x] 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.
📝 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.
/bot run -disable-fail-fast
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
/bot run --disable-fail-fast
PR_Github #51766 [ run ] triggered by Bot. Commit: ff169c6 Link to invocation
PR_Github #51766 [ run ] completed with state SUCCESS. Commit: ff169c6
/LLM/main/L0_MergeRequest_PR pipeline #41134 completed with status: 'FAILURE'
⚠️ 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
/bot help
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) --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.
PR_Github #52226 Bot args parsing error: usage: /bot [-h] {run,kill,skip,submit,reviewers,reuse-pipeline,reuse-review} ... /bot: error: unrecognized arguments: --help
/bot run --disable-fail-fast
PR_Github #52564 [ run ] triggered by Bot. Commit: 7b30cfc Link to invocation
PR_Github #52564 [ run ] completed with state SUCCESS. Commit: 7b30cfc
/LLM/main/L0_MergeRequest_PR pipeline #41848 completed with status: 'FAILURE'
⚠️ 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
/bot run --disable-fail-fast
PR_Github #52693 [ run ] triggered by Bot. Commit: 346b2ea Link to invocation
PR_Github #52693 [ run ] completed with state SUCCESS. Commit: 346b2ea
/LLM/main/L0_MergeRequest_PR pipeline #41961 completed with status: 'FAILURE'
⚠️ 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
/bot run --disable-fail-fast
PR_Github #52929 [ run ] triggered by Bot. Commit: 1c327ce Link to invocation
PR_Github #52929 [ run ] completed with state SUCCESS. Commit: 1c327ce
/LLM/main/L0_MergeRequest_PR pipeline #42174 completed with status: 'FAILURE'
⚠️ 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