Repository navigation
fix(exl3): invalidate native cache after inference metadata edits - #3732
Merged
Merged
Conversation
Qubitium
force-pushed
the
codex/fix-exl3-cache-signature
branch
from
November 9, 2026 17:50
02f7f3c to
1a35148
Compare
Qubitium
force-pushed
the
codex/fix-exl3-cache-signature
branch
from
November 9, 2026 18:30
1a35148 to
0f291b2
Compare
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
Fix the remaining EXL3 native-cache hole for packed sign metadata created under
torch.inference_mode(). Such tensors have no version counter, so the first version-counter patch could still reuse a native handle containing stale unpacked signs.Before a signature is recorded,
ExllamaV3Linear._normalize_inference_metadata()copies inference-created sign and codebook metadata once into versioned checkpoint buffers. A later in-place edit changes the signature and rebuildsLinearEXL3. The packed trellis remains shared by reference.clear_weight_cache()provides an explicit refresh after writes that bypass PyTorch version counters.No dense, dequantized, or expanded weight cache is added. The change copies only
suh,svh,su,sv,mcg, andmul1metadata when needed; the large trellis is not copied. No internal backward-compatibility guarantee is added;hf_APIs are unchanged.Before and after
su/svedited in place_current_signature()storedversion=Noneand matched the old handle (gptqmodel/nn_modules/exllamav3.py:137-145at0f291b21).LinearEXL3had already unpacked the old signs._normalize_inference_metadata()rebinds versioned packed metadata before signature and handle construction (gptqmodel/nn_modules/exllamav3.py:125-166at88cfc49d). The edit changes the signature.ExllamaV3Linear.clear_weight_cache()drops the native and Torch handles (gptqmodel/nn_modules/exllamav3.py:180-182).Runtime flow
flowchart TD A["ExllamaV3Linear._ensure_inner"] --> B{"Trellis materialized?"} B -- No --> X["RuntimeError: missing or meta trellis"] B -- Yes --> C{"validate_device accepts CUDA?"} C -- No --> Y["NotImplementedError: unsupported device"] C -- Yes --> D["_coerce_buffer_dtypes"] D --> E["_current_signature"] E --> F["_normalize_inference_metadata"] F --> G{"Inference-created metadata?"} G -- Yes --> H["Copy metadata once outside inference mode"] G -- No --> I["_bias_version"] H --> I I --> J{"Signature matches _inner_signature?"} J -- Yes --> K["Reuse LinearEXL3"] J -- No --> L["_drop_inner and _stored_features"] L --> M{"Storage geometry valid?"} M -- No --> Z["ValueError: invalid storage geometry"] M -- Yes --> N["Build LinearEXL3 and save signature"] P["clear_weight_cache"] --> Q["_drop_inner"] Q --> R["Next _ensure_inner"] R --> B classDef failure fill:#ffe8e8,stroke:#b30000,color:#111; class X,Y,Z failure;Reference page: EXL3 native buffer lifecycle, linked from the README.
Validation
python -m pytest tests/test_exl3_cache_signature.py tests/test_exllamav3_torch_padding.py tests/test_exllamav3.py -q -o log_cli=false— 94 passed, 55 skipped.ruff check gptqmodel/nn_modules/exllamav3.py tests/test_exl3_cache_signature.py— passed.git diff --check— passed. GitHub Ruff Check on88cfc49d— passed.su/svmutation, replacement, checkpoint loading, unload/rebuild, explicit clear, trellis aliasing, and absence of a dense 128×128 tensor in module/handle state. The fixture'ssu/svare 32 packed bytes total; the trellis is 4,096 packed bytes and is not copied.rtol=atol=2e-3. It skipped here because this host has no available CUDA or ROCm device. Native accuracy and latency are therefore not measured on this host.The steady-state path checks six metadata slots for inference tensors and creates no copy after the first normalization. GPU latency was not benchmarked on this host.