Skip to content

test: skip CUDA-only kernels on ROCm with a shared requires_nvidia_cuda gate (#4770) - #5056

Merged
Qubitium merged 1 commit into
mainfrom
root/rocm-gating-4770
Nov 18, 2026
Merged

Qubitium merged 1 commit into
mainfrom
root/rocm-gating-4770

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

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 device
namespace. 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:

def requires_nvidia_cuda() -> bool:
    return torch.cuda.is_available() and torch.version.hip is None

It matches the repo's existing inline convention
(not torch.cuda.is_available() or torch.version.hip is not None), now named
once. A unit test patches torch.version.hip and asserts the predicate is
False 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.py
  • test_marlin_scratch_cuda.py (module gate, plus require_dtype() now
    pytest.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, Machete
    availability), test_hf_packing_api.py (GPU feasibility),
    test_model.py::TestModelSave::test_moe
  • test_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 TensorCore
    code and the library rejects it on ROCm)
  • test_checkpoint_modules.py::test_qqq_optional_group_scales_schema and the
    two test_qqq_jit.py JIT tests (QQQ has no ROCm kernel; the remaining QQQ
    CUDA 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 (bc branch 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.py
    quantize+reload legs

test_marlin_device_profile.py was already gated on
torch.version.hip is not None on main; it is unchanged.

Section 2 uses skipif(torch.version.hip is not None) (not the device gate) for
the 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 tests
  • test_max_memory_kernel_devices_4632.py: the mixed-capability refusal

Section 3: test_allspark_awq.py::test_awq_module_export_keeps_checkpoint_layout
now expects qzeros_format and excludes it from the export, exactly like
test_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.hip patched.

  • tests/test_accelerator_gates.py: 26 passed (25 before; +1 new
    predicate test). Red proof on unmodified origin/main: the helper does not
    exist (hasattr(tests.accelerator_gates, "requires_nvidia_cuda") is False),
    so the new test cannot pass there.
  • Representative touched files on this CUDA host (GPU 5), branch vs. base
    worktree at the same commit:
    • 14 touched files: 383 passed, 16 failed, 53 skipped
    • base origin/main: 382 passed, 16 failed, 53 skipped
    • the only delta is the new predicate test; the 16 failures are pre-existing
      AVX512-only / device-move nodes on this host and reproduce identically on
      base. No gated node skipped on CUDA.
  • Additional runs on CUDA: test_marlin_scratch_cuda.py 62 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.
  • Simulated HIP (torch.version.hip patched before collection) on the same
    nodes: 10 passed, 100 skipped, 0 failed - every gated node skips with its
    reason, while ungated nodes still run.
  • test_dynamic.py and kernels/test_static_cache_compile_4669.py fail
    identically on base (5 failed each) due to host issues (broken
    flash_attn_2_cuda import and the kernels.CUDAProperties name clash in this
    venv); not related to this diff.
  • ruff check clean 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 its
qzeros_format expectation was verified against the CUDA twin plus a direct
AllSparkAwqLinear.state_dict() key check on this host.

…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.
@Qubitium
Qubitium merged commit 4d2174f into main Nov 18, 2026
9 checks passed
@Qubitium
Qubitium deleted the root/rocm-gating-4770 branch November 18, 2026 00:54
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant