fix: reap the MPExecutor process group to free GPU on task failure#85
Merged
Conversation
timzsu
approved these changes
Jun 26, 2026
timzsu
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. Thanks for the prompt fix.
An unexpected (non-ExecutionError) failure hard-killed only the worker subprocess, orphaning the vLLM engine-core grandchild that holds the GPU; the next task then OOMed at model load. Shut the subprocess down gracefully while it is still responsive so the inner executor releases the GPU cleanly, and signal the whole process group on teardown so an orphaned engine is reaped rather than leaked. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Noppanat Wadlom <noppanat.wad@gmail.com>
d40088e to
d8b6336
Compare
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.
Purpose
When an executor hosted in
MPExecutorfailed with an unexpected (non-ExecutionError) exception after loading its engine — e.g. a vLLM inference task that loads onto the GPU and then raises during prompt rendering — the worker hard-killed only the direct subprocess. vLLM's engine-core child is a grandchild of that subprocess, so it was orphaned and kept holding the GPU. The next task on that worker then OOMed at model load. This is a regression from the unexpected-failure teardown added in #82, which terminated only the direct child.Changes
src/worker/executors/mp_executor.py— on an unexpected failure, shut the subprocess down gracefully while it is still responsive, then reap its whole process group on teardown so an orphaned engine-core child is killed rather than leaked.tests/worker/test_mp_executor_lifecycle.py— cover graceful inner cleanup on an unexpected failure, and process-group reaping of an orphaned grandchild.Design
The worker subprocess leads its own process group (
os.setsid()), so teardown signals the group — reaching the engine-core grandchild vLLM spawns, not just the direct child. When the subprocess is still responsive, a graceful shutdown runs the inner executor's cleanup first so the GPU is released cleanly; the group kill is the backstop and also covers the OOM-killed-subprocess path, where graceful shutdown isn't possible.Test Plan
End-to-end on a local root + single GPU worker on freshly built images carrying this branch: submit a vLLM inference task that loads its engine and then fails during graph-template rendering, then submit a follow-up vLLM task on the same worker — comparing the worker's GPU state and the follow-up's outcome with and without the fix. GPU memory is attributed per worker container (the worker's own processes) so the reading is robust to other tenants sharing the device.
Test Result
End-to-end: without the fix, the failed task left an orphaned vLLM engine-core process holding ~5.7 GiB on the worker, and the follow-up task failed with vLLM's
No available memory for the cache blocks. With the fix, the worker's GPU footprint returned to 0 after the failure and the follow-up task ran to DONE.Pre-submission Checklist
pre-commit runon the changed files and fixed any issues.[BREAKING]and described migration steps above.