Repository navigation
test: fix collection errors and gate CUDA-only kernels on ROCm - #3772
Merged
Merged
Conversation
_merge_prefix_tensors_into_state_dict was removed in #3602, and _normalize_out_of_model_tensors_entries now returns four selector lists. Update the MTP absent-auxiliary test to the current _merge_selected_tensors_into_state_dict API so collection no longer fails.
Optional server dependencies and CUDA-only kernels must not break collection or fail on ROCm: - Skip test_openai_server.py and test_openai_server_contract.py at module scope when openai / fastapi are not installed, instead of raising during collection. - Gate every backend in test_gptq.py through the kernel's own SUPPORTS_DEVICES family declaration, validate_device() rules and validate_once() availability. TRITON, MARLIN, MACHETE, SWORDFISH and EXLLAMA_V2 now skip on ROCm instead of failing while loading. - Stub cached_validate_once() alongside the dummy BitBLAS operator in test_qlinear_hierarchy.py so the runtime-state assertions do not require a CUDA BitBLAS install.
ZX-ModelCloud
force-pushed
the
fix/mimo-writer-out-of-model-test
branch
from
November 11, 2026 12:04
9e3844e to
5572929
Compare
test_openai_server_contract.py imported httpx at module scope, so a server environment without the optional httpx package still failed collection after fastapi and starlette were gated. Skip the module when httpx is absent. _kernel_skip_reason() assumed validate_once() always returns (ok, error). TritonV2Linear raises ImportError when its optional runtime is missing, which turned the new gate into a test error instead of a skip. Treat a raising probe as an unavailable kernel, and cover the family mismatch, device rejection, unavailable and raising paths with a host-independent unit test.
ZX-ModelCloud
commented
Nov 11, 2026
ZX-ModelCloud
left a comment
Collaborator
Author
There was a problem hiding this comment.
Reviewed the branch on both accelerator families and fixed two remaining blockers in 403e662ce:
tests/test_openai_server_contract.pystill importedhttpxat module scope, so the module failed collection whenever the optionalhttpxpackage was absent — the same failure this PR set out to remove. It is now gated withpytest.importorskip._kernel_skip_reason()assumedvalidate_once()always returns(ok, error), butTritonV2Linear.validate_once()raises when Triton is missing, turning the new gate into a test error instead of a skip. A raising probe now counts as an unavailable kernel, and the helper has a host-independent unit test for the family-mismatch, device-rejection, unavailable and raising paths.
Verified after the fixes, with the branch merged onto current main:
- CUDA:
tests/kernels/test_gptq.py18 passed / 8 skipped / 0 failed;test_qlinear_hierarchy.py,test_mimo_mixed_source.pyand the server modules 60 passed / 2 skipped;--collect-only15032 tests, 0 errors. - ROCm:
tests/kernels/test_gptq.py+test_qlinear_hierarchy.py15 passed / 20 skipped / 0 failed;--collect-only14983 tests, with only unrelatedeinops/peftmodules still erroring. ruff checkon the changed files: pass.
The kernel-declaration approach (SUPPORTS_DEVICES + validate_device() + validate_once()) is the right replacement for torch.cuda.is_available().
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.
Summary
This PR fixes three test-only defects found while running the full suite on the current
maintree.1. Mimo writer test used a removed symbol
tests/test_mimo_mixed_source.pyimported_merge_prefix_tensors_into_state_dict, which was removed in #3602, sopytest --collect-onlyfailed with:The same test unpacked
_normalize_out_of_model_tensors_entriesas two lists, while the current API returns four selector lists (files, prefixes, suffixes, tensor_names).Fix: use the current successor
_merge_selected_tensors_into_state_dict, unpack all four selector lists, and keep the test intent unchanged: absent MTP auxiliary tensors remain optional and leave the state dict empty.2. Optional server dependencies were not gated
tests/test_openai_server.pyandtests/test_openai_server_contract.pyimportedopenai/fastapiat module scope, so collection failed when those optional packages were absent:ModuleNotFoundError: No module named 'openai'ModuleNotFoundError: No module named 'fastapi'Fix:
pytest.importorskip(...)at module scope. The modules now report as skipped instead of aborting collection.3. CUDA-only kernels were not gated by device family on ROCm
tests/kernels/test_gptq.py::_maybe_skip_backendonly special-cased BitBLAS / Machete / Swordfish / ExLlamaV2. TRITON and MARLIN therefore ran on ROCm, where the kernels correctly refuse:TritonV2Linear is CUDA-only and does not run on ROCm(SUPPORTS_DEVICES = [DEVICE.CUDA])Marlin kernel is not supported on ROCm.The same pattern broke
tests/kernels/test_qlinear_hierarchy.py::test_grouped_nonpacked_kernels_do_not_store_packed_runtime_state: its dummy BitBLAS install stubbed the operator but notcached_validate_once(), so construction raisedNotImplementedError: BitBLAS ... is CUDA-onlyon ROCm.Fix: ask the kernel instead of
torch.cuda.is_available()(HIP reuses torch'scudanamespace, so that check is also true on ROCm)._maybe_skip_backendnow checks every backend'sSUPPORTS_DEVICESfamily declaration,validate_device()rules andvalidate_once()availability, so a kernel added later is gated without editing the test. The dummy BitBLAS install now also stubscached_validate_once(), matching the dummy operator it already installs.Verification
On the rebased tree:
pytest --collect-only -q: 14999 tests collected, 0 errors (previously 2 collection errors).tests/kernels/test_gptq.py: 17 passed, 8 skipped, 0 failed.tests/kernels/test_gptq.py -k "triton or marlin": 8 skipped, 0 failed (these were the 8 failures).tests/kernels/test_qlinear_hierarchy.py: 9 passed (previously 1 failed).ruff checkon all four changed files: pass.No open PR fixes these collection or ROCm test-gating failures. The earlier
fix/rocm-test-gatesbranch targets an older tree and is not merged; this change rewrites only the parts still needed on currentmain.Notes
No production kernel behavior changes: the kernels already rejected unsupported devices correctly; only the tests were wrong.