Make soak test actually detect leaks - #6
Merged
Conversation
The original soak test allocated [8] f32 tensors (64 bytes/iter) and checked delta <= 1 MB after 5000 iters. Maximum possible leak was ~320 KB — well under the tolerance — so even a total refcount breakage would pass the test. New design: - 1 Mi-element f32 tensors (4 MB each), 500 iters. - Warm-up loop of 20 iters before sampling the baseline so MLX's one-time allocator setup (kernel cache, Metal libraries) doesn't look like phantom growth. - Tolerance dropped to 2 MB — half of one iteration's allocation, so a single retained tensor per cycle would trip the test. Validated by forcing a deliberate leak (retaining every tensor in a list): delta measured at 407 MB vs 2 MB tolerance, test correctly fails. The clean path still passes.
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
The soak test as it landed in #5 had two problems that only showed up under the full suite:
Re-tuned around rate detection instead of absolute retention:
Validated by injection: a deliberate 1 %-per-iter leak yields delta 45 MB vs 4 MB tolerance → fails by 10×. Clean path passes in ~1 s as part of `mix precommit`.
Test plan