Skip to content

fix: ROCm GPU enumeration - #1039

Merged
ndizazzo merged 4 commits into
mainfrom
codex/issue-651-rocm-gpu-enumeration
Jul 22, 2026
Merged

fix: ROCm GPU enumeration#1039
ndizazzo merged 4 commits into
mainfrom
codex/issue-651-rocm-gpu-enumeration

Conversation

@ndizazzo

@ndizazzo ndizazzo commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • read ROCm architecture evidence from Linux KFD topology sysfs without invoking or parsing rocminfo
  • use that evidence only to select the compatible native runtime; Skippy backend ABI remains authoritative for device identity, ordering, memory, and selectability
  • preserve fallback adapter labels without synthesizing GPU inventory or backend ordinals
  • treat numbered ROCmN and HIPN selectors as aliases while preserving the exact runtime-emitted backend identifier in discovery and CLI output
  • add regression coverage for KFD gfx target conversion, runtime selection without inventory synthesis, multi-adapter discovery, and mesh-llm gpus output

Root cause

ROCm adapters could be present but lack the gfx architecture evidence required before the native runtime is loaded. Native-runtime resolution then rejected the ROCm artifact, loaded a CPU runtime, and the authoritative embedded backend reported no selectable GPUs.

The bootstrap probe now reads gfx_target_version from /sys/class/kfd/kfd/topology/nodes. It does not create advertised GPU records. Once the ROCm runtime is loaded, the same in-process Skippy backend enumeration used by other backends supplies the actual devices. llama.cpp currently emits numbered ROCmN identifiers for HIP builds; mesh-llm accepts equivalent HIPN selectors for compatibility but does not rename the backend-reported device.

Validation

  • cargo test -p mesh-llm-hardware-profile --lib
  • cargo test -p mesh-llm-system --features skippy-devices --lib
  • cargo test -p mesh-llm-commands --lib gpus::tests::
  • cargo test -p mesh-llm-commands --lib gpu_tune_accepts_hip_alias_for_rocm_backend_device
  • cargo check -p mesh-llm-system -p mesh-llm-commands -p mesh-llm
  • cargo clippy -p mesh-llm-system -p mesh-llm-commands -p mesh-llm --all-targets -- -D warnings
  • just test-all

Fixes #651

Summary by CodeRabbit

  • New Features

    • Added Linux ROCm GFX-architecture discovery from KFD topology sysfs to seed GPU profile detection.
    • GPU profile detection now merges ROCm architecture evidence from environment input, discovered arches, and per-GPU overrides.
  • Bug Fixes

    • Improved human-readable GPU listing to render consistent output as a single formatted string, including correct multi-GPU blocks and preserved identifiers.
    • Backend device resolution now treats ROCm and HIP aliases as equivalent for matching and selection; GPU tuning honors HIP aliases for ROCm backends.
  • Tests

    • Added/updated unit tests covering ROCm architecture evidence, multi-GPU rendering output, ROCm+HIP GPU facts, and HIP alias acceptance.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: dfabb1ee-e14e-463c-ba6c-b39b5f4cfbc2

📥 Commits

Reviewing files that changed from the base of the PR and between ddadefa and 4a724f3.

📒 Files selected for processing (7)
  • crates/mesh-llm-commands/src/gpus.rs
  • crates/mesh-llm-commands/src/gpus/tune_hardware/evaluate.rs
  • crates/mesh-llm-commands/src/gpus/tune_hardware/tests/selection.rs
  • crates/mesh-llm-hardware-profile/src/lib.rs
  • crates/mesh-llm-hardware-profile/src/rocm.rs
  • crates/mesh-llm-system/src/backend.rs
  • crates/mesh-llm-system/src/hardware/skippy_devices.rs
🚧 Files skipped from review as they are similar to previous changes (6)
  • crates/mesh-llm-system/src/hardware/skippy_devices.rs
  • crates/mesh-llm-hardware-profile/src/rocm.rs
  • crates/mesh-llm-system/src/backend.rs
  • crates/mesh-llm-commands/src/gpus.rs
  • crates/mesh-llm-commands/src/gpus/tune_hardware/tests/selection.rs
  • crates/mesh-llm-hardware-profile/src/lib.rs

📝 Walkthrough

Walkthrough

ROCm architecture detection now reads validated GFX evidence from KFD topology data, incorporates it into profile detection, removes rocminfo label synthesis, formats human-readable GPU output through reusable string helpers, and matches ROCm/HIP device aliases during selection.

Changes

GPU detection and selection

Layer / File(s) Summary
ROCm architecture detection
crates/mesh-llm-hardware-profile/src/rocm.rs, crates/mesh-llm-hardware-profile/src/lib.rs
Discovers validated GFX architectures from KFD topology nodes, merges them with existing ROCm evidence, removes rocminfo label synthesis, and adds detection tests.
GPU command formatting
crates/mesh-llm-commands/src/gpus.rs
Replaces direct printing with format_gpus and format_gpu, preserving optional GPU fields and testing multiple ROCm GPU blocks.
Backend alias resolution
crates/mesh-llm-system/src/backend.rs, crates/mesh-llm-commands/src/gpus/tune_hardware/evaluate.rs, crates/mesh-llm-commands/src/gpus/tune_hardware/tests/selection.rs, crates/mesh-llm-system/src/hardware/skippy_devices.rs
Adds case-insensitive ROCm/HIP ordinal matching, uses it for device selection, and validates ROCm and HIP GPU facts.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant run_gpus
  participant detect_rocm_profile
  participant rocm_gpu_arches
  participant KFDTopology
  participant format_gpus

  User->>run_gpus: run gpus command
  run_gpus->>detect_rocm_profile: detect hardware profile
  detect_rocm_profile->>rocm_gpu_arches: collect GFX architectures
  rocm_gpu_arches->>KFDTopology: read KFD topology
  KFDTopology-->>rocm_gpu_arches: validated architecture evidence
  rocm_gpu_arches-->>detect_rocm_profile: architecture set
  detect_rocm_profile-->>run_gpus: hardware survey
  run_gpus->>format_gpus: format GPU survey
  format_gpus-->>User: human-readable GPU blocks
Loading

Suggested reviewers: michaelneale

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and directly describes the main change: fixing ROCm GPU enumeration.
Linked Issues check ✅ Passed The changes address #651 by improving ROCm GPU detection and backend-device discovery for command-line enumeration and pinning.
Out of Scope Changes check ✅ Passed The added backend alias matching, ROCm arch detection, and test updates all support the stated ROCm enumeration fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/issue-651-rocm-gpu-enumeration

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request is currently a draft. Reviews will not take place until the PR is marked as ready for review.

@ndizazzo
ndizazzo marked this pull request as ready for review July 21, 2026 18:09
@github-actions
github-actions Bot requested a review from michaelneale July 21, 2026 18:09

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/mesh-llm-hardware-profile/src/lib.rs`:
- Around line 78-80: Update the ROCm/fallback reconciliation around rocm_gpus
and fallback_gpus so it removes only fallback adapters proven to duplicate a
detected ROCm device, using parsed PCI identity or equivalent per-device
matching. Retain unmatched AMD/Radeon/Instinct fallback entries, and add a
regression test covering a host with a detected MI300X plus a separate
fallback-only Radeon adapter.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 46b5eaa6-7a33-4f6c-8eb2-05c0c1e75255

📥 Commits

Reviewing files that changed from the base of the PR and between a6c7ddb and d9e92b6.

📒 Files selected for processing (3)
  • crates/mesh-llm-commands/src/gpus.rs
  • crates/mesh-llm-hardware-profile/src/lib.rs
  • crates/mesh-llm-hardware-profile/src/rocm.rs

Comment thread crates/mesh-llm-hardware-profile/src/lib.rs Outdated
@ndizazzo ndizazzo changed the title Fix ROCm GPU enumeration fix: ROCm GPU enumeration Jul 21, 2026
@ndizazzo
ndizazzo force-pushed the codex/issue-651-rocm-gpu-enumeration branch from ddadefa to 4a724f3 Compare July 22, 2026 00:07
@ndizazzo
ndizazzo merged commit 24915ec into main Jul 22, 2026
22 checks passed
@ndizazzo
ndizazzo deleted the codex/issue-651-rocm-gpu-enumeration branch July 22, 2026 01:21
michaelneale added a commit that referenced this pull request Jul 22, 2026
…ngram

* origin/main:
  Add GLM DSA correctness trace reporting (#1033)
  Add GLM DSA package contract validation (#1032)
  Add direct quant layer package tooling (#1031)
  Lock split topology placement (#1050)
  fix nightly stability Qwen thinking
  ui(data-mode): migrate legacy harness storage to v2 (#1040)
  fix: Windows Vulkan runtime dependencies (#1046)
  test: validate MI300 runtime selection and placement (#1045)
  fix: support ROCm RDNA APU kernels safely (#1044)
  fix: ROCm GPU enumeration (#1039)
  Document public packaging installation channels
  Fix Windows autoupdate import (#1030)
  Update llama.cpp upstream pin
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.

GPUs do not enumerate using mesh-llm gpus for ROCm

1 participant