Repository navigation
ROCMAI-214: extract GPU/device-policy parsing and VRAM usage warnings into gpu_policy.rs - #750
Draft
jussielo-amd wants to merge 2 commits into
Draft
jussielo-amd wants to merge 2 commits into
jussielo-amd wants to merge 2 commits into
Conversation
8 tasks done
There was a problem hiding this comment.
🟡 Changes recommended
Unconditional filesystem and path imports become unused on Windows non-test targets, causing warnings-as-errors checks to fail.
1 open issue
What changed in this PR
Continues the main.rs modularization by moving GPU policy parsing, selection, and VRAM warnings into a dedicated module, with no intended behavior change.
Changes:
- Relocates GPU helpers and 33 tests into
gpu_policy.rs. - Updates caller imports and the command-message allowlist.
- Documents the new module and corrects comments about helper ownership.
Verification used the supplied diffs; the repository snapshot was unavailable, so builds and tests were not run.
| File | Description |
|---|---|
docs/architecture.md |
Documents GPU module responsibilities and callers. |
apps/rocm/src/serve_cmd.rs |
Updates GPU imports and ownership comments. |
apps/rocm/src/main.rs |
Removes relocated helpers and tests; imports the new module. |
apps/rocm/src/gpu_policy.rs |
Houses GPU parsing, selection, telemetry, warnings, and tests. |
apps/rocm/src/engine_ipc.rs |
Imports device-policy parsing from its new location. |
apps/rocm/src/advised_commands.rs |
Updates the error-message allowlist path. |
Review effort: Balanced
Comment on lines
+64
to
+65
| use std::fs; | ||
| use std::path::Path; |
…into engine_ipc.rs Signed-off-by: Jussi Elo <jussi.elo@amd.com>
… into gpu_policy.rs Signed-off-by: Jussi Elo <jussi.elo@amd.com>
jussielo-amd
force-pushed
the
rocmai-214-gpu-policy
branch
from
October 28, 2026 08:28
6ba9e65 to
f469b97
Compare
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.

Summary
Phase 6f-7 of the
main.rsmodularization (epic ROCMAI-27). Mechanical relocation, no behavior change: moves GPU/device-policy parsing and VRAM usage warning logic out ofapps/rocm/src/main.rsinto a newapps/rocm/src/gpu_policy.rs.parse_device_policy/parse_gpu_selection/parse_gpu_indices_arg,select_gpu_indices_under_launch_lock,validate_pinned_gpu_index,effective_gpu_count,auto_select_gpu_indices/select_auto_gpu_index,gpu_vram_usageand its platform-gatedgpu_vram_usage_sysfsvariants (moved intact, cfg-gates unchanged — no platform-support change),read_drm_vram_usage/read_sysfs_u64/drm_device_is_amd,parse_gpu_vram_usage,gpu_low_memory_warning/vram_capacity_is_meaningful/serve_gpu_low_memory_warning,busy_gpu_indices,detect_gpu_count, plusstruct GpuVramUsageandAUTO_FREE_VRAM_FRACTION, interleaved but part of the same cluster.main.rs" by two earlier PRs in this same stack (ROCMAI-213: extract engine plugin binary resolution and IPC envelope into engine_ipc.rs #749'sengine_ipc.rs, andserve_cmd.rs's pre-existing doc comment) — both corrected in this PR along with their imports, since those items are part of this ticket.main.rsfixed:engine_ipc.rs,serve_cmd.rs.advised_commands.rs's file-path allowlist for a CPU-fallback error string had to be updated to point at the new file.dispatch()'sCommand::EngineServeHttparm callsparse_gpu_indices_argdirectly — body confirmed byte-identical (independently re-verified by SHA-256), only the import changed.vram(),host_gpu()) duplicated intomain.rs's test module where a test that stays behind also needs them — documented inline. Total workspace test count unchanged.docs/architecture.mdupdated with this module's entry.Test plan
cargo build --workspacecargo build --workspace --all-targets --features e2e-test-hookscargo clippy --workspace --all-targets -- -D warningscargo fmt --all -- --checkcargo xtask check-crate-edgescargo test --workspace --no-fail-fast— 4322 passed, 0 failed, 17 ignored (independently re-run, matches baseline exactly; two unrelated pre-existing timing flakes observed and confirmed to pass in isolation —therock::tests::wait_with_output_bounded_waits_unbounded_when_no_timeout_is_givenandcli_progress::tests::animated_spinner_keeps_ticking_without_progress_calls, neither in a file this PR touches)cargo xtask manifest --checkpython scripts/smoke_local.py --profile debug --skip-builddispatch()call sites confirmed byte-identical (SHA-256 of the function body)x86_64-pc-windows-gnuis not installed in this environment; skipped and flagged rather than silently omitted. Platform-gated code (gpu_vram_usage_sysfs's twocfgvariants) moved with its cfg-gates textually unchanged, not reauthored.Depends on #749 (ROCMAI-213) — fourth PR in the ROCMAI-86 (Phase 6f) stack.
Part of Jira ROCMAI-214 / epic ROCMAI-27.
🤖 Generated with Claude Code