Skip to content

[PyTorch] Use FP16 tols for distributed tests with TF32 compute #1831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions tests/pytorch/distributed/run_numerics.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@
)


# Disable TF32
torch.backends.cuda.matmul.allow_tf32 = False
torch.backends.cudnn.allow_tf32 = False


# Quantization recipe setup
def quantization_recipe() -> Recipe:
if QUANTIZATION == "fp8":
Expand Down Expand Up @@ -166,7 +161,7 @@ def backward(ctx, grad_output):


def _constant(tensor):
return nn.init.constant_(tensor, 0.5)
return nn.init.constant_(tensor, 0.05)


def dist_print(msg, src=None, end="\n", error=False):
Expand All @@ -189,7 +184,8 @@ def _get_tolerances(dtype):
if dtype == torch.bfloat16:
return {"rtol": 1.6e-2, "atol": 1e-5}
if dtype == torch.float32:
return {"rtol": 1.2e-4, "atol": 1e-4}
# TF32 has same mantissa bits as FP16
return {"rtol": 1e-3, "atol": 1e-5}
raise ValueError(f"Unsupported dtype ({dtype})")


Expand Down
2 changes: 1 addition & 1 deletion tests/pytorch/distributed/test_numerics.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_distributed(quantization):
if quantization == "fp8" and not fp8_available:
pytest.skip(reason_for_no_fp8)
if quantization == "fp8_cs" and not fp8_available:
pytest.skip(fp8_available)
pytest.skip(reason_for_no_fp8)
if quantization == "mxfp8" and not mxfp8_available:
pytest.skip(reason_for_no_mxfp8)
if quantization == "fp8_block_scaling" and not fp8_block_scaling_available:
Expand Down
Loading