fix(omnidreams): robust native build locking + memory-aware nvcc fanout#332
Draft
jmccaffrey-nv wants to merge 1 commit into
Draft
fix(omnidreams): robust native build locking + memory-aware nvcc fanout#332jmccaffrey-nv wants to merge 1 commit into
jmccaffrey-nv wants to merge 1 commit into
Conversation
The single-view native extension loader stalled indefinitely when a prior build was interrupted (Ctrl-C, OOM, machine crash). PyTorch's FileBaton polls a leftover `<build_dir>/lock` forever because nothing ever reclaims an orphaned lock. Compounding it, MAX_JOBS was capped only by CPU count, so on memory-constrained hosts many parallel nvcc processes exhaust RAM+swap and freeze the machine -- which is exactly how the orphaned locks get left behind in the first place. - Add a non-blocking flock build guard around cpp_extension.load. The kernel auto-releases an flock when its holder dies, so an interrupted build never wedges the next run. While we hold the guard, any leftover `lock`/ `.ninja_lock` is provably stale and is reclaimed (logged on deletion). If a *live* process holds the guard we fail fast with NativeBuildBusyError and a clear message instead of polling. No-op on non-POSIX (Windows) -- preserves prior behavior. - Cap compile parallelism by host RAM as well as CPU: min(cpu_count, 8, RAM_GB // per_job). per_job defaults to 8 GiB (realistic for the -O3 CUTLASS/SageAttention TUs) and is tunable via OMNIDREAMS_SINGLEVIEW_NATIVE_MEM_PER_JOB_GB. Explicit MAX_JOBS / max_jobs= still win. Adds 7 tests; full `pytest -m ci_cpu` is green (508 passed). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
The single-view native extension loader stalled indefinitely when a prior build was interrupted (Ctrl-C, OOM, machine crash). PyTorch's FileBaton polls a leftover
<build_dir>/lockforever because nothing ever reclaims an orphaned lock. Compounding it, MAX_JOBS was capped only by CPU count, so on memory-constrained hosts many parallel nvcc processes exhaust RAM+swap and freeze the machine -- which is exactly how the orphaned locks get left behind in the first place.lock/.ninja_lockis provably stale and is reclaimed (logged on deletion). If a live process holds the guard we fail fast with NativeBuildBusyError and a clear message instead of polling. No-op on non-POSIX (Windows) -- preserves prior behavior.Adds 7 tests; full
pytest -m ci_cpuis green (508 passed).