Skip to content

Treat an unreadable accelerator as active, and measure Neuron, Gaudi and AMD (#954) - #986

Merged
scttfrdmn merged 4 commits into
mainfrom
fix/954
Oct 17, 2026
Merged

scttfrdmn merged 4 commits into
mainfrom
fix/954

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #954. Stacked on #977 (fix/948) → #969 → #960 → #955 → #936. The base is fix/948, so the diff shows only #954.

What was wrong

getGPUUtilization returned 0, which the idle check reads as a measured "GPU idle", in three cases:

  • nvidia-smi is present but failing: driver/kernel mismatch, "No devices were found", or a GPU that has fallen off the bus.
  • Every output line is [N/A] or [Not Supported].
  • nvidia-smi is absent, which is correct only when there is no NVIDIA GPU.

Trainium/Inferentia, Gaudi and AMD accelerators were never checked, so a device-bound job with little host CPU could be idle-stopped.

What changed (pkg/agent/accel.go, untagged)

  • gpuUtilization() (pct, measured, why) uses the same semantics as cpuUsage/networkBytes/diskIOBytes. Unknown means assume active, with one warning per accelerator family saying idle-stop will not trigger. A busy device decides "active" even next to an unreadable one. Otherwise any unreadable device makes the reading unknown. No accelerator at all is a measured 0. idleDecision logs Not idle: accelerator utilization could not be measured (<why>); assuming active.
  • Presence is decided by structure, not by whether the tool is on PATH. A Deep Learning AMI ships nvidia-smi on GPU-less instances, where it can only fail, so keying on the tool would disable idle-stop there.
    • GPUs and Gaudi are found from /sys/bus/pci/devices/*/{vendor,class}: NVIDIA 0x10de and AMD 0x1002 in a display class (0x03xxxx), and Habana 0x1da3.
    • Neuron is found from /dev/neuronN. The Annapurna PCI vendor 0x1d0f is also used by ENA and the EBS NVMe controller, and the fixture includes both.
    • On Windows (no /sys), the presence of nvidia-smi means NVIDIA.
  • Measurement, where only a successful parse of real numbers can read as idle:
    • nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits
    • hl-smi -Q utilization.aip -f csv,noheader,nounits (a % suffix is tolerated)
    • rocm-smi --showuse --json (card* → "GPU use (%)")
    • neuron-monitor: the first streamed JSON report, after which the process is killed. The value is the max of neuron_runtime_data[].report.neuroncore_counters.neuroncores_in_use.*.neuroncore_utilization. An empty neuron_runtime_data is a measured idle, because NeuronCores are only usable through a runtime and neuron-monitor reports every runtime. A missing list, a runtime/counter error, or a missing utilisation is unknown.
    • A device whose tool is not installed is unknown (<family> device present but <tool> is not installed).
  • I removed three monitoring_test.go GPU tests. They re-implemented the parsing inline and asserted it, including "Empty output" → 0.0, which was the bug (rule 5).

Tests (pkg/agent/accel_test.go)

Detection fixtures cover a plain instance (ENA, EBS NVMe, an AMD EPYC host bridge, Nitro VGA), g4dn T4, g4ad V520, dl1 Gaudi, trn1 /dev/neuron0, neuron/neuronx names that are not device nodes, and an NVIDIA audio function. There are parser tables for all four tools. The other tests are:

  • a failing tool is unknown and warned once over 3 calls;
  • a device without its tool is unknown, for each family;
  • the combination rules;
  • idleDecision stays not idle when nvidia-smi fails;
  • a real streaming fake neuron-monitor on PATH returns its first line and is killed.

I checked the /sys/bus/pci/devices vendor/class format in an AL2023 container (0x1af4 0x020000).

Revert checks. Each revert compiled, and the test ran and failed:

revert failing tests
unparseable/empty lines skipped (the old parse) ParsePercentLines (4 cases), ParseRocmSmiJSON, ParseNeuronMonitor
tool failure → measured 0 (the old behaviour) FailingToolIsUnknownAndWarnedOnce, IdleDecision_UnmeasurableAcceleratorIsNotIdle
missing tool → measured 0 DeviceWithoutToolIsUnknown
warn on every call FailingToolIsUnknownAndWarnedOnce
any PCI class counts DetectAccelerators_ByStructure/NVIDIA audio function is not a GPU

go test -race ./pkg/agent passes, and the whole pkg/agent suite passes on Linux (an arm64 test binary run in AL2023). make check passes except for the known Docker-only test, and make check-nested passes (9/9). Every test run used the credential-stripping environment from #968.

Caveats (read these before the demo)

  • None of the vendor tool formats was captured from real hardware. No AWS launches were allowed. They come from the tools' documented output. A wrong guess fails safe: an unparseable or unexpected format is unknown, which keeps the instance running and logs one warning, not idle. The cost of a wrong guess is that idle-stop does not fire on that instance family until the parser is fixed.
  • The parser most likely to need adjusting is the Neuron one, specifically the empty-runtime-list rule and the neuroncore_counters path. It should be checked on a trn1/inf2 before relying on idle-stop there. Gaudi hl-smi -Q utilization.aip and rocm-smi --showuse --json should be checked the same way.
  • neuron-monitor prints its first report after one period, 5 s by default, so on Neuron hosts the tick takes about 5 s longer. The tool runs only when every earlier idle check has passed.
  • amd-smi (the successor to rocm-smi) is not used. With only amd-smi installed, an AMD GPU is unknown.
  • An NVIDIA GPU with no driver loaded is unknown (nvidia-smi fails), so idle-stop does not fire there. That errs towards active, and is warned once.
  • The Prometheus GetGPUStats is still NVIDIA-only and unchanged.

…and AMD (#954)

getGPUUtilization returned 0, a measured "GPU idle", when nvidia-smi was
present but failed, and when every line was [N/A]/[Not Supported]. Neuron,
Gaudi and AMD accelerators were never looked at.

- accel.go (untagged, tested everywhere): gpuUtilization returns
  (pct, measured, why) like the counters. Unknown is assumed active and
  warned once per accelerator family. A busy device decides "active" even
  beside an unreadable one; otherwise any unreadable one is unknown. No
  accelerator is a measured 0.
- Presence is structural, not "is the tool on PATH": GPUs and Gaudi by PCI
  vendor (0x10de/0x1002 in a display class, 0x1da3) from
  /sys/bus/pci/devices, Neuron by /dev/neuronN (Annapurna's PCI vendor is
  also ENA's and EBS NVMe's). A DLAMI on a GPU-less instance has
  nvidia-smi but no GPU, and keying on the tool would make it unknown for
  ever. Windows: nvidia-smi present means NVIDIA (no /sys there).
- Measurement: nvidia-smi and hl-smi CSV, rocm-smi --showuse --json,
  neuron-monitor's first streamed report (killed after one line). Only a
  successful parse of real numbers can read as idle; an empty
  neuron_runtime_data list is a measured idle (cores are only usable through
  a runtime, and neuron-monitor reports every runtime).
- Removed three monitoring_test.go GPU tests that re-implemented the
  parsing inline and asserted it, including "Empty output -> 0".

(#954)
@codecov

ghost commented Oct 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.95349% with 19 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/agent/accel.go 89.15% 11 Missing and 7 partials ⚠️
pkg/agent/agent.go 75.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 72b5d4e into main Oct 17, 2026
@scttfrdmn
scttfrdmn deleted the fix/954 branch October 17, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Idle GPU check: nvidia-smi failure reads as 0% (idle), and Neuron/Gaudi/AMD accelerators are never measured

1 participant