unsloth/tests/studio
Daniel Han 4ada33011f Add comprehensive ROCm support test suite (68 tests)
Add tests/studio/install/test_rocm_support.py with 68 test cases
covering all ROCm-related code paths across install_llama_prebuilt.py,
install_python_stack.py, hardware.py, tokenizer_utils.py, and
install.sh. All tests use mocks and run without AMD hardware.

Test classes and coverage:

TestResolveUpstreamAssetChoice (11 tests):
  NVIDIA gets CPU asset, ROCm gets ROCm prebuilt, CPU gets CPU,
  macOS/Windows paths, NVIDIA+ROCm precedence, no prebuilt fallback,
  Windows+ROCm no HIP falls to CPU, macOS+ROCm, Linux aarch64+ROCm

TestRuntimePatterns (5 tests):
  Correct file globs for linux-cpu, linux-cuda, linux-rocm,
  windows-hip, macos-arm64

TestHostInfoRocm (4 tests):
  Default has_rocm=False, explicit True, NVIDIA host no ROCm,
  detect_host checks ROCM_PATH

TestDetectRocmVersion (9 tests):
  No ROCm returns None, version from file (7.1, 6.2), hipconfig
  fallback, empty version file, epoch prefix, multiple sources
  first wins, multiline hipconfig, hipconfig timeout

TestEnsureRocmTorch (9 tests):
  No ROCm skips, torch has CUDA skips, torch has HIP skips,
  CPU torch triggers reinstall, ROCm 6.3 correct tag, old ROCm
  skips, version unreadable warning, ROCm 7.2 capped to 7.1,
  probe timeout handled

TestRocmTorchIndex (8 tests):
  Mapping sorted descending, ROCm 7.2 not in map, key lookups,
  all tags use download.pytorch.org, newer ROCm selects best match

TestHardwareRocmFlag (8 tests):
  IS_ROCM defined, set on HIP, still returns CUDA for ROCm,
  no DeviceType.ROCM, IS_ROCM exported, in __all__,
  get_package_versions has rocm key

TestTokenizerErrorMessage (2 tests):
  No old "We do not support AMD" message, new message has docs link

TestInstallShStructure (10 tests):
  No <<< here-strings, ROCm detection present, CUDA precedence,
  bitsandbytes install, CPU hint mentions AMD, ROCm 7.2 capped,
  validation guard exists, dpkg epoch handling, no [[ ]] syntax,
  macOS returns CPU before ROCm

TestLiveRegression (1 test):
  Live nvidia-smi returns CUDA URL (skipped if no GPU)

Depends on #4714, #4715, #4716, #4717 being merged first.
2026-03-31 08:34:05 +00:00
..
install Add comprehensive ROCm support test suite (68 tests) 2026-03-31 08:34:05 +00:00