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] resolve_quantize_backend writes the generated policy into QuantizeConfig.kernel: reusing a qcfg raises "legacy kernel=" errors or leaks typed settings (regression from #4375) #4446
if policy is not None: qcfg.kernel = policy stores the adapter it generated in the field that means "the caller supplied a legacy kernel=".
On the next call, if kernel is None: kernel = qcfg.kernel reads it back as if the user had supplied it.
The identity escape (_backend_kernel) exists only for typed backends, not for the runtime=-only path.
Repro (facebook/opt-125m, CPU is enough)
fromgptqmodelimportGPTQModel, BACKENDfromgptqmodel.backendimportRuntimeConfig, TorchConfigfromgptqmodel.quantizationimportQuantizeConfigM="facebook/opt-125m"# (a) documented flow: typed backend passed to quantize() after a runtime= qcfgqcfg=QuantizeConfig(bits=4, runtime=RuntimeConfig(max_packers=2))
m=GPTQModel.load(M, quantize_config=qcfg)
m.quantize(["hello world "*20] *4, backend=TorchConfig(streaming=True))
# ValueError: backend=BackendConfig(...) and legacy kernel= cannot be supplied together# (a 2nd GPTQModel.load(M, quantize_config=qcfg, backend=TorchConfig(...)) raises the same)# (b) reuse a qcfg with a different runtimeq=QuantizeConfig(bits=4)
GPTQModel.load(M, quantize_config=q, runtime=RuntimeConfig(max_packers=2))
GPTQModel.load(M, quantize_config=q, runtime=RuntimeConfig(max_packers=3))
# ValueError: runtime= and legacy kernel= cannot be supplied together# (c) typed settings leak into a later "defaults" selectionq=QuantizeConfig(bits=4)
GPTQModel.load(M, quantize_config=q, backend=TorchConfig(streaming=True, stream_tile=128))
GPTQModel.load(M, quantize_config=q, backend=BACKEND.TORCH)
# q.kernel.torch_streaming=True, torch_stream_tile=128; the process policy is also streaming=True.# Same for m.quantize(backend=BACKEND.MARLIN) after a typed TorchConfig load: torch_streaming stays True.
Expected:
(a) and (b) work. The docs say quantize() accepts typed configs and that runtime= is the shared control.
(c) uses defaults. The docs say "BACKEND.MARLIN selects Marlin with defaults".
Related: QuantizeConfig.runtime combined with kernel= silently drops the runtime settings
backend_config.py:265-269 reads runtime from the qcfg only when kernel is None, and resolve_kernel_config then lets kernel win:
The qcfg ends up with both .runtime and .kernel set, a state its own __post_init__ rejects. Passing runtime= and kernel= as arguments does raise the documented ValueError; this path should raise too.
Found during an AI-assisted review (Claude Code, round 13) of 489aed6; repros were run at that commit (A/B against def6e61 where noted) on RTX 4090/5090 (CUDA 13) and/or Radeon AI PRO R9700 (ROCm) unless marked static/suspected.
Activity
fix(backend): keep resolved policy out of QuantizeConfig.kernel; appl…