-
Notifications
You must be signed in to change notification settings - Fork 249
[AMD][AgentX] benchmark_lib: add wait_for_amd_gpu_clean GPU-drain gate #2490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,6 +163,30 @@ | |
| GPU_MONITOR_PID="" | ||
| } | ||
|
|
||
| # Block until the GPUs have released a prior job's memory before starting a run. | ||
| # Polls rocm-smi VRAM% every 10s for up to 15 minutes; succeeds once the busiest | ||
| # GPU is at <=10% VRAM, otherwise returns 1 so the caller aborts rather than | ||
| # starting a benchmark on GPUs still draining the previous run's memory. | ||
| wait_for_amd_gpu_clean() { | ||
| local gpu_clean=false vram_max i | ||
| for i in $(seq 1 90); do | ||
| vram_max=$(rocm-smi --showmemuse 2>/dev/null \ | ||
| | grep -oE "GPU Memory Allocated \(VRAM%\): [0-9]+" \ | ||
| | awk '{if ($NF > m) m = $NF} END {print m+0}') | ||
| if [ "${vram_max:-0}" -le 10 ]; then | ||
| echo "GPUs clean (vram%max=$vram_max after $((i * 10))s)" | ||
| gpu_clean=true | ||
| break | ||
|
Check warning on line 179 in benchmarks/benchmark_lib.sh
|
||
| fi | ||
| echo "waiting for prior-job GPU memory reclaim: vram%max=$vram_max" | ||
| sleep 10 | ||
| done | ||
| if [ "$gpu_clean" != "true" ]; then | ||
| echo "Error: GPUs still draining prior job's memory after 15min" >&2 | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
|
Check warning on line 189 in benchmarks/benchmark_lib.sh
|
||
|
Comment on lines
+166
to
+189
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π‘ wait_for_amd_gpu_clean (benchmarks/benchmark_lib.sh:166-189) treats "no VRAM data" the same as "0% VRAM": if rocm-smi is missing, errors out, or its output format doesn't match the fixed regex, grep returns zero matches and the awk pipeline still prints Extended reasoning...
vram_max=$(rocm-smi --showmemuse 2>/dev/null \
| grep -oE "GPU Memory Allocated \(VRAM%\): [0-9]+" \
| awk '{if ($NF > m) m = $NF} END {print m+0}')The This means the "no data" case and the "genuinely 0% VRAM, GPU is clean" case are indistinguishable to the caller. Three realistic conditions collapse grep's output to zero matches:
In any of these cases, Step-by-step proof:
Why existing code doesn't prevent it: there's no check on Suggested fix: distinguish "no data" from "actually 0%", e.g. check Severity: this is being filed as a nit rather than blocking. The happy path (a correctly provisioned AMD host with a |
||
| # Return success only while a PID exists and is not a zombie waiting to be | ||
| # reaped. `kill -0` alone treats zombies as live processes. | ||
| _background_process_is_running() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π‘ The success log in wait_for_amd_gpu_clean() uses$((i * 10)) for elapsed seconds, but the VRAM check runs before the sleep, so it's overstated by one 10s poll interval (e.g. printing "after 10s" when GPUs were already clean at 0s). Purely cosmetic β use $ (((i - 1) * 10)) instead.
Extended reasoning...
The bug: In
wait_for_amd_gpu_clean()(benchmarks/benchmark_lib.sh:167-190), the loop body checks the VRAM usage first, then only sleeps 10s at the bottom if the check fails. The success-path log line, however, computes elapsed time as$((i * 10)), which implicitly assumes a sleep has already happened for every completed iteration including the current one.Code path:
By the time iteration
iruns its VRAM check, exactlyi - 1sleeps have elapsed (zero sleeps before the first check, one sleep before the second check, and so on). So the true wait time at success is(i - 1) * 10seconds, noti * 10.Concrete proof:
Why nothing catches this: The function has no test coverage (it's new in this PR), and the value is only used in an informational
echoβ it isn't captured, compared, or asserted on anywhere, so nothing would fail even though the message is wrong.Impact: This is purely a misleading log/telemetry value. The gate's actual behavior β waiting for VRAM to drop and returning 0 on success / 1 on timeout β is unaffected; only the human-readable timestamp in the success message is wrong. Anyone reading benchmark logs to gauge how long GPU-drain waits actually took would see numbers consistently 10s too high, which is a minor but avoidable inaccuracy in operational logs used for tuning timeouts.
Fix: Change the success log to
echo \"GPUs clean (vram%max=$vram_max after $(((i - 1) * 10))s)\"so it reflects the number of completed sleeps rather than the loop counter.