Skip to content

feat(amdsmi): add metric --usage-fields and keep partial usage - #12600

Open
koushikbillakanti-amd wants to merge 4 commits into
developfrom
users/kbillaka/ROCM-31813-usage
Open

koushikbillakanti-amd wants to merge 4 commits into
developfrom
users/kbillaka/ROCM-31813-usage

Conversation

@koushikbillakanti-amd

@koushikbillakanti-amd koushikbillakanti-amd commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

amd-smi metric --usage always prints every usage field, and if one data source fails, the whole section turns into N/A, even when other sources have good readings. This PR lets users pick the fields they want and keeps the readings that work.

Technical Details

  • New amd-smi metric --usage-fields FIELD[,...] prints only the named usage fields, in order, for human, JSON, and CSV output. A named field always shows up, as N/A if it isn't available.
  • Each usage source is now read on its own, so one failure no longer hides the others. usage is always a set of fields, even when every source fails.
  • amd-smi metric --watch --file now keeps the last sample for GPU, NIC, and switch, including on Ctrl-C. A watch stopped before its first sample leaves an existing file alone.
  • CSV columns are written in a stable order.
  • CLI only. No library, bindings, or ABI changes. Docs and CHANGELOG are updated.

About the ticket's N/A fields: on the R9700 (metrics table v1.3), UMC, MM, and VCN activity read fine. JPEG activity, GFX busy, and JPEG busy aren't in that table, so they stay N/A until the driver exposes a newer one.

Left for a follow-up: amd-smi monitor watch files still drop the last sample.

JIRA ID

JIRA ID: ROCM-31813

Test Plan

  • Python unit tests, pre-commit, and a Python 3.6 syntax check.
  • Ran develop and this branch side by side on real GPUs with the same library, covering all output formats, --file, watch runs, and bad input.

Test Result

  • 358 unit tests pass, and every fix has a test that fails without it.
  • End-to-end checks pass on a local Radeon + APU and on MI350 with the final code. On MI350, watch files keep 16 of 16 samples (develop keeps 8). R9700 and an RDNA4 GPU with no usage data passed on an earlier revision.
  • NIC and switch watch paths are covered by unit tests; none of the test systems have Broadcom NIC support enabled.
  • CI is green except ASAN unit tests (and the bot check that reports it), which fails on develop with the same 16 C++ tests. This PR has no C++ changes.

Submission Checklist

@koushikbillakanti-amd
koushikbillakanti-amd requested a review from a team September 30, 2026 23:54
@github-actions github-actions Bot added documentation Improvements or additions to documentation project: amdsmi labels Sep 30, 2026
@therock-pr-bot

Copy link
Copy Markdown

✅ All Policy Checks Passed

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ✅ Pass —
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —

🎉 All policy checks passed!

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@koushikbillakanti-amd
koushikbillakanti-amd force-pushed the users/kbillaka/ROCM-31813-usage branch 2 times, most recently from ba17b79 to caa56ee Compare October 8, 2026 15:48
Signed-off-by: Koushik Billakanti <kbillaka@amd.com>
@koushikbillakanti-amd
koushikbillakanti-amd force-pushed the users/kbillaka/ROCM-31813-usage branch from e61a161 to 50a9c34 Compare October 8, 2026 21:56
@koushikbillakanti-amd koushikbillakanti-amd changed the title fix(amdsmi): select and preserve usage fields feat(amdsmi): add metric --usage-fields and keep partial usage Oct 8, 2026
@dmitrii-galantsev

Copy link
Copy Markdown
Contributor

🤖 claude: Merged develop at 839470366c into this branch (202743bc52b1).
Only CHANGELOG.md conflicted; retained develop's text and moved this PR's five entries into the 10.2.0 Added, Changed and Resolved Issues sections.
Built with BUILD_TESTS=ON; the installed unit.gpu.test_cli_metric_usage suite runs 60 tests successfully, with one skip.

Koushik Billakanti added 2 commits October 19, 2026 12:05
Signed-off-by: Koushik Billakanti <kbillaka@amd.com>
Signed-off-by: Koushik Billakanti <kbillaka@amd.com>
)
engine_usage["gfx_busy_inst"] = new_xcp_dict
engine_usage.update(amdsmi_interface.amdsmi_get_gpu_activity(args.gpu))
except amdsmi_exception.AmdSmiLibraryException as error:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this now catches only AmdSmiLibraryException, an AmdSmiParameterException from a bad handle (a sibling class, not a subclass) would escape and abort the whole metric run — losing power/clock/temp readings too, not just usage. Same pattern repeats at the amdsmi_get_vcn_busy_percent call below (~line 563). Worth widening the catch here, or fixing it once in amdsmi_cli.py's top-level handler so every call site in the file benefits.

values_dict["usage"] = {
key: "N/A"
if usage_fields and value in ({}, [])
else self._format_usage_value(value)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usage_fields and guard means an empty vcn_activity renders as [] under plain --usage but as N/A under --usage-fields vcn_activity — same underlying data, different output depending which flag was used. Might be worth dropping the usage_fields and so both paths treat an empty container as N/A consistently.

writer.writerows(rows)

def _print_dual_csv_output(self, multiple_device_enabled=False, watching_output=False):
if multiple_device_enabled:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_print_dual_csv_output (used by amd-smi monitor --process --csv, not the standalone process subcommand) still builds its header from a set, so column order here is hash-seed dependent — the same instability _print_csv_output just got fixed for above. The PR description says "CSV columns are written in a stable order," but that's only true for the metric path.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation organization: ROCm project: amdsmi

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants