[xpu][test][dtypes] Finish XPU enablement of test_affine_quantized_float - #4637
Conversation
Most tests in this file are already device-agnostic. Two gaps remain:
1. test_per_row_with_float32 was still CUDA-only:
- gate -> torch.accelerator.is_available()
- is_sm_at_least_89() scoped behind torch.cuda.is_available(), so the
sm89 requirement still applies to CUDA but does not exclude XPU
- .to("cuda") -> .to(get_current_accelerator_device()), resolved in
the test body
The assertion under test is raised in _input_activation_quant_func_fp8
after _fp8_mm_compat(), which only checks tensor rank and that both
dims are multiples of 16 - no device or vendor probe - so a 64x64
model raises it on any accelerator before any fp8 kernel runs.
2. Non-XPU fix: the gate on test_dequantize_affine_float8 compared a
bool to a string (torch.cuda.is_available() == "cuda"), so it was
always False and the sm89 requirement was never enforced on CUDA.
No effect on sm89+ or XPU; pre-sm89 NVIDIA now correctly skips.
test_quantize_dequantize_fp8_inductor is left alone: it is CPU-only by
construction and making it accelerator-aware needs XPU inductor codegen
expectations, which is separate scope.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/4637
Note: Links to docs will display an error until the docs builds have been completed. ❌ You can merge normally! (5 Unrelated Failures), 1 Unclassified FailureAs of commit 72c043e with merge base 03ca489 ( UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Need to wait until CI "global" fail will be over (see: #4625). |
|
affine_quantized_float is deprecated now I think, cc @andrewor14 @vkuzo maybe migrate useful tests to test_float8_tensor and remove the file? |
|
@pytorchbot label "module: not user facing" |
|
The ciflow label(s) ciflow/xpu will be added, but CI won't be triggered until the workflows are approved (scroll to the bottom of this page). Please ping one of the reviewers if you do not have access to approve and run workflows. |
|
|
Summary
Two targeted fixes to complete XPU enablement of
test/dtypes/test_affine_quantized_float.py:test_per_row_with_float32— last CUDA-hardcoded testReplaces the
torch.cuda.is_available()skip and hardcoded"cuda"device with the device-agnostic pattern.test_dequantize_affine_float8(line 144)The previous gate was:
torch.cuda.is_available()returnsbool, not a string, so this comparison is alwaysFalse. The sm89 requirement was never enforced on pre-sm89 CUDA hardware. This is a leftover from the earlier partial device-agnostic conversion (the sibling testtest_choose_scale_float8_boundsalready carries the correcttorch.cuda.is_available() and not is_sm_at_least_89()form). Fixed to the correct form.Validation
All checks performed on an XPU machine (torch 2.14.0.dev20260714+xpu):
ruff checkandruff format --checkboth clean. Grep sweep for.cuda()/device="cuda"/hardcoded skip strings returns nothing. Remainingtorch.cuda.is_available()occurrences are all properly paired withand not is_sm_at_least_89().