Repository navigation
Description
Audit of main @ a15e6bf. The affected files are unchanged through 110136f. Platforms: RTX 4090 (CUDA) and R9700 gfx1201 (ROCm 10.1). Found during an end-to-end ROCm method/kernel matrix (quantize → save → reload → wikitext-2 PPL).
1. GGUFConfig(bits=4) (default q_0 → Q4_0) and q5_0 crash in quantize() with backend=AUTO, on CUDA and ROCm (medium)
GGUFConfig(bits=4) resolves to format="q_0", i.e. Q4_0. When packing, AUTO selection (models/base.py:1989/2030, select_quant_linear) looks only at the bit width. So Q4_0 and Q5_0 select GGUFTritonKernel (SUPPORTS_BITS [1,4,5,6]), whose constructor (nn_modules/qlinear/gguf_triton.py:1786-1791) only accepts Q1_0/Q4_K/Q5_K/Q6_K. The load path (create_quant_layer, utils/model.py:884) catches that NotImplementedError and falls back to GGUFTorchLinear. The weight-only finalize path (looper/weight_only_processor.py:212-229 → create_quant_module, utils/model.py:808) passes a single class and has no fallback, so quantization aborts on the first module:
GPTQModel.load(Qwen2.5-0.5B-Instruct, GGUFConfig(bits=4)).quantize(None, backend=BACKEND.AUTO)
RTX 4090 -> NotImplementedError: GGUFTritonKernel only supports fused GGUF Triton formats (Q1_0, Q4_K, Q5_K, Q6_K). Actual GGUF qtype: Q4_0.
R9700 -> same; format="q_0", bits=5 -> same with Q5_0
AUTO pack selection: q4_0 -> GGUFTritonKernel, q5_0 -> GGUFTritonKernel, q4_k_m -> GGUFTritonKernel (ok), q8_0 -> GGUFTorchLinear (ok)
backend=BACKEND.GGUF_TORCH, q4_0 -> OK, PPL 21.135 (fp16 base 18.549)
Fix: make GGUFTritonKernel.validate / select_quant_linear aware of the GGUF qtype so non-fused qtypes are rejected during selection, or reuse create_quant_layer's NotImplementedError candidate fallback in create_quant_module. tests/test_weight_only.py::test_baseqmodel_quantize_allows_direct_gguf_export parametrizes only K formats; add q_0 4/5 (the default for bits=4).
2. [ROCm] AWQ format=gemv quantize with backend=AUTO fails before calibration, although AWQ_GEMV_TRITON packs the same layout (low)
models/base.py:1927-1928 hardcodes preferred_backend = BACKEND.AWQ_GEMV, which is the CUDA-only AwqGEMVLinear. GEMM switches to a portable packer through awq_gemm_pack_backend(is_rocm=...), and QQQ has a ROCm branch, but GEMV has neither:
ROCm, AWQConfig(bits=4, group_size=128, format=FORMAT.GEMV).quantize(..., backend=AUTO)
-> ValueError: AwqGEMVLinear does not support device: DEVICE.ROCM (AwqGEMVLinear is CUDA-only ...; select a portable `*Torch` or `*Triton` backend ...)
backend=BACKEND.AWQ_GEMV_TRITON -> OK; reload -> AwqGEMVTritonLinear, "The capital of France is Paris…",
PPL(40 win) 23.66 vs GEMM-format AWQ 23.69; decode M=1/2/5/16 vs prefill OK
The error message suggests a *Torch backend, but AWQ_TORCH does not accept GEMV. Fix: BACKEND.AWQ_GEMV_TRITON if IS_ROCM else BACKEND.AWQ_GEMV. tests/test_rocm_awq_gemv_gating.py only covers loading; add a quantize case.
Minor: the TorchFusedLinear / TorchFusedAwqLinear rejection message on ROCm says "CUDA-only", but these classes are CPU/XPU kernels.
Checked on ROCm (R9700), matches CUDA
Qwen2.5-0.5B and Llama-3.2-1B, 80×512 wikitext-2:
- Methods: RTN (bit-identical), GPTQ 2/3/4/8-bit (sym/asym, desc_act, g32/64/128/−1), AWQ sym/asym, GPTAQ, FOEM, QQQ (fix(awq,qqq,paroquant): gauge offset-gain folds and fix QQQ/ParoQuant load paths (#4074) #4081 damp confirmed), GGUF q4_k_m/q4_0/q8_0, EXL3 under the default auto_nf12 (fix(looper,gptq): restore EXL3 AUTO_NF12 and the in-memory v2 qzero layout (#4063) #4069), ParoQuant, FP8 and NF12 all match CUDA within calibration noise.
- Kernels: every forced backend either matches TORCH exactly or refuses with a clear error.
- Inference paths: prefill matches incremental decode (M=1/2/5/16, batch 3, fp16/bf16). The in-memory model matches the reloaded one for GPTQ/AWQ. Cross-process PPL is bit-identical (fix(rocm): install deterministic ROCm env defaults (#4072, #4075) #4079).
- FP8 fuzz: 1920 cases, all formats, layouts and dtypes, 0 bad.
- External checkpoints: HF-GPTQv2, vortex desc g32, EXL3 W4/W2 and GPTQ-4bit-gp128 load under AUTO and agree with CPU.
Open lead, not filed as a bug: VPTQ PPL on ROCm is 18–23% above the CUDA numbers from older commits (Qwen 70.5–73.3 vs 59.5, Llama 82.4 vs 69.7). Per-module quantization losses match CUDA within ±3%. ROCm inference matches CPU fp32, and the old source gives the same PPL on ROCm. We could not determine the cause without a CUDA run at HEAD cross-evaluated on ROCm.
🤖 Generated with Claude Code
Activity
fix(kernels): gate GGUF AUTO selection by qtype and resolve AWQ GEMV …