Repository navigation
refactor(looper): give both quantization loops one run-exit recovery owner (#5060) - #5066
Merged
Merged
Conversation
…owner The calibrated and weight-only loops each ordered the same failure repairs in their own exception handler, and the calibrated loop had a second recovery path for a failing success tail. Every new obligation (fence, in-flight restore, base-module restore, meta materialization, kernel rehome, version counters, offload-root retention) had to be added twice. Add `gptqmodel/looper/run_exit_recovery.py::RunExitRecovery`, a run-scoped owner with one success sequence (`complete()`) and one abort sequence (`abort()`). Each looper supplies its processor-specific callbacks; steps the run did not acquire are skipped. Success is published only after every restore step succeeds. Stop, exception and interrupt enter `abort()`, which is idempotent, fences submitted work first, and records secondary repair failures on `failures` without ever replacing the primary exception. The calibrated looper's separate `_recover_post_loop_tail_failure` is retired into the same abort path; the weight-only loop gains the fence and run-workspace release it previously skipped, while keeping its in-flight restore before processor release to preserve the #5011 contract. Add `tests/test_run_exit_recovery_contract_5060.py`, the shared conformance fixture: tiny GPTQ and RTN runs with a next-layer fault and a final-restore fault, disk offload on/off, the calibrated post-forward stop, a secondary repair failure, a successful-run control, and assertions for the original error, a grad-enabled forward, usable completed/in-flight/unreached layers, no hooks/inference tensors/late mutation, and retained disk-shell backing. Update the cancelled-run contract page to name the shared owner. Part of #5060
Collaborator
Author
|
Independent note from a parallel attempt at this issue (I closed my narrower #5067 as superseded by this PR). Before this PR, Two properties that matter for it, both of which my branch pinned with a unit test that drives the exit path directly (pool still writing into the run directory when the run fails):
If |
This was referenced Nov 18, 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.
Implements the bounded migration in #5060: the run, not each looper's exception handler, now owns the model-state obligations of a quantization run's exit. Design decision accepted as written in the issue; no checkpoint or public-API change.
What changed
New
gptqmodel/looper/run_exit_recovery.py—RunExitRecovery, a run-scoped owner withrun(body)/complete()/abort():run(body)executes the layer loop; success callscomplete(), whose steps are the shared success tail._completedis published only after every restore step succeeds.complete()enters the sameabort()path, which re-raises the original exception.abort()is idempotent and never raises. Each step is best effort and independent; a secondary repair failure is appended torecovery.failuresand logged, never raised in place of the exception that ended the run.release_processors_before_restorekeeps the two existing orderings (calibrated loop releases processors first; weight-only restores its in-flight layer first per [BUG] #4979 (fix of #4947) incomplete: a failed weight-only quantize (RTN/GGUF/FP8) leaves the in-flight layer on cuda:0; next forward raises a device mismatch (no #4580 in-flight restore in WeightOnlyLooper) #5011). The owner still runs the release exactly once.ModuleLooper.loop()andWeightOnlyLooper.loop()now both delegate to it.ModuleLooper._recover_post_loop_tail_failureand the ~145-line weight-only failure branch are retired; the same obligations can no longer be forgotten in one loop only (#5031, #5039, #5049 were each that failure mode).Verification (this host,
origin/main468c201d)New
tests/test_run_exit_recovery_contract_5060.py— 16 conformance cases against both loopers, covering the issue's acceptance list:StopMainLoopafter a forward);Deferred / residual risk
release_processors_before_restore; unifying them is a further contract change, not part of this slice.abort()deliberately does not restore disk-offloaded modules (matches both previous failure branches);complete()does._fence_run_workdrains device/stream pools but has no dangling-watcher registry (it never had one).recovery.failures) plus a log line, not surfaced through a public API.Part of #5060.