fix(ci): ignore exited and zombie KFD PIDs in box_step.sh so CI steps do not self-preempt
Based on main d552394eb (#1060–#1065 merged).
What
On lucebox3, .github/ci/box_step.sh preempts its own ctest steps when a short-lived test child exits, waits 120 s for the GPUs to stay quiet, and restarts the step from test #1.
In main run 43754866765, all 7 GPU yields (5 on R9700, 2 on Strix Halo, ~20 min total wall time) were self-kills immediately after a passing ctest child exited:
20:54:18.094 105/136 Test #1402: ds4_maskless_prefill_disabled ... Passed 0.23 sec
20:54:18.095 box_step.sh: line 39: /proc/346852/environ: No such file or directory
20:54:18.096 box_step.sh: line 45: /proc/346852/stat: No such file or directory
20:54:18.099 ##[warning]Another process started using a GPU; stopping this step, to rerun it once the GPUs are free. In use by:
pid 346852 (exited)
Cause: Linux KFD tears down /sys/class/kfd/kfd/proc/<pid> asynchronously after /proc/<pid> is reaped. While that entry lingers, ours() and monitor() fail to open /proc/<pid>/{environ,stat,cmdline} and return 1, so others() reports the exited child PID as an external GPU process.
Fix (.github/ci/box_step.sh):
- Add
alive()checking that/proc/<pid>/statis readable and not in stateZ,X, orx, and call it both before and afterours/monitorinothers()to close the TOCTOU window when a process exits mid-check. - Recognize step session descendants via
sid == $stepinours()(covers grandchildren reparented to PID 1 insidesetsid). - Wrap
/procreads in{ ...; } 2>/dev/nullso vanished or other-user/procfiles do not leak bash open errors to stderr. - Allow env overrides for
kfd,proc,vmstat, and poll/quiet intervals (defaults unchanged) so the script can be unit-tested without KFD hardware.
Behavior for live external GPU processes is unchanged: a live non-monitor process in KFD still preempts the step, waits for the quiet window, and reruns.
Tests
- New
.github/ci/test_box_step.py(4 cases):test_exited_kfd_pid_does_not_preempt_step: stale KFD dir with no/proc/<pid>does not yield and emits noNo such file or directorystderr.test_zombie_kfd_pid_does_not_preempt_step: zombie (Z) entry in KFD does not yield.test_monitor_and_own_job_kfd_pids_do_not_preempt:rocm-smiand ownRUNNER_TRACKING_IDentries are ignored.test_live_external_gpu_process_yields_and_reruns: live external GPU process (withchmod 000environsimulating another user) still preempts, waits, and reruns the step cleanly with noPermission deniedstderr.
- Run locally:
bash -n .github/ci/box_step.sh,pytest .github/ci/(109 passed),ruff checkon.github/ci/*.py, andcheck_commit_messages.py. - Run on CI:
uv-workspace,build-megakernel, andgpu-tests(DGX GB10) passed;lucebox3jobs are queued.
Known limits, not addressed here
- Not yet observed live on
lucebox3(jobs are queued behind the current runner backlog); the failing sequence from run43754866765is reproduced bytest_exited_kfd_pid_does_not_preempt_step.