Skip to content

[https://nvbugs/6581067][fix] Request the unbiased GEMM in fp32 and add bias.float() before a single cast… - #17505

Merged
luyiyun1021 merged 2 commits into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6581067
Aug 27, 2026
Merged

[https://nvbugs/6581067][fix] Request the unbiased GEMM in fp32 and add bias.float() before a single cast…#17505
luyiyun1021 merged 2 commits into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6581067

Conversation

@trtllm-agent

@trtllm-agent trtllm-agent commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: The parity reference nvfp4_gemm(bfloat16) + bias rounds to bf16 twice whereas the fused epilogue rounds once, so at |out|≈374 (1 bf16 ULP = 2.0) cancellation against the bias promotes the reference's already-discarded remainder into a multi-ULP error exceeding atol=5e-3.
  • Fix: Request the unbiased GEMM in fp32 and add bias.float() before a single cast to bf16, making the reference single-rounded so the original tight tolerance passes unchanged (fused becomes bit-identical across 4 shapes × 2 backends × 5 seeds); removed the 4 now-passing waivers.
  • Original test: pytest tests/unittest/_torch/thop/parallel/test_fp4_linear.py::test_fp4_gemm_bias_per_backend -k "mnk2 or mnk3" -v
  • Automated fix generated by repair-bot

Test plan

  • Verify fix on the same GPU type as the original failure
  • Check for regressions in related tests

Links

Dev Engineer Review

  • The reference path performs the NVFP4 GEMM in float32.
  • The reference path adds bias.float() before one cast to bfloat16.
  • This avoids double rounding and restores bit-identical parity with the fused epilogue.
  • The original tolerance remains unchanged.
  • The waiver file removes four obsolete CUBLASLt and CUTLASS bias test waivers.
  • The waiver changes use the existing format and do not expand test scope.

QA Engineer Review

  • Modified the NVFP4 linear bias parity test in tests/unittest/_torch/thop/parallel/test_fp4_linear.py.
  • The test is covered by the four removed entries in tests/integration/test_lists/waives.txt.
  • Coverage spans four shapes, two backends, and five seeds.
  • Verdict: sufficient.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 61b88497-fdf4-4230-b945-ff8e281852d1

📥 Commits

Reviewing files that changed from the base of the PR and between 3035d47 and 0f09f5c.

📒 Files selected for processing (2)
  • tests/integration/test_lists/waives.txt
  • tests/unittest/_torch/thop/parallel/test_fp4_linear.py
💤 Files with no reviewable changes (1)
  • tests/integration/test_lists/waives.txt
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/unittest/_torch/thop/parallel/test_fp4_linear.py

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


Walkthrough

The FP4 bias parity test now computes its reference in float32 before casting to bfloat16. Four CUBLASLt and CUTLASS skip waivers were removed. The tolerance rationale now covers autotuner and accumulation-order differences.

Changes

FP4 bias validation

Layer / File(s) Summary
Update FP4 bias reference and integration coverage
tests/unittest/_torch/thop/parallel/test_fp4_linear.py, tests/integration/test_lists/waives.txt
The reference path performs the unbiased GEMM and bias addition in float32, then casts once to bfloat16. The tolerance comment describes possible autotuner tactic and accumulation-order differences. Four skipped CUBLASLt and CUTLASS bias-per-backend entries were removed.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 0f09f

This localized change aligns the fp32 reference computation with the fused bf16 behavior and removes obsolete test waivers; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: qijune, schetlur-nv, yuanjingx87

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the NVBugs issue, fix type, and primary change: using an unbiased FP32 GEMM and applying bias before one BF16 cast.
Description check ✅ Passed The description clearly explains the double-rounding root cause, the fix, the removed waivers, and the relevant test command. It includes test coverage evidence, although it does not use the template …
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 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.
Full details: Description check

Explanation

The description clearly explains the double-rounding root cause, the fix, the removed waivers, and the relevant test command. It includes test coverage evidence, although it does not use the template headings exactly and omits the PR checklist confirmation.

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

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

@brnguyen2 brnguyen2 left a comment

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.

Approving — the comments below are optional touch-ups, not blockers.

Confirmed fp32 out_dtype is accepted by all three backends this test parametrizes (fp4Gemm.cpp:198, cublasFp4ScaledMM.cpp:75, cudaNvfp4MM.cpp), so the unwaived cuda_core case at mnk0 isn't affected. The fix makes the reference strictly more accurate, which tightens the assertion rather than loosening it.

One correction for the description: at |out|≈374 the effective budget is atol + rtol*|ref| ≈ 3.7, so the failure was rtol-dominated (2 ULP = 4.0), not "exceeding atol=5e-3". Worth fixing so the next reader doesn't chase the wrong term.

Comment thread tests/unittest/_torch/thop/parallel/test_fp4_linear.py
@trtllm-agent
trtllm-agent force-pushed the repair-bot-bug6581067 branch from 239b497 to 583795d Compare August 26, 2026 00:26
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@yiqingy0 yiqingy0 left a comment

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.

Approved for infra part. Need to trigger CI.

@luyiyun1021

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #69413 [ run ] triggered by Bot. Commit: 583795d Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #69413 [ run ] completed with state FAILURE. Commit: 583795d
/LLM/main/L0_MergeRequest_PR pipeline #56750 completed with status: 'UNSTABLE'

CI Report

⚠️ Multi-GPU Label Required:
Multi-GPU tests require the ci: full pre-merge approved label on this PR. Ask a member of NVIDIA/trt-llm-ci-approvers to add the label, then re-trigger CI with the same bot command (no rebase needed).

⚠️ 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

…p4_gemm_bias_per_backend

The reference out_no_bias + bias rounded to bf16 twice while the fused
epilogue rounds once, so at |out|~374 (1 bf16 ULP = 2.0) cancellation
against the bias promoted the remainder the reference had already
discarded into a multi-ULP error, exceeding atol=5e-3.

Compute the unbiased GEMM in fp32 and add the bias in fp32, rounding to
bf16 exactly once. The fused result is then bit-identical to the
reference across 4 shapes x 2 backends x 5 seeds, so the original
tolerance is retained rather than widened.

Remove the now-passing waivers for this bug.

Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
@trtllm-agent
trtllm-agent force-pushed the repair-bot-bug6581067 branch from 583795d to 0f09f5c Compare August 27, 2026 06:04
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@luyiyun1021

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #69666 [ run ] triggered by Bot. Commit: 0f09f5c Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #69666 [ run ] completed with state SUCCESS. Commit: 0f09f5c
/LLM/main/L0_MergeRequest_PR pipeline #56970 completed with status: 'SUCCESS'

CI Report

Link to invocation

@luyiyun1021
luyiyun1021 merged commit 0a41020 into NVIDIA:main Aug 27, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants