Repository navigation
fix(ck-tile): Prefer using amd-smi over rocm-smi - #9731
Merged
Merged
Conversation
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🎉 All checks passed! This PR is ready for review. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR centralizes Composable Kernel tile-engine GPU SMI interactions behind Python wrappers that prefer amd-smi and fall back to rocm-smi, and updates Python/Bash call sites to use the unified interface.
Changes:
- Introduces
smi_utils.pywrappers +smi_cli.pyCLI to standardize GPU discovery/info acrossamd-smi/rocm-smi. - Updates existing Python and shell tooling to call the wrappers (via
ck_smi_*Bash delegates) instead of invokingrocm-smidirectly. - Adds live (GPU-host) Python unittest coverage and a pure-bash comparison script to validate normalized fields between tools.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/composablekernel/tile_engine/ops/gemm/gemm_full_benchmark.py | Switches device detection to shared detect_gpu_ids() wrapper. |
| projects/composablekernel/tile_engine/ops/common/smi_utils.py | Adds centralized SMI parsing + wrapper functions with amd-smi-first fallback behavior. |
| projects/composablekernel/tile_engine/ops/common/smi_cli.py | Adds argparse-based CLI for reuse from shell scripts. |
| projects/composablekernel/tile_engine/ops/common/test_smi_utils.py | Adds live GPU-host unit tests comparing normalized fields and wrapper behavior. |
| projects/composablekernel/test_data/generate_test_dataset.sh | Replaces direct rocm-smi usage with ck_smi_* helpers and improves GPU checks/messages. |
| projects/composablekernel/script/tools/test_ck_smi_helpers.sh | Adds a pure-bash live equivalence test for rocm-smi vs amd-smi fields. |
| projects/composablekernel/script/tools/common.sh | Adds ck_smi_* helper functions and container GPU-info helper. |
| projects/composablekernel/script/tools/ck-status | Uses container GPU-info helper instead of hardcoded rocm-smi call. |
| projects/composablekernel/script/tools/ck-start | Uses container GPU-info helper instead of hardcoded rocm-smi call. |
| projects/composablekernel/script/tools/ck-shell | Updates help text example to use SMI wrapper helper. |
| projects/composablekernel/script/tools/ck-rocprof.md | Updates documentation to reference new SMI wrapper tooling. |
| projects/composablekernel/script/tools/ck-exec | Updates help text to reference SMI wrapper helper. |
| projects/composablekernel/script/tools/ck-docker | Uses container GPU-info helper instead of hardcoded rocm-smi call. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
andriy-ca
approved these changes
Jul 27, 2026
assistant-librarian Bot
pushed a commit
to ROCm/composable_kernel
that referenced
this pull request
Jul 27, 2026
fix(ck-tile): Prefer using amd-smi over rocm-smi ## Motivation CK tooling invokes `rocm-smi` directly in many places for GPU discovery and info. `amd-smi` is the modern replacement and is preferred going forward, but call sites should not need to know which tool is present. This PR centralizes GPU SMI access behind a single set of wrappers that prefer `amd-smi` and transparently fall back to `rocm-smi`, so every call site gets consistent behavior with no duplicated detection logic. ## Technical Details - Added `tile_engine/ops/common/smi_utils.py` as the single source of truth for SMI access: parsers for both tools plus wrappers `detect_gpu_ids()`, `count_gpus()`, `show_gpu_info()`, `check_gpu_available()`, and `show_version()`. - Tool order is chosen by `_smi_order()`: `amd-smi` first, `rocm-smi` fallback if `amd-smi` is missing or fails. `CK_SMI_TOOL=rocm-smi` forces rocm-smi first (mainly for testing). - Added `tile_engine/ops/common/smi_cli.py`, an argparse CLI (`list-ids`, `count`, `show-info`, `check`, `show-version`) so shell scripts can reuse the same Python logic. - Added thin `ck_smi_*` delegates in `script/tools/common.sh` that call `smi_cli.py` (no parsing logic in Bash). - Migrated call sites off direct `rocm-smi`: `gemm_full_benchmark.py` now uses `detect_gpu_ids()`; `generate_test_dataset.sh`, `ck-status`, `ck-start`, `ck-docker`, `ck-exec`, `ck-shell`, `ck-rocprof.md`, and the GEMM `README.md` now use the wrappers. ## Test Plan - `python3 -m unittest tile_engine.ops.common.test_smi_utils -v` live tests comparing `rocm-smi` vs `amd-smi` normalized fields (GPU IDs, product, gfx, driver) and verifying each wrapper against live output. - `CK_SMI_TOOL=rocm-smi python3 -m unittest tile_engine.ops.common.test_smi_utils -v` verifies the rocm-smi override path. - `bash script/tools/test_ck_smi_helpers.sh` pure-bash live comparison of the two tools' fields (no Python dependency). - Ran on a GPU host. ## Test Result All 11 unittest cases pass; the bash comparison reports all fields matching. Both the default (amd-smi first) and `CK_SMI_TOOL=rocm-smi` paths return identical GPU IDs. ## Submission Checklist - [x] Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests. JIRA ID : AICK-1649
1 task done
ozturkosu
added a commit
that referenced
this pull request
Jul 30, 2026
detect_devices() in batched_gemm_full_benchmark.py called `rocm-smi --showid` directly for GPU id detection. Delegate to smi_utils.detect_gpu_ids() (added in #9731), which prefers amd-smi and falls back to rocm-smi, matching gemm_full_benchmark.py. Added common/ to sys.path, dropped unused `import re`. JIRA ID : ROCM-28734
geyyer
pushed a commit
that referenced
this pull request
Aug 4, 2026
…marks (#10204) ## Motivation PR #9731 centralized GPU SMI access behind `tile_engine/ops/common/smi_utils.py`, which prefers `amd-smi` and transparently falls back to `rocm-smi`, and migrated `gemm_full_benchmark.py` off direct `rocm-smi` calls. Three Tile Engine benchmark scripts were left calling `rocm-smi --showid` directly (with an `amd-smi list` fallback), so the migration is incomplete. Although wrapped in try/except today, these direct calls will break once `rocm-smi` is removed from future ROCm releases. This completes the migration for the remaining scripts, as requested by the tech lead and tracked in JIRA **ROCM-28734**. ## Technical Details Migrated the identical hand-rolled `detect_devices()` (env → `rocm-smi --showid` → `amd-smi list` → hardcoded `["0"]`) to a single `smi_utils.detect_gpu_ids()` call, mirroring the already-landed `gemm_full_benchmark.py`: - `tile_engine/ops/gemm/block_scale_gemm/gemm_bquant/gemm_bquant_full_benchmark.py` - `tile_engine/ops/gemm/gemm_multi_d_full_benchmark.py` - `tile_engine/ops/gemm/streamk_gemm_full_benchmark.py` Each script adds `common/` to `sys.path`, imports `detect_gpu_ids`, and drops the now-unused `import re`. Net -67 lines. ## Test Plan / Result Validated on an MI350 (gfx950) host, exercising the exact `sys.path` arithmetic + `smi_utils` import + `detect_gpu_ids()` for both the shallow (`gemm/`) and deep (`block_scale_gemm/gemm_bquant/`) script locations: - Default (amd-smi first): `detect_devices()` returns the live GPU ids; `count_gpus()`/`check_gpu_available()` consistent. - `CK_SMI_TOOL=rocm-smi` (forced fallback): identical result. Both `python3 -m py_compile` cleanly. ## Submission Checklist - [x] Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests. https://amd-hub.atlassian.net/jira/software/c/projects/AICK/boards/4399?selectedIssue=ROCM-28734 JIRA ID : ROCM-28734 Co-authored-by: Muhammed Emin Ozturk <3836908+ozturkosu@users.noreply.github.com>
3 tasks done
ozturkosu
added a commit
that referenced
this pull request
Aug 11, 2026
## Summary Extends the amd-smi-first migration (#9731, #10204) from the Tile Engine to the dispatcher's GPU-architecture detection. - Adds `detect_gpu_arch()` to the shared `tile_engine/ops/common/smi_utils.py` wrapper: amd-smi `static` (`TARGET_GRAPHICS_VERSION`) first, rocm-smi `--showproductname` (`GFX Version`) fallback — same amd-smi-first policy as the rest of the wrapper. - `dispatcher_common.detect_gpu_arch()`: prefers amd-smi via the wrapper, then rocminfo, then the caller-supplied default. Also removes a **duplicate** definition of this function. - `gemm_utils._get_arch()`: tries amd-smi via the wrapper before rocminfo, preserving the raise-on-unresolved (no silent default) behavior. ## Motivation Per the directive behind #9731, device-property access should prefer `amd-smi` (rocm-smi is being phased out). The Tile Engine was already migrated (#9731, #10204); the dispatcher still detected the GPU arch by shelling out to `rocminfo` directly. Tracked in JIRA **ROCM-28734**. ## Design note The dispatcher reaches the sibling `tile_engine/ops/common/smi_utils.py` through a guarded import and falls back to `rocminfo` if the wrapper is unavailable, so behavior is unchanged on hosts without amd-smi. (Open to moving the shared wrapper to a neutral location if reviewers prefer avoiding the dispatcher → tile_engine reach.) ## Test plan (MI350X / gfx950) - [x] New mock-based unit tests for `detect_gpu_arch()` (amd-smi preference, rocm-smi fallback, default) + a live check — 4/4 pass. - [x] `dispatcher_common.detect_gpu_arch()` and `gemm_utils._get_arch()` both return `gfx950` via amd-smi on the live host. - [x] `test_gemm_utils` 21/21 still pass (no arch-detection regression). --------- Co-authored-by: Muhammed Emin Ozturk <3836908+ozturkosu@users.noreply.github.com>
shumway
pushed a commit
to ROCm/composable_kernel
that referenced
this pull request
Aug 18, 2026
fix(ck-tile): Prefer using amd-smi over rocm-smi ## Motivation CK tooling invokes `rocm-smi` directly in many places for GPU discovery and info. `amd-smi` is the modern replacement and is preferred going forward, but call sites should not need to know which tool is present. This PR centralizes GPU SMI access behind a single set of wrappers that prefer `amd-smi` and transparently fall back to `rocm-smi`, so every call site gets consistent behavior with no duplicated detection logic. ## Technical Details - Added `tile_engine/ops/common/smi_utils.py` as the single source of truth for SMI access: parsers for both tools plus wrappers `detect_gpu_ids()`, `count_gpus()`, `show_gpu_info()`, `check_gpu_available()`, and `show_version()`. - Tool order is chosen by `_smi_order()`: `amd-smi` first, `rocm-smi` fallback if `amd-smi` is missing or fails. `CK_SMI_TOOL=rocm-smi` forces rocm-smi first (mainly for testing). - Added `tile_engine/ops/common/smi_cli.py`, an argparse CLI (`list-ids`, `count`, `show-info`, `check`, `show-version`) so shell scripts can reuse the same Python logic. - Added thin `ck_smi_*` delegates in `script/tools/common.sh` that call `smi_cli.py` (no parsing logic in Bash). - Migrated call sites off direct `rocm-smi`: `gemm_full_benchmark.py` now uses `detect_gpu_ids()`; `generate_test_dataset.sh`, `ck-status`, `ck-start`, `ck-docker`, `ck-exec`, `ck-shell`, `ck-rocprof.md`, and the GEMM `README.md` now use the wrappers. ## Test Plan - `python3 -m unittest tile_engine.ops.common.test_smi_utils -v` live tests comparing `rocm-smi` vs `amd-smi` normalized fields (GPU IDs, product, gfx, driver) and verifying each wrapper against live output. - `CK_SMI_TOOL=rocm-smi python3 -m unittest tile_engine.ops.common.test_smi_utils -v` verifies the rocm-smi override path. - `bash script/tools/test_ck_smi_helpers.sh` pure-bash live comparison of the two tools' fields (no Python dependency). - Ran on a GPU host. ## Test Result All 11 unittest cases pass; the bash comparison reports all fields matching. Both the default (amd-smi first) and `CK_SMI_TOOL=rocm-smi` paths return identical GPU IDs. ## Submission Checklist - [x] Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests. JIRA ID : AICK-1649 --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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
CK tooling invokes
rocm-smidirectly in many places for GPU discovery and info.amd-smiis the modern replacement and is preferred going forward, but call sites should not need to know which tool is present. This PR centralizes GPU SMI access behind a single set of wrappers that preferamd-smiand transparently fall back torocm-smi, so every call site gets consistent behavior with no duplicated detection logic.Technical Details
tile_engine/ops/common/smi_utils.pyas the single source of truth for SMI access: parsers for both tools plus wrappersdetect_gpu_ids(),count_gpus(),show_gpu_info(),check_gpu_available(), andshow_version()._smi_order():amd-smifirst,rocm-smifallback ifamd-smiis missing or fails.CK_SMI_TOOL=rocm-smiforces rocm-smi first (mainly for testing).tile_engine/ops/common/smi_cli.py, an argparse CLI (list-ids,count,show-info,check,show-version) so shell scripts can reuse the same Python logic.ck_smi_*delegates inscript/tools/common.shthat callsmi_cli.py(no parsing logic in Bash).rocm-smi:gemm_full_benchmark.pynow usesdetect_gpu_ids();generate_test_dataset.sh,ck-status,ck-start,ck-docker,ck-exec,ck-shell,ck-rocprof.md, and the GEMMREADME.mdnow use the wrappers.Test Plan
python3 -m unittest tile_engine.ops.common.test_smi_utils -vlive tests comparingrocm-smivsamd-sminormalized fields (GPU IDs, product, gfx, driver) and verifying each wrapper against live output.CK_SMI_TOOL=rocm-smi python3 -m unittest tile_engine.ops.common.test_smi_utils -vverifies the rocm-smi override path.bash script/tools/test_ck_smi_helpers.shpure-bash live comparison of the two tools' fields (no Python dependency).Test Result
All 11 unittest cases pass; the bash comparison reports all fields matching. Both the default (amd-smi first) and
CK_SMI_TOOL=rocm-smipaths return identical GPU IDs.Submission Checklist
JIRA ID : AICK-1649