Skip to content

fix(config): restore P2P policy from saved quantization metadata - #3850

Merged
Qubitium merged 3 commits into
mainfrom
fix/3831-p2p-config-roundtrip
Nov 13, 2026
Merged

Qubitium merged 3 commits into
mainfrom
fix/3831-p2p-config-roundtrip

Conversation

@ZX-ModelCloud

@ZX-ModelCloud ZX-ModelCloud commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #3831

Change

Saved P2P policies were written to meta.p2p but ignored on reload, so an explicit policy such as mode="off" became p2p=None and the next quantization run installed defaults. Add p2p to the existing meta_field_map so the complete policy is restored before normalization.

Explicit top-level values keep precedence, including None and 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 failure
Loading

The before column refers to e310049849b109c9da64d2c542a7ea99594f55a0.

Input / mechanism Before After
Saved meta.p2p gptqmodel/quantization/config.py:4623 omitted p2p from meta_field_map, leaving p2p=None. The map restores the saved policy before _normalize_p2p_config validates it.
Explicit top-level p2p The presence check at gptqmodel/quantization/config.py:4682 gave top-level values precedence. The same check also protects explicit None and empty dictionaries from stale metadata.
Invalid saved policy Ignored with the other unpromoted metadata. Normalization raises ValueError or TypeError; it cannot silently install defaults.
Missing or null policy None selected defaults when consumed by configure_p2p. Unchanged: older configs still use defaults.

Reference: P2P policy persistence, also linked from the README.

Validation

tests/qcfg/test_p2p_meta_roundtrip.py: 14 passed, covering full dictionary and P2PConfig round 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.

python -m pytest tests/qcfg tests/test_p2p.py tests/test_p2p_copy_utils.py -q --tb=short
bash format/check.sh

With the GIL disabled:

Suite Result
Related config and P2P tests, CUDA 170 passed, 14 skipped
Related config and P2P tests, ROCm 169 passed, 15 skipped

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) and git diff --check pass.

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 ZX-ModelCloud left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Qubitium
Qubitium merged commit d831ba0 into main Nov 13, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/3831-p2p-config-roundtrip branch November 13, 2026 11:46

@ZX-ModelCloud ZX-ModelCloud left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

[BUG] QuantizeConfig save/load silently loses the configured P2P policy

2 participants