Repository navigation
test: skip CUDA-only kernels on ROCm with a shared requires_nvidia_cuda gate (#4770) - #5056
Merged
Merged
Conversation
…availability `torch.cuda.is_available()` is true on ROCm because HIP reuses the CUDA device namespace, so tests that drive an NVIDIA-only kernel reached the kernel and failed with its "CUDA-only" refusal instead of skipping. Add a shared `requires_nvidia_cuda()` predicate to `tests/accelerator_gates.py` (`torch.cuda.is_available() and torch.version.hip is None`) and use it wherever a test names a CUDA-only backend. - kernels: AWQ native autograd, static-cache compile, Marlin scratch (also make `require_dtype()` skip on HIP), QQQ JIT. - Marlin/ExLlamaV2/Triton/NF12/BitBLAS model tests and reload legs. - Asymmetric real-model gates and kernel-audit contract tests. - Section 2: the CUDA-capability fakes cannot group or refuse on ROCm, so they skip on HIP while still running on CPU-only hosts. - Section 3: `test_allspark_awq.py` expects the `qzeros_format` marker like its CUDA twin. ROCm itself was not executed here; the predicate is unit-tested with `torch.version.hip` patched, and every gated node still runs on this CUDA host.
This was referenced Nov 18, 2026
Qubitium
added a commit
that referenced
this pull request
Nov 18, 2026
- #4387: the biased GGUFCudaKernel layer now caches its (0, 4) uint8 shift table as an immutable per-module constant (#5014), so the exact `before - qweight.nbytes` bound is 512 B short. Allow the module's small cached constants, then drop the derived caches and assert the exact packed-weight release, so a second weight copy still fails. - #5014: Q2_K/Q3_K packing needs llama.cpp's native quantizer. Skip only the host-dequant declaration nodes when llama-cpp-python is absent and add a unit check for that skip reason. - #5020: gate the GPTQ_TRITON node, and the repeated-generate node that uses the same backend, on the shared #5056 `requires_nvidia_cuda()` predicate instead of hard-coding a CUDA-only kernel on ROCm.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4770 (section 1, section 2, and section 3's stale expectation only).
Problem
torch.cuda.is_available()is true on ROCm because HIP reuses the CUDA devicenamespace. Tests that drive an NVIDIA-only kernel therefore ran on ROCm and
failed with the library's explicit "CUDA-only ... use X on ROCm" refusal instead
of skipping. The same applies to fakes that feed
get_device_capability(),which selector validation deliberately ignores on ROCm (
utils/importer.py).Change
One shared predicate in
tests/accelerator_gates.py:It matches the repo's existing inline convention
(
not torch.cuda.is_available() or torch.version.hip is not None), now namedonce. A unit test patches
torch.version.hipand asserts the predicate isFalse for a HIP build, False with no device, and True only on a CUDA build with
a device.
Applied to:
kernels/test_awq_native_eval_autograd.py,kernels/test_static_cache_compile_4669.pytest_marlin_scratch_cuda.py(module gate, plusrequire_dtype()nowpytest.skips on HIP as the issue asks),test_marlin_g_idx.py,test_q4_marlin.py,test_lora.py(all Marlin nodes),test_gptaq.py,test_dynamic.py(Triton/Marlin params),test_inference_speed.py(Marlin case)
test_asymmetric_real_model_gates.py(build-failure propagation),test_kernel_audit_regressions.py(AWQ GEMM contract, Macheteavailability),
test_hf_packing_api.py(GPU feasibility),test_model.py::TestModelSave::test_moetest_q4_exllama_v2.py,test_eval_runtime.py::test_eval_path,test_packable.py(ExLlamaV2/Triton/Marlin),test_serialization.py(2 Marlin + ExLlamaV2),
test_bits.py,test_save_loaded_quantized_model.py(Triton),
test_bitblas.py(whole module: BitBLAS emits NVIDIA TensorCorecode and the library rejects it on ROCm)
test_checkpoint_modules.py::test_qqq_optional_group_scales_schemaand thetwo
test_qqq_jit.pyJIT tests (QQQ has no ROCm kernel; the remaining QQQCUDA nodes already skipped on
qqq_runtime_available()but now say why)test_glm5_core_cuda.py,test_kimi_k3_core_cuda.py,test_exl3_wide_input.py(bcbranch is NVIDIA-only),test_gptqmodel_nf12_api.py(loader tests),test_awq_gemv_insession_4554.py,and the
test_awq_gemm.py/test_awq_gemv_fast.py/test_awq_llm_awq.pyquantize+reload legs
test_marlin_device_profile.pywas already gated ontorch.version.hip is not Noneonmain; it is unchanged.Section 2 uses
skipif(torch.version.hip is not None)(not the device gate) forthe capability fakes, so they keep running on CPU-only hosts and only skip
where the capability tuple is ignored:
test_default_device_mixed_capability_4705.py: the 3 grouping/refusal teststest_max_memory_kernel_devices_4632.py: the mixed-capability refusalSection 3:
test_allspark_awq.py::test_awq_module_export_keeps_checkpoint_layoutnow expects
qzeros_formatand excludes it from the export, exactly liketest_allspark_awq_cuda.py(the marker was added in #4134).Out of scope (unchanged): HIP numeric tolerances (clip tie-break, benchmark
wall-clock, QQQ Hessian peak) and section 4's card-instability/library items.
No library code is touched.
Verification (this host: 8x PG506, sm_80, CUDA 13, torch 2.15)
The ROCm side was not executed here (no AMD device). The gate is correct
because it is the same predicate the repo already uses at 48 call sites, and
the helper is unit-tested with
torch.version.hippatched.tests/test_accelerator_gates.py: 26 passed (25 before; +1 newpredicate test). Red proof on unmodified
origin/main: the helper does notexist (
hasattr(tests.accelerator_gates, "requires_nvidia_cuda")is False),so the new test cannot pass there.
worktree at the same commit:
origin/main: 382 passed, 16 failed, 53 skippedAVX512-only / device-move nodes on this host and reproduce identically on
base. No gated node skipped on CUDA.
test_marlin_scratch_cuda.py62 nodes -> 60 passed,2 skipped (the two-GPU cases);
test_glm5_core_cuda.py(10 nodes) +test_allspark_awq_cuda.py::test_awq_module_export_keeps_checkpoint_layout(2 nodes) -> 12 passed.
torch.version.hippatched before collection) on the samenodes: 10 passed, 100 skipped, 0 failed - every gated node skips with its
reason, while ungated nodes still run.
test_dynamic.pyandkernels/test_static_cache_compile_4669.pyfailidentically on base (5 failed each) due to host issues (broken
flash_attn_2_cudaimport and thekernels.CUDAPropertiesname clash in thisvenv); not related to this diff.
ruff checkclean on every touched file.Not verified: ROCm execution; the AllSpark HIP twin
(
test_allspark_awq.py) is RDNA4-only and skips on this CUDA host, so itsqzeros_formatexpectation was verified against the CUDA twin plus a directAllSparkAwqLinear.state_dict()key check on this host.