Skip to content
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
4 changes: 2 additions & 2 deletions tests/pytorch/test_fusible_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def make_reference_and_test_tensors(
test = test.dequantize()

# Make sure reference and test tensors match each other
ref.copy_(test)
ref.copy_(test.to(dtype=ref.dtype))

ref.requires_grad_(requires_grad)
test.requires_grad_(requires_grad)
Expand Down Expand Up @@ -1956,7 +1956,7 @@ def test_dropout(
)
with torch.no_grad():
x_test += 1
x_ref.copy_(x_test)
x_ref.copy_(x_test.to(dtype=x_ref.dtype))
dy_ref, dy_test = make_reference_and_test_tensors(
shape,
test_dtype=dtype,
Expand Down
2 changes: 1 addition & 1 deletion tests/pytorch/test_quantized_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def make_reference_and_test_tensors(
raise ValueError(f"Unsupported quantization scheme ({quantization})")

# Make sure reference and test tensors match each other
ref.copy_(test)
ref.copy_(test.to(dtype=ref.dtype))

ref.requires_grad_(requires_grad)
test.requires_grad_(requires_grad)
Expand Down
2 changes: 1 addition & 1 deletion transformer_engine/pytorch/quantized_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ def __torch_dispatch__(cls, func, types, args, kwargs=None):
dst.quantize_(src)
else:
if isinstance(src, QuantizedTensor):
dtype = src.dtype
dtype = dst.dtype
if dtype not in (torch.float32, torch.float16, torch.bfloat16):
dtype = torch.float32
src = src.dequantize(dtype=dtype)
Expand Down