You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] EXL3 in-session forward/generate after quantize() always fails in fp16 with default offload: EXL3 missing from _IN_SESSION_KERNEL_METHODS, ExllamaV3Linear left on CPU raises 'EXL3_EXLLAMA_V3 inference requires NVIDIA CUDA' on a CUDA host #4789
Found on main @ dba142d, RTX 5090 (CUDA 13.2, torch 2.15, transformers 5.22).
What is wrong
After quantize() with the default offload_to_disk=True, the quantize loop leaves the packed layers on CPU. rehome_quantized_kernel() (gptqmodel/models/base.py:639) is supposed to make the in-session model usable on that device. It either switches the modules to a layout-compatible portable kernel, or raises the "save and reload" guidance (the #4381 / #4203 contract). It only does this for _IN_SESSION_KERNEL_METHODS = {AWQ, QQQ, GGUF} (base.py:573). EXL3 is not in that set, so an EXL3 model keeps ExllamaV3Linear (SUPPORTS_DEVICES = [CUDA]) on CPU.
As a result, in the default fp16 flow every in-session forward and generate() after quantize() fails. The error message is also wrong for an NVIDIA CUDA host:
NotImplementedError: EXL3_EXLLAMA_V3 inference requires NVIDIA CUDA; use EXL3_TORCH on ROCm or CPU.
It is raised from ExllamaV3Linear._ensure_inner() → validate_device(trellis.device) (gptqmodel/nn_modules/exllamav3.py:233), because the trellis is on CPU.
The failure depends on dtype. ExllamaV3Linear.forward sends non-fp16 inputs to _ensure_torch_inner() (exllamav3.py:311-314), which has no device check. So the same flow works in bf16 (in-session vs reload max logit diff 0.25), but fails in fp16. EXL3's own kernels require fp16, so fp16 is the natural dtype for it. A portable kernel already exists (ExllamaV3TorchLinear, BACKEND.EXL3_TORCH), and the error message itself recommends it.
Explicitly moving the model fixes it: after m.model.to("cuda") the in-session logits match the reloaded checkpoint exactly (max diff 0.0). So the saved checkpoint is fine. Only the in-session contract is broken.
Repro
importtorchfromgptqmodelimportGPTQModelfromgptqmodel.quantization.configimportCalibrationConfig, EXL3Configm=GPTQModel.load("Qwen/Qwen2.5-0.5B-Instruct", EXL3Config(bits=4), dtype=torch.float16) # offload_to_disk default Truem.quantize(CalibrationConfig(dataset=calib_texts)) # 32 C4 rowsids=m.tokenizer("The capital of France is", return_tensors="pt").input_idsm.model(ids) # (1)m.generate("The capital of France is", max_new_tokens=5) # (2)
devices {'cpu'} kernels {'Linear', 'ExllamaV3Linear'}
FAIL forward cpu ids NotImplementedError EXL3_EXLLAMA_V3 inference requires NVIDIA CUDA; use EXL3_TORCH on ROCm or CPU.
FAIL generate str NotImplementedError EXL3_EXLLAMA_V3 inference requires NVIDIA CUDA; use EXL3_TORCH on ROCm or CPU.
OK model.to(cuda)
OK forward cuda ids
inmem (after .to(cuda)) vs reloaded checkpoint: max logit diff 0.0
With dtype=torch.bfloat16, the same script works in-session on CPU. Every other method in my round-trip matrix also works in-session: GPTQ v1/v2/asym/desc_act/3/8-bit, AWQ gemm/gemv/gemv_fast, QQQ, FP8, NF12, GGUF, BnB 4/8, Paro, MACaQ and VPTQ.
Suggested fix
Add METHOD.EXL3 to _IN_SESSION_KERNEL_METHODS, and make select_in_session_quant_linear return ExllamaV3TorchLinear for CPU. The two kernels share the trellis/suh/svh layout, so _switch_quant_linear_class can reinterpret the modules in place. As an alternative, ExllamaV3Linear.forward could fall back to _ensure_torch_inner() whenever trellis is not on CUDA, the same way it already does for non-fp16 input. Separately, validate_device should say "is on <device>; move the model to CUDA" instead of claiming that the host lacks NVIDIA CUDA.
Test that should have caught it
The in-session tests added for #4381/#4554/#4736 cover AWQ/QQQ/GGUF only. A parametrized "quantize (offload on) → in-session forward in fp16" test over every method in METHOD would catch this.
Severity
Medium. The default fp16 quantize → evaluate-in-session flow (for example generate() or an lm-eval run right after quantize()) crashes for EXL3, and the error points the user in the wrong direction. The saved checkpoint is correct.
More data from the same round-trip matrix (main @ dba142d, RTX 5090). The failure is not limited to the default offload. With EXL3Config(bits=4) and offload_to_disk=False, the in-session model also ends up on CPU with ExllamaV3Linear, and the first fp16 forward raises the same NotImplementedError: EXL3_EXLLAMA_V3 inference requires NVIDIA CUDA; use EXL3_TORCH on ROCm or CPU. A dynamic run (-: exclusion plus +: 8-bit rule) fails the same way.
EXL3 run (Qwen2.5-0.5B-Instruct, 2 layers)
in-session forward after quantize()
fp16, offload on
NotImplementedError ... requires NVIDIA CUDA
fp16, offload off
NotImplementedError ... requires NVIDIA CUDA
fp16, offload on, dynamic
NotImplementedError ... requires NVIDIA CUDA
bf16, offload on
works (max logit diff vs reload 0.25, Torch trellis path)
The saved checkpoints are fine in every case: save → load → save → load is byte-identical. So the fix in rehome_quantized_kernel (or the CPU fallback in ExllamaV3Linear.forward) has to cover the non-offload path too.
Activity
Qubitium commentedon Nov 17, 2026
More data from the same round-trip matrix (
main@ dba142d, RTX 5090). The failure is not limited to the default offload. WithEXL3Config(bits=4)andoffload_to_disk=False, the in-session model also ends up on CPU withExllamaV3Linear, and the first fp16 forward raises the sameNotImplementedError: EXL3_EXLLAMA_V3 inference requires NVIDIA CUDA; use EXL3_TORCH on ROCm or CPU.Adynamicrun (-:exclusion plus+:8-bit rule) fails the same way.quantize()NotImplementedError ... requires NVIDIA CUDANotImplementedError ... requires NVIDIA CUDANotImplementedError ... requires NVIDIA CUDAThe saved checkpoints are fine in every case: save → load → save → load is byte-identical. So the fix in
rehome_quantized_kernel(or the CPU fallback inExllamaV3Linear.forward) has to cover the non-offload path too.🤖 Generated with Claude Code
Qubitium commentedon Nov 17, 2026
Agent claim released:
agent-53ba17eb4d83finished this issue.Pull request: #4835
Fixing: EXL3 in-session fp16 after quantize (missing from _IN_SESSION_KERNEL_METHODS); regression test.
fix(exl3): reconstruct through the portable kernel when the trellis i…