Repository navigation
fix(looper): fence a failed weight-only run's submitted work, via one shared exit helper (#5060) - #5067
fix(looper): fence a failed weight-only run's submitted work, via one shared exit helper (#5060)#5067Qubitium wants to merge 1 commit into
Conversation
… shared exit helper (ModelCloud#5060) `ModuleLooper` has drained the work a failed run already submitted since ModelCloud#4595: `DEVICE_THREAD_POOL`, its finalizer watcher threads and `STREAM_DEVICE_POOL`, before it restores the in-flight layer or releases the per-run offload root. `WeightOnlyLooper` submits submodule finalizers to the same pool (the pack/replace steps) but its failure branch went straight to `_restore_inflight_layer()`, `rehome_failed_run_kernels()` and `release_private_offload_root()`. That is the ModelCloud#4595 defect class in the other looper: a finalizer the run already submitted keeps packing and replacing modules after `quantize()` has raised, and re-creates the offload directory the teardown just removed (one leaked bundle set per failed run). ModelCloud#5049 made the same "the calibrated looper already guarantees this" argument for the in-flight placement. This is the first step of ModelCloud#5060's bounded migration: the identical part of the two exit sequences now lives in `gptqmodel/looper/run_exit.py`, so a new obligation is added once instead of twice. - `fence_submitted_work()` / `run_exit_waits()` own the waits and the "each wait is independent, never mask the run error" policy. - `ModuleLooper._fence_run_work()` delegates to it with the same waits, labels and order; it still passes its module-level `DEVICE_THREAD_POOL` so a substituted pool keeps taking effect (the ModelCloud#4595 tests are unchanged). - `WeightOnlyLooper` gains the same fence and calls it before its first repair step. It has no finalizer watcher threads, so only the two pools apply. Behaviour for the calibrated looper is unchanged. The rest of ModelCloud#5060 (one run-exit owner covering body and tail, obligations derived from what the run acquired) stays as follow-up. `tests/test_failed_run_fence_5060.py` drives the weight-only exit path with a pool that is still writing when the run fails: it asserts the drain happens before the in-flight restore and before the offload root is released, that the released directory is not re-created, and that a wedged drain neither skips the repairs nor replaces the run's exception. All three nodes fail on unmodified `main` (`WeightOnlyLooper` has no fence at all). The ModelCloud#4595 suite, the cancelled-run suite and the end-to-end RTN failed-run cases stay green.
|
Closing as superseded by #5066, which another agent opened for this issue while I was working on it. #5066 implements the full bounded migration ( The finding that motivated this branch is still worth recording on the issue: before #5066, Nothing from this branch is needed beyond that; the regression test I wrote is subsumed by |
First step of #5060's bounded migration. Does not close the issue.
Problem
ModuleLooperhas drained the work a failed run already submitted since #4595 —DEVICE_THREAD_POOL, its finalizer watcher threads andSTREAM_DEVICE_POOL— before it restores the in-flight layer or releases the per-run offload root.WeightOnlyLoopersubmits submodule finalizers to the same pool (the pack/replace steps,weight_only_looper.py:650and:708) but its failure branch went straight to_restore_inflight_layer(),rehome_failed_run_kernels()andrelease_private_offload_root().That is the #4595 defect class in the other looper: a finalizer the run already submitted keeps packing and replacing modules after
quantize()has raised, and re-creates the offload directory the teardown just removed (one leaked bundle set per failed run). #5049 made the same "the calibrated looper already guarantees this" argument for the in-flight placement, and this issue's contract states the obligation for both loopers.Change
The identical part of the two exit sequences now lives in
gptqmodel/looper/run_exit.py, so a new obligation is added once instead of twice:fence_submitted_work(waits)owns the waits and the policy — each wait is independent, a failure is logged, nothing masks the run's exception.run_exit_waits(...)builds the ordered(label, wait)list, with the looper-specific pieces passed in as callbacks.ModuleLooper._fence_run_work()delegates to it with the same waits, labels and order, still passing its module-levelDEVICE_THREAD_POOLso a substituted pool keeps taking effect (the [BUG] #4470 only half fixed by #4515: failed quantize() returns while finalizers still run; they recreate the deleted offload run dir (orphaned bundles) and mutate the model after the exception #4595 tests are untouched).WeightOnlyLoopergains the same fence and calls it as the first step of its failure branch. It keeps no finalizer watcher threads, so only the two pools apply.Calibrated-looper behaviour is unchanged. The rest of #5060 — one run-exit owner covering body and tail, with obligations derived from what the run actually acquired — remains as follow-up; this PR is the "extract their common exit sequence around the existing helpers" step, done one piece at a time.
Verification
tests/test_failed_run_fence_5060.pydrives the weight-only exit path with a pool that is still writing when the run fails:_restore_inflight_layer()and before the offload root is released, and that the released directory is not re-created;All three nodes fail on unmodified
main(AttributeError: type object 'WeightOnlyLooper' has no attribute '_fence_run_work').Green with the change:
tests/test_failed_run_fence_5060.py+tests/test_failed_run_fence_4595.py: 6 passed.tests/test_failed_run_model_state_5009.py(incl. the end-to-end RTN failed-run cases with offload on/off),test_cancelled_quantize_layer_cleanup_4546.py,test_cancelled_quantize_default_offload_4860.py,test_cancelled_quantize_disk_offload_4807.py,test_cancelled_quantize_kernel_rehome_4947.py,test_subset_cancel_hook_cleanup_4470.py,test_offload_base_modules_restored.py: 22 passed, 8 skipped.ruff checkclean.