Repository navigation
fix(config): restore P2P policy from saved quantization metadata - #3850
Conversation
Restore the incoming process-wide policy in fixture teardown. Cover full-policy persistence, explicit resets, legacy configs and invalid metadata, and document policy recovery and precedence.
ZX-ModelCloud
left a comment
There was a problem hiding this comment.
Reviewed the metadata-promotion fix and corrected fixture cleanup to restore the previous P2P policy. Expanded coverage for complete disk round trips, explicit resets, legacy configs and invalid metadata, and documented recovery precedence.
Validation: 14 focused tests pass; related config/P2P suites report 170 passed / 14 skipped on CUDA and 169 passed / 15 skipped on ROCm. Ruff passes. No remaining blockers found.
ZX-ModelCloud
left a comment
There was a problem hiding this comment.
Re-reviewed 35da91f: saved P2P policies, explicit override precedence, invalid-policy validation and fixture cleanup are correct. No further fixes needed.
Fresh validation with the GIL disabled: config/P2P suites passed on CUDA and ROCm (170 passed, 14 skipped each); skips follow existing safety guards. Threaded mover fallback, Ruff and diff checks passed.
Fixes #3831
Change
Saved P2P policies were written to
meta.p2pbut ignored on reload, so an explicit policy such asmode="off"becamep2p=Noneand the next quantization run installed defaults. Addp2pto the existingmeta_field_mapso the complete policy is restored before normalization.Explicit top-level values keep precedence, including
Noneand empty dictionaries. Missing or null metadata still uses defaults; invalid restored policies raise through the existing normalizer. The test fixture also saves and restores the incoming process-wide policy instead of resetting it to defaults.Configuration recovery
flowchart TD A["BaseQuantizeConfig.to_dict()<br/>writes meta.p2p"] --> B["BaseQuantizeConfig.from_quant_config()"] B --> C{"Top-level p2p present?"} C -->|Yes, including None or an empty dict| D["Keep explicit p2p"] C -->|No| E{"meta.p2p present?"} E -->|Yes| F["meta_field_map promotes meta.p2p"] E -->|No| G["p2p = None"] D --> H["_normalize_p2p_config()"] F --> H G --> H H -->|Valid policy or None| I["BaseQuantizeConfig.p2p"] H -->|Invalid type or fields| J["ValueError / TypeError"] I --> K["ModuleLooper.__init__()<br/>configure_p2p(config.p2p)"] classDef failure fill:#fee,stroke:#b00,color:#900 class J failureThe before column refers to
e310049849b109c9da64d2c542a7ea99594f55a0.meta.p2pgptqmodel/quantization/config.py:4623omittedp2pfrommeta_field_map, leavingp2p=None._normalize_p2p_configvalidates it.p2pgptqmodel/quantization/config.py:4682gave top-level values precedence.Noneand empty dictionaries from stale metadata.ValueErrororTypeError; it cannot silently install defaults.Noneselected defaults when consumed byconfigure_p2p.Reference: P2P policy persistence, also linked from the README.
Validation
tests/qcfg/test_p2p_meta_roundtrip.py: 14 passed, covering full dictionary andP2PConfiground trips, disk persistence, explicit overrides, legacy defaults, and invalid metadata. A non-default incoming policy is preserved after running the file; the original fixture failed that check.With the GIL disabled:
Existing capability and safety guards account for the skips. The threaded mover fallback test executed successfully on both backends. The complete CI Ruff gate (
format/check.sh, Ruff 0.14.2) andgit diff --checkpass.