Repository navigation
fix: clean up prefetch workers on early consumer exit - #308
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 57 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
ryoari
left a comment
There was a problem hiding this comment.
Thanks. The fix in prefetch() (a stop event, put with a timeout, the loader closed in the worker, a bounded join) is right, and the tests for it are good.
Please keep this PR to that change. run_phases, cmd_bench and bench_sizes.py don't need the closing(...) wrappers. When a for loop is left by return, break or an exception, CPython drops its iterator at once, and the generator's finally runs then. The project only runs on CPython. Those wrappers re-indent the training loop, which is the published training path, and that makes the diff much harder to check, for no change in behaviour. The benchmark timing change only follows from the wrappers.
So please drop the closing(...) changes, the bench_sizes.py and cmd_bench changes and the README paragraph. Keep the prefetch() change and the tests that call prefetch() directly (close with a full queue, loader error, terminal delivery, exhaustion). Then mark it ready for review and I'll merge it.
8e230ad to
200dc7f
Compare
ryoari
left a comment
There was a problem hiding this comment.
Thanks, this is now only the prefetch() fix and its tests, which is much easier to check. Merging.
Summary
Closes #305.
finally; retain the worker and join for at most one second when the consumer exits.run_phases,cmd_benchandbench_sizes, including STOP, errors and timed breaks.Verification
ruff check simple testsandgit diff --check: passed.ovl.pyfunctions (including both loaders,step, digests, checkpoint and verifier functions) are unchanged.Limits / review focus
Cancellation is cooperative: a thread inside arbitrary blocking I/O cannot be killed safely and can outlive the one-second join until I/O returns. No full RTX 5090 segment replay, CUDA bit-equivalence, GPU memory reduction or throughput speedup is claimed. Benchmark tests use a simulated clock and mocked CUDA accounting on CPU, not performance measurements. Existing short-stream benchmark arithmetic issue #223 is deliberately unchanged.
Base: f42508c. No changes to release recipe, RNG, optimizer arithmetic, batch construction/order, digests, chain or checkpoints. This branch contains no other pending fixes.