Repository navigation
Conversation
✅ All Policy Checks Passed
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
Library (rocm_smi, amd_smi.cc, amdsmi.h): - Report a driver-rejected write (EPERM) as AMDSMI_STATUS_NO_PERM instead of NOT_SUPPORTED; WriteSysfsStr() dropped the errno - Treat a UINT64_MAX platform max as unavailable in the setter and restore the previous number parsing for existing NPM readers - Move the setter checks into validate_npm_board_limit() so they run in unit tests without root - Validate node handles against the handle registry itself and replace the BUILD_TESTS-only pointer hook with an unguarded amdsmi_test_get_node_handle(), like amdsmi_test_sleep() - Pin sizeof(amdsmi_npm_info_t) to 64 and correct the doxygen return codes for amdsmi_get_npm_info() and amdsmi_set_npm_limit() CLI (set_value.py, amdsmi_helpers.py, amdsmi_parser.py, node.py): - Record NOT_SUPPORTED and library errors so a failed set -n exits non-zero - Raise AmdSmiInvalidParameterException for -n with -g instead of calling sys.exit(2) - Use static -n help text and drop the hardware probe at parser build - Emit the CSV node column only for node -p Python API (amdsmi_interface.py): - Reject bool limits and fix the node_handle type hints and docstrings Tests and docs: - Add root-free validate_npm_board_limit() tests and use mkdtemp for temp board directories - Move the amdsmi_get_power_info() null check to the power read test - Remove __future__ imports (Python 3.6) and stale test comments - Update CHANGELOG, Python API reference, and CLI docs Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
marifamd
force-pushed
the
users/marifamd/npm-power-limit-followup
branch
from
October 13, 2026 17:33
a2455d2 to
4b873b7
Compare
bill-shuzhou-liu
approved these changes
Oct 13, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Follow-up to #11471. It fixes the failure reporting, test-hook, and doc issues found in review after that PR merged.
Technical Details
Library (
rocm_smi/src/rocm_smi_npm.cc,rocm_smi/src/rocm_smi.cc,src/amd_smi/amd_smi.cc):EPERM(non-permitted guest) now returnsAMDSMI_STATUS_NO_PERM. Before,WriteSysfsStr()reported it asNOT_SUPPORTEDamdsmi_set_npm_limit()treats aUINT64_MAXplatform max as unavailable (AMDSMI_STATUS_UNEXPECTED_DATA) instead of an unlimited boundvalidate_npm_board_limit()so unit tests cover them without rootBUILD_TESTS-only pointer hook and its CMake defines are replaced byamdsmi_test_get_node_handle(), which works likeamdsmi_test_sleep()static_assert(sizeof(amdsmi_npm_info_t) == 64)Header / docs (
include/amd_smi/amdsmi.h,rocm_smi/include/rocm_smi/rocm_smi.h):amdsmi_get_npm_info()/amdsmi_set_npm_limit()return codes; shortened the doxygenrsmi_npm_info_t.reservedcomment (it wasreserved[5], and two fields were added)CLI (
set_value.py,amdsmi_helpers.py,amdsmi_parser.py,node.py):amd-smi set -nnow exits non-zero (recordsNOT_SUPPORTEDand library errors)-nwith-graisesAmdSmiInvalidParameterExceptioninstead ofsys.exit(2)-nhelp text is static. The parser no longer probes hardware to print the maxnodeCSV column is emitted only foramd-smi node -pPython API (
py-interface/amdsmi_interface.py):amdsmi_set_npm_limit()rejectsboollimits; fixed thenode_handletype hints and docstringsTests:
validate_npm_board_limit()tests; temp board directories usemkdtempamdsmi_get_power_info()null check into the functional power read testfrom __future__ import annotations(Python 3.6) and stale comments from the NPM testsDocs:
CHANGELOG.md,docs/reference/amdsmi-py-api.md,docs/how-to/amdsmi-cli-tool.mdNot changed here (need the spec owner):
Issue Tracking
JIRA ID: ROCM-31980
Test Plan
-DBUILD_TESTS=ON(Ubuntu 22.04, non-NPM GPU, non-root)amdsmitst --gtest_filter='GpuUnit*:*TestPowerRead*'python3 -m unittest discover -s unitfromtests/python, run against the build's Python packageclang-format,ruff format/ruff check,gersemi,check_test_conventions.py, license headersTest Result
SetNpmLimitRoot*, NPM hardware, read-write power test), 0 failedtest_runner_hygieneSubmission Checklist