Skip to content

feat(writer): compose native checkpoint passthrough and save overlays - #3602

Merged
Qubitium merged 2 commits into
ModelCloud:mainfrom
tpurtell:upstream/22-native-checkpoint-export-20261108
Nov 9, 2026
Merged

Qubitium merged 2 commits into
ModelCloud:mainfrom
tpurtell:upstream/22-native-checkpoint-export-20261108

Conversation

@tpurtell

@tpurtell tpurtell commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Preserve source-native checkpoint names and untouched tensors, compose validated auxiliary overlays, stream exact passthrough exports, reject incomplete publication trees, and publish EXL3 ledgers without embedding the tensor manifest in model config. Retain early auxiliary-source validation and the earlier atomic shard writer.

This is layer 22/36, extracted from an already-used fork for initial maintainer feedback. It depends on #3601. Review only this feature; the cross-fork Files changed view is cumulative because the PR targets upstream main.

Incremental change: 9 files, +1576/−126 lines, including carried tests and the mechanism reference. No merge is automatic. Review value and API shape first; substantial rework can follow that feedback.

Flow and existing-code boundary

flowchart TD
    S0["_validated_save_state_overlay"]
    S1["_exllamav3_checkpoint_passthrough_plan"]
    S2["_build_exllamav3_checkpoint_passthrough_state_dict"]
    S3["ModelWriter"]
    E["RuntimeError, TypeError, ValueError"]
    S0 -->|"raises on rejected input/state"| E
    S1 -->|"raises on rejected input/state"| E
    S2 -->|"raises on rejected input/state"| E
    S3 -->|"calls where selected"| S0
    S3 -->|"calls where selected"| S1
    S3 -->|"calls where selected"| S2
    S3 -->|"raises on rejected input/state"| E
    style E fill:#fee,stroke:#b22
Loading
Before this extraction layer Carried implementation
API absent in the previous stack layer (path/symbol checked) gptqmodel/models/writer.py:658: _validated_save_state_overlay
API absent in the previous stack layer (path/symbol checked) gptqmodel/models/writer.py:792: _exllamav3_checkpoint_passthrough_plan
API absent in the previous stack layer (path/symbol checked) gptqmodel/models/writer.py:936: _build_exllamav3_checkpoint_passthrough_state_dict
Previous stack layer: gptqmodel/models/writer.py:799 gptqmodel/models/writer.py:1387: ModelWriter

Committed reference: docs/native-checkpoint-export.md, linked from README. Class entry points/calls and rejected-state paths describe code present in this branch, rather than planned integrations.

Validation

Carried test files: tests/test_writer_state_overlay.py, tests/test_writer_attention.py, tests/test_writer_quant_log.py, tests/test_out_of_model_tensors.py, tests/test_split_by_layer_save.py, tests/test_offload_files.py

This packaging pass checked Python parsing, whitespace, dependency order and balanced Mermaid blocks. The author reports successful prior use of these features. Per the requested resource limit and feedback-first scope, existing model quantization, GPU/ROCm tests, heavyweight CPU workloads and full model benchmarks were not rerun; no new performance or model-accuracy claim is made. Tests accompanying earlier stack layers retain their previously reported results.

tpurtell and others added 2 commits November 9, 2026 09:29
Extract the existing working fork feature for first maintainer feedback. Preserve carried code and tests; limit validation to lightweight structural checks. See the linked mechanism reference for actual API/call and failure paths.
@Qubitium
Qubitium force-pushed the upstream/22-native-checkpoint-export-20261108 branch from fdeb514 to 56742ff Compare November 9, 2026 09:30

@Qubitium Qubitium left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed against current main. The layer composes cleanly:

  • _merge_missing_config_fields keeps source-only config keys (including nested text_config) while letting the live serialized config win, and _CONFIG_MERGE_SKIP_KEYS correctly excludes the regenerated quantization_config/quantize_config so _quantization_config_for_model_config remains the single writer of that field.
  • _quantization_config_for_model_config strips tensor_storage for EXL3 so the multi-megabyte manifest is not duplicated into config.json; the external quantize config stays authoritative.
  • _validated_save_state_overlay / _exllamav3_checkpoint_passthrough_plan / _build_exllamav3_checkpoint_passthrough_state_dict fail closed on missing prefixes, ambiguous prefix contracts, missing source suffixes, and tensor-contract violations, and the EXL3 publication guard rejects native recovery targets.
  • _merge_selected_tensors_into_state_dict generalizes prefix selection to suffix/exact selections while keeping undeclared prefixes optional and still erroring on declared-but-unreadable tensors.
  • Split-by-layer save suspends active source staging during materialization, as exercised by the new test.

Validation: ruff check clean on the touched modules; pytest on the six touched test files reports 134 passed, 3 skipped (the skips are the pre-existing CUDA/optional-dtype guards).

No blocking issues found.

@Qubitium
Qubitium marked this pull request as ready for review November 9, 2026 09:32
@Qubitium
Qubitium merged commit 5806645 into ModelCloud:main Nov 9, 2026
ZX-ModelCloud added a commit that referenced this pull request Nov 11, 2026
_merge_prefix_tensors_into_state_dict was removed in #3602, and
_normalize_out_of_model_tensors_entries now returns four selector
lists. Update the MTP absent-auxiliary test to the current
_merge_selected_tensors_into_state_dict API so collection no longer
fails.
Qubitium pushed a commit that referenced this pull request Nov 11, 2026
* test(mimo): use current writer out-of-model selector API

_merge_prefix_tensors_into_state_dict was removed in #3602, and
_normalize_out_of_model_tensors_entries now returns four selector
lists. Update the MTP absent-auxiliary test to the current
_merge_selected_tensors_into_state_dict API so collection no longer
fails.

* test: gate optional deps and CUDA-only kernels by device family

Optional server dependencies and CUDA-only kernels must not break collection or fail on ROCm:

- Skip test_openai_server.py and test_openai_server_contract.py at module
  scope when openai / fastapi are not installed, instead of raising during
  collection.
- Gate every backend in test_gptq.py through the kernel's own
  SUPPORTS_DEVICES family declaration, validate_device() rules and
  validate_once() availability. TRITON, MARLIN, MACHETE, SWORDFISH and
  EXLLAMA_V2 now skip on ROCm instead of failing while loading.
- Stub cached_validate_once() alongside the dummy BitBLAS operator in
  test_qlinear_hierarchy.py so the runtime-state assertions do not require
  a CUDA BitBLAS install.

* test: gate optional httpx and harden the kernel skip gate

test_openai_server_contract.py imported httpx at module scope, so a server
environment without the optional httpx package still failed collection after
fastapi and starlette were gated. Skip the module when httpx is absent.

_kernel_skip_reason() assumed validate_once() always returns (ok, error).
TritonV2Linear raises ImportError when its optional runtime is missing, which
turned the new gate into a test error instead of a skip. Treat a raising probe
as an unavailable kernel, and cover the family mismatch, device rejection,
unavailable and raising paths with a host-independent unit test.

Copy link
Copy Markdown
Collaborator

Review found selected checkpoint tensor names could disappear silently. #3712 now validates the indexed names before continuing.

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.

2 participants