Skip to content
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

fix bug with float8 + inference_mode #659

Merged
merged 1 commit into from
Aug 12, 2024
Merged
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: 8 additions & 2 deletions test/float8/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,14 @@ def test_repr(self):
s = m.__repr__()
assert "i:dyn,w:del,go:dyn" in s

@unittest.skipIf(not is_cuda_8_9, "CUDA 8.9 not available")
def test_inference_mode(self):
x = torch.randn(32, 32, device='cuda')
m = nn.Sequential(nn.Linear(32, 32)).cuda()
m = convert_to_float8_training(m)
with torch.inference_mode(mode=True):
y = m(x)


class TestScaledMM:
@unittest.skipIf(
Expand Down Expand Up @@ -718,8 +726,6 @@ def test_fp8_tensor_statistics(self):
(zero_cnt, max_cnt) = fp8_tensor_statistics(fp8_over_underflow, lp_dtype)
self.assertEqual((zero_cnt, max_cnt), (tensor_len, tensor_len))

# ghstack test 1
# ghstack test 2

if __name__ == "__main__":
pytest.main([__file__])
1 change: 1 addition & 0 deletions torchao/float8/float8_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def decorator(func):
aten.slice.Tensor,
aten.transpose.int,
aten.fill_.Scalar,
aten.reshape.default,
]
)
def float8_desugar_op(aten_op, args, kwargs=None):
Expand Down
Loading