Repository navigation
feat(checkpoint): subset-granular resume and per-module result objects in CheckpointConfig - #6492
Merged
Merged
Conversation
…s in CheckpointConfig
First generic piece of the ds4rt deprecation (map PR-G1): the EXL3-only
projection checkpoint becomes two typed CheckpointConfig fields that any
processor can adopt. GPTQ and RTN are the reference adopters; EXL3 is not
touched here (PR-E1).
- CheckpointConfig.interval accepts "subset:<n>". The ModuleLooper and
WeightOnlyLooper plans then carry LoopStep("subset", layer,
"<layer>:subset<g>") for every group of layer_module_groups() before each
layer step. run_layer_stage publishes a subset step after the group's
process() (empty groups publish with the next group) and passes the
processed but unfinalized modules as LoopBoundary.pending. The adapter
stores their module_result_state_dict() in the continuation; on resume a
committed subset is not forwarded or solved, its modules are placed as
before (memoized device) and loaded from the stored result.
- CheckpointConfig.module_results (requires "subset:1") stores each solved
module of the running subset under sha256(identity, module, weight,
statistic) in <checkpoint>/results as soon as its process() returns. A
resume re-forwards the subset and calls process() only on a miss, so a
changed Hessian can never reuse a stale result. A commit drops the cache.
- LoopProcessor gains no-op defaults: the checkpoint_subset_boundaries flag,
module_result_statistic(), module_result_state_dict() and
load_module_result_state_dict(). Plain GPTQ implements them (G2PTQ, EoRA,
W4A, GSQ and ADMM-Q opt out); weight-only declares the flag because it packs
every subset before its boundary. CheckpointExtension.on_start rejects
"subset:<n>" for other processors or multi-processor chains before restore.
- The capture skips transient AUTO_NF12 forward views (AutoNF12HookedLinear)
of untouched source weights, which exist inside a running layer on CUDA.
- interval_layers becomes interval_steps (the count is plan steps).
With the defaults (interval="layer:1", module_results=False) the LoopPlan
is unchanged and none of the new branches run: a plan A/B over 24
configurations is identical, and GPTQ/RTN Qwen2.5-0.5B plus a tiny
Qwen3-MoE quantized on one GPU with checkpointing off are bit-identical
to origin/main. This is a feature PR, so production lines go up (+437/-46).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Qubitium
marked this pull request as ready for review
November 30, 2026 11:10
2 tasks done
Qubitium
added a commit
that referenced
this pull request
Dec 1, 2026
…6506) `tests/test_docs_contract_refs.py` had 8 failures on main: - docs/cancelled-run-contract.md (+ the citation table) still cited `_copy_checkpoint_tensors_into_submodule` / `_publish_checkpoint_param_` in gptqmodel/utils/structure.py; #6473 moved both to gptqmodel/weight_loader/source.py. - docs/weight-loader.md blocks 0/1 (#6473) executed on a CPU-only host: a two-accelerator `accel:0`/`accel:1` placement map and a continuation that needs `model` and a real checkpoint. Skip-listed with reasons. - docs/measurement.md block 3 is a continuation snippet (prose-defined `texts`, `tokenizer`, models); skip-listed. - Skip-list digests refreshed for docs/calibration-config.md::0 (#6500 added `exclude_attention_sinks=None`) and docs/looper-checkpoint-redesign.md::0 (#6492 added subset intervals); both reasons still hold. The eighth, docs/jit-kernel-builds.md::0, is fixed in #6505. Co-authored-by: Claude Opus 5.5 <[email protected]>
This was referenced Dec 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First generic piece of the ds4rt deprecation (map PR-G1). The EXL3-only projection checkpoint is generalized into two typed
CheckpointConfigfields that any processor can adopt, on the existingLoopPlan/LoopExtensions/CheckpointStore(after #6477, #6467, #6406). Plain GPTQ and RTN are the reference adopters. EXL3/ds4rt code is not touched here (PR-E1).CheckpointConfig(interval="subset:<n>"): one planned step per module subset. A crash loses at most one subset instead of one layer.CheckpointConfig(module_results=True)(requires"subset:1"): each module result in the running subset is stored as soon as itsprocess()returns. A resume solves only the modules that have no stored result. The key covers identity, module, weight and statistic, so a changed Hessian always misses.The defaults are
interval="layer:1"andmodule_results=False. With them theLoopPlanis unchanged and no new branch runs. This was checked with a plan A/B over 24 configs and a GPU bit-identical A/B, both below. This is a feature PR, so lines go up:gptqmodel/+437/-46, tests +348/-3, docs +57/-3. It adds no meta keys, no environment switches and no new classes. The new surface is two typed config fields, one processor flag and three processor methods with no-op defaults.No issue is fixed. This is the planned feature step of the ds4rt deprecation.
What Changed
looper/checkpoint_store.pyCheckpointConfig.intervalaccepts(layer|subset):<n>, andCheckpointConfig.module_results: bool = Falseis new. Usingmodule_resultswithout"subset:1"raisesValueError.interval_layersis replaced byinterval_steps(the count is plan steps), andsubset_stepsis added.CheckpointStore.put_result/result_path/drop_results:results/<key>names a content-addressed object.collect()keeps those objects reachable until the next commit drops them. A damaged entry counts as a miss.looper/extension.pyLoopBoundary.pendingholds the processed but not yet finalized modules of the running layer.LoopExtensions.publish(step, futures, pending=None).LoopExtensions.subset_stepsandmodule_resultsare new properties.looper/checkpoint.py(CheckpointExtension)interval_stepssteps.on_startrejects, before restore, a processor withoutcheckpoint_subset_boundariesor a multi-processor chain.boundary.pendingtoadapter.capture. Layer mode still callscapture()unchanged.restored_result,result_key,load_result,save_result. A commit drops the result cache.looper/gptq_checkpoint.pycapture(pending=None)storesmodule_result_state_dict()for each pending module under the continuation key"pending". This key is only present for subset steps.restorehands the stored results back throughrestored_results.captureskipsAutoNF12HookedLinear, the transient forward-only NF12 view of an untouched source weight. These views exist inside a running layer on CUDA, and before this change their capture failed restore withcheckpoint module kernel is unavailable.looper/module_looper.py,looper/weight_only_looper.py: plans addLoopStep("subset", L, "<layer>:subset<g>")for each group oflayer_module_groups()before the layer step, but only when an extension asks for subset steps. The weight-only loop now finds steps by object rather than byplan.steps[layer_index].looper/stage_subset.pylayer_module_groups()is extracted frombuild_layer_subset_plans, so the plan and the runtime share one source.SubsetPlan.group_indexis new._collect_worker_results(on_result=)saves each result in submission order as soon as it resolves.process()whenresult_keyhits.looper/stage_layer.py_prepare_named_module_for_quantization, which uses the memoized device so placement is unchanged, and thenload_module_result_state_dict.looper/loop_processor.py: no-op defaultscheckpoint_subset_boundaries = False,module_result_statistic(),module_result_state_dict()andload_module_result_state_dict(). Alsomodule_stat_row()/restore_stat_row(), so a restored result republishes its quant-log row once.looper/gptq_processor.pyGPTQ.snapshot_hessian(). The result holds the replay weight,q_scales,q_zeros,q_g_idx, the optionalpack_wqand the stat row.calculate_w_wq_diff), W4A activation modes, GSQ, ADMM-Q, andG2PTQProcessor(pristine-layer refresh).looper/weight_only_processor.py:checkpoint_subset_boundaries = True, because the weight-only looper packs every subset before its boundary.docs/looper-checkpoint-redesign.md: new section "Subset steps and module results" with the flow diagram and table.Tests
New tests:
tests/test_checkpoint_quantization.py::test_quantized_tensors_equal_after_subset_resume[llama-gptq, llama-rtn, qwen3_moe-gptq, qwen3_moe-rtn, llama-gptq-last-subset, llama-gptq-cuda, qwen3_moe-gptq-cuda]model.layers.1:subset1boundary (or:subset3, the last one). Resume runsprocess()/RTN only for the remaining layer-1 groups, and every saved tensor is bit-identical to a run without a checkpoint.tests/test_checkpoint_quantization.py::test_module_results_skip_solved_experts_after_killprocess()for exactly the other 5, never for layer 0 or attention, and the output is bit-identical.tests/test_checkpoint_quantization.py::test_module_result_misses_when_hessian_changestests/test_checkpoint_quantization.py::test_checkpoint_plan_steps[layer:1, subset:1]plan.steps: the default is layer steps only, and subset mode is 4 subset steps plus the layer step per layer.tests/test_checkpoint_store.py::test_invalid_config,test_checkpoint_config_defaults_and_interval,test_module_results_live_until_droppedcollect()untildrop_results().tests/test_checkpoint_extension.py::test_subset_interval_rejects_processors_without_subset_boundaries[...]Red evidence: each defect below was injected in a disposable worktree and the run failed at the intended assertion.
if False:on the restore branch)subset_resume[llama-gptq],[qwen3_moe-gptq]processedincludesself_attn.q_proj/o_projtest_module_result_misses_when_hessian_changesassert 5 == 8subset_resume[llama-gptq-cuda]model.layers.1.mlp.gate_proj.qweightdifferssubset_resume[llama-gptq]model.layers.1.self_attn.q_proj.qweightdifferscapture(first version of this branch)subset_resume[*-gptq-cuda]CheckpointError: checkpoint module kernel is unavailable: ...AutoNF12HookedLinear(Dropping only the result weight, or only the running layer's dense tensors, still passes. Each one restores the processed weights on its own.)
Skips and what they leave unverified:
checkpoint_recoveryfiles. Both groups were then run on GPU 0, above.test_checkpoint_devicesmulti-GPU restore, thetest_awq_balanced_moe*placement tests, and thecuda:1telemetry/adapter nodes. Multi-GPU placement after a subset resume is therefore not exercised. The memoized per-module device map makes it deterministic by construction, but that is untested.module_resultson CUDA. The kill/tamper tests run on CPU only; subset resume itself runs on CUDA.Structural A/B (default plan unchanged)
plan_ab.pypatchesLoopExtensions.start, records everyLoopPlan.stepsthe loopers build, and runs the same script on origin/main and on this branch. It covers 3 tiny families (llama, qwen3_moe, qwen2_untied, 3 layers) × {GPTQ, RTN} × {no dynamic, last layer excluded by-:} × {checkpoint off,CheckpointConfig()default}, which is 24 configs. Result: identical (sha256c8a06e8e6a73bf07…on both trees).GPU A/B (checkpointing off)
gpu_ab.pywas run on origin/main (126e83f) and on this branch with an identical config. Setup:CUDA_VISIBLE_DEVICES=0), seed 0.batch_size=4.BACKEND.TORCH, defaultoffload_to_disk.ExpertsRoutingOverride)Measured Impact
Not applicable. No issue is claimed. With the defaults, quantization output is bit-identical and no new code runs. Subset-mode cost is described under Notes; it was not benchmarked.
Model Support / Module Plan
Not applicable. No model, alias, definition or module tree changes.
AWQ onboarding safety
Not applicable. AWQ is not touched. It keeps layer boundaries, and
"subset:<n>"is rejected for it inon_start.Logic Flow Documentation
file:lineevidence.docs/repeats the diagrams, titled for the mechanism, and is linked fromdocs/README.md.flowchart TD A["ModuleLooper / WeightOnlyLooper build LoopPlan"] -->|"interval subset:n"| B["per layer: subset steps, then layer step"] A -->|"interval layer:n"| C["layer steps only, unchanged"] B --> D["CheckpointExtension.on_start"] D -->|"processor lacks checkpoint_subset_boundaries<br/>or several processors"| X["NotImplementedError"] D --> E["run_layer_stage from cursor"] E -->|"subset committed before this run"| F["_prepare_named_module_for_quantization<br/>load_module_result_state_dict"] E -->|"subset to run"| G["subset forward, then per module"] G -->|"module_results and result_key hits"| H["load_result, skip process"] G -->|"miss"| I["process, then save_result"] F --> J["publish subset step with pending modules"] H --> J I --> J J --> K["adapter.capture stores module_result_state_dict of pending"] K -->|"commit"| L["drop_results"] F -->|"no stored result"| Y["RuntimeError"] style X fill:#fee,stroke:#b22 style Y fill:#fee,stroke:#b22re.fullmatch(r"layer:(\d+)")(checkpoint_store.py:50)(layer|subset):(\d+)plusmodule_results(checkpoint_store.py:55-64)LoopStep("layer", ...)only (module_looper.py:2052,weight_only_looper.py:1066)LoopStep("subset", ...)perlayer_module_groups()group when an extension asks (module_looper.py:2058)interval_layers(checkpoint.py:143)interval_steps(checkpoint.py:199)stage_layer.py:1456)publish_subset_stepsafter each group withpending(stage_layer.py:943)restored_result(stage_layer.py:958)process()result_keyhit loads the stored result (stage_subset.py:1592)layer_index < start_step(weight_only_looper.py:1082)layer_step in committed, and the same per group (weight_only_looper.py:1097,:1172)layer:1(before and after)subset:1subset:1+module_resultsReview Requirements
Kernel Accuracy Requirements
Not applicable. No kernel, packer or dispatch changes.
Notes
subset:1. Each subset commit rewrites the full continuation, including the layer input cache and the running layer's materialized tensors. The processed weights are stored twice, once in the dense capture and once in the result. Referencing the input cache by digest and dropping duplicated weights are follow-ups; neither was measured here.module_results=Truealso hashes each module's weight and a CPU snapshot of its Hessian beforeprocess().CheckpointConfig.interval_layersis renamed tointerval_steps. Its only in-tree reader wascheckpoint.py, andtests/test_checkpoint_store.pyis updated.AutoNF12HookedLinearskip incaptureonly matters at subset boundaries. At layer boundaries no such view remains in the tree, and the default-path A/B above is unchanged.🤖 Generated with Claude Code