Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
to_dict()/save_pretrained()crash on object-valued per-module overrides. Thedynamicserializer only convertedbitsand copied every other value through, soFallback,MSEConfig,torch.dtypeand smoother objects reachedjson.dumpsunchanged._serialize_dynamic_override_valuenow recursively converts dataclasses, enums andtorch.dtypeto their JSON-safe forms.preprocessors(smoother).GPTQConfig._update_meta_payloadnever calledsuper(), soPreProcessorConfig'spreprocessorspayload was never written. QQQ and VPTQ inherit that hook;ParoConfighad the same missingsuper()call. All now serializesmoother/preprocessors. VPTQ and Paro also serializesymnow (VPTQ previously omitted it, which made every reload log a misleading "missingsym" warning).elifchain wrotefoemonly whengptaqwas set and never wrotegptaq. Both are now written independently, so FOEM-only and GPTAQ+FOEM configs surviveto_dict()/save_pretrained().QuantizeConfig(**cfg.to_dict())ignoredmeta. The factory filtered to dataclass fields, sofallback,damp_percent,mse,gptaq,weight_only, ... stayed insidemetaand the target class restored its defaults.weight_onlywas also invisible to class resolution, which is why an RTNformat="gemm"payload was rebuilt asAWQConfig. The meta->field mapping thatfrom_quant_configused is now a shared_lift_serialized_meta_fieldshelper, called by both reload paths, so the two cannot drift.damp_percent,damp_auto_incrementandstatic_groupsare written tometabyto_dict()(the writer already recorded them there), so the factory round-trip is lossless for those calibration controls.Tests
New test file
tests/test_config_serialization_roundtrip_4201.pycovers each repro from the issue: object-valued dynamic overrides throughjson.dumps,save_pretrained, GPTQ/QQQ/VPTQ/Paro smoother round-trip, FOEM-only and GPTAQ+FOEM, VPTQsym, meta lifting (fallback/damp/mse/gptaq), explicitfallback=None, and RTN staying RTN.Fixes #4201