Repository navigation
fix(looper): keep a post-loop tail failure inside the failed-run cleanup (#5023) - #5039
Merged
Qubitium merged 1 commit intoNov 18, 2026
Merged
Conversation
…nup (ModelCloud#5023) `WeightOnlyLooper.loop()` and `ModuleLooper.loop()` guarded only `_loop_impl(...)` with the best-effort failure cleanup. The tail that turns the lazy offloaded shell back into an in-session model ran *after* that guard, so a Ctrl-C, an OOM or an I/O error landing there skipped the cleanup entirely: `model.embed_tokens`, `model.norm` and `rotary_emb` stayed on meta and every later in-session forward failed with a meta-tensor error. For RTN the window is about 15% of the run, and `_restore_disk_offloaded_modules` reads every quantized layer back from disk. Weight-only: the tail now runs inside the same `try`, so a failure there goes through the existing recovery (non-strict base-module restore, materialize the unreached layers, kernel rehome, version-counter repair, keep the offload root while modules still read from it). GPTQ: the tail is wrapped in its own guard that calls the new `_recover_post_loop_tail_failure()` before re-raising. `_loop_impl` already returned, so the in-flight layer and the processors need no work; the recovery restores the base modules, materializes the remaining meta modules, repairs the version counters and keeps the offload root, all best effort so it can never mask the failure. Regression tests (4 of 6 nodes red on the parent commit): `tests/test_post_loop_tail_failure_5023.py` injects one failure at the first call of `restore_disk_offloaded_modules`, `replace_inference_parameters`, `materialize_remaining_meta_modules` (RTN) and `restore_offloaded_modules` / `materialize_remaining_meta_modules` (GPTQ), then asserts the in-session forward returns finite logits.
This was referenced Nov 18, 2026
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.
Summary
WeightOnlyLooper.loop()andModuleLooper.loop()guarded only_loop_impl(...)with the best-effort failure cleanup. The tail that turns the lazy offloaded shell back into an in-session model ran after that guard:A Ctrl-C, an OOM or an I/O error landing there skipped the cleanup entirely:
model.embed_tokens,model.normandrotary_embstayed on meta and every later in-session forward failed with a meta-tensor error. For RTN the window is about 15% of the run.Closes #5023.
Fix
WeightOnlyLooper.loop()try, so a failure there runs the existing recovery (non-strict base-module restore, materialize unreached layers, kernel rehome, version-counter repair, keep the offload root while modules still read from it)ModuleLooper.loop()_recover_post_loop_tail_failure()before re-raising_loop_implhas already returned when the GPTQ tail fails, so the in-flight layer and the processors need no work: the recovery restores the base modules, materializes the remaining meta modules, repairs the version counters and keeps the offload root. Every step is best effort so it can never mask the failure that got us there.Tests
New
tests/test_post_loop_tail_failure_5023.pyinjects one failure at the first call of a tail helper (what an interrupt delivered at that point does; the recovery's later call runs the real helper), then asserts the in-session forward returns finite logits.Related suites (CPU, this host):
ruff checkon both loopers and the new test: All checks passed.Logic Flow Documentation
Not applicable: the existing cleanup path is reused; GPTQ gains one best-effort recovery helper.
Model Support / Module Plan
Not applicable: no definition or plan change.