Skip to content

fix(ci): runner probe for #1949 evidence, do not merge - #2120

Closed
inureyes wants to merge 3 commits into
mainfrom
ci-probe/issue-1949-runner-evidence
Closed

inureyes wants to merge 3 commits into
mainfrom
ci-probe/issue-1949-runner-evidence

Conversation

@inureyes

@inureyes inureyes commented Oct 5, 2026

Copy link
Copy Markdown
Member

Throwaway probe for the runner-side acceptance criteria of #1949 (PR #2119). Do not merge; it will be closed and its branch deleted once the WebUI installed artifact job finishes.

On top of the PR #2119 head, the Activity gate step runs activity_gate_host.py precheck under one busy loop per CPU (must refuse naming host load), again without the load (must pass), then starts the real verifier and SIGKILLs it once the activity script and browser are running, and fails the step. The Reap Activity gate processes step must then stop everything, and a final probe step checks that nvidia-smi --query-compute-apps and pgrep -af mlxcel-server-webui are both empty.

The WebUI Activity gate leaked its server when the verifier died or its cleanup gave up, and the leak failed every later run of the job at the GPU precondition, which printed only a count. The gate also scored while another compile ran on the runner and reported degradations inside its own noise.

- scripts/webui/activity_gate_host.py precheck runs first in the gate body: it stops a process an earlier run leaked (executable in the installed-artifact directory or working in a verifier run directory, and orphaned or with its directory deleted), waits up to 600 s for the mean runnable-task count from /proc/loadavg to fall to a quarter of the CPUs, then fails closed naming each remaining GPU compute process. It writes the host state it saw for the evidence.
- activity_gate_host.py reap runs as an always() step after the gate: it stops what the verifier's pid file names, checking start times so a reused pid is never signalled, plus anything else of the job's identity, and fails the job if anything survives.
- verify_activity_performance.py records every owned process in --pid-file, embeds --host-state into the full evidence with an after-activity load sample, and terminate_owned no longer raises from its SIGKILL wait and now stops group members a quickly exiting leader left behind.
- Tests for both failure paths in terminate_owned (each fails on the previous code), the host helper with real processes, and summary compatibility of the new evidence field.

Closes #1949
Review follow-ups for the Activity gate host guards.

- Processes with a controlling terminal are never signalled, and a process matched only by its working directory or HOME is signalled alone, never with its group, so a developer's shell sitting in a run directory cannot take its editor or pager down with it.
- The browser Playwright launches leads a process group of its own; it, node and the server now match by HOME=<run directory>/home. The verifier records the node activity script in the pid file and starts Xvfb and openbox in the run directory.
- Signals go through a pidfd checked against the recorded start time; a reused pid ends the recorded group instead of being signalled. Pid-file records carry the boot id, and an unreadable file or record no longer stops the identity sweep (it still fails the step).
- GPU processes that are not the job's are named without executable or directory paths, and host snapshots list only compiler names and pids, since the logs and artifacts are public.
- The precheck checks the GPU before and after the quiet wait, records host snapshots at start and end, and writes the host state atomically. nvidia-smi timeouts are refusals.
- The after-activity load sample is taken before the output is validated, so a noisy verdict keeps it; terminate_owned records a PermissionError instead of raising it.
- Job timeout 90 to 120 minutes to fit two cold builds plus the 75 minute gate step; the reap step skips when the checkout never happened.
Throwaway: the Activity gate step runs the precheck under synthetic CPU load (must refuse), then without it (must pass), then SIGKILLs the verifier mid-activity and fails, so the always() reap step has to clean up; a final step checks no GPU process or server is left.
@inureyes inureyes closed this Oct 5, 2026
@inureyes
inureyes deleted the ci-probe/issue-1949-runner-evidence branch October 5, 2026 23:33
inureyes added a commit that referenced this pull request Oct 5, 2026
…2119)

## Summary

The `WebUI installed artifact` job's Activity performance gate had two environmental faults on the GB10 runner (#1949). It leaked its server when the verifier was killed or its cleanup gave up, and the leaked server then failed every later run at the GPU precondition, which printed only a count (on 2026-10-05, five consecutive runs of PR #2117 after `main` 680f64e failed in scoring). It also scored while other work ran on the host and reported degradations inside its own noise. This PR closes both in the job itself.

## Changes

- **`scripts/webui/activity_gate_host.py precheck`** replaces the bare `nvidia-smi` count as the first command of the gate body (after the CI flock and `gpu-lock`):
  - A process carries the job's identity when its executable is in `$RUNNER_TEMP/mlxcel-webui-installed/`, or its working directory or `HOME` is a verifier run directory (`$RUNNER_TEMP/mlxcel-activity-performance-*`). The verifier gives the server, node and the browser `HOME=<run dir>/home`; Playwright launches the browser `detached`, in a process group of its own, so `HOME` is what reaches it.
  - Stops a process of that identity an earlier run leaked: orphaned (PPID 1), or with its directory or executable reading `(deleted)` or its run directory gone. A live process of that identity, or a leak owned by another uid, fails closed instead.
  - Fails closed if any GPU compute process remains, before the quiet wait (so a conflict is reported at once) and again after it, naming each with pid, process name, memory, parent and uid. Executable and directory paths are printed only for the job's own processes, since logs and artifacts are public.
  - Waits up to 600 s until the mean runnable-task count from `/proc/loadavg` over 10 one-second samples is at most a quarter of the CPUs (5 on GB10), and fails closed with a host snapshot otherwise. Load averages and `ps %cpu` lag a fresh compile, so neither is used, and the window must fill before the gate can refuse.
  - Writes the observed host state (snapshots at start and end with load averages and compiler pids, quiet-wait samples, anything reaped, any refusal) to `webui-activity-host-state.json`, uploaded with the diagnostics.
- **`activity_gate_host.py reap`**, a new `if: always()` step after the gate: stops the process groups the verifier's pid file names and anything else of the job's identity, prints what it found, and fails the job if anything survives or the pid file is unreadable (the identity sweep still runs). A missing pid file is a clean no-op.
- **Signalling safety:** processes with a controlling terminal (a developer's shell on the runner) are never touched; a process matched only by directory or `HOME` is signalled alone, never with its group; signals go through a pidfd checked against the recorded start time, so a reused pid is never signalled; pid-file records carry the boot id.
- **`verify_activity_performance.py`**:
  - `--pid-file` records every owned process (Xvfb, openbox, the server, the node activity script) outside the run directory as it starts; Xvfb and openbox now run in the run directory.
  - `--host-state` embeds the precheck's state into the full evidence as `host_state.gate_start`, plus a `host_state.after_activity` load sample taken before the output is validated, so a noisy verdict keeps it. The summary does not carry it and `summarize_activity_evidence.py` is unchanged.
  - `terminate_owned` no longer raises out of its SIGKILL wait or on a `PermissionError`, and it stops group members a quickly exiting leader left behind instead of only recording `process_group_empty: false`.
- Step timeout 65 to 75 minutes for the quiet wait, job timeout 90 to 120 for two cold builds plus that step; docs in `docs/webui-integration-matrix.md`; the new tests join `make verify-webui-helper-tests` and the job's helper test step.

The server spawns no child processes (model workers are in-process threads), so its process group is the whole server. The verdict rule and thresholds are untouched (#1925).

## Changes during review

The security review found that a directory-only match could SIGKILL a developer's shell and its whole group, that node and the browser had no reap handle, and that paths of unrelated GPU processes would reach public logs. All three are fixed above, together with pidfd signalling, tolerant pid-file parsing, the GPU check before the quiet wait, and the after-activity sample on the failure path from the implementation review.

## Verification

- `make verify-webui-helper-tests`: all suites pass (18 host-helper tests, 21 verifier tests, 10 summary tests). The two `terminate_owned` tests fail on the previous code: one raises `subprocess.TimeoutExpired` from the SIGKILL wait, the other ends with the group still populated. `actionlint` 1.7.7 is clean.
- **Runner, `lablup-dgxspark21` (machine spark-101):**
  - Run [37387059748](https://github.com/lablup/mlxcel/actions/runs/37387059748) (first head): the precheck found the real leaked server from the earlier failed run, pid 1453937 with executable and cwd both `(deleted)` and PPID 1, stopped it with SIGTERM, and the gate then passed. This is the leak that failed PR #2117's five runs.
  - Run [37388347876](https://github.com/lablup/mlxcel/actions/runs/37388347876) (final head 634444a): green. Host quiet at mean 1.4 runnable tasks (threshold 5), no GPU process, `server_shutdown` `exit_code 0`, `forced false`, `process_group_empty true`, full evidence carries `host_state.gate_start` and `after_activity`, and reap found nothing to do.
  - Run [37388422039](https://github.com/lablup/mlxcel/actions/runs/37388422039), job 112027483381 (throwaway probe PR #2120 on top of the final head, closed): under one busy loop per CPU the precheck refused with `host did not become quiet within 60s: mean runnable tasks 23.8 over the last 10 samples, threshold 5`; with the load removed it passed at 1.1. The verifier was then SIGKILLed mid-activity while the server held 4604 MiB, and the always() reap stopped Xvfb, openbox, the server, node and the browser (the last by `HOME`); the following check found `nvidia-smi --query-compute-apps` and `pgrep -af mlxcel-server-webui` both empty.
- **GB10 simulation on spark-102** (real `mlxcel-server` serving qwen3-0.6b-4bit, under `gpu-lock`): a leaked server (PPID 1, deleted run directory, 4116 MiB) was named and stopped; a foreign GPU process was refused at once, named without its path, and left running; a busy host (another session's compile) was refused after the wait; a server left by a SIGKILLed verifier was reaped by pid file.

Closes #1949
@inureyes inureyes added priority:low Low priority status:done Completed type:chore Maintenance tasks (build, CI, etc.) labels Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:low Low priority status:done Completed type:chore Maintenance tasks (build, CI, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant