Skip to content

Commit

Permalink
preserve global tf32 in test_sparse_tensors (fairinternal/xformers#1075)
Browse files Browse the repository at this point in the history
__original_commit__ = fairinternal/xformers@449da3b
  • Loading branch information
bottler authored and xFormers Bot committed Apr 4, 2024
1 parent b3fe601 commit 41c2e1d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/test_sparse_tensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from xformers.ops import masked_matmul
from xformers.sparse import BlockSparseTensor, SparseCSRTensor

from .utils import disable_tf32

cuda_only = pytest.mark.skipif(not torch.cuda.is_available(), reason="requires CUDA")
_devices = (
["cpu", "cuda:0"] if torch.cuda.is_available() and torch.version.cuda else ["cpu"]
Expand Down Expand Up @@ -103,6 +105,7 @@ def test_sparse_binary_ops(func, device):
assert torch.allclose(res, res_gt)


@disable_tf32
@pytest.mark.parametrize("tensor_type", _tensor_types)
@pytest.mark.parametrize("device", _devices)
def test_masked_matmul(tensor_type, device):
Expand Down Expand Up @@ -155,6 +158,7 @@ def test_masked_matmul(tensor_type, device):
assert torch.allclose(b.grad, bb.grad, atol=atol)


@disable_tf32
@pytest.mark.parametrize("tensor_type", _tensor_types)
@pytest.mark.parametrize("device", _devices)
def test_bmm(tensor_type, device):
Expand Down Expand Up @@ -204,6 +208,7 @@ def test_bmm(tensor_type, device):
), f"{torch.max(torch.abs(a_grad-a_sparse.grad.to_dense()))}"


@disable_tf32
@pytest.mark.parametrize("tensor_type", _tensor_types)
@pytest.mark.parametrize("device", _devices)
def test_sparse_softmax(tensor_type, device):
Expand Down

0 comments on commit 41c2e1d

Please sign in to comment.