Repository navigation
Description
Audit of main @ beb6db8 (first seen at 27c6b7b); follow-up on #4364/#4375. All items reproduce at beb6db8, including after #4390.
1. cpu_workers (RuntimeConfig) is ignored by GPTQModel.from_pretrained, and by every load after the first (medium)
models/auto.py:982 resolves the policy, but from_pretrained never calls configure_kernel before _prebuild_device_thread_pool (auto.py:998). The pool is a per-process singleton (gptqmodel/__init__.py:392, :437). load() does it in the right order (auto.py:838-842) but never resizes an existing pool.
Qwen2.5-0.5B, CPU:
from_pretrained(..., runtime=RuntimeConfig(cpu_workers=2)) -> pool workers 12
from_pretrained(quantize_config=QuantizeConfig(runtime=RuntimeConfig(cpu_workers=2))) -> pool workers 12
load(cpu_workers=2) then load(cpu_workers=6): policy reports 6, pool workers 2
27c6b7b^ with GPTQMODEL_CPU_WORKERS=2: 2
At 27c6b7b, quantizing this way ran with 445 OS threads (12 workers) against 365 (2 workers), and RSS 1.54 vs 1.43 GiB. cpu_workers is the API-level control for thread over-subscription (#4356), but it doesn't take effect through from_pretrained. Fix: call configure_kernel before the pool prebuild, and resize the pool (or warn) when a later run asks for a different count. tests/test_kernel_config.py has no from_pretrained or pool-size test.
2. lru_cache freezes the cpu_bf16x3_matmul policy at its first read (low-medium)
utils/cpu_features.py:96 and nn_modules/exllamav3_torch.py:40 cache the result. Before #4364 they cached a process-constant env var; now they cache a mutable policy:
on then off: second policy.cpu_bf16x3_matmul=False -> mkldnn precision in scope still 'bf16', rel_err 5.74e-07 (expected 2.63e-07)
off then on: second policy.cpu_bf16x3_matmul=True -> precision 'none' (never enabled)
This affects GGUF torch CPU, bitsandbytes CPU and EXL3 torch. Fix: cache only the hardware capability probe, not the policy read. tests/test_exllamav3_cpu.py:16-19 calls cache_clear(), which hides the bug.
3. Env vars retired by #4364 are now silently ignored (low-medium)
GPTQ_TORCH_STREAMING=1 -> TorchLinear streaming_enabled=False
(4096x14336 4-bit, 1-row CUDA forward peak 40.0 MiB with streaming vs 144.1 MiB without: 3.6x)
GPTQMODEL_CPU_WORKERS=2 -> 12 workers
The commit also deleted the existing GPTQMODEL_RESUME retirement guard (models/base.py:1934), which used to raise. Other path-selecting env vars are still read outside KernelConfig, so #4180 is incomplete (static read only): GPTQMODEL_PAROQUANT_ROTATE_AUTOTUNE_* (gptqmodel_ext/paroquant/rotation.cu:672-810), GPTQMODEL_POOL_PREWARM, NF12_TC_KC, TTBFP_FORCE_*. Fix: warn once for each retired variable found in os.environ, naming its replacement field.
4. Native-GGUF loads through GPTQModel.load still drop kernel= / runtime= / p2p= (medium; incomplete fix in #4375)
#4375 fixed the inner redirect (loader.py:1850), but auto.py:1082-1091 (from_pretrained → model_definition.from_pretrained) never forwards these arguments:
Bonsai-1.7B-Q1_0.gguf, kernel=KernelConfig(gguf_cpp_native_matmul=False, gguf_cpp_threads=3):
GPTQModel.load(...) -> all 196 GGUFCppKernel layers (native_matmul, threads) = (None, 8) (defaults)
GPTQModel.from_quantized(...) -> (False, 3) (as requested)
logits differ between the two by up to 0.1875
5. internal_gguf.install_runtime() replaces a real installed gguf with a Qwen3-only shim (medium)
utils/internal_gguf.py:712-714 (called from utils/hf.py:849) sets sys.modules["gguf"] unconditionally. With the real gguf 0.19 installed (the gguf extra):
GPTQModel.load("Llama-3.2-1B-Instruct-Q4_K_M.gguf")
-> NotImplementedError: Unknown gguf model_type: llama in gguf-py ... | sys.modules['gguf'] = <internal shim>
same with the shim disabled -> LOADED LlamaForCausalLM (real gguf)
The real module is also lost process-wide. Fix: install the shim only when importlib.util.find_spec("gguf") is None. tests/test_hf_config_compat.py:192-205 only covers the case where gguf is absent.
Checked, clean
- KernelConfig defaults match the old env-var defaults for every field.
- At default settings,
torch.get_num_threads()and OS thread counts are unchanged. - No new cached buffers.
- Unify backend selection and tuning with typed BackendConfig #4375 fixed explicit per-layer config and the cross-model retune.
🤖 Generated with Claude Code
Activity
Qubitium commentedon Nov 16, 2026
Taking this. I'll investigate against current
main, add a targeted regression test, and open a PR. Will report back here if the claim turns out to be invalid or already fixed.Qubitium commentedon Nov 16, 2026
Fixed in #4423: #4423
fix: honour cpu_workers and live kernel policy; warn on retired env v…
fix: restore base modules and re-pick CPU kernels after weight-only q…