Repository navigation
fix(exl3): reconstruct through the portable kernel when the trellis is off CUDA (#4789) - #4835
Merged
Merged
Conversation
…s off CUDA (#4789) After `quantize()` the packed layers stay on CPU (with the default `offload_to_disk=True` and with it disabled), so the first in-session forward hit `ExllamaV3Linear._ensure_inner` -> `validate_device(cpu)` and raised `NotImplementedError: EXL3_EXLLAMA_V3 inference requires NVIDIA CUDA`. Only FP16 failed because BF16 off CUDA already routed to `_ensure_torch_inner`. `ExllamaV3Linear.forward` now reconstructs through the portable kernel whenever its materialized trellis is not on CUDA, reusing the existing `_ensure_torch_inner` path. The class is deliberately left alone instead of switching it to `ExllamaV3TorchLinear` in place: * `ExllamaV3Linear` is not a `BaseQuantLinear`, so `rehome_quantized_kernel` never collects it, and `select_quant_linear` has no EXL3 entry (`Unsupported quantization method: METHOD.EXL3`), so the suggested selector would need new special cases in the rehome machinery. * the checkpoint writer keys the EXL3 module schema on `type(module) is ExllamaV3Linear` (`looper/checkpoint_modules.py`), so an in-place class switch would change what `save()` writes; this fix keeps the saved native EXL3 layout byte-identical. * `ExllamaV3TorchLinear.forward` reads `_compiled_forward`, which only `__init__` sets, so a raw `__class__` swap is not attribute-complete. CUDA models keep `_ensure_inner` (including the BF16 fast path), and an absent or meta trellis keeps its existing error. `validate_device` now names the device the module is on and tells the caller to move the model to CUDA instead of claiming the host lacks NVIDIA CUDA. Tests: fp16/bf16 module and decoder-stack forwards match the reloaded EXL3_TORCH checkpoint exactly (atol=0); the in-session forward leaves the saved EXL3 module schema unchanged; the new device message and the preserved CUDA/meta paths are pinned.
This was referenced Nov 17, 2026
sLaffey
pushed a commit
to sLaffey/GPTQModel
that referenced
this pull request
Nov 18, 2026
… the native stub (ModelCloud#4895) (ModelCloud#4924) tests/test_exllamav3_inner_handle_4793.py built its trellis on CPU. Since ModelCloud#4835 (fa91047), forward() sends every non-CUDA trellis to _ensure_torch_inner(), so the burst never reached _ensure_inner() and the stubbed native handle was never built. It failed on the fake 2x2x16 trellis with "storage differs from logical dimensions or 128-channel padding" instead of guarding the ModelCloud#4793 handle race. Build the trellis on CUDA, where _needs_torch_fallback() is false, and skip the file without CUDA so a CPU-only host does not silently test the portable path. Assert that the stubbed LinearEXL3 served every forward and that no torch inner was built, so a future routing change fails loudly instead of quietly losing the ModelCloud#4793 regression guard. Red on origin/main: 2 failed. Green: 2 passed.
sLaffey
pushed a commit
to sLaffey/GPTQModel
that referenced
this pull request
Nov 18, 2026
…lCloud#4978) Seven tests went red because their doubles/oracles predate library changes that behave as intended. This is test-only; no product code changes. - test_fusion_kernel_backends: gc.collect() before the weakref check; ModelCloud#4871 leaves transient Dynamo trace garbage that keeps the pre-fusion weight alive. The refs are still asserted dead afterwards. - test_failed_run_fence_4595: del qmodel + gc.collect() so ModelCloud#4829's finalizer runs before the no-leak assertion; a late finalizer must not recreate the released run dir. - test_exl3_projection_resume: add _release_deferred_hessian_sources() to the _Capture double (ModelCloud#4837). - test_kernel_audit_regressions: stub _needs_torch_fallback=lambda: False on the SimpleNamespace self (ModelCloud#4835). - test_moe_resave_preserves_experts_4589: accept the earlier RuntimeError "does not provide tensors" refusal (ModelCloud#4810); still assert no safetensors. - test_positional_mask_capture_4660: build the native oracle with the same mask-derived position_ids the capture uses (ModelCloud#4930). - test_qqq_kernel_memory_4387: snapshot the oracle weight/s_channel before the first forward, which may drop the checkpoint layout (ModelCloud#4856).
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.
Fixes #4789.
After
quantize()the packed layers stay on CPU (defaultoffload_to_disk=True,and also with it disabled), so the first in-session forward hit
ExllamaV3Linear._ensure_inner->validate_device(cpu)and raisedNotImplementedError: EXL3_EXLLAMA_V3 inference requires NVIDIA CUDA. Only FP16failed; BF16 off CUDA already routed to
_ensure_torch_inner.Change
ExllamaV3Linear.forwardnow reconstructs through the portable kernel wheneverits materialized trellis is not on CUDA (
_needs_torch_fallback()), reusing theexisting
_ensure_torch_innerpath. An absent or meta trellis keeps the nativepath and its existing error. CUDA models keep
_ensure_inner(including theBF16 fast path).
The class is deliberately left alone instead of switching to
ExllamaV3TorchLinearin place:ExllamaV3Linearis not aBaseQuantLinear, sorehome_quantized_kernelnever collects it, and
select_quant_linearhas no EXL3 entry(
Unsupported quantization method: METHOD.EXL3), so the suggested selectorroute needs new special cases in three places.
type(module) is ExllamaV3Linear(looper/checkpoint_modules.py), so anin-place switch would change what
save()writes.ExllamaV3TorchLinear.forwardreads_compiled_forward, which only__init__sets, so a raw__class__swap is not attribute-complete.validate_devicenow names the device the module is on and tells the caller tomove the model to CUDA, instead of claiming the host lacks NVIDIA CUDA.
Tests
New
tests/test_exl3_in_session_fp16_4789.py(11 tests): fp16 and bf16 moduleand two-projection decoder-stack forwards match the reloaded
EXL3_TORCHcheckpoint bit-exactly (
rtol=0, atol=0); the in-session forward leavespacked_module_config(the saved EXL3 schema) unchanged; the new device messageand the CUDA/meta paths are pinned.
Red on parent: 8 failed, 2 passed — fp16 forward/decoder/schema/message cases
fail with the exact reported
NotImplementedError; the bf16 controls pass.ruff: clean.