Repository navigation
fix: scope MPS daemon detection and cleanup to our pipe dir (#166) - #189
Merged
Merged
Conversation
_mps_daemon_running fell back to a host-wide pgrep, so another job's MPS daemon (other pipe directory) looked like ours; the health probe on our pipe dir then failed and the stale cleanup ran pkill -u $UID on every MPS server and control process, killing the other job's daemon. Liveness is now our control socket only, and the stale cleanup sends quit to our pipe dir and removes our socket, without pkill. Adds tests/test_mps_manager.py with a fake pipe dir. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 23, 2026
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.
Background
MPSManager.startdecides whether an MPS daemon is running with_mps_daemon_running, which fell back to a host-widepgrep -x nvidia-cuda-mps-server|control(#166). A daemon of another job, serving another pipe directory, therefore looked like ours. The health probe (get_server_liston our pipe dir) then failed, and_force_cleanup_stale_daemonranpkill -u $UID -xon every MPS server and control process of the user. For example: job A runs with/tmp/mps-a, job B starts with the default dir, and job A's daemon is killed.Changes
opt_prime/opt_prime/mps_manager.py_mps_daemon_running(was :504-530): liveness is our pipe directory'scontrolsocket only; the twopgrepprobes are removed.opt_prime/opt_prime/mps_manager.py_force_cleanup_stale_daemon(was :801-808): thepkillloop is removed. The cleanup still sendsquitto our pipe dir (viaCUDA_MPS_PIPE_DIRECTORY) and removes our control socket so a new daemon can bind.opt_prime/tests/test_mps_manager.py: with a fake pipe dir and asubprocess.runstub on which every command succeeds (as if another job's daemon were up),_mps_daemon_runningis False until ourcontrolsocket exists, and the stale cleanup issues nopkill/killalland removes our socket.Net -30 lines in
mps_manager.py.Verification
Environment: Python 3.10, torch 2.10.0+cu128, CPU only (no MPS daemon started). Base: optimus-rm @253be20.
2 failed._mps_daemon_runningreturned True for an empty pipe dir, and the cleanup issuedpkill -u <uid> -x nvidia-cuda-mps-serverand... nvidia-cuda-mps-control.2 passed.Full suite (
cd opt_prime && TORCH_DEVICE_BACKEND_AUTOLOAD=0 CUDA_VISIBLE_DEVICES=1 PYTHONPATH=$PWD python3 -m pytest -q tests):400 passed, 23 skipped, 135 subtests passed402 passed, 23 skipped, 135 subtests passedCompatibility and limits
start()then spawns a new daemon on our pipe dir, which is the intended scope.quit, its process is no longer force-killed; the socket is removed and a new daemon is started. Killing it would need its PID tied to our pipe dir, which the manager does not track today.Related Issue
Closes #166
🤖 Generated with Claude Code