AMD ROCm Readiness & Verification in HyperGAN
HyperGAN has experimental, hardware-untested readiness for AMD ROCm GPUs that does not regress NVIDIA CUDA or CPU execution. This document covers current support status, host requirements, execution of the automated preflight qualification script (scripts/rocm_preflight.sh), an overview of the collected preflight report metrics, the complete 38-row codebase audit for NVIDIA assumptions, and 10 open hardware questions mapped to preflight report sections.
1. Current ROCm Support Status in HyperGAN#
Status: experimental, untested on AMD hardware. No HyperGAN run has executed on an AMD GPU yet; the components below are covered only by CPU tests that patch torch.cuda. Running scripts/rocm_preflight.sh (section 3) on a real host is the first hardware check.
HyperGAN targets AMD ROCm architectures via PyTorch's HIP abstraction layer (device = "cuda"), backed by hardware-independent readiness components landed in exp/rocm-readiness:
-
GPU Inventory Provider Abstraction (
src/hypergan/gpu_inventory.py):- Behind
hypergan.queue.inspect_gpu_hardware()andhypergan.queue.inspect_gpu_processes(), a unified provider interface dynamically selects betweenNvidiaSmiProvider,AmdSmiProvider(amd-smi static/metric/process --json), and fallbackRocmSmiProvider(rocm-smi --json). - Normalizes hardware records (
index,name,uuid/serial,memory_total,memory_free,memory_used,utilization) and process records (gpu_uuid,pid,process_name,used_memory,cmdline). - Emits exactly one
WARNINGlog across the process lifecycle if no GPU management tool is found, gracefully degrading rather than throwing unhandled exceptions.
- Behind
-
ROCm Runtime Identity & Checkpoint Metadata Parity (
src/hypergan/training.py,src/hypergan/distributed_checkpoints.py):- Captures
torch.version.hipand GPU architectureproperties.gcnArchName(e.g.gfx1100,gfx90a,gfx942) in runtime info only when running on ROCm (torch.version.hip is not None). - Strict Backward Compatibility: Leaves existing NVIDIA and CPU metadata byte-identical, preserving cryptographic config hashes and checkpoint compatibility guarantees.
- Missing or non-standard device properties (such as consumer GPU UUIDs) gracefully degrade to
'unavailable'.
- Captures
-
Checkpoint Compatibility Hardware Tolerance (
src/hypergan/checkpoint_compatibility.py):- Adds
'cuda.gcnArchName'toHARDWARE_TOLERANCE_KEYSand tolerance matching rules. - Resuming ROCm checkpoints across different AMD GPU models (or across architectures) issues structured
HyperGANHardwareWarningevents without halting execution (Decision D9).
- Adds
-
ROCm Determinism Error Guards & BLAS Workspace Gating (
src/hypergan/numerical_policy.py):CUBLAS_WORKSPACE_CONFIGvalidation and warning checks are gated to execute only whentorch.version.hip is None. On ROCm, whererocBLAShandles matrix operations,CUBLAS_WORKSPACE_CONFIGenforcement is a clean no-op.- When non-deterministic operations trigger PyTorch
RuntimeErrorundertorch.use_deterministic_algorithms(True), HyperGAN enriches the exception with the failing ATen operation and instructions to relax determinism viatraining.backend.deterministic_algorithms = false.
-
Device Ordering Documentation (
src/hypergan/execution.py):- Preserves NVIDIA
CUDA_DEVICE_ORDER=PCI_BUS_IDbehavior without modification, while documenting AMD ROCm ordering considerations and providing side-by-side device index mapping in preflight tooling.
- Preserves NVIDIA
2. Prerequisites & Host Requirements#
Before executing HyperGAN on AMD ROCm hardware, ensure the host system satisfies driver, device node, and permission requirements.
2.1 Kernel Modules & Device Nodes#
/dev/kfd(Kernel Fusion Driver): The AMD KFD character device node is mandatory for user-space HSA compute dispatch.- Verification:
test -e /dev/kfd - If missing: install the AMD kernel driver (e.g.
amdgpu-dkms) and load the module viasudo modprobe amdgpu.
- Verification:
/dev/dri(Direct Rendering Infrastructure): DRM render nodes (e.g./dev/dri/renderD128) must exist and be accessible.
2.2 User Group Permissions#
The user account running HyperGAN or the preflight script must belong to the render group (and video group on certain Linux distributions):
sudo usermod -a -G render,video $USERAfter adding groups, log out and back in or launch a new shell with newgrp render.
2.3 Supported AMD GPU Architectures#
Official PyTorch ROCm wheels target the following GFX architectures:
- RDNA 3:
gfx1100(AMD Radeon RX 7900 XTX / 7900 XT / PRO W7900),gfx1101(RX 7800 XT),gfx1102(RX 7700 XT) - CDNA 3:
gfx942(AMD Instinct MI300X, MI300A) - CDNA 2:
gfx90a(AMD Instinct MI250X, MI250, MI210) - CDNA 1:
gfx908(AMD Instinct MI100)
Note on RDNA 3 Consumer GPUs: For consumer RDNA3 cards (e.g. RX 7900 XTX) running ROCm, export HSA_OVERRIDE_GFX_VERSION=11.0.0 if the driver does not natively recognize the PCI revision ID.
2.4 Python Interpreter Compatibility#
Official PyTorch ROCm wheels on download.pytorch.org/whl/rocm6.2 are prebuilt for:
- Python 3.9, 3.10, 3.11, and 3.12 (
cp39throughcp312). - Python 3.14 does not currently host official prebuilt ROCm wheels on PyTorch's index.
3. Running scripts/rocm_preflight.sh#
HyperGAN ships an idempotent, automated preflight script (scripts/rocm_preflight.sh) that runs top-to-bottom on a fresh single-GPU AMD Linux host or container.
3.1 Basic Usage#
# Full preflight run (creates .venv-rocm, runs reference suite, single-GPU tests/cuda tests, and training)
./scripts/rocm_preflight.sh
# Quick smoke mode (smoke reference tests and 10 training steps)
./scripts/rocm_preflight.sh --quick
# Custom output directory and existing venv
./scripts/rocm_preflight.sh --output-dir /tmp/rocm_eval --skip-install3.2 CLI Arguments#
| Flag | Description | Default |
|---|---|---|
--output-dir DIR |
Output directory for rocm_preflight_report.md and raw CLI logs |
rocm_preflight_output |
--venv DIR |
Path to virtual environment to create or activate | .venv-rocm |
--skip-install |
Skip venv creation and wheel installation (use active Python environment) | false |
--quick |
Quick execution mode: runs fast smoke tests and 10 training steps | false |
--help, -h |
Display help message and exit | - |
3.3 Environment Variables#
| Variable | Description | Default |
|---|---|---|
TORCH_ROCM_WHEEL_URL |
PyTorch ROCm wheel index repository URL | https://download.pytorch.org/whl/rocm6.2 |
TORCH_VERSION |
PyTorch package version string | 2.5.1+rocm6.2 |
TORCHVISION_VERSION |
Torchvision package version string | 0.20.1+rocm6.2 |
HSA_OVERRIDE_GFX_VERSION |
AMD HSA GFX architecture override (e.g. 11.0.0 for RX 7900 XTX) |
Unset |
3.4 Expected Runtime#
- Quick Mode (
--quick): ~15–30 seconds. - Full Mode: ~2–4 minutes (depending on CPU speed for
tests/referenceand compilation of first-run MIOpen kernels).
4. Preflight Output Overview (9 Sections)#
The preflight tool generates rocm_preflight_report.md inside --output-dir containing 9 comprehensive sections:
- Section 1: Environment Checks:
- Host OS, Linux kernel release, architecture.
/dev/kfdHSA character device presence and read/write accessibility./dev/driDRM render nodes and user group memberships (render,video).- Detected GPU GFX architecture and available SMI management tool (
amd-smivsrocm-smi).
- Section 2: Venv Setup & Wheel Installation:
- Virtualenv directory, Python version.
- Installed PyTorch ROCm wheel (
torch==2.5.1+rocm6.2) andtorchvision. - HyperGAN editable installation with optional extras (
[train,image,cifar,fid,test]).
- Section 3: Sanity Check:
- Query results for
torch.version.hip, device count, device name, andgcnArchName. - Forward and backward matrix multiplication (
matmul) numerical parity vs CPU reference. - Forward and backward 2D convolution (
conv2d) numerical parity vs CPU reference. - Maximum absolute error metrics compared against tolerance (
rtol=1e-3, atol=1e-3).
- Query results for
- Section 4: Device-Order Table:
- Side-by-side comparison table: PyTorch index (
cuda:0,cuda:1) → Name, UUID vs driver SMI index → Name, Serial, PCI Bus ID (BDF). - Alignment verification resolving whether device enumeration preserves PCIe bus order.
- Side-by-side comparison table: PyTorch index (
- Section 5: CPU Reference Suite:
- Execution results of
pytest tests/referenceverifying baseline stability inside the ROCm environment. - Passed, failed, skipped counts and execution duration.
- Execution results of
- Section 6: Single-GPU
tests/cudaExecution:- Partitioning of the collected
tests/cudatests by themulti_gpupytest marker (seepyproject.toml):- Single-GPU tests (no
multi_gpumarker): executed directly against the target AMD GPU, recording per-test outcome and failure tracebacks. - Multi-GPU tests (marked
multi_gpu): cataloged explicitly in the report asdeferred: needs >=2 GPUs.
- Single-GPU tests (no
- The counts come from collection at run time;
pytest tests/cuda --collect-only -q -m multi_gpulists the deferred set.
- Partitioning of the collected
- Section 7: Short Real Training Run:
- Real training execution of the
gaussian-gridrecipe oncuda:0(50 steps, or 10 on quick mode). - Measures step throughput (
steps/sec), peak allocated VRAM (MB), execution duration, and final loss metrics. - Single seed, metrics-only (no image rendering).
- Real training execution of the
- Section 8: GPU Inventory Provider Validation:
- Live execution of
hypergan.queue.inspect_gpu_hardware()andinspect_gpu_processes(). - Dumps both raw CLI tool output (
amd-smi/rocm-smi) and normalized JSON records into the report.
- Live execution of
- Section 9: Failure Classification & Summary:
- Automatic classification of every error across all steps into 5 canonical categories:
crash|numerical tolerance|determinism error|tooling|unknown. - Overall qualification verdict for the AMD host.
- Automatic classification of every error across all steps into 5 canonical categories:
5. Summary of Codebase Audit for NVIDIA Assumptions#
The Phase 1 audit investigated all occurrences of NVIDIA-specific assumptions and CUDA symbols across src/, scripts/, and tests/. Below is the complete 38-row audit table:
| Location | Assumption | Behavior on ROCm | Fix in this PR or Deferred to Hardware |
|---|---|---|---|
src/hypergan/queue.py:95-123 |
Queries nvidia-smi CLI via CSV output to inspect GPU inventory, name, UUID, VRAM, and utilization |
degrades |
Fix in this PR (Phase 2A) |
src/hypergan/queue.py:126-161 |
Queries nvidia-smi --query-compute-apps to inspect active GPU compute processes |
degrades |
Fix in this PR (Phase 2A) |
src/hypergan/queue.py:183-214 |
Matches target devices and active processes against NVIDIA GPU UUIDs (GPU-...) |
breaks |
Fix in this PR (Phase 2A) |
src/hypergan/inspection.py:1469-1508 |
Enriches active runs in ps with live VRAM and device index via nvidia-smi process table |
degrades |
Fix in this PR (Phase 2A) |
src/hypergan/workspace.py:245-254 |
Runs nvidia-smi --query-gpu=index via subprocess when torch is not loaded to resolve auto device selection |
breaks |
Fix in this PR (Phase 2A) |
src/hypergan/execution.py:175, 194 |
Sets os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" to enforce bus-order device indexing |
unknown |
Fix in this PR (Phase 2C comments / documented) |
src/hypergan/execution.py:176, 190, 195 |
Sets CUDA_VISIBLE_DEVICES to select physical GPU or isolate to CPU |
works |
Fix in this PR (documented) |
src/hypergan/snapshot_renderer.py:13 |
Sets os.environ['CUDA_VISIBLE_DEVICES'] = '' to force preview renderer to run on CPU |
works |
Fix in this PR |
src/hypergan/metric_plugins.py:153 |
Sets os.environ['CUDA_VISIBLE_DEVICES'] = '' to force observation workers to run on CPU |
works |
Fix in this PR |
src/hypergan/provenance.py:100 |
Records CUDA_VISIBLE_DEVICES and CUDA_DEVICE_ORDER in attempt launch provenance metadata |
works |
Fix in this PR |
src/hypergan/numerical_policy.py:13-20 |
Requires CUBLAS_WORKSPACE_CONFIG (:4096:8 or :16:8) before CUDA init for deterministic execution |
breaks |
Fix in this PR (Phase 2D no-op on ROCm) |
src/hypergan/numerical_policy.py:22 |
Assumes all operators have deterministic kernels under torch.use_deterministic_algorithms(True) |
breaks |
Fix in this PR (Phase 2D enriched error) |
src/hypergan/config.py:565-567 |
Validates training.backend.cublas_workspace_config values in experiment configs |
works |
Fix in this PR |
src/hypergan/numerical_policy.py:26-27, 41-42 |
Reads and writes torch.backends.cuda.matmul.allow_tf32 and torch.backends.cudnn.allow_tf32 |
works |
Deferred to hardware |
src/hypergan/image_metrics.py:96-100, 113-114 |
Toggles TF32 flags off during Inception-v3 FID evaluation | works |
Deferred to hardware |
src/hypergan/training.py:116 |
Records result['cuda']['version'] = torch.version.cuda and cuDNN version; omits HIP version |
degrades |
Fix in this PR (Phase 2B) |
src/hypergan/training.py:117 |
Assumes torch.cuda.get_device_capability() returns CUDA major/minor compute capability |
degrades |
Fix in this PR (Phase 2B) |
src/hypergan/training.py:118-119 |
Reads properties.uuid with fallback to 'unavailable' |
degrades |
Fix in this PR (Phase 2B) |
src/hypergan/distributed_checkpoints.py:74 |
Calls torch.cuda.nccl.version() to record NCCL version in distributed runtime metadata |
unknown |
Fix in this PR (Phase 2B getattr fallback) |
src/hypergan/distributed_checkpoints.py:77-80 |
Records per-rank device metadata with CUDA capability, name, UUID, omitting gcnArchName and hip |
degrades |
Fix in this PR (Phase 2B) |
src/hypergan/checkpoint_compatibility.py:34-45 |
HARDWARE_TOLERANCE_KEYS validates saved vs current runtime keys during checkpoint resume |
breaks |
Fix in this PR (Phase 2B added cuda.gcnArchName) |
src/hypergan/distributed_training.py:250 |
Fused device-side nonfinite gradient check via torch._amp_foreach_non_finite_check_and_unscale_ |
unknown |
Deferred to hardware |
src/hypergan/cpu_worker_service.py:165-167 |
Validates backend == 'nccl' with message referencing available NVIDIA GPUs |
works |
Fix in this PR (modernized error message) |
src/hypergan/distributed.py:21-27 |
Restricts distributed backends to gloo (CPU) and nccl (CUDA/ROCm) |
works |
Deferred to hardware |
src/hypergan/execution_profiles.py:12, 91 |
Uses execution profile name cuda-replicated-nccl for multi-GPU replicated training |
works |
Deferred to hardware |
src/hypergan/cli.py:891-902 |
hypergan doctor reads torch.version.cuda and omits torch.version.hip |
degrades |
Fix in this PR |
src/hypergan/cli.py:736-742 |
Formats console banner device string as (CUDA {dev_idx}: {prop.name}) |
degrades |
Fix in this PR |
src/hypergan/recipes.py:77 |
Raises error recommending to check the NVIDIA driver when CUDA is unavailable |
degrades |
Fix in this PR |
scripts/metrics_training_proof.py:207-209, 275 |
Probes GPU stats via nvidia-smi and reads torch.version.cuda |
degrades |
Deferred to hardware |
scripts/benchmark_particlegan_cifar.py:82-84 |
Sets deterministic_algorithms=True without cublas_workspace_config |
breaks |
Fix in this PR |
scripts/start-cifar-tiny-transformer-resnet-features-pg07-lr2e-4-demo.sh:26 |
Exports hardcoded NVIDIA device UUID GPU-ed080e41-3193-3755-6756-f3d46c433331 |
breaks |
Deferred to hardware |
tests/cuda/nccl_smoke.py:107, 111, 208-210 |
Directly accesses properties.uuid without getattr; reads torch.version.cuda; executes nvidia-smi and topo -m |
breaks |
Deferred to hardware |
tests/cuda/test_metric_scalar_transfer.py:20-27 |
Profiler key averages assert string match on 'cudaStreamSynchronize' and 'cudaLaunchKernel' |
unknown |
Deferred to hardware |
tests/cuda/test_hndl_images.py:4, 18 |
Sets CUBLAS_WORKSPACE_CONFIG and torch.use_deterministic_algorithms(True) |
breaks |
Fix in this PR |
tests/cuda/test_interval_evaluation.py:16-17 |
Sets deterministic_algorithms = true on cuda without cublas_workspace_config |
breaks |
Fix in this PR |
tests/cuda/test_native_cuda.py |
Runs single-GPU training, updates, model parameter devices, and exact RNG restoration | works |
Deferred to hardware |
tests/cuda/test_trainer_host_syncs.py |
Single-GPU qualification of fused nonfinite check and EMA lerp/copy | unknown |
Deferred to hardware |
tests/cuda/ multi-GPU tests (marked multi_gpu) |
Assumes >= 2 CUDA GPUs with NCCL collectives | unknown |
Deferred to hardware |
6. 10 Open Questions Requiring AMD Hardware Mapped to Preflight Sections#
The following 10 open questions cannot be resolved without physical AMD hardware and live ROCm drivers. Each question is mapped directly to the preflight report section that will answer it:
- Host Environment, Kernel Driver & Device Node Accessibility:
- Question: Are the ROCm kernel modules (
amdgpu,amdkfd) loaded, does/dev/kfdexist with user read/write permissions (video/rendergroup), and what is the exact hardware GFX architecture (gfx1100,gfx90a,gfx942)? - Mapped Preflight Section: Section 1: Environment Checks
- Question: Are the ROCm kernel modules (
- PyTorch ROCm Wheel Version & Compatibility:
- Question: Does the target PyTorch ROCm wheel (
torch==2.5.1+rocm6.2fromhttps://download.pytorch.org/whl/rocm6.2) install cleanly alongside matchingtorchvision==0.20.1+rocm6.2, and do HyperGAN dependencies install without binary symbol collisions? - Mapped Preflight Section: Section 2: Venv Setup & Wheel Install
- Question: Does the target PyTorch ROCm wheel (
- HIP Runtime Identity & Core Tensor Kernels:
- Question: What exact values are returned by
torch.version.hip,torch.cuda.get_device_name(0), andproperties.gcnArchName? Do standard FP32matmulandconv2dforward/backward passes oncuda:0match CPU reference tensors within numerical tolerance (1e-3)? - Mapped Preflight Section: Section 3: Sanity Check
- Question: What exact values are returned by
- Device Ordering & Bus ID Alignment:
- Question: Does PyTorch's default device enumeration index (
cuda:0,cuda:1) match the PCIe bus ID order reported byamd-smi/rocm-smi? Does settingCUDA_DEVICE_ORDER=PCI_BUS_IDalter or preserve this order on ROCm? - Mapped Preflight Section: Section 4: Device-Order Table
- Question: Does PyTorch's default device enumeration index (
- CPU Reference Suite Stability in HIP/ROCm Environment:
- Question: Does
pytest tests/referencepass with 100% success inside the ROCm environment without triggering unexpected GPU driver initialization or library symbol collisions? - Mapped Preflight Section: Section 5: CPU Reference Suite
- Question: Does
- Single-GPU CUDA Test Execution & Profiler Activity Events:
- Question: Do the single-GPU tests in
tests/cuda(those without themulti_gpumarker) pass without modification on the AMD GPU? Specifically, does the PyTorch Kineto profiler intest_metric_scalar_transfer.pyreport'cudaStreamSynchronize'or'hipStreamSynchronize'? - Mapped Preflight Section: Section 6: Single-GPU
tests/cudaExecution
- Question: Do the single-GPU tests in
- Multi-GPU / RCCL Collective Support & Deferral:
- Question: On a single-GPU AMD box, does the preflight runner cleanly identify and defer every test marked
multi_gpuasdeferred: needs >=2 GPUs? When >= 2 AMD GPUs are present, doesbackend='nccl'(RCCL) successfully initialize process groups and reduce gradients? - Mapped Preflight Section: Section 6: Single-GPU
tests/cudaExecution (deferral partition) and Section 9: Failure Classification
- Question: On a single-GPU AMD box, does the preflight runner cleanly identify and defer every test marked
- Live Training Dynamics, Step Throughput, and Peak VRAM:
- Question: When executing a short training run of
gaussian-gridoncuda:0for 50 steps, what is the sustained throughput (steps/s), peak allocated VRAM (MB), and final loss value? Does training proceed without numerical divergence? - Mapped Preflight Section: Section 7: Short Real Training Run
- Question: When executing a short training run of
- Live GPU Management CLI Output Validation (
amd-smi/rocm-smi):- Question: Does the target system run
amd-smior legacyrocm-smi? Does raw JSON output conform to the official documentation schema, and does HyperGAN's Phase 2A provider extract normalized records (index, name, memory, utilization, processes) correctly? - Mapped Preflight Section: Section 8: GPU Inventory Provider Validation
- Question: Does the target system run
- Operator Determinism & Failure Classification on AMD Hardware:
- Question: Which specific PyTorch/MIOpen operators raise
RuntimeErrorundertorch.use_deterministic_algorithms(True), does HyperGAN's error handler enrich the traceback with the failing operation and recommend settingtraining.backend.deterministic_algorithms = false, and is the failure correctly categorized asdeterminism error? - Mapped Preflight Section: Section 9: Failure Classification & Summary
- Question: Which specific PyTorch/MIOpen operators raise