Skip to content

fix(backend): keep resolved policy out of QuantizeConfig.kernel; apply every pool setting (#4446, #4448, #4449) - #4497

Merged
Qubitium merged 1 commit into
mainfrom
fix/backend-config-resolution-4446-4448
Nov 16, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/backend-config-resolution-4446-4448

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Fixes #4446
Fixes #4448
Fixes #4449

#4446: the resolved policy is no longer written into QuantizeConfig.kernel

  • Cause: resolve_quantize_backend (gptqmodel/utils/backend_config.py:265-278 at 489aed6) stored the policy it generated in qcfg.kernel. The next call read it back as a legacy kernel= supplied by the caller.
  • Where state lives now:
    • The derived policy goes to the private qcfg._resolved_kernel.
    • qcfg.kernel and qcfg.runtime hold only settings the caller supplied. The loader's kernel=/runtime= replace the field of the same kind, after validation.
  • One conflict rule: a legacy kernel conflicts with a typed backend or a runtime, wherever each was supplied. So QuantizeConfig.runtime + kernel= now raises instead of silently dropping the runtime.
  • Resolution order: resolve_kernel_config checks _resolved_kernel > kernel > runtime > process default.
  • Plumbing:
    • GPTQModel.load and from_pretrained forward the caller's own arguments to the model definition; resolving them again is idempotent.
    • The from_quantized redirects keep the already-resolved pair.
    • Every config's quant_linear_init_kwargs uses resolve_kernel_config(self).
Second call on the same config Before After
QuantizeConfig(runtime=R), then backend=TorchConfig(...) (load or quantize) ValueError merged
runtime=R1, then runtime=R2 ValueError R2
TorchConfig(streaming=True), then BACKEND.TORCH streaming leaks defaults
QuantizeConfig(runtime=R) + kernel=K R dropped ValueError
flowchart TD
    A["resolve_quantize_backend"] --> I{"inherit and AUTO?"}
    I -- yes --> T["qcfg._backend_config"]
    I -- no --> S
    T --> S["effective kernel = arg or qcfg.kernel<br/>effective runtime = arg or qcfg.runtime"]
    S --> C{"kernel with typed backend or runtime?"}
    C -- yes --> F["ValueError naming each source; nothing recorded"]
    C -- no --> P["resolve_backend_config"]
    P --> W["record caller args; _backend_config; _resolved_kernel"]
    classDef failure fill:#ffe0e0,stroke:#b00,color:#600
    class F failure
Loading

#4448

  1. Pool resize: resize_device_thread_pool compares (cpu_workers, cuda_workers, pool_intraop_threads) and rebuilds the pool on any change. On CUDA, cuda:0 workers 1 → 3 is now applied; before, it stayed at 1.
  2. Typed fields: adds RuntimeConfig.pool_intraop_threads and BitsAndBytesConfig(triton=). torch_cache_weights and torch_lookahead stay unexposed, because they are compatibility shims that were refused.
  3. No-op options:
    • AWQ Marlin now honours MarlinConfig(fp32=). Default logits are bitwise unchanged, and fp32=False now differs (max 0.039).
    • Llama-3.2-1B AWQ PPL is 20.5517 with fp32 and 20.5513 with fp32=False.
    • GGUFCUDAConfig drops the options ggml-cuda never read.
  4. Validation:
    • KernelConfig.rocm_quant_blas rejects unknown spellings.
    • Retired env vars are re-checked at each load.
    • Concrete config classes lift meta-held fields, so GPTQConfig(**cfg.to_dict()) keeps true_sequential, damp_percent, offload_to_disk and pack_impl.

#4449

  • The GGUF_CPP accuracy test uses GGUFCPPConfig(native_matmul=...) instead of the retired env var.
  • Docs fixed:
    • the GGUF exact path;
    • the RDNA4 hipBLASLt recipe, now via QuantizeConfig.runtime;
    • the invalid shell line;
    • PAROQUANT_CUDA.
  • device=<int> beyond the visible devices now raises a clear ValueError.

Tests

  • New:
    • tests/test_backend_config_reuse_4446.py;
    • tests/test_runtime_config_4448.py;
    • out-of-range ordinal cases in tests/test_layerwise_device_placement.py;
    • the rocm_quant_blas rejection in tests/test_rocm_quant_tuning.py.
  • Also fixed: the pre-existing fake-builder signature in tests/test_thread_pool_exit.py.
  • Results after rebasing on 860ae2d: CPU run of 32 related files gives 741 passed, 48 skipped. The 8 failures (test_moe_config ×4, test_excluded_device_warmup ×3, test_rocm_backend_gating ×1) also fail on main.

🤖 Generated with Claude Code

…y every pool setting (#4446, #4448, #4449)

#4446: resolve_quantize_backend stored its generated policy in
QuantizeConfig.kernel, so a reused config raised "legacy kernel= cannot be
supplied together" for typed backends and runtime=, and an enum selection
re-applied the previous typed settings. The derived policy now lives in the
private _resolved_kernel; kernel/runtime only hold caller settings. A legacy
kernel conflicts with a typed backend or runtime wherever each was supplied,
so QuantizeConfig.runtime + kernel= now raises instead of dropping runtime.
load/from_pretrained forward the caller's arguments to the model definition;
every config's quant_linear_init_kwargs uses resolve_kernel_config.

#4448: resize_device_thread_pool compares (cpu_workers, cuda_workers,
pool_intraop_threads) and rebuilds on any change. RuntimeConfig gains
pool_intraop_threads and BitsAndBytesConfig gains triton. AWQ Marlin honours
MarlinConfig(fp32=...); GGUFCUDAConfig drops options ggml-cuda never read.
KernelConfig rejects unknown rocm_quant_blas spellings. Retired env vars are
re-checked at each load. Concrete config classes lift meta-held fields from
their own to_dict() payload.

#4449: GGUF_CPP test uses GGUFCPPConfig instead of the retired env var; docs
fixed (GGUF exact path, RDNA4 hipBLASLt recipe, invalid shell line,
PAROQUANT_CUDA); device=<int> beyond the visible devices raises ValueError.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment