Harden Apple MPS runs against command-buffer recovery - #57
Merged
Conversation
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.
Root cause
The attached failure is not a primary WeightWatcher/SVD problem. Metal reported asynchronous command-buffer recovery twice, the second recovery was followed by non-finite train/validation metrics, and the later NumPy SVD failure was only the first CPU operation that rejected the contaminated matrices.
Changes
checkpoint_latest.ptand only after the updated loader verifies that the checkpoint is finite;--mps-retriesand a debugging-only--no-mps-isolationoverride;Scientific behavior
The patch does not change the model, optimizer equations, learning-rate schedules, batch size, data sampling, evaluation probes, WeightWatcher settings, or result-directory layout. A retry restores model, optimizer, training-generator, Python/NumPy/Torch, and MPS RNG state from the last finite atomic checkpoint. It does not silently switch devices.
Expected behavior
On MPS, a multi-seed command now launches one sequential worker process per optimizer/seed. If Metal recovery corrupts a worker, current finite-metric checks terminate it before WeightWatcher. The supervisor waits briefly and resumes once from the last verified checkpoint in a new Metal process. A repeated failure remains visible and stops the experiment.
Tests
New tests cover:
--overwrite/--no-resumeon a recovery attempt;