Quark torch install

From amd/Quark · View interactive version

Quark torch install is an AI agent skill from the GitHub repository amd/Quark. Install or verify the correct PyTorch build for a user's accelerator backend before Quark installation. Use when the user needs PyTorch set up, reports torch version conflicts, CUDA/ROCm package mismatches, or when torch.cuda.is_available() returns False. Trigger for "install PyTorch", "pip install

How to use this skill

Skill file

quark-torch-install

Purpose

Install the correct PyTorch build for the user's accelerator backend. PyTorch must be installed before Quark because Quark depends on PyTorch at both install time and runtime. Getting this wrong — installing the CPU build on a GPU machine, or mixing a CUDA-built PyTorch with a ROCm environment — causes cryptic failures that are hard to diagnose later. This skill exists separately from quark-install so that PyTorch setup has a clear, single-responsibility boundary.

Inputs

Outputs: pytorch_install_result.json

Records the installed PyTorch build, accelerator backend tag, and verification status.

Schema: CODE0

{
  "status": "ok",
  "pytorch_version": "2.5.1+cu126",
  "accelerator_tag": "cu126",
  "torchvision_version": "0.20.1+cu126",
  "torchaudio_version": "2.5.1+cu126",
  "verification": {
    "import_ok": true,
    "cuda_available": true,
    "gpu_count": 1
  }
}

On failure, set status: "failed" and include a failure_reason with the exact failing verification command.

Python Version Requirements

PyTorch Version Matrix

Authoritative source: tools/ci/install_torch.sh

Before generating install commands, always read this script to get the current list of verified accelerator/PyTorch combinations. The script defines which PyTorch versions are tested with each accelerator backend (ROCm, CUDA, CPU) and the corresponding --index-url values.

How to read the source

  1. Open tools/ci/install_torch.sh and locate the version arrays or case/if blocks that map accelerator tags to PyTorch versions.
  2. Extract the accelerator identifier (e.g., rocm7.1, cu126, cpu).
  3. Extract the supported PyTorch version list for that accelerator.
  4. Construct the install command using the pattern below.

Install command pattern

# ROCm — torchvision only, no torchaudio
pip install torch torchvision --index-url https://download.pytorch.org/whl/<rocm_tag>

# CUDA — includes torchaudio
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/<cuda_tag>

# CPU — includes torchaudio
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu

Replace <rocm_tag> with the ROCm version tag (e.g., rocm6.4, rocm7.0, rocm7.1) and <cuda_tag> with the CUDA version tag (e.g., cu118, cu126, cu128, cu130). Always use the exact tags from install_torch.sh.

Critical: Never use bare pip install torch for GPU setups — it installs the CPU version by default.

Rules

Verification Commands

# PyTorch backend check
python -c "import torch; print('PyTorch:', torch.__version__); print('CUDA:', torch.version.cuda); print('HIP:', torch.version.hip)"

# GPU availability
python -c "import torch; print('CUDA available:', torch.cuda.is_available()); print('GPU count:', torch.cuda.device_count())"

Interaction Flow

  1. Intake: Determine what the user already has installed and what accelerator they need. Check if quark-env-preflight has already run.
  2. Plan: Present the accelerator-specific PyTorch installation command with version justifications.
  3. Confirm: Required before any package installation. Show: what will be installed, which --index-url will be used, and what environment will be modified.
  4. Execute: Run the installation commands.
  5. Verify: Run all verification commands. Report pass/fail for each.

Recovery

Windows-Specific Notes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.