Skip to content

fix: serialize object-valued dynamic overrides and lift meta on factory reload (#4201) - #4296

Merged
Qubitium merged 1 commit into
mainfrom
pr/4201
Nov 16, 2026
Merged

Qubitium merged 1 commit into
mainfrom
pr/4201

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

Fixes #4201. A quantized run could finish and then fail while saving, and a saved config reloaded with class defaults instead of the measured settings.

What Changed

  1. to_dict() / save_pretrained() crash on object-valued per-module overrides. The dynamic serializer only converted bits and copied every other value through, so Fallback, MSEConfig, torch.dtype and smoother objects reached json.dumps unchanged. _serialize_dynamic_override_value now recursively converts dataclasses, enums and torch.dtype to their JSON-safe forms.
  2. GPTQ-family dropped preprocessors (smoother). GPTQConfig._update_meta_payload never called super(), so PreProcessorConfig's preprocessors payload was never written. QQQ and VPTQ inherit that hook; ParoConfig had the same missing super() call. All now serialize smoother/preprocessors. VPTQ and Paro also serialize sym now (VPTQ previously omitted it, which made every reload log a misleading "missing sym" warning).
  3. GPTAQ / FOEM were lost. The old elif chain wrote foem only when gptaq was set and never wrote gptaq. Both are now written independently, so FOEM-only and GPTAQ+FOEM configs survive to_dict()/save_pretrained().
  4. QuantizeConfig(**cfg.to_dict()) ignored meta. The factory filtered to dataclass fields, so fallback, damp_percent, mse, gptaq, weight_only, ... stayed inside meta and the target class restored its defaults. weight_only was also invisible to class resolution, which is why an RTN format="gemm" payload was rebuilt as AWQConfig. The meta->field mapping that from_quant_config used is now a shared _lift_serialized_meta_fields helper, called by both reload paths, so the two cannot drift.
  5. GPTQ damp_percent, damp_auto_increment and static_groups are written to meta by to_dict() (the writer already recorded them there), so the factory round-trip is lossless for those calibration controls.

Tests

python3 -m pytest tests/test_config_serialization_roundtrip_4201.py -q
# 19 passed

python3 -m pytest tests/test_config_serialization_roundtrip_4201.py \
  tests/test_gguf_dynamic_format.py tests/test_awq_per_module_bits.py \
  tests/test_writer_dynamic_order.py tests/test_weight_only_config.py \
  tests/test_qqq_config.py tests/test_config_only_export.py -q
# 174 passed, 32 skipped

ruff check gptqmodel/quantization/config.py tests/test_config_serialization_roundtrip_4201.py
# All checks passed!

New test file tests/test_config_serialization_roundtrip_4201.py covers each repro from the issue: object-valued dynamic overrides through json.dumps, save_pretrained, GPTQ/QQQ/VPTQ/Paro smoother round-trip, FOEM-only and GPTAQ+FOEM, VPTQ sym, meta lifting (fallback/damp/mse/gptaq), explicit fallback=None, and RTN staying RTN.

Fixes #4201

@Qubitium
Qubitium merged commit e9abea3 into main Nov 16, 2026
7 of 9 checks passed
@Qubitium
Qubitium deleted the pr/4201 branch November 16, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant