From 031fddc62ca69f1f82d2bb66fce02b7a26c35d55 Mon Sep 17 00:00:00 2001 From: chaog992 <338238273+chaog992@users.noreply.github.com> Date: Fri, 9 Oct 2026 20:36:03 +0800 Subject: [PATCH] tools tests: test_amd_is_not_asked mocks the Linux HIP engine build too (it wrote sys.prefix/.strata-rocm.json) IQ4XS.test_amd_is_not_asked mocks get_prebuilt_hip, the engine setup.main takes on Windows. On Linux setup.main compiles the HIP engine instead (build_engine_hip), which the test did not mock. Without a usable system ROCm 7, as on the tested machine, rocm_root then fetched AMD's ROCm index (https://rocm.nightlies.amd.com/v2/gfx120X-all/rocm/), wrote Path(sys.prefix)/.strata-rocm.json and tried to run /rocm-sdk. Where sys.prefix is not writable (the system Python) that is a PermissionError. Where it is (a venv), the test passed while setup.main stopped at the ROCm step with exit code 1, and a stamp with the same version and index can make a later setup in that venv skip the ROCm install. The test now mocks build_engine_hip the same way, so on Linux setup.main runs to the end (exit code 0) with no network request, no subprocess and no write outside the test's temp folder. setup.py is unchanged; the Windows path never reaches build_engine_hip, so it runs as before. Tests: python3 -m unittest tools.test_setup_unsloth (WSL2): with the system Python 3.12.3 FAILED (errors=1) before, 38 tests OK after; in venvs on 3.10.22, 3.12.3, 3.13.7 and 3.14.8 OK before and after, and no stamp after. With the system Python the other 27 tools/test_setup_*.py files give the same results as before. --- tools/test_setup_unsloth.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/test_setup_unsloth.py b/tools/test_setup_unsloth.py index 27a7b9a3..e9bdaa3d 100644 --- a/tools/test_setup_unsloth.py +++ b/tools/test_setup_unsloth.py @@ -550,7 +550,8 @@ class IQ4XS(Base): def test_amd_is_not_asked(self): r9700 = [{"index": 0, "name": "AMD Radeon AI PRO R9700", "vram_gb": 31.9, "arch": "gfx1201", "driver": "amdgpu"}] - with mock.patch.object(setup, "get_prebuilt_hip", lambda *a, **k: self.t / "engine"): + with mock.patch.object(setup, "get_prebuilt_hip", lambda *a, **k: self.t / "engine"), \ + mock.patch.object(setup, "build_engine_hip", lambda *a, **k: self.t / "engine"): # Linux compiles it code, out, cfg = self.main(["--context", "8192", "--backend", "hip"], version="0.1.38", amd=r9700, m=X) self.assertNotIn("has not been run on AMD cards yet", out) self.assertIn("RAM budget: 40 GiB of UD-IQ4_XS's experts", out)