diff --git a/setup.py b/setup.py index bd59a306172..9d4d6beb491 100644 --- a/setup.py +++ b/setup.py @@ -10312,7 +10312,7 @@ def main() -> int: else: table = hipblaslt_table(gpu["arch"], lib_dirs, meta.get("hipblaslt_version"), [eng / "tuning"]) if table: - cfg["env"] = {"STRATA_HIPBLASLT_TUNING": str(table)} + cfg.setdefault("env", {})["STRATA_HIPBLASLT_TUNING"] = str(table) if GFX1103_OPT_IN and gfx_arch_is(gpu["arch"], "gfx1103") and not WIN: # the 780M's KFD queues are evicted (a GPU reset) while transparent huge pages move the pinned expert arena cfg.setdefault("env", {})["STRATA_NO_ARENA_THP"] = "1" diff --git a/tools/test_setup_unsloth.py b/tools/test_setup_unsloth.py index 2d32c13976b..ac76aa6e8c6 100644 --- a/tools/test_setup_unsloth.py +++ b/tools/test_setup_unsloth.py @@ -286,6 +286,22 @@ def test_amd_is_not_asked(self): self.assertNotIn("has not been run on AMD cards yet", out) self.assertIn("RAM budget: 40 GiB of UD-Q4_K_XL's experts", out) + def test_hip_keeps_the_env_of_an_all_ram_install(self): + """The hipBLASLt table joined setup's env instead of replacing it: an Unsloth install whose experts all stay + in RAM lost STRATA_ROUTE_TAIL_SKIP=0, and the skip costs these files KL (docs/QUANTS.md).""" + r9700 = [{"index": 0, "name": "AMD Radeon AI PRO R9700", "vram_gb": 31.9, "arch": "gfx1201", + "driver": "amdgpu"}] + table = self.t / "tools" / "hip" / "gfx1201-hipblaslt-100401.txt" + 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"), \ + mock.patch.object(setup, "hipblaslt_table", lambda *a, **k: table): + code, out, cfg = self.main(["--context", "8192", "--backend", "hip", "--vision", "no"], + amd=r9700, ram=95.8) + self.assertEqual(code, 0, out) + self.assertNotIn("--resident-budget-gib", cfg["args"]) # 96 GB holds every expert: no budget, the skip is off + self.assertEqual(cfg["env"]["STRATA_HIPBLASLT_TUNING"], str(table)) + self.assertEqual(cfg["env"]["STRATA_ROUTE_TAIL_SKIP"], "0") + def test_resumed_download_needs_room_for_the_rest_only(self): """#425: the disk check counts the finished shards and .part files already there (sizes scaled down: a 2 MB "model" with 1.5 MB on the disk, 8 GB of other room needed, 8.001 GB free)."""