Skip to content

chore(writer): delete the save-state overlay contract (no implementer since #6435) - #6667

Merged
Qubitium merged 1 commit into
mainfrom
refactor/save-state-overlay
Dec 1, 2026
Merged

Qubitium merged 1 commit into
mainfrom
refactor/save-state-overlay

Conversation

@Qubitium

@Qubitium Qubitium commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The save-state overlay was a writer hook for an attached auxiliary model to replace tensor prefixes during save (built for the DeepSeek-V4 MTP stack). Its only implementer, DeepSeekV4QModel.save_state_overlay, was deleted with the unreachable DeepSeek-V4 MTP calibration stack in #6435. Current origin/main has zero implementers, so this PR deletes the contract instead of polishing its validators.

No behavior change: with no provider, every removed call was a no-op.

Zero-implementer verification

  • git grep -n "save_state_overlay" over the whole repository: only gptqmodel/models/writer.py (the provider lookup), tests/test_writer_state_overlay.py (the test _Owner), tests/test_docs_contract_refs.py (the citation entry) and docs/native-checkpoint-export.md (the call map).
  • AST scan of every .py file under gptqmodel/ (including models/ports/), tests/, docs/, examples/ for the attribute name, string literals and getattr strings: no other production reference.
  • git grep over AGENTS.md, contracts/ and docs/ finds no out-of-tree extension-point contract for the hook. docs/native-checkpoint-export.md documents the writer's internal call map, not a definition API; it is updated by this PR.

What Changed

gptqmodel/models/writer.py (+8/−270):

  • Deleted the provider lookup _validated_save_state_overlay and its two field validators (_validated_save_state_overlay_suffixes, _validated_save_state_overlay_removals).
  • Deleted _apply_save_state_overlay (state-dict prefix replacement) and _build_exllamav3_tensor_storage_for_save (its only purpose was merging overlay EXL3 storage; save_quantized now calls build_exllamav3_tensor_storage(self.model) directly).
  • Removed the validated_overlay parameters and overlay branches from _validate_exllamav3_publication_modules and _build_exllamav3_checkpoint_passthrough_state_dict, and the overlay call/args in save_quantized.
  • Kept the normal save paths: the EXL3 publication guard, checkpoint passthrough, and native-source ownership scope are unchanged.

Tests (only the contract): deleted _Owner and 9 tests / 11 nodes from tests/test_writer_state_overlay.py:

  • test_save_state_overlay_replaces_only_declared_prefixes
  • test_save_state_overlay_removes_checkpoint_alias_prefixes
  • test_save_state_overlay_removal_fails_closed_on_missing_source_suffix
  • test_save_state_overlay_fails_closed_on_missing_prefix
  • test_save_state_overlay_fails_closed_on_tensor_contract
  • test_save_state_overlay_rejects_ambiguous_prefix_contract (3 params)
  • test_save_tensor_storage_includes_exact_overlay_modules
  • test_save_tensor_storage_fails_closed_on_missing_overlay_module
  • test_save_tensor_storage_fails_closed_on_tensor_contract

Kept the 8 normal-path tests (EXL3 publication guard, checkpoint passthrough, prefixed state collection).

Docs: docs/native-checkpoint-export.md retitled and de-overlayed; the _validated_save_state_overlay citation removed from tests/test_docs_contract_refs.py; link text and the offload-directory note updated.

Tests

  • Unit tests have been executed and passed.
  • A new unit test is not applicable: this deletes a contract with no implementer; the save A/B below proves the saved bytes are unchanged.
export HF_HOME=/root/.cache/huggingface HF_HUB_OFFLINE=1 CUDA_VISIBLE_DEVICES=""

python -P -m pytest -p no:cacheprovider -q -rs --timeout 1800 \
  tests/test_writer_state_overlay.py tests/test_writer_save_tail_helpers.py \
  tests/test_writer_quant_log.py tests/test_writer_attention.py \
  tests/test_writer_dynamic_order.py tests/test_writer_instance_attrs.py \
  tests/test_writer_remote_code_policy.py tests/test_save_kwargs_validation_4686.py \
  tests/test_docs_contract_refs.py tests/test_save_dispatch.py \
  "tests/test_deepseek_v4_support.py::test_rtn_round_trip_keeps_the_deepseek_v4_final_norm" \
  "tests/test_deepseek_v4_support.py::test_default_quantize_keeps_integrated_mtp_tensors_native"
#   origin/main 0127a0313: 342 passed in 196.34s
#   branch 49f7ad319:      330 passed in 191.44s
#   330 common node ids: identical outcomes (0 differences)
#   main-only: the 11 deleted overlay nodes + the removed docs-contract citation (by design)

bash format/check.sh   # All checks passed! (ruff 0.14.2)

Save A/B

The same 8-config writer harness from #6666 (meta_ab.py, kept out of the repo) on main vs branch: gptq_default, gptq_gptaq, gptq_foem, gptq_jointq, awq, gguf, paro, exl3. Each case saves config.json, quantize_config.json and model.safetensors; the dump records the sha256 of every file plus the meta key order.

cases: 8; errors: 0; diff: none
# records.json byte-identical main vs branch (includes the EXL3 save path,
# which now calls build_exllamav3_tensor_storage directly)

The two DeepSeek-V4 save tests (the ex-overlay consumer's family) pass on both trees.

Measured Impact

Not applicable: no runtime, memory or accuracy change; the deleted calls returned immediately without a provider.

Model Support / Module Plan

Not applicable: no MODEL_MAP, module-tree, plan or definition change.

AWQ onboarding safety

Not applicable: no AWQ grouping, search, replay or fold change; AWQ appears only as a save A/B case.

Logic Flow Documentation

Removed path: save_quantized -> _validated_save_state_overlay (provider lookup) -> overlay validation/application -> EXL3 storage merge. With no provider, the lookup returned None and every consumer returned unchanged.

flowchart LR
    A[save_quantized] --> B{provider?}
    B -->|none| C[normal save]
    B -->|contract| D[validated overlay]
    D --> E[apply overlay / merge EXL3 storage]
    style D fill:#fee,stroke:#b22
    style E fill:#fee,stroke:#b22
Loading
Removed Kept (normal path)
_validated_save_state_overlay, _validated_save_state_overlay_suffixes, _validated_save_state_overlay_removals _validate_exllamav3_publication_modules
_apply_save_state_overlay _build_exllamav3_checkpoint_passthrough_state_dict
_build_exllamav3_tensor_storage_for_save (overlay merge wrapper) build_exllamav3_tensor_storage (called directly)
validated_overlay= parameters and branches _exllamav3_checkpoint_passthrough_plan, _exllamav3_owned_native_source_names

No docs page is needed for a deletion; the updated docs/native-checkpoint-export.md covers the remaining passthrough flow.

Review Requirements

  • Reviewed this PR.
  • Checked that the code matches existing project structure, APIs, and conventions.
  • Avoided unnecessary monkeypatching and used the project's normal extension points where possible.
  • Minimized and compacted the impacted code surface.
  • Considered and eliminated potential regressions.

Kernel Accuracy Requirements

Not applicable: no kernel, dispatch or fusion change.

Notes

  • save_quantized now calls build_exllamav3_tensor_storage(self.model) directly; the deleted wrapper did exactly that when no overlay existed.
  • docs/native-checkpoint-export.md is a proposed-feature reference page; it now documents only the passthrough it still ships.
  • The unreachable split_by="layer" writer was left untouched.

🤖 Generated with Claude Code

… since #6435)

The save-state overlay was a hook for an attached auxiliary model to
replace tensor prefixes during save. Its only implementer,
DeepSeekV4QModel.save_state_overlay, was deleted with the unreachable
DeepSeek-V4 MTP calibration stack in #6435; `git grep` plus an AST
string/attribute scan over gptqmodel/ (including ports/), tests/, docs/
and examples/ finds no other provider, and the hook is not documented as
an out-of-tree extension point.

Delete the contract: the provider lookup, the three validators, the
tensor-storage merge, the passthrough/state-dict application, and the
tests that only exercised the overlay. The EXL3 publication guard and
checkpoint passthrough (normal save paths) stay; save_quantized calls
them without an overlay. The native-checkpoint-export reference page is
updated accordingly.

No behavior change: with no provider the removed calls were no-ops.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Qubitium
Qubitium force-pushed the refactor/save-state-overlay branch from f41eef2 to 49f7ad3 Compare December 1, 2026 16:32
@Qubitium Qubitium changed the title refactor(writer): one unique-string validator for the save-state overlay contract chore(writer): delete the save-state overlay contract (no implementer since #6435) Dec 1, 2026
@Qubitium
Qubitium marked this pull request as ready for review December 1, 2026 17:43
@Qubitium
Qubitium merged commit 282d949 into main Dec 1, 2026
6 checks passed
@Qubitium
Qubitium deleted the refactor/save-state-overlay branch December 1, 2026 17:43
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.

1 participant