fix(compute): reap kernel workers + cap compute subagents (follow-up to #102 thread-cap)#182
Open
KB (KB-syntheticsciences) wants to merge 1 commit into
Open
fix(compute): reap kernel workers + cap compute subagents (follow-up to #102 thread-cap)#182KB (KB-syntheticsciences) wants to merge 1 commit into
KB (KB-syntheticsciences) wants to merge 1 commit into
Conversation
… regress_out (#102) Complements the thread-cap already in main (pythonThreadCapEnv) with the axes it doesn't cover: - Reap orphaned workers: python/R kernels now spawn detached (own process group) and every kill path (timeout, abort, idle-reap, shutdown, process-exit) routes through Shell.killTree/killTreeSync, so joblib/BLAS worker children die with the kernel instead of lingering and thrashing swap. Group kill only fires when the child leads its own group (verified via /proc on Linux). - Bound concurrent compute subagents (biology/ml/physics) with an abort-aware counting semaphore (OPENSCIENCE_MAX_COMPUTE_SUBAGENTS, default 2): N parallel subagent kernels each holding a dataset copy no longer sum to an OOM. A cancelled subagent still queued unblocks immediately and leaks no slot. - Scanpy template: size regress_out's n_jobs to the worker copies that fit in RAM and skip (with guidance) only when even one won't fit; warn on a dense adata.X. regress_out stays enabled by default. Full suite green (1138 pass).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Context
Follow-up hardening on top of the #102 fix already merged in
main. #102 is closed —060e1dd(#178) addedpythonThreadCapEnv, which caps thread/worker fan-out inside one kernel. This PR does not re-open or re-litigate that; it keepspythonThreadCapEnvand adds the OOM axes that cap doesn't cover (orphaned workers, parallel-kernel concurrency) plus a code-level scanpy guard where main currently relies on prompt advice.Changes
Reap orphaned workers
detached(own process group), and every kill path — startup timeout, cell timeout, abort, idle-reap,shutdown, and process-exit — routes throughShell.killTree/killTreeSync. So joblib/BLAS worker children die with the kernel instead of lingering./procon Linux); a non-detached child is killed singly, so the group signal can never reach our own process group.Bound concurrent compute subagents
biology/ml/physics) run at once (OPENSCIENCE_MAX_COMPUTE_SUBAGENTS, default 2). Nested compute calls skip the cap so a small pool can't self-deadlock.acquire(signal)is abort-aware: a subagent cancelled while still queued rejects and leaves the wait queue, sorelease()never hands a slot to a dead waiter.Scanpy template guard
regress_out(densifies + forks one dense copy per worker) now sizesn_jobsto the worker copies that fit in available RAM and skips (with guidance) only when even one won't fit. Warns on a denseadata.X.regress_outstays enabled by default — this is pure sizing/skip safety, not a behavior change.Why each helps beyond the merged thread-cap
biology/mlsubagents each holding a dataset copy still sum to an OOM — this was the subagent-multiplication mechanism diagnosed for bug #102. The semaphore serializes them.n_jobs=-1") relies on the model complying; code enforcement doesn't — which matters for exactly the weak models that OOM.Testing
bun test— full suite green (1138 pass / 1 skip / 0 fail).Notes
killTreeSync/group-kill are best-effort; the group signal is guarded so it can't hit the wrong group.Follow-up to the merged #102 thread-cap (#178) — #102 is already closed; this hardens the axes that fix didn't cover. Not intended to re-open the issue.