Skip to content

fix(loader): report KV-cache quantization as KV-cache quantization - #4508

Merged
Qubitium merged 1 commit into
ModelCloud:mainfrom
Lumea-art:feat/kv-cache-rejection-diagnosis
Nov 17, 2026
Merged

Qubitium merged 1 commit into
ModelCloud:mainfrom
Lumea-art:feat/kv-cache-rejection-diagnosis

Conversation

@Lumea-art

Copy link
Copy Markdown
Contributor

Summary

A checkpoint that declares kv_cache_scheme is refused with:

GPT-QModel currently does not support loading of activation quantized models.
Detected unsupported metadata: kv_cache_scheme.

Activation quantization is not what the checkpoint asked for. The KV cache is allocated and dequantized by the serving runtime, so the user is told to look at their activation config for a field that is not there - and tests/test_model.py pinned that wording, so the wrong message was locked in.

The two rejection paths also disagreed about the boundary: the early config check (models/auto.py) refused any non-empty kv_cache_scheme, while the ModelOpt runtime check (models/base.py) refused only num_bits < 16. A 16-bit scheme was rejected during load() and accepted later.

Change

gptqmodel/utils/quant_metadata.py classifies the payload once:

kind message
kv_cache "checkpoints that quantize the KV cache... allocated and dequantized by the serving runtime... Load a weight-only variant, or serve this checkpoint with a runtime that applies its KV-cache scheme"
activation unchanged wording, now including the declared width
checkpoint_scales unchanged, distinct from both

Both call sites render from that classification, and declares_reduction() is the single boundary rule:

  • num_bits >= 16 — a no-op, does not block loading;
  • num_bits missing — treated as quantized (the safe reading of "there is a scheme here");
  • empty/None/non-dict — not a scheme.

Before / after for the same payload:

$ # kv_cache_scheme {"num_bits": 8}
- GPT-QModel does not support loading of activation quantized models. Detected unsupported metadata: kv_cache_scheme.
+ GPT-QModel does not support loading of checkpoints that quantize the KV cache. The KV cache is
+ allocated and dequantized by the serving runtime, so a declared kv_cache_scheme cannot be honored
+ by this loader. Detected unsupported metadata: kv_cache_scheme (8 bits). Load a weight-only variant,
+ or serve this checkpoint with a runtime that applies its KV-cache scheme.

Tests

tests/test_quant_metadata_rejection.py    18 passed

Covers both kinds, the "not activation" assertion on the KV path, the 16-bit boundary, a widthless scheme, empty/None payloads, activation winning over KV when both are present, and the ModelOpt runtime path returning a kv_cache classification rather than a bare string.

tests/test_model.py changes one assertion: the KV test now expects quantize the KV cache instead of activation quantized models. That file could not be collected on this machine before (parameterized was missing); after installing it the file runs, and the counts are identical with and without this patch:

2 failed, 23 passed, 1 skipped, 3 errors     # both failures and all 3 errors pre-exist on main

The two failures are test_dequantize_model_awq and test_hide_unsupported_quantization_config_for_eval_temporarily_clears_gguf_bits; verified by stashing this branch and running the same command on main.

format/check.sh passes.

A checkpoint that declares `kv_cache_scheme` was refused with "GPT-QModel
currently does not support loading of activation quantized models", and
tests/test_model.py pinned that message. Activation quantization is not what the
checkpoint asked for: the KV cache is allocated and dequantized by the serving
runtime, so the user is sent looking at their activation config for a field that
is not there.

The two rejection paths also disagreed about the boundary. The early config check
refused any non-empty `kv_cache_scheme`; the ModelOpt runtime check refused only
`num_bits < 16`. A 16-bit scheme was rejected at load in one place and accepted in
the other.

`gptqmodel/utils/quant_metadata.py` now classifies the payload once
(`activation` / `kv_cache` / `checkpoint_scales`) and both sites render the
message from that classification:

    kv_cache_scheme, 8 bits:
      GPT-QModel does not support loading of checkpoints that quantize the KV
      cache. The KV cache is allocated and dequantized by the serving runtime...
      Detected unsupported metadata: kv_cache_scheme (8 bits).

    input_activations, 4 bits:
      GPT-QModel does not support loading of activation quantized models.
      Detected unsupported metadata: input_activations (4 bits).

`declares_reduction` is the single boundary rule: a scheme with `num_bits >= 16`
is a no-op and does not block loading, a scheme without a width is treated as
quantized.

    tests/test_quant_metadata_rejection.py    18 passed
    tests/test_model.py                       2 failed / 23 passed before and after
                                              (both failures pre-exist on main)
@Qubitium
Qubitium merged commit f201837 into ModelCloud:main Nov 17, 2026
Qubitium added a commit that referenced this pull request Nov 17, 2026
Fix the test-side fallout of #4716, #4657, #4627 and #4508. Only entries
that fail on this sm_80 host (PG506) and whose stated reasoning reproduces
were changed; the rest are recorded with their outcome.

1. 8587f0b (#4716, native FP8 GEMM for a wide bias)
   - tests/kernels/test_fp8_kernel.py::test_fp8_default_forward_is_w8a16
     REPRODUCED on sm_80: 6 bf16 cases failed with 1-ulp (0.0078125) diffs
     against rtol/atol 2e-3. The oracle now narrows the decoded weight to
     the activation dtype, matching the native path; the bound is the
     half-ulp at unity (2^-9 ~= 2e-3). FIXED.
   - tests/test_fp8_bias_range.py::test_fp8_gpu_dequant_fallback_keeps_bias_wide
     REPRODUCED on sm_80 (fp16: actual 0.0 vs oracle 0.0078125). Renamed to
     test_fp8_gpu_native_gemm_keeps_bias_wide and rewritten for the #3737
     intent: finite output, FP32 bias, residual bounded by one activation-
     dtype ulp of |x.w|. FIXED.

2. bf5adeb (#4657, Marlin bias kept in checkpoint order)
   - tests/test_marlin_scratch_cuda.py 288/200 cases REPRODUCED on sm_80:
     8 failed with "b_bias.size(0) != size_n". scripts/marlin_scratch_fixture.py
     now passes layer._kernel_bias(a) (padded, tile-ordered FP32) instead of
     the checkpoint-order layer.bias. FIXED (8 failed -> 68 passed, 2 skipped).

3. 60376e9 (#4714, default placement in one capability group)
   - tests/test_tenstorrent_support.py already passes on current main: the
     monkeypatched _record accepts **kwargs (fixed upstream by 50f1752).
     ALREADY PASSES on sm_80.

4. 34672a7 (#4585, modules snapshot the kernel policy)
   - tests/kernels/test_bitsandbytes_rocm_triton.py triton cases SKIP on
     sm_80 (no tuned bitsandbytes tile for this family). DEFERRED: the
     stated failure cannot be reproduced here.

5. dfa180d (#4627, GGUF path chosen from static gates)
   - both tests REPRODUCED on sm_80 with AttributeError
     _benchmark_forward_runner. The removed timing hook is no longer patched;
     each test asserts the hook stays absent. FIXED.

6. fd8d524 (#4599, AwqGEMVTorchLinear CPU reader)
   - both kernel-registry contract tests already pass on current main
     (AwqGEMVTorchLinear is in EXCLUDED and the ROCm audit table; fixed
     upstream by ab151fe). ALREADY PASSES on sm_80.

7. d2a0508 (#4283, dense-module adapters)
   - tests/kernels/test_gptq.py::TestKernelOutput errors on sm_80 before the
     adapter path: this host's flash_attn_2_cuda has an undefined symbol, so
     the stated Lora assertion is never reached. DEFERRED: blocked by the
     pre-existing host flash_attn failure; the fix cannot be verified here.

8. f201837 (#4508, activation-quantization wording)
   - both tests REPRODUCED on sm_80. The refusal still fires; the regex now
     matches "activation quantized|activation scales". FIXED.

9. b225a43 (#4727, static-cache compile test)
   - ROCm-only failure. On sm_80 the CUDA leg runs and fails earlier on the
     host flash_attn symbol, so the ROCm gate cannot be reproduced.
     DEFERRED.

Test run (GPU 4):
  tests/kernels/test_fp8_kernel.py tests/test_fp8_bias_range.py
  tests/test_marlin_scratch_cuda.py tests/test_marlin_scratch_benchmark.py
  tests/kernels/test_gguf_cpp_activation_quantization.py
  tests/kernels/test_gguf_cpp_path_selection.py tests/test_auto_module_decoder.py
  => 254 passed, 35 skipped, 1 failed.
The single failure is the pre-existing sm_80
test_fp8_w8a8_forward_is_batch_invariant (native torch._scaled_mm needs
sm_89+); it fails identically on origin/main.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants