Skip to content

feat(exl3): resume capture at calibration-batch boundaries - #3595

Merged
Qubitium merged 17 commits into
ModelCloud:mainfrom
tpurtell:upstream/15-exl3-capture-batch-spool-20261108
Nov 9, 2026
Merged

Qubitium merged 17 commits into
ModelCloud:mainfrom
tpurtell:upstream/15-exl3-capture-batch-spool-20261108

Conversation

@tpurtell

@tpurtell tpurtell commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Carry the existing batch spool with provenance and tensor-geometry validation, atomic batch commits, and exact committed-batch recovery. Looper callbacks follow in the replay layer.

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

Incremental change: 4 files, +619/−0 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["EXL3CaptureBatchSpool"]
    M0_0["EXL3CaptureBatchSpool.__init__"]
    M0_1["EXL3CaptureBatchSpool.committed_indices"]
    M0_2["EXL3CaptureBatchSpool.commit"]
    S1["canonical_json_bytes"]
    E["EXL3CaptureBatchSpoolError, KeyError"]
    S0 -. "exposes" .-> M0_0
    S0 -. "exposes" .-> M0_1
    S0 -. "exposes" .-> M0_2
    S0 -->|"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/utils/exl3_capture_batch_spool.py:101: EXL3CaptureBatchSpool
API absent in the previous stack layer (path/symbol checked) gptqmodel/utils/exl3_capture_batch_spool.py:44: canonical_json_bytes

Committed reference: docs/exl3-capture-batch-spool.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_exl3_capture_batch_spool.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.

Serialize configs without the empty state-dict cleanup path and replace completed shard files atomically. Keep live config fields authoritative and preserve source-only extensions. Retain the previous shard on write failures.
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.
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.
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.
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.
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.
A failed progress.json publication restored _records but left the batch in
_pending_records and removed its payload file, so a retry returned a record
with no backing file. Drop the pending entry in the commit failure path so
the retry rewrites it. Add a regression test.

@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.

Review (layer 15)

Reviewed the incremental layer-15 commit (d70ddbe06, 4 files, +619). The atomic batch rename + bounded progress.json checkpoint and the interrupted-temp/unmanifested-file cleanup are sound. I pushed a fix commit (1a6f485da).

Fixed

  1. Failed checkpoint left a stale pending record. When _atomic_json(progress.json) raised, checkpoint() restored _records and re-raised, but the batch stayed in _pending_records while commit()'s error path deleted its payload. A retry then returned a record with no backing file. The pending entry is now dropped on the failure path so the retry rewrites it. Regression test added.
  2. Ruff I001 (import order) in both new files.

Verification

tests/test_exl3_capture_batch_spool.py: 9 passed (8 original + 1 new). ruff check clean.

Notes (not changed)

  • load() validates tensor geometry against the record but does not re-hash the payload; content is checked at _restore. Tampering during a live process is not detected.
  • commit() returns the existing record for an already-committed/pending index without comparing the new tensors or metadata, so a conflicting rewrite is silently accepted.
  • provenance is normalized with plain json.dumps; a non-finite value survives that step and only fails later in the canonical hash. A pre-check would give a clearer error.

@Qubitium
Qubitium marked this pull request as ready for review November 9, 2026 09:01
@Qubitium
Qubitium merged commit d058c1d into ModelCloud:main Nov 9, 2026
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