Skip to content

Fix all reduce precision in TP Newton Schulz - #304

Merged
skyw merged 1 commit into
mainfrom
fix_ns_all_reduce_prec
Sep 24, 2026
Merged

skyw merged 1 commit into
mainfrom
fix_ns_all_reduce_prec

Conversation

@skyw

@skyw skyw commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

When fp32 matmul precision is set to medium, we explicitly cast tensor to bfloat16 because PyTorch lack of bfloat16 I/O kernels and will fallback to TF32. However, that has introduced unintentional behavior that all-reduce in TP happens in bf16.

@copy-pr-bot

copy-pr-bot Bot commented Sep 24, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Signed-off-by: Hao Wu <skyw@nvidia.com>
@skyw
skyw force-pushed the fix_ns_all_reduce_prec branch from 33aeac3 to 5cf479e Compare September 24, 2026 15:59
@greptile-apps

greptile-apps Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The PR appears safe to merge, with a non-blocking gap in regression coverage for its precision fix.

Findings

  1. P2 Precision fix lacks regression coverage ▶

Summary

The PR performs tensor-parallel Newton–Schulz all-reduces in FP32, then restores the Gram matrix to the iteration dtype, across all four step variants.

  • The changed BF16 reduction behavior needs a numerical regression test.

Reviews (1) · Last reviewed commit: "all reduce in fp32 in tp newton schulz"

"""
A = X @ X.mT
if tp_group is not None:
A = A.to(torch.float32)

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.

P2 Precision fix lacks regression coverage

The new FP32 all-reduce path has no numerical test for BF16 tensor-parallel shards. The distributed step tests use FP32 inputs, where these casts are no-ops, while the medium-precision test checks only argument forwarding. A test with values sensitive to reduction rounding would help catch regressions in the behavior this change fixes.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@skyw
skyw requested a review from mkhona-nvidia September 24, 2026 16:11
@skyw

skyw commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 5cf479e

@skyw
skyw enabled auto-merge (squash) September 24, 2026 16:14
@github-actions

Copy link
Copy Markdown

Test Results

   97 files  ±0    191 suites  ±0   2m 8s ⏱️ -5s
1 464 tests ±0  1 464 ✅ +1  0 💤 ±0  0 ❌  - 1 
3 344 runs  ±0  3 344 ✅ +1  0 💤 ±0  0 ❌  - 1 

Results for commit 5cf479e. ± Comparison against base commit 0c5cdcd.

@skyw
skyw merged commit 840ae70 into main Sep 24, 2026
31 checks passed
@skyw
skyw deleted the fix_ns_all_reduce_prec branch September 24, 2026 16:43
@codecov

codecov Bot commented Sep 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...optimizers/orthogonalized_optimizers/muon_utils.py 50.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

This branch was successfully deployed

2 active deployments
public — 5cf479e0 Deployed Sep 24, 2026 by copy-pr-bot[bot] via release / finalize / notify #266
test — 5cf479e0 Deployed Sep 24, 2026 by copy-pr-bot[bot] via cicd-wait-in-queue #1051
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.

2 participants