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

[tests] enable testing for xpu (rebased) #349

Merged
merged 2 commits into from
Nov 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
2 changes: 1 addition & 1 deletion optimum/quanto/library/qbytes_mm.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def qbytes_mm_impl_cuda(activations: torch.Tensor, weights: torch.Tensor, output
def qbytes_mm_impl_cpu(activations: torch.Tensor, weights: torch.Tensor, output_scales: torch.Tensor) -> torch.Tensor:
if (
# FIXME: accuracy issues with 2.4.x
version.parse(torch.__version__).release > version.parse("2.5.0").release
version.parse(torch.__version__).release >= version.parse("2.6.0").release
and activations.dtype == torch.int8
and weights.dtype == torch.int8
):
Expand Down
2 changes: 2 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
devices += ["cuda"]
elif torch.backends.mps.is_available():
devices += ["mps"]
elif torch.xpu.is_available():
devices += ["xpu"]


@pytest.fixture(scope="module", params=devices)
Expand Down
3 changes: 3 additions & 0 deletions test/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ def get_device_memory(device):
elif device.type == "mps":
torch.mps.empty_cache()
return torch.mps.current_allocated_memory()
elif device.type == "xpu":
torch.xpu.empty_cache()
return torch.xpu.memory_allocated()
return None


Expand Down
2 changes: 1 addition & 1 deletion test/tensor/weights/weight_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def check_weight_qtensor_linear(qweight, batch_size, tokens, use_bias, rel_max_e
max_err = (out - qout).abs().max()
rel_max_err = max_err / mean_val
# These values were evaluated empirically without any optimized kernels.
rtol = {"cpu": 1e-2, "cuda": 2e-2, "mps": 1e-2}[device.type]
rtol = {"cpu": 1e-2, "cuda": 2e-2, "mps": 1e-2, "xpu": 2e-2}[device.type]
assert (
rel_max_err < rtol
), f"Maximum error {max_err:.2f} is too high for input of mean value {mean_val:.2f} ({rel_max_err*100:.2f} %)"
Loading