Repository navigation
fix(tests,jit): repair false-green gates and report the real ninja failure - #3525
Conversation
…ilure Five audited P0/P1 items; each was reproduced on hardware before changing it. B1 test_intel_cpu_xpu.py: `setUp` was a @classmethod, so unittest passed the class as `self` and `self.forward(self.torch_model, ...)` bound unbound: 6x `TypeError: forward() missing 1 required positional argument: 'x'`. Drop the decorator; 8 passed on 2x RTX 4090 (was 6 failed / 2 passed). B2 test_asymmetric_real_models.py: Machete is Hopper-only (SM90, and >=204800 bytes opt-in shared memory), but the cases only gated on `torch.cuda.is_available()`, so all four failed on an SM89 4090. Gate on the kernels' own runtime checks instead: `machete_runtime_error()`, plus `marlin_runtime_error()` for Marlin, which is CUDA-only and also failed on ROCm (where `torch.cuda.is_available()` is True). 2 passed / 4 skipped on the 4090 and on ROCm GPUs 2,3. B3 test_selection.py asserted `GGUFCudaKernel not in candidates`, but #3434 added bits 1/2/3 to that kernel, so the assertion was stale and contradicted the implementation. Verified against an independent Torch GGUF oracle on the 4090 that all routed qtypes agree: Q1_0 maxdiff 4.88e-4, IQ1_S/IQ1_M 1.95e-3, Q2_K/Q2_0/IQ2_* <= 1.95e-3, Q4-Q8 <= 1.95e-3 (fp16, atol 8e-2). Update the assertion to require the kernel only after Triton. Found while validating B3: TQ1_0 and TQ2_0 have no GPU convert kernel, and ggml-cuda hits `GGML_ASSERT(convert_func != nullptr)`, which aborts the whole interpreter rather than raising. The CPU backend does support them, so add a CUDA-only reject set (sharing the existing Q8_1/Q8_K CPU set) and raise `NotImplementedError` before any graph is built. Add CUDA oracle coverage for 1-bit/2-bit and a CPU ternary regression test that pins the set split. B4 utils/cpp.py surfaced `Ninja is required to load C++ extensions` verbatim while the real cause was ninja living in `$CONDA_PREFIX/bin` with that bin directory missing from PATH. Reproduced both ways on ExLlamaV2 (JIT fails without the env bin on PATH, builds in 20s with it). Add ninja/cmake resolution, versions, `$CONDA_PREFIX` PATH hint, and an actionable hint to the JIT failure diagnostics. B5 test_w4a_nvfp4_gb10.py asserted `_weight_e4m3.numel() == in*out`, encoding the expanded-cache violation as expected behavior. Already fixed upstream by #3492 (NVFP4 stages the E4M3 operand per forward); the audit ran a branch 22 commits behind origin/main and no change is needed here. Validation: 197 passed / 48 skipped for the touched CUDA suites on 2x RTX 4090; 271 passed / 429 skipped for tests/test_gguf_all_formats.py with the llama-cpp CUDA runtime present; ROCm (GPUs 2,3) shows the same skips and no new failures. A pre-existing `test_load_defaults_to_all_extensions` failure and two pre-existing ROCm selection failures also fail on unmodified main.
Request changes — the new CUDA guard fires too late for AUTOVerified on real hardware (2x RTX 4090, worktree Blocking: AUTO still selects
|
`select_quant_linear` validates candidates by `bits` only, so it cannot see the GGUF qtype. For TQ1_0/TQ2_0 it kept `GGUFCudaKernel` in the AUTO candidate list; `GGUFTritonKernel` rejects those types in `__init__`, so `create_quant_layer` fell through to `GGUFCudaKernel`, which constructed fine. The existing guard lived in `quantized_matmul_cuda`, i.e. the first `forward`, and `create_quant_layer` only retries the next AUTO candidate on a `NotImplementedError` raised during construction. The result was no runtime fallback at all: AUTO built the layer and then failed during inference, while the class comment claimed GGUF_TORCH was the fallback. Move the rejection into `GGUFCudaKernel.__init__`, matching the precedent in `GGUFTritonKernel`, and keep the `quantized_matmul_cuda` check as defence in depth. Verified on 2x RTX 4090 through the real loader entry point: AUTO now resolves tq1_0/tq2_0 to `GGUFTorchLinear` and forward succeeds. Update the explicit-constructor test to assert the constructor raises, and add AUTO-path coverage that mirrors `create_quant_layer`: build candidates in priority order, skip constructor rejections, and require the selection to land on `GGUFTorchLinear` with a working forward. Asserting on the `multi_select` candidate list would be wrong, since selection is bits-based and `GGUFCudaKernel` legitimately remains a candidate.
|
#3525 (comment) Confirmed: on Fixed in Test coverage — One note on your suggested assertion: "auto-selection never picks Minor points, both correct:
Re-validation after the fix:
Also noted: |
|
Review of Build failures are converted to test skips in The earlier GGUF constructor-fallback issue is fixed. I installed Fixed and pushed in Added 21 regression cases covering Hopper, Ada, Blackwell, Turing, insufficient shared memory, ROCm, explicit target-device validation, and build-error propagation through the generation test entry point. Before the fix: 11 failed / 10 passed. After the fix, the regression, selection, JIT, and native GGUF suites report 211 passed / 30 skipped. The four Machete real-model cases still correctly skip on the RTX 4090. Ruff check, formatting check for the new test file, and |
Summary
Four test-gating and diagnostic defects, plus one audit finding that was already
fixed upstream. Each item was reproduced on real hardware before anything was
changed, and the one review finding that proved real was fixed and re-verified.
tests/kernels/test_intel_cpu_xpu.pytests/kernels/test_asymmetric_real_models.pyGGUFCudaKernelassertion intests/kernels/test_selection.pyNinja is requiredJIT error ingptqmodel/utils/cpp.pytests/kernels/test_w4a_nvfp4_gb10.pyChanges
Test setup was bound to the class, not the instance
tests/kernels/test_intel_cpu_xpu.pydecoratedsetUpwith@classmethod, sounittest passed the class as
selfandself.forward(self.torch_model, ...)bound unbound:
6 failed before, 8 passed after (2x RTX 4090).
Hardware gates relied on
torch.cuda.is_available()tests/kernels/test_asymmetric_real_models.pygated Machete cases only ontorch.cuda.is_available(), but Machete is Hopper-only (SM90, and >=204800bytes opt-in shared memory), so all four failed on an SM89 4090. The cases now
ask each kernel's own runtime check instead of re-deriving capability:
machete_runtime_error()marlin_runtime_error()— Marlin is CUDA-only and also failed on ROCm, wheretorch.cuda.is_available()isTrue(same class of gate error)Result: 2 passed / 4 skipped on the 4090 and on AMD GPUs 2,3.
Selection assertion contradicted the kernel contract
tests/kernels/test_selection.pyassertedGGUFCudaKernel not in candidates,but #3434 added bits 1/2/3 to that kernel, leaving the assertion stale. Verified
against an independent Torch GGUF oracle on the 4090 that every AUTO-routed
qtype agrees with the Triton/Torch reference:
The assertion now requires
GGUFCudaKernelto appear only afterGGUFTritonKernel, keeping AUTO's Triton-first priority while allowing the CUDAkernel as a fallback.
Additional hazard found while validating:
TQ1_0andTQ2_0have no GPUconvert kernel, and ggml-cuda hits
GGML_ASSERT(convert_func != nullptr), whichaborts the whole interpreter rather than raising — yet
GGUFCudaKerneladvertises bits 1/2. The guard is a CUDA-only reject set:
The CPU-side
Q8_1/Q8_Kguard already exists onmain(gguf_cpp.py:715);this PR only extends the mechanism to the CUDA backend, which is where the
process-abort hazard lives. The CPU path handles
TQ1_0/TQ2_0correctly(maxdiff 0.0 vs the Torch oracle), so the sets are deliberately split and a CPU
regression test pins that split.
The CUDA rejection moved into the constructor
Review on real hardware showed the first version of this guard did not produce
the fallback it claimed.
select_quant_linearvalidates candidates bybitsonly, so it cannot see the GGUF qtype and
GGUFCudaKernelstayed a legitimateAUTO candidate for ternary weights.
GGUFTritonKernelalready rejects thosetypes in
__init__, socreate_quant_layerfell through toGGUFCudaKernel,which constructed successfully — the guard lived in
quantized_matmul_cuda,i.e. the first
forward. Sincecreate_quant_layeronly retries the next AUTOcandidate on a
NotImplementedErrorraised during construction, there was noruntime fallback at all: the layer was built and then failed during inference.
GGUFCudaKernel.__init__now raisesNotImplementedErrorfor_GGML_CUDA_MATMUL_UNSUPPORTED, matching the precedent inGGUFTritonKernel,and the
quantized_matmul_cudacheck stays as defence in depth. Through thereal loader path on 2x RTX 4090:
Test coverage was corrected alongside it:
test_gguf_cuda_kernel_rejects_qtypes_without_gpu_kernelsasserted therejection happened at
forward, which encoded the bug. It now requires theexplicit constructor call to raise.
test_gguf_auto_selection_falls_back_to_torch_for_ternarycovers the AUTOpath that the explicit-constructor test cannot reach. It mirrors
create_quant_layer: build candidates in priority order, skip constructorrejections, and require the selection to land on
GGUFTorchLinearwith aworking forward. It asserts on the constructed outcome rather than on the
multi_selectcandidate list, because that list is bits-based andGGUFCudaKernellegitimately remains a candidate.JIT failure reported the symptom instead of the cause
An ExLlamaV2 JIT failure surfaced
Ninja is required to load C++ extensionsverbatim while the real cause was
ninjaliving in$CONDA_PREFIX/binwiththat bin directory missing from PATH. Reproduced both directions: fails without
the env bin on PATH, builds in 20s with it.
gptqmodel/utils/cpp.pydiagnostics now reportshutil.which("ninja")/shutil.which("cmake")resolution and versions, a$CONDA_PREFIXPATH hint,and an actionable hint naming the missing PATH entry, instead of only echoing
the upstream exception.
Expanded-weight assertion is already fixed upstream
tests/kernels/test_w4a_nvfp4_gb10.pyasserted_weight_e4m3.numel() == in * out, which encoded the expanded-cache violationas expected behavior. #3492 already moved NVFP4 to stage the E4M3 operand per
forward, so the audit finding was against a branch 22 commits behind
origin/main. No change is needed here.Validation
All GPU runs are non-sandboxed on the host, with the worktree first on
PYTHONPATHso the editable package under test is the one being measured.test_selection,test_gguf_cpp,test_torch_ops_jit_extension,test_intel_cpu_xpu,test_asymmetric_real_models,test_w4a_nvfp4_gb10)tests/kernels/test_gguf_cpp.pyalone (all CUDA cases executed, none skipped)tests/test_gguf_all_formats.py(with llama-cpp CUDA runtime)The GGUF CUDA suites need
LD_LIBRARY_PATHpointed at anvidia/*/libtree:this env's
llama_cpplinkslibcudart.so.12while the env ships CUDA 13.2, soimport llama_cppfails otherwise. That is an environment quirk, not a PRdefect, but it means the GGUF rows are only reproducible with the shim:
Pre-existing failures, reproduced on unmodified
mainviagit stash:tests/test_extension_load_api.py::test_load_defaults_to_all_extensionstest_selection.pycasesruff checkclean on all touched files.ruff format --checkreports apre-existing multiline-list difference in
gguf_cpp.pythat is present atHEADand unrelated to these edits, so it is left alone.Storage-gate note
No inference path retains a dense or expanded weight cache. The GGUF guard now
rejects unsupported qtypes at construction, before any graph or tensor is built.