Skip to content

fix(qqq): initialize cache after kernel rehome - #4490

Merged
Qubitium merged 1 commit into
ModelCloud:mainfrom
mikemikimike:fix/4451-qqq-cache
Nov 16, 2026
Merged

Qubitium merged 1 commit into
ModelCloud:mainfrom
mikemikimike:fix/4451-qqq-cache

Conversation

@mikemikimike

Copy link
Copy Markdown
Contributor

Summary

Fixes the QQQ in-session kernel rehome regression reported in Issue #4451.

Resolves #4451

When QQQLinear is rehomed to QQQTorchLinear, the target constructor is intentionally skipped so packed buffers can be preserved. The target cache reset now lazily creates _torch_int_mm_failed_shapes before clearing it, allowing quantization to finish and the model to be saved.

flowchart TD
    A["quantize(offload_to_disk=False)"] --> B["rehome_quantized_kernel(model)"]
    B --> C["switch QQQLinear -> QQQTorchLinear"]
    C --> D["clear_weight_cache()"]
    D --> E{"failed-shape cache exists?"}
    E -- "no" --> F["create empty set"]
    E -- "yes" --> G["reuse existing set"]
    F --> H["continue quantization and save"]
    G --> H
    style E fill:#ffe0b2,stroke:#e65100
    style H fill:#c8e6c9,stroke:#2e7d32
Loading

Before, the class switch raised AttributeError: 'QQQTorchLinear' object has no attribute '_torch_int_mm_failed_shapes' at loop end, so the quantized model could not be saved. After, the cache is initialized only when needed, packed state is preserved, and normally constructed modules keep the existing clear behavior.

Failure contract

If a target class is missing this constructor-only cache during rehome, initialize that cache and continue. Kernel selection, unsupported-device errors, and other validation failures retain their existing behavior.

Validation

  • pytest -q tests/test_quantize_in_session_4381.py (8 passed)
  • Ruff checks for changed Python files passed
  • python -m py_compile gptqmodel/nn_modules/qlinear/qqq.py tests/test_quantize_in_session_4381.py passed
  • git diff --check passed
  • Full-suite collection remains environment-blocked by unavailable Triton/pyarrow dependencies and Windows platform limitations; the clean baseline shows the same failures.

@Qubitium

Copy link
Copy Markdown
Collaborator

@mikemikimike merge conflict

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants