Pull requests / #1759

#1759 tools tests: test_amd_is_not_asked mocks the Linux HIP engine build too (it wrote sys.prefix/.strata-rocm.json)

open · @chaog992 · 0 コメント · GitHub で見る

Setup & installAMD / HIPNVIDIA / CUDAWindowsLinux

本文

## Title

Issue: no dedicated issue opened. This is the separate Unsloth test failure noted in #1658.

Related precedent: #975, fixed test-only in d1ec32b. This change is independent of #1658.

## Summary

`IQ4XS.test_amd_is_not_asked` mocks `get_prebuilt_hip`, which setup uses on Windows, but not `build_engine_hip`,
which setup uses on Linux. The tested Linux machine has no usable system ROCm, so the test runs setup's real ROCm step.
That step requests AMD's ROCm package index, writes `Path(sys.prefix)/.strata-rocm.json` and tries to launch
`rocm-sdk`. The file's docstring promises "Mocked - no GPU, no downloads, nothing written outside a temp folder".

With the system Python, the stamp write raises `PermissionError`. In a fresh venv the test passes and leaves the
stamp, even though `setup.main()` has stopped with exit code 1: its two string assertions do not check that setup
completed. A stamp with the same version and index can also make a later setup in that environment skip the ROCm
install.

## What changed

`tools/test_setup_unsloth.py` (+2/-1): the test also mocks `build_engine_hip`, returning the same temporary engine
directory as the existing `get_prebuilt_hip` mock.

`setup.py` and the assertions are unchanged. No CUDA, HIP or SYCL engine code is changed.

## Extra Notes

WSL2, Ubuntu 24.04.1. Base fb58e0d, head cfa6197.

- `python3 -m unittest tools.test_setup_unsloth`, three runs per revision with the system Python 3.12.3 and with a
  venv made from it:
  - system Python: one error before; all 38 tests pass after;
  - venv: all 38 pass before and after, but only the base leaves the ROCm stamp.
- Python 3.10.22, 3.13.7 and 3.14.8 venvs: all 38 tests pass on both revisions; only the base leaves the stamp.
- An audit hook on this test's `setup.main()` call in a venv:
  - base: exits 1, requests the ROCm index and tries to launch `rocm-sdk path --root`;
  - head: exits 0, with none of those effects and no stamp.
- A deliberate mutation that turns on the AMD warning for UD-IQ4_XS makes the fixed test fail at its warning
  assertion, so the test still guards what it is for.
- With the system Python, the other 27 setup test files give the same results on both revisions. The existing
  failures remain in `test_setup_risk` (#1658 addresses it) and `test_setup_engine_hash` (#1510 addresses it).
- Other tests in this file still attempt read-only `nvidia-smi` queries.
- With `setup.WIN=True` on Linux, this test stops at the device check on both revisions. So an exit-code assertion
  would also need a `hip_card` mock.
- Not run: actual Windows and native Linux.

関連リンク

インストール・モデル・リリースへの站内リンク。