setup: recognize AMD Strix Halo (gfx1151) exactly, size its unified memory, recommend UD-IQ4_XS
gfx1151 is now a supported AMD arch (TheRock gfx1151 index; HIP build on Linux, docs/STRIX_HALO.md). The check is exact (gfx_arch_is, as the engine's gfx_arch.hpp): gfx1150 / gfx1152 / gfx1103 are named as Strix Point / Krackan / Phoenix-Hawk Point and stay unsupported. PCI 1002:1586 (one id for the 8060S / 8050S / 8040S) and the Windows adapter names map to gfx1151; the KFD simd_count names the 8060S / 8050S / 8040S. Unified memory: the BIOS carve-out + the shared pool (GTT; Windows half the RAM) size the context; only the carve-out counts as extra room in the low-RAM mode. A discrete card is picked before an APU. A Windows zip without gfx1151 code is refused with the reason. UD-IQ4_XS is the recommended model from ~80 GB of memory; setup changes no host setting. tools/test_setup_strix_halo.py uses Aurora's real sysfs.
This commit is contained in:
1 parent
e8e11a915f
commit
c4a329fefe
4 files changed
+690
-34
No files matched your search
+6
-2
@@ -3,8 +3,12 @@
|
||||
Strata runs on the Ryzen AI Max "Strix Halo" APUs (Radeon 8060S / 8050S, RDNA3.5, `gfx1151`, one pool of LPDDR5X shared by the
|
||||
CPU and the GPU) through the same HIP backend as the Radeon cards in [AMD_HIP.md](AMD_HIP.md). **Status: experimental.**
|
||||
Everything here was built and measured on one machine, the maintainers' Strix Halo box (Ryzen AI Max+ 395, 128 GB,
|
||||
Ubuntu 26.04, kernel 7.0, ROCm 7.14.1). There is no ready-made engine for it and setup (`setup.sh`) does not offer it:
|
||||
it lists integrated Radeon GPUs as not supported. You build the engine yourself, as below.
|
||||
Ubuntu 26.04, kernel 7.0, ROCm 7.14.1). Setup (`setup.sh`, `START-HERE.bat`) recognizes it from 0.1.40, by its PCI id (`1002:1586`, one id for the 8060S, 8050S and 8040S) and by
|
||||
`gfx1151` exactly: a Strix Point (890M / 880M, gfx1150), Krackan (860M / 840M, gfx1152) or Phoenix / Hawk Point (780M / 760M, gfx1103) Radeon is
|
||||
named as what it is and not supported. On Linux setup compiles the engine for gfx1151 itself (the steps below are the same, by hand). On
|
||||
Windows the ready-made `strata-windows-x64-hip.zip` carries gfx1151 code from 0.1.40 (untested on a Windows Strix Halo so far); a zip
|
||||
without it is refused with a message, never used. Setup counts the GPU's memory as the BIOS carve-out plus the shared memory
|
||||
(the GTT pool; on Windows half the RAM) and recommends UD-IQ4_XS from about 80 GB of memory; it changes no BIOS or kernel setting.
|
||||
|
||||
What the engine does differently on this chip:
|
||||
|
||||
|
||||
@@ -1488,25 +1488,158 @@ ROCM_INDEXES = {"gfx1100": "https://rocm.nightlies.amd.com/v2/gfx110X-dgpu/",
|
||||
"gfx1200": "https://rocm.nightlies.amd.com/v2/gfx120X-all/",
|
||||
"gfx1201": "https://rocm.nightlies.amd.com/v2/gfx120X-all/",
|
||||
"gfx1030": "https://rocm.nightlies.amd.com/v2/gfx103X-all/",
|
||||
"gfx1031": "https://rocm.nightlies.amd.com/v2/gfx103X-all/"}
|
||||
"gfx1031": "https://rocm.nightlies.amd.com/v2/gfx103X-all/",
|
||||
"gfx1151": "https://rocm.nightlies.amd.com/v2/gfx1151/"} # Strix Halo (docs/STRIX_HALO.md)
|
||||
ROCM_VERSION = os.environ.get("STRATA_ROCM_VERSION", "7.10.0a20251120") # what Strata's HIP build was tested with
|
||||
ROCM_SYSTEM_MIN = (7, 0) # an older system ROCm is passed over for the wheels (gfx1201 needs ROCm 6.4 or newer)
|
||||
AMD_ARCHS = ("gfx1100", "gfx1101", "gfx1200", "gfx1201", "gfx1030", "gfx1031")
|
||||
AMD_ARCHS = ("gfx1100", "gfx1101", "gfx1200", "gfx1201", "gfx1030", "gfx1031", "gfx1151")
|
||||
AMD_NAMES = {"gfx1100": "AMD Radeon RX 7900 series (gfx1100)", # when sysfs has no product name
|
||||
"gfx1101": "AMD Radeon RX 7800 XT / 7700 XT (gfx1101)",
|
||||
"gfx1200": "AMD Radeon RX 9060 series (gfx1200)",
|
||||
"gfx1201": "AMD Radeon RX 9070 series / AI PRO R9700 (gfx1201)",
|
||||
"gfx1030": "AMD Radeon RX 6800 / 6900 series (gfx1030)",
|
||||
"gfx1031": "AMD Radeon RX 6700 XT series (gfx1031)"}
|
||||
"gfx1031": "AMD Radeon RX 6700 XT series (gfx1031)",
|
||||
"gfx1151": "AMD Radeon 8060S / 8050S / 8040S (Ryzen AI Max, Strix Halo, gfx1151)",
|
||||
# integrated Radeons of other Ryzen families: named so they are not taken for Strix Halo (not supported)
|
||||
"gfx1150": "AMD Radeon 890M / 880M (Ryzen AI 300, Strix Point, gfx1150)",
|
||||
"gfx1152": "AMD Radeon 860M / 840M (Ryzen AI 300, Krackan Point, gfx1152)",
|
||||
"gfx1103": "AMD Radeon 780M / 760M / 740M (Ryzen 7040 / 8040, Phoenix / Hawk Point, gfx1103)"}
|
||||
AMD_CARDS = ("the RX 7900 XT / XTX (gfx1100), RX 7800 XT / 7700 XT (gfx1101), RX 9060 XT (gfx1200) and "
|
||||
"RX 9070 / 9070 XT / Radeon AI PRO R9700 (gfx1201), and the RX 6800 / 6900 series (gfx1030) and RX 6700 XT "
|
||||
"(gfx1031, #524), both unvalidated")
|
||||
"(gfx1031, #524), both unvalidated, and the Ryzen AI Max \"Strix Halo\" APU (Radeon 8060S / 8050S / 8040S, "
|
||||
"gfx1151: experimental, docs/STRIX_HALO.md)")
|
||||
|
||||
|
||||
def rocm_index(arch):
|
||||
return os.environ.get("STRATA_ROCM_INDEX") or ROCM_INDEXES[arch]
|
||||
|
||||
|
||||
# Strix Halo (Ryzen AI Max 380 / 385 / 390 / 395 + PRO: Radeon 8040S / 8050S / 8060S, RDNA 3.5, gfx1151) and the other
|
||||
# integrated Radeons it must never be taken for. pci.ids lists ONE device id for the whole Strix Halo family
|
||||
# ("1586 Strix Halo [Radeon Graphics / Radeon 8050S Graphics / Radeon 8060S Graphics]"; the 8040S shares it: the
|
||||
# three differ by their CU count, 40 / 32 / 16, not by id). Aurora's real answers (tools/test_setup_strix_halo.py):
|
||||
# KFD gfx_target_version 110501, vendor_id 4098, device_id 5510 (0x1586), simd_count 80.
|
||||
STRIX_HALO_ARCH = "gfx1151"
|
||||
STRIX_HALO_PCI_IDS = frozenset({0x1586})
|
||||
AMD_IGPU_PCI = {0x1586: "gfx1151", # Strix Halo
|
||||
0x150E: "gfx1150", # Strix Point: Radeon 880M / 890M
|
||||
0x1114: "gfx1152", 0x1902: "gfx1152", # Krackan Point (Krackan2): Radeon 840M / 860M
|
||||
0x15BF: "gfx1103", 0x15C8: "gfx1103", 0x164F: "gfx1103", # Phoenix: Radeon 740M / 760M / 780M
|
||||
0x1900: "gfx1103", 0x1901: "gfx1103"} # Hawk Point
|
||||
STRIX_HALO_BY_SIMDS = {80: "8060S", 64: "8050S", 32: "8040S"} # KFD simd_count (2 per CU): 40 / 32 / 16 CUs
|
||||
UMA_OS_LEFT_GB = 6 # the share of the unified memory kept for the OS: what the engine's device_free_bytes() leaves
|
||||
|
||||
|
||||
def gfx_arch_is(arch, name) -> bool:
|
||||
"""include/strata/kernels/gfx_arch.hpp's gfx_arch_is: `arch` (gcnArchName, "gfx1151" or "gfx1151:sramecc-:xnack-")
|
||||
is exactly `name`, never a prefix: gfx1150 and gfx1152 are not gfx1151 (and gfx1151 is not gfx115)."""
|
||||
arch = str(arch or "")
|
||||
return arch == name or arch.startswith(name + ":")
|
||||
|
||||
|
||||
def is_strix_halo(g) -> bool:
|
||||
return isinstance(g, dict) and gfx_arch_is(g.get("arch"), STRIX_HALO_ARCH)
|
||||
|
||||
|
||||
def amd_apply_uma(g: dict, gtt_gb: float = 0.0, ram: float | None = None) -> dict:
|
||||
"""Strix Halo is an APU with unified memory. Its "dedicated VRAM" is a BIOS carve-out (512 MB to 96 GB; 2 GB on the
|
||||
maintainers' box) and the GPU also reaches shared system memory (Linux: the GTT pool, `mem_info_gtt_total`, half the
|
||||
RAM unless the kernel was told otherwise; Windows: "shared GPU memory", half the RAM). The shared part IS the RAM
|
||||
the model's experts live in, so it is not extra room beside the RAM. g gets: uma, dedicated_gb (the carve-out: the
|
||||
only part that adds to the RAM, which the low-RAM mode counts) and vram_gb = the memory the GPU can use in all
|
||||
(the carve-out plus the shared pool less what the OS keeps), which sizes the context and the parallel slots."""
|
||||
if g.get("uma") or not is_strix_halo(g):
|
||||
return g
|
||||
ram = ram_gb() if ram is None else ram
|
||||
carve = max(0.0, float(g.get("vram_gb") or 0.0))
|
||||
shared = gtt_gb if gtt_gb > 0 else ram / 2
|
||||
shared = max(0.0, min(shared, ram - UMA_OS_LEFT_GB))
|
||||
g.update({"uma": True, "dedicated_gb": carve, "shared_gb": shared, "vram_gb": carve + shared})
|
||||
return g
|
||||
|
||||
|
||||
def low_ram_vram(g) -> float:
|
||||
"""The GPU memory the low-RAM mode may count as room beside the RAM: a discrete card's VRAM; an APU's BIOS
|
||||
carve-out only (its shared memory is the RAM itself)."""
|
||||
return g.get("dedicated_gb", 0.0) if g.get("uma") else g["vram_gb"]
|
||||
|
||||
|
||||
def amd_mem_text(g) -> str:
|
||||
"""How setup says a card's memory: "24 GB VRAM", or for an APU its unified memory."""
|
||||
if g.get("uma"):
|
||||
return (f"unified memory: {g['dedicated_gb']:.1f} GB BIOS carve-out + {g['shared_gb']:.0f} GB shared with the "
|
||||
f"RAM, {g['vram_gb']:.0f} GB usable by the GPU")
|
||||
return f"{g['vram_gb']:.0f} GB VRAM"
|
||||
|
||||
|
||||
STRIX_HALO_FAMILY, STRIX_HALO_MODEL = "unsloth", "UD-IQ4_XS" # the model docs/STRIX_HALO.md measures
|
||||
STRIX_HALO_MIN_GB = 80 # UD-IQ4_XS keeps all of its experts in memory from ~80 GB (its menu line says so)
|
||||
|
||||
|
||||
def strix_halo_recommends(gpu, ram) -> bool:
|
||||
"""Is UD-IQ4_XS the recommended model here: a Strix Halo whose unified memory (the OS's RAM plus the BIOS carve-out)
|
||||
holds it - the model docs/STRIX_HALO.md measures. A recommendation only: the menus still list every size."""
|
||||
return bool(gpu.get("uma")) and ram + gpu.get("dedicated_gb", 0.0) >= STRIX_HALO_MIN_GB
|
||||
|
||||
|
||||
def strix_halo_notes(gpu, ram) -> list[str]:
|
||||
"""What setup tells a Strix Halo owner (a leading "!" = a warning): the unified memory, the build, the guide, and the
|
||||
memory settings that give the GPU room. Nothing is changed or refused: recommend, never force."""
|
||||
notes = [f" Strix Halo (gfx1151, Ryzen AI Max): the CPU and the GPU share one memory pool ({ram:.0f} GB seen by the "
|
||||
f"OS + a {gpu.get('dedicated_gb', 0.0):.1f} GB BIOS carve-out), so the model's experts live in that pool "
|
||||
"and the expert cache is sized from the memory the OS can give back, not from the carve-out."]
|
||||
notes.append(" " + ("The engine is compiled here for gfx1151" if not WIN else "Windows uses the ready-made AMD engine, "
|
||||
"which must be built for gfx1151")
|
||||
+ " (experimental, measured on one machine): see docs/STRIX_HALO.md.")
|
||||
if not WIN and gpu.get("shared_gb", 0) < 0.75 * ram - 1:
|
||||
notes.append(f"!the GPU can reach {gpu.get('shared_gb', 0):.0f} GB of shared memory (the GTT pool; the kernel's "
|
||||
f"default is about half of the RAM). docs/STRIX_HALO.md boots with ttm.pages_limit and "
|
||||
"ttm.page_pool_size to give it most of the RAM; setup changes no host setting - a bigger model "
|
||||
"needs the room, a smaller one runs as it is")
|
||||
if gpu.get("dedicated_gb", 0.0) > 16:
|
||||
notes.append(f"!the BIOS carve-out is {gpu['dedicated_gb']:.0f} GB: that memory is taken from the OS, while the GPU "
|
||||
"reaches the shared memory anyway. A small carve-out (the BIOS's default or 512 MB - 2 GB) leaves "
|
||||
"the RAM to the model")
|
||||
if strix_halo_recommends(gpu, ram):
|
||||
notes.append(f" Recommended model: {STRIX_HALO_MODEL} (the one docs/STRIX_HALO.md measures); the menus list the "
|
||||
"others.")
|
||||
return notes
|
||||
|
||||
|
||||
def amd_rank(g):
|
||||
"""The order setup picks a card in, best first: a discrete card before an APU (its own GDDR is faster than the
|
||||
shared LPDDR5X), then the most memory. A Strix Halo beside a Radeon RX / PRO card is therefore left to --gpu N."""
|
||||
return (bool(g.get("uma")), -round(g["vram_gb"]), g["index"])
|
||||
|
||||
|
||||
def amd_pci_devices(sysfs="/sys") -> list[dict]:
|
||||
"""The AMD (vendor 0x1002) display devices the kernel lists in /sys/class/drm/card*/device, as [{"pci_id",
|
||||
"vram_gb", "gtt_gb", "arch"}] with the arch AMD_IGPU_PCI knows ("" when it does not). The KFD topology answers the
|
||||
same without ROCm; this one only names a card the topology does not list (a kernel without /dev/kfd)."""
|
||||
found = []
|
||||
base = Path(sysfs) / "class/drm"
|
||||
if not base.is_dir():
|
||||
return found
|
||||
for card in sorted(base.glob("card[0-9]*")):
|
||||
if not card.name[4:].isdigit():
|
||||
continue
|
||||
try:
|
||||
dev = card / "device"
|
||||
if int((dev / "vendor").read_text().strip(), 16) != 0x1002:
|
||||
continue
|
||||
did = int((dev / "device").read_text().strip(), 16)
|
||||
except (OSError, ValueError):
|
||||
continue
|
||||
row = {"pci_id": did, "arch": AMD_IGPU_PCI.get(did, ""), "vram_gb": 0.0, "gtt_gb": 0.0}
|
||||
for key, f in (("vram_gb", "mem_info_vram_total"), ("gtt_gb", "mem_info_gtt_total")):
|
||||
try:
|
||||
row[key] = int((dev / f).read_text()) / 2 ** 30
|
||||
except (OSError, ValueError):
|
||||
pass
|
||||
found.append(row)
|
||||
return found
|
||||
|
||||
|
||||
def amd_gpus(sysfs="/sys"):
|
||||
"""AMD GPUs from the kernel's KFD topology (the amdgpu driver; no ROCm needed), numbered as HIP numbers them:
|
||||
the GPU nodes in order, the CPU nodes skipped. Integrated GPUs are listed too (not supported).
|
||||
@@ -1540,14 +1673,26 @@ def amd_gpus(sysfs="/sys"):
|
||||
name = f"AMD Radeon ({arch})"
|
||||
if name == f"AMD Radeon ({arch})" and arch in AMD_NAMES:
|
||||
name = AMD_NAMES[arch]
|
||||
found.append({"index": len(found), "name": name, "vram_gb": vram, "arch": arch, "driver": "amdgpu",
|
||||
"vendor": "amd"})
|
||||
if gfx_arch_is(arch, STRIX_HALO_ARCH) and int(props.get("simd_count") or 0) in STRIX_HALO_BY_SIMDS:
|
||||
name = (f"AMD Radeon {STRIX_HALO_BY_SIMDS[int(props['simd_count'])]} "
|
||||
"(Ryzen AI Max, Strix Halo, gfx1151)") # the CU count tells the 8060S / 8050S / 8040S apart
|
||||
try:
|
||||
gtt = int((dev / "mem_info_gtt_total").read_text()) / 2 ** 30
|
||||
except (OSError, ValueError):
|
||||
gtt = 0.0
|
||||
g = {"index": len(found), "name": name, "vram_gb": vram, "arch": arch, "driver": "amdgpu", "vendor": "amd"}
|
||||
try:
|
||||
g["pci_id"] = int((dev / "device").read_text().strip(), 16)
|
||||
except (OSError, ValueError):
|
||||
pass
|
||||
found.append(amd_apply_uma(g, gtt)) # Strix Halo: unified memory (carve-out + shared)
|
||||
return found
|
||||
|
||||
|
||||
def amd_problem(g):
|
||||
if g["arch"] not in AMD_ARCHS:
|
||||
return f"not supported - Strata's AMD backend runs on {AMD_CARDS} only, this is {g['arch']}"
|
||||
return (f"not supported - Strata's AMD backend runs on {AMD_CARDS} only, this is {g['arch']}"
|
||||
+ (" (an integrated Radeon, not Strix Halo)" if g["arch"] in ("gfx1150", "gfx1152", "gfx1103") else ""))
|
||||
if g.get("cannot_run"): # Windows: the installed engine's own check (--list-devices)
|
||||
return g["cannot_run"]
|
||||
return None
|
||||
@@ -1556,7 +1701,18 @@ def amd_problem(g):
|
||||
def amd_gpus_win() -> list[dict]:
|
||||
"""Windows: the AMD GPUs as the HIP runtime numbers them once the HIP engine is installed (hip_devices), else in
|
||||
the display-adapter order (amd_gpus_windows)."""
|
||||
return hip_devices() or amd_gpus_windows()
|
||||
hip = hip_devices()
|
||||
if not hip:
|
||||
return amd_gpus_windows()
|
||||
halo = [g for g in hip if is_strix_halo(g)]
|
||||
if halo: # an APU: the HIP runtime's figure is not the BIOS carve-out
|
||||
reg = [r for r in amd_gpus_windows() if is_strix_halo(r)]
|
||||
for k, g in enumerate(halo):
|
||||
reported = g["vram_gb"]
|
||||
g["vram_gb"] = reg[k]["dedicated_gb"] if k < len(reg) else 0.0
|
||||
amd_apply_uma(g)
|
||||
g["vram_gb"] = max(g["vram_gb"], reported)
|
||||
return hip
|
||||
|
||||
|
||||
def amd_parse_gpus(text, amd) -> list:
|
||||
@@ -1565,7 +1721,7 @@ def amd_parse_gpus(text, amd) -> list:
|
||||
architectures: the engine is compiled for each). Returns the cards, the main one first."""
|
||||
usable = [g for g in amd if amd_problem(g) is None]
|
||||
if str(text).strip().lower() == "all":
|
||||
sel = [g["index"] for g in sorted(usable, key=lambda x: (-round(x["vram_gb"]), x["index"]))]
|
||||
sel = [g["index"] for g in sorted(usable, key=amd_rank)]
|
||||
else:
|
||||
try:
|
||||
sel = [int(x) for x in str(text).split(",") if x.strip()]
|
||||
@@ -1603,8 +1759,13 @@ _WIN_AMD_DID = {0x744C: "gfx1100", 0x7448: "gfx1100", 0x745E: "gfx1100",
|
||||
0x7590: "gfx1200", # RX 9060 XT
|
||||
0x7550: "gfx1201", 0x7551: "gfx1201", # RX 9070 / 9070 XT, AI PRO R9700
|
||||
0x73BF: "gfx1030", 0x73AF: "gfx1030", 0x73A5: "gfx1030", # RX 6800 / 6800 XT / 6900 XT / 6950 XT
|
||||
0x73DF: "gfx1031"} # RX 6700 XT / 6750 XT / 6800M (#881)
|
||||
_WIN_AMD_NAME = ((re.compile(r"\b9070\b|R9700", re.I), "gfx1201"),
|
||||
0x73DF: "gfx1031", # RX 6700 XT / 6750 XT / 6800M (#881)
|
||||
**AMD_IGPU_PCI} # Ryzen APUs: 0x1586 = Strix Halo (gfx1151)
|
||||
_WIN_AMD_NAME = ((re.compile(r"\b80[456]0S\b", re.I), "gfx1151"), # Radeon 8060S / 8050S / 8040S
|
||||
(re.compile(r"\b8[89]0M\b", re.I), "gfx1150"), # Radeon 890M / 880M
|
||||
(re.compile(r"\b8[46]0M\b", re.I), "gfx1152"), # Radeon 860M / 840M
|
||||
(re.compile(r"\b7[468]0M\b", re.I), "gfx1103"), # Radeon 780M / 760M / 740M
|
||||
(re.compile(r"\b9070\b|R9700", re.I), "gfx1201"),
|
||||
(re.compile(r"\b9060\b", re.I), "gfx1200"),
|
||||
(re.compile(r"RX\s*7900|W7900|W7800", re.I), "gfx1100"),
|
||||
(re.compile(r"RX\s*7800|RX\s*7700(?!\s*S)|W7700", re.I), "gfx1101"),
|
||||
@@ -1704,8 +1865,9 @@ def amd_gpus_windows(adapters=None, registry=None) -> list[dict]:
|
||||
vram = ad["ram"] / 2 ** 30 # WMI's 32-bit figure (at most 4 GB)
|
||||
arch = win_amd_arch(did, ad.get("name", ""))
|
||||
name = ad.get("name") or AMD_NAMES.get(arch, f"AMD Radeon (device {did:04X})")
|
||||
found.append({"index": len(found), "name": name, "vram_gb": vram, "arch": arch or f"unknown (PCI {did:04X})",
|
||||
"driver": driver or "amd", "vendor": "amd"})
|
||||
g = {"index": len(found), "name": name, "vram_gb": vram, "arch": arch or f"unknown (PCI {did:04X})",
|
||||
"driver": driver or "amd", "vendor": "amd", "pci_id": did}
|
||||
found.append(amd_apply_uma(g)) # Strix Halo: the registry's figure is the BIOS carve-out only
|
||||
return found
|
||||
|
||||
|
||||
@@ -1814,7 +1976,8 @@ def hip_card(eng: Path, gpu: dict, listed: list[dict]) -> dict:
|
||||
fail(f"HIP device {m['index']} ({m['name']}) cannot be used: {amd_problem(m)}")
|
||||
if gpu.get("driver") != "hip" and m["index"] != gpu["index"]:
|
||||
ok(f"HIP numbers this card {m['index']} (an integrated GPU comes first): the engine is pointed at it")
|
||||
return {**gpu, "index": m["index"], "count": len(hip), "vram_gb": m["vram_gb"] or gpu["vram_gb"], "driver": "hip"}
|
||||
vram = gpu["vram_gb"] if gpu.get("uma") else (m["vram_gb"] or gpu["vram_gb"]) # an APU: not the runtime's figure
|
||||
return {**gpu, "index": m["index"], "count": len(hip), "vram_gb": vram, "driver": "hip"}
|
||||
|
||||
|
||||
def get_prebuilt_hip(url_base, gpu, updating=False) -> Path | None:
|
||||
@@ -1869,6 +2032,12 @@ def get_prebuilt_hip(url_base, gpu, updating=False) -> Path | None:
|
||||
elif gpu["arch"] not in meta.get("archs", []):
|
||||
why = (f"it is built for {', '.join(meta.get('archs', []))}; your GPU is {gpu['arch']}. A card it has no code "
|
||||
"for runs from a self-build of the engine: see docs/AMD_HIP.md (--build)") # #881
|
||||
if is_strix_halo(gpu): # never a zip without gfx1151 code: say so, and what to do
|
||||
why = (f"it is built for {', '.join(meta.get('archs', [])) or 'other GPUs'} and has no gfx1151 code: your "
|
||||
f"{gpu['name']} (Strix Halo) needs a ready-made engine from Strata 0.1.40 or newer, whose zip is "
|
||||
"built for gfx1151 too. Until then: the Linux guide docs/STRIX_HALO.md, or compile the engine "
|
||||
"here with tools\\hip\\build_windows.bat (its default list has gfx1151) and start setup with "
|
||||
"--prebuilt <its dist folder>")
|
||||
if why:
|
||||
warn(f"the ready-made AMD engine at {base} cannot be used: {why}")
|
||||
shutil.rmtree(tmp, ignore_errors=True)
|
||||
@@ -3185,7 +3354,7 @@ def hip_config_cards(sel) -> list[dict]:
|
||||
amd = amd_gpus()
|
||||
if sel is None:
|
||||
usable = [g for g in amd if amd_problem(g) is None]
|
||||
sel = max(usable, key=lambda x: (round(x["vram_gb"]), -x["index"]))["index"] if usable else None
|
||||
sel = min(usable, key=amd_rank)["index"] if usable else None
|
||||
byid = {g["index"]: g for g in amd}
|
||||
cards = []
|
||||
for i in (sel if isinstance(sel, list) else [sel]):
|
||||
@@ -4064,7 +4233,8 @@ def main() -> int:
|
||||
say(" This PC has NVIDIA and AMD cards Strata can use:")
|
||||
say(" 1) NVIDIA: " + ", ".join(f"{g['name']} ({g['vram_gb']:.0f} GB)" for g in found if gpu_problem(g) is None)
|
||||
+ " (recommended)")
|
||||
say(" 2) AMD: " + ", ".join(f"{g['name']} ({g['vram_gb']:.0f} GB)" for g in amd_ok)
|
||||
say(" 2) AMD: " + ", ".join(f"{g['name']} ({g['vram_gb']:.0f} GB{', unified memory' if g.get('uma') else ''})"
|
||||
for g in amd_ok)
|
||||
+ f" ({'the ready-made AMD engine, no images' if WIN else 'compiled here, images on the CPU'}"
|
||||
" - docs/AMD_HIP.md)")
|
||||
hip = ask("Which cards?", ["1", "2"], "1", a.yes or a.check) == "2"
|
||||
@@ -4077,8 +4247,14 @@ def main() -> int:
|
||||
say(" Your AMD GPUs:" if amd else " No AMD GPU found (" + ("Windows lists no AMD display adapter)." if WIN
|
||||
else "the amdgpu driver's KFD topology is empty)."))
|
||||
for g in amd:
|
||||
say(f" GPU {g['index']}: {g['name']}, {g['vram_gb']:.0f} GB VRAM - " + (amd_problem(g) or "can be used"))
|
||||
say(f" GPU {g['index']}: {g['name']}, {amd_mem_text(g)} - " + (amd_problem(g) or "can be used"))
|
||||
usable = [g for g in amd if amd_problem(g) is None]
|
||||
if not amd and not WIN: # the KFD topology is empty: name a Strix Halo the kernel sees
|
||||
for d in amd_pci_devices():
|
||||
if d["pci_id"] in STRIX_HALO_PCI_IDS:
|
||||
say(f" The kernel lists an AMD Strix Halo (PCI 1002:{d['pci_id']:04x}) but /dev/kfd's topology is "
|
||||
"empty: ROCm cannot use it yet (docs/STRIX_HALO.md: the amdgpu driver and /dev/kfd access, "
|
||||
"your user in the render and video groups)")
|
||||
if not usable:
|
||||
fail("no AMD GPU Strata can use", f"the AMD backend runs on {AMD_CARDS}")
|
||||
if a.gpus: # a layer split across these cards, the first one the main
|
||||
@@ -4090,8 +4266,13 @@ def main() -> int:
|
||||
fail(f"AMD GPU {a.gpu} cannot be used", "use one of: " + ", ".join(f"--gpu {g['index']}" for g in usable))
|
||||
chosen = [gpu]
|
||||
else:
|
||||
gpu = max(usable, key=lambda x: (round(x["vram_gb"]), -x["index"]))
|
||||
gpu = min(usable, key=amd_rank) # a discrete card before an APU, then the most memory
|
||||
chosen = [gpu]
|
||||
if len(usable) > 1 and any(g.get("uma") for g in usable) != all(g.get("uma") for g in usable):
|
||||
others = [g for g in usable if g is not gpu]
|
||||
say(f" Using GPU {gpu['index']} ({gpu['name']}); setup recommends the card with its own memory over "
|
||||
"the APU's shared memory. To use another: "
|
||||
+ ", ".join(f"--gpu {g['index']} ({g['name']})" for g in others))
|
||||
# the engine is compiled for every chosen card's architecture
|
||||
gpu = {**gpu, "count": len(amd), "archs": sorted({g["arch"] for g in chosen})}
|
||||
chosen = [gpu] + chosen[1:]
|
||||
@@ -4100,7 +4281,11 @@ def main() -> int:
|
||||
a.gpu = gpu["index"] if len(amd) > 1 else a.gpu
|
||||
if multi:
|
||||
ok("GPUs: " + " + ".join(gpu_name(x) for x in chosen) + " together (the model's layers are split across them)")
|
||||
ok(f"GPU: {gpu['name']}, {gpu['vram_gb']:.1f} GB VRAM, {gpu['arch']} (AMD: docs/AMD_HIP.md)")
|
||||
ok(f"GPU: {gpu['name']}, {amd_mem_text(gpu) if gpu.get('uma') else format(gpu['vram_gb'], '.1f') + ' GB VRAM'}, "
|
||||
f"{gpu['arch']} (AMD: docs/{'STRIX_HALO' if gpu.get('uma') else 'AMD_HIP'}.md)")
|
||||
if gpu.get("uma"):
|
||||
for line in strix_halo_notes(gpu, ram_gb()):
|
||||
(warn if line.startswith("!") else say)(line.lstrip("!"))
|
||||
else:
|
||||
if not found:
|
||||
fail("no NVIDIA GPU found (nvidia-smi did not answer)",
|
||||
@@ -4128,11 +4313,12 @@ def main() -> int:
|
||||
("" if cuda_tk == 12 else f" (or --cuda 12: the experimental CUDA 12 engine runs with driver "
|
||||
f"{CUDA12_MIN_DRIVER} or newer, docs/OLDER_GPUS.md)"))
|
||||
if gpu["vram_gb"] < 11:
|
||||
warn("less than 12 GB of VRAM: Strata will run, but most experts stay on the CPU and it will be slow")
|
||||
warn("less than 12 GB of " + ("GPU memory (this APU's carve-out + shared memory)" if gpu.get("uma") else "VRAM")
|
||||
+ ": Strata will run, but most experts stay on the CPU and it will be slow")
|
||||
ram = ram_gb()
|
||||
cpu, avx2, avx512 = cpu_info()
|
||||
need = min(d["ram_gb"] for d in MODELS.values())
|
||||
low_ok = low_ram_fits("IQ1_M", ram, gpu["vram_gb"]) and a.low_ram != "off" # the smallest model, mapped
|
||||
low_ok = low_ram_fits("IQ1_M", ram, low_ram_vram(gpu)) and a.low_ram != "off" # the smallest model, mapped
|
||||
if ram < need - 4 and not a.check and not low_ok:
|
||||
# every model keeps ALL its experts in RAM (23+ GB); VRAM only holds a copy of the most-used ones, so a
|
||||
# bigger GPU does not lower this. The owner's rule: a stop by default, a risk the user can take (--model
|
||||
@@ -4180,9 +4366,9 @@ def main() -> int:
|
||||
"read from the SSD" if ram >= d["ram_gb"] else "does not fit")
|
||||
if hip: # #429: not run on AMD yet (its prompt kernels are CUDA-only)
|
||||
verdict += " - NVIDIA only so far, untested on AMD"
|
||||
elif low_ram_needed(m, ram) and low_ram_fits(m, ram, gpu["vram_gb"]) and a.low_ram != "off":
|
||||
verdict = (f"fits in the low-RAM mode (the GPU holds ~{100 * low_ram_gpu_share(m, gpu['vram_gb']):.0f}% "
|
||||
"of its experts, " + ("the rest stays in RAM)" if low_ram_resident(m, ram, gpu["vram_gb"])
|
||||
elif low_ram_needed(m, ram) and low_ram_fits(m, ram, low_ram_vram(gpu)) and a.low_ram != "off":
|
||||
verdict = (f"fits in the low-RAM mode (the GPU holds ~{100 * low_ram_gpu_share(m, low_ram_vram(gpu)):.0f}% "
|
||||
"of its experts, " + ("the rest stays in RAM)" if low_ram_resident(m, ram, low_ram_vram(gpu))
|
||||
else "the rest is read from the SSD as needed)"))
|
||||
any_fits = any_fits or not verdict.startswith("does not fit")
|
||||
say(f" {m:8s} needs ~{d['ram_gb']} GB RAM: {verdict}")
|
||||
@@ -4201,10 +4387,13 @@ def main() -> int:
|
||||
if a.family:
|
||||
family = a.family
|
||||
else:
|
||||
rec_fam = STRIX_HALO_FAMILY if strix_halo_recommends(gpu, ram) and STRIX_HALO_FAMILY in fams else fams[0]
|
||||
for i, f in enumerate(fams, 1):
|
||||
d = FAMILIES[f]
|
||||
say(f" {i}) {d['title']:20s} {d['by']} - {d['about']}" + (" [experimental]" if d.get("experimental") else ""))
|
||||
family = fams[int(ask("Which model?", [str(i) for i in range(1, len(fams) + 1)], "1", a.yes)) - 1]
|
||||
say(f" {i}) {d['title']:20s} {d['by']} - {d['about']}" + (" [experimental]" if d.get("experimental") else "")
|
||||
+ (f" (recommended for Strix Halo: {STRIX_HALO_MODEL})" if f == rec_fam and rec_fam != fams[0] else ""))
|
||||
family = fams[int(ask("Which model?", [str(i) for i in range(1, len(fams) + 1)],
|
||||
str(fams.index(rec_fam) + 1), a.yes)) - 1]
|
||||
fam = FAMILIES[family]
|
||||
ok(f"model: {fam['title']}")
|
||||
if fam.get("license"):
|
||||
@@ -4226,9 +4415,9 @@ def main() -> int:
|
||||
say(f" {i}) {m} {d['about']}; download {d['download_gb']:.0f} GB, keeps ~"
|
||||
f"{resident_budget_gib(m, ram)} GB of its {d['arena_gb']:.0f} GB of experts in RAM{fit}")
|
||||
continue
|
||||
if low_ram_needed(m, ram) and low_ram_fits(m, ram, gpu["vram_gb"]) and a.low_ram != "off":
|
||||
fit = (f" <- fits in the low-RAM mode (the GPU holds ~{100 * low_ram_gpu_share(m, gpu['vram_gb']):.0f}%, "
|
||||
+ ("the rest in RAM)" if low_ram_resident(m, ram, gpu["vram_gb"]) else "the rest from the SSD)"))
|
||||
if low_ram_needed(m, ram) and low_ram_fits(m, ram, low_ram_vram(gpu)) and a.low_ram != "off":
|
||||
fit = (f" <- fits in the low-RAM mode (the GPU holds ~{100 * low_ram_gpu_share(m, low_ram_vram(gpu)):.0f}%, "
|
||||
+ ("the rest in RAM)" if low_ram_resident(m, ram, low_ram_vram(gpu)) else "the rest from the SSD)"))
|
||||
say(f" {i}) {m:8s} {d['about']}; download {d['download_gb']:.0f} GB, uses ~{d['arena_gb']:.0f} GB of RAM{fit}")
|
||||
rec = str(names.index("IQ3_XXS") + 1) if ram >= 60 and "IQ3_XXS" in names else "1"
|
||||
model = a.model or names[int(ask("Which size?", [str(i) for i in range(1, len(names) + 1)], rec, a.yes)) - 1]
|
||||
@@ -4358,13 +4547,13 @@ def main() -> int:
|
||||
resident = False
|
||||
if low_ram:
|
||||
arena = MODELS[model]["arena_gb"]
|
||||
vram = gpu["vram_gb"] - (VISION[vision]["reserve_mib"] / 1024 if vision != "none" else 0)
|
||||
vram = low_ram_vram(gpu) - (VISION[vision]["reserve_mib"] / 1024 if vision != "none" else 0)
|
||||
share = low_ram_gpu_share(model, vram, ctx, kv)
|
||||
rest = arena - low_ram_gpu_gb(model, vram, ctx, kv)
|
||||
resident = a.low_ram == "resident" or (a.low_ram != "mmap" and low_ram_resident(model, ram, vram, ctx, kv))
|
||||
if multi: # every chosen card's share (the image encoder on the main one); #364 #384: the mapped variant
|
||||
held = min(arena, low_ram_gpu_gb(model, vram, ctx, kv) +
|
||||
sum(low_ram_gpu_gb(model, x["vram_gb"], ctx, kv) for x in chosen[1:]))
|
||||
sum(low_ram_gpu_gb(model, low_ram_vram(x), ctx, kv) for x in chosen[1:]))
|
||||
share, rest = held / arena, arena - held
|
||||
# #642: the resident variant on a split, by the same rule as on one card - what no card holds fits the RAM
|
||||
resident = resident_split() and (a.low_ram == "resident" or
|
||||
|
||||
@@ -256,7 +256,7 @@ class WindowsDetection(unittest.TestCase):
|
||||
("AMD Radeon RX 9060 XT", "gfx1200"), ("AMD Radeon RX 7900 GRE", "gfx1100"),
|
||||
("AMD Radeon PRO W7800", "gfx1100"), ("AMD Radeon RX 7700 XT", "gfx1101"),
|
||||
("AMD Radeon RX 7600", "gfx1102"), ("AMD Radeon RX 6950 XT", "gfx1030"),
|
||||
("AMD Radeon RX 6800M", ""), ("AMD Radeon 780M Graphics", ""), ("AMD Radeon RX 7700S", "")):
|
||||
("AMD Radeon RX 6800M", ""), ("AMD Radeon 780M Graphics", "gfx1103"), ("AMD Radeon RX 7700S", "")):
|
||||
self.assertEqual(setup.win_amd_arch(None, name), arch, name)
|
||||
self.assertEqual(setup.win_amd_arch(0x744C, "whatever"), "gfx1100")
|
||||
|
||||
|
||||
@@ -0,0 +1,463 @@
|
||||
"""Tests for setup.py's recognition of AMD Strix Halo (Ryzen AI Max, Radeon 8060S / 8050S / 8040S, gfx1151): the exact
|
||||
arch check (never a prefix: gfx1150 / gfx1152 are other chips), the PCI ids and marketing names, the unified-memory
|
||||
sizing, which card setup picks beside a discrete one, and the Windows engine zip (a zip without gfx1151 code is never used).
|
||||
|
||||
The Linux fixture is Aurora's real answer (the maintainers' Strix Halo box, read-only):
|
||||
KFD node 1: gfx_target_version 110501, simd_count 80, vendor_id 4098, device_id 5510 (0x1586), drm_render_minor 128
|
||||
/sys/class/drm/card1/device: vendor 0x1002, device 0x1586, mem_info_vram_total 2147483648 (a 2 GiB BIOS carve-out),
|
||||
mem_info_gtt_total 120259084288 (112 GiB: ttm.pages_limit=29360128), no product_name
|
||||
lspci -nn: c6:00.0 Display controller [0380]: AMD/ATI Strix Halo [Radeon Graphics / Radeon 8050S Graphics /
|
||||
Radeon 8060S Graphics] [1002:1586] (rev c1); MemTotal 127098456 kB
|
||||
The other chips are synthetic (their KFD gfx_target_version and pci.ids ids). No GPU, no ROCm, no downloads.
|
||||
|
||||
python -m unittest tools.test_setup_strix_halo
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT))
|
||||
import setup # noqa: E402
|
||||
|
||||
AURORA_RAM_GB = 127098456 * 1024 / 2 ** 30 # /proc/meminfo MemTotal on Aurora: 121.2 GiB
|
||||
GIB = 1 << 30
|
||||
|
||||
|
||||
def fake_gpu(root: Path, node: int, ver: int, simd: int, minor: int, pci_id: int, vram: int, gtt: int,
|
||||
product: str | None = None, card: int | None = None) -> None:
|
||||
"""One KFD GPU node + its drm device, laid out as the kernel does (see the module docstring)."""
|
||||
n = root / "class/kfd/kfd/topology/nodes" / str(node)
|
||||
n.mkdir(parents=True, exist_ok=True)
|
||||
(n / "properties").write_text(f"cpu_cores_count 0\nsimd_count {simd}\nmem_banks_count 1\n"
|
||||
f"gfx_target_version {ver}\nvendor_id 4098\ndevice_id {pci_id}\n"
|
||||
f"drm_render_minor {minor}\nlocal_mem_size 0\n")
|
||||
d = root / f"class/drm/renderD{minor}/device"
|
||||
d.mkdir(parents=True, exist_ok=True)
|
||||
for name, val in (("vendor", "0x1002"), ("device", f"0x{pci_id:04x}"), ("mem_info_vram_total", str(vram)),
|
||||
("mem_info_gtt_total", str(gtt))):
|
||||
(d / name).write_text(val + "\n")
|
||||
if product:
|
||||
(d / "product_name").write_text(product + "\n")
|
||||
if card is not None: # /sys/class/drm/card<N>/device (what amd_pci_devices reads)
|
||||
c = root / f"class/drm/card{card}/device"
|
||||
c.mkdir(parents=True, exist_ok=True)
|
||||
for name in ("vendor", "device", "mem_info_vram_total", "mem_info_gtt_total"):
|
||||
(c / name).write_text((d / name).read_text())
|
||||
|
||||
|
||||
def cpu_node(root: Path, node: int = 0) -> None:
|
||||
n = root / "class/kfd/kfd/topology/nodes" / str(node)
|
||||
n.mkdir(parents=True, exist_ok=True)
|
||||
(n / "properties").write_text("cpu_cores_count 32\nsimd_count 0\ngfx_target_version 0\nvendor_id 0\ndevice_id 0\n")
|
||||
|
||||
|
||||
class LinuxBase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.root = Path(self.tmp.name)
|
||||
self.win = setup.WIN
|
||||
setup.WIN = False
|
||||
p = mock.patch.object(setup, "ram_gb", return_value=AURORA_RAM_GB)
|
||||
p.start()
|
||||
self.addCleanup(p.stop)
|
||||
|
||||
def tearDown(self):
|
||||
setup.WIN = self.win
|
||||
self.tmp.cleanup()
|
||||
|
||||
def aurora(self, node=1, minor=128, card=1):
|
||||
fake_gpu(self.root, node, 110501, 80, minor, 0x1586, 2 * GIB, 120259084288, None, card)
|
||||
|
||||
|
||||
class ExactArch(unittest.TestCase):
|
||||
def test_gfx1151_is_exact(self):
|
||||
self.assertTrue(setup.gfx_arch_is("gfx1151", "gfx1151"))
|
||||
self.assertTrue(setup.gfx_arch_is("gfx1151:sramecc-:xnack-", "gfx1151")) # gcnArchName
|
||||
for other in ("gfx1150", "gfx1152", "gfx115", "gfx11510", "gfx1103", "gfx1100", "gfx1201", "gfx1030", "", None):
|
||||
self.assertFalse(setup.gfx_arch_is(other, "gfx1151"), other)
|
||||
self.assertFalse(setup.is_strix_halo({"arch": other}), other)
|
||||
self.assertFalse(setup.gfx_arch_is("gfx1151", "gfx115")) # no prefix match either way
|
||||
self.assertFalse(setup.is_strix_halo({}))
|
||||
|
||||
def test_matches_the_engines_header(self):
|
||||
"""include/strata/kernels/gfx_arch.hpp is the reference: gfx1151 has the WMMA kernels and the gfx1151 defaults;
|
||||
gfx1103 and gfx1152 are outside its list."""
|
||||
hpp = (ROOT / "include/strata/kernels/gfx_arch.hpp").read_text(encoding="utf-8")
|
||||
wmma = re.search(r"gfx_arch_is_gfx11_wmma.*?\n}", hpp, re.S).group(0)
|
||||
listed = set(re.findall(r'"(gfx\d+)"', wmma))
|
||||
self.assertIn("gfx1151", listed)
|
||||
self.assertNotIn("gfx1103", listed)
|
||||
self.assertNotIn("gfx1152", listed)
|
||||
self.assertIn('gfx_arch_is(gcn, "gfx1151")', hpp)
|
||||
self.assertEqual(setup.STRIX_HALO_ARCH, "gfx1151")
|
||||
|
||||
def test_arch_lists(self):
|
||||
self.assertIn("gfx1151", setup.AMD_ARCHS)
|
||||
self.assertIn("gfx1151", setup.ROCM_INDEXES)
|
||||
self.assertTrue(setup.ROCM_INDEXES["gfx1151"].endswith("/gfx1151/"))
|
||||
for a in ("gfx1150", "gfx1152", "gfx1103"): # never supported by accident
|
||||
self.assertNotIn(a, setup.AMD_ARCHS)
|
||||
self.assertIn("docs/STRIX_HALO.md", setup.AMD_CARDS)
|
||||
|
||||
|
||||
class PciIds(unittest.TestCase):
|
||||
def test_strix_halo_id(self):
|
||||
# pci.ids: one id for every Strix Halo part (8060S, 8050S, 8040S share it; they differ by CU count)
|
||||
self.assertEqual(setup.STRIX_HALO_PCI_IDS, {0x1586})
|
||||
self.assertEqual(setup.AMD_IGPU_PCI[0x1586], "gfx1151")
|
||||
|
||||
def test_other_igpus_are_not_strix_halo(self):
|
||||
for did, arch in ((0x150E, "gfx1150"), (0x1114, "gfx1152"), (0x1902, "gfx1152"), (0x15BF, "gfx1103"),
|
||||
(0x15C8, "gfx1103"), (0x164F, "gfx1103"), (0x1900, "gfx1103"), (0x1901, "gfx1103")):
|
||||
self.assertEqual(setup.AMD_IGPU_PCI[did], arch)
|
||||
self.assertNotIn(did, setup.STRIX_HALO_PCI_IDS)
|
||||
self.assertEqual([a for a in setup.AMD_IGPU_PCI.values() if a == "gfx1151"], ["gfx1151"])
|
||||
|
||||
def test_windows_id_then_name(self):
|
||||
f = setup.win_amd_arch
|
||||
self.assertEqual(f(0x1586, ""), "gfx1151")
|
||||
self.assertEqual(f(0x1586, "AMD Radeon(TM) Graphics"), "gfx1151") # the generic name Windows may show
|
||||
for name in ("AMD Radeon(TM) 8060S Graphics", "AMD Radeon(TM) 8050S Graphics", "AMD Radeon(TM) 8040S Graphics"):
|
||||
self.assertEqual(f(None, name), "gfx1151", name) # an id we do not know: by name
|
||||
self.assertEqual(f(0x150E, "AMD Radeon(TM) 890M Graphics"), "gfx1150")
|
||||
self.assertEqual(f(None, "AMD Radeon(TM) 880M Graphics"), "gfx1150")
|
||||
self.assertEqual(f(None, "AMD Radeon(TM) 860M Graphics"), "gfx1152")
|
||||
self.assertEqual(f(None, "AMD Radeon(TM) 840M Graphics"), "gfx1152")
|
||||
self.assertEqual(f(0x15BF, "AMD Radeon(TM) 780M Graphics"), "gfx1103")
|
||||
self.assertEqual(f(None, "AMD Radeon(TM) 760M Graphics"), "gfx1103")
|
||||
# the discrete cards keep their own arch
|
||||
self.assertEqual(f(0x744C, "AMD Radeon RX 7900 XTX"), "gfx1100")
|
||||
self.assertEqual(f(None, "AMD Radeon RX 7900 XTX"), "gfx1100")
|
||||
self.assertEqual(f(0x7550, "AMD Radeon RX 9070 XT"), "gfx1201")
|
||||
self.assertEqual(f(None, "AMD Radeon RX 7600M XT"), "gfx1102") # not the 780M rule
|
||||
self.assertEqual(f(None, "AMD Radeon RX 6800M"), "")
|
||||
|
||||
|
||||
class AuroraFixture(LinuxBase):
|
||||
def test_aurora(self):
|
||||
cpu_node(self.root, 0)
|
||||
self.aurora()
|
||||
g = setup.amd_gpus(str(self.root))
|
||||
self.assertEqual(len(g), 1)
|
||||
g = g[0]
|
||||
self.assertEqual((g["index"], g["arch"], g["pci_id"]), (0, "gfx1151", 0x1586))
|
||||
self.assertEqual(g["name"], "AMD Radeon 8060S (Ryzen AI Max, Strix Halo, gfx1151)") # 80 SIMDs = 40 CUs
|
||||
self.assertIsNone(setup.amd_problem(g))
|
||||
self.assertTrue(g["uma"] and setup.is_strix_halo(g))
|
||||
self.assertAlmostEqual(g["dedicated_gb"], 2.0) # the BIOS carve-out
|
||||
self.assertAlmostEqual(g["shared_gb"], 112.0) # GTT, below RAM - 6
|
||||
self.assertAlmostEqual(g["vram_gb"], 114.0)
|
||||
self.assertAlmostEqual(setup.low_ram_vram(g), 2.0) # the shared pool is the RAM itself
|
||||
self.assertIn("unified memory", setup.amd_mem_text(g))
|
||||
|
||||
def test_marketing_name_by_cu_count(self):
|
||||
for simd, name in ((80, "8060S"), (64, "8050S"), (32, "8040S")):
|
||||
root = Path(tempfile.mkdtemp(dir=self.root))
|
||||
fake_gpu(root, 0, 110501, simd, 128, 0x1586, 2 * GIB, 112 * GIB)
|
||||
g = setup.amd_gpus(str(root))[0]
|
||||
self.assertIn(name, g["name"])
|
||||
self.assertEqual(g["arch"], "gfx1151")
|
||||
root = Path(tempfile.mkdtemp(dir=self.root))
|
||||
fake_gpu(root, 0, 110501, 48, 128, 0x1586, 2 * GIB, 112 * GIB) # an unknown CU count
|
||||
self.assertEqual(setup.amd_gpus(str(root))[0]["name"], setup.AMD_NAMES["gfx1151"])
|
||||
|
||||
def test_name_from_sysfs_is_kept(self):
|
||||
fake_gpu(self.root, 0, 110501, 80, 128, 0x1586, 2 * GIB, 120259084288, "AMD Radeon 8060S")
|
||||
self.assertEqual(setup.amd_gpus(str(self.root))[0]["name"], "AMD Radeon 8060S")
|
||||
|
||||
def test_pci_scan(self):
|
||||
self.aurora()
|
||||
d = setup.amd_pci_devices(str(self.root))
|
||||
self.assertEqual([(x["pci_id"], x["arch"]) for x in d], [(0x1586, "gfx1151")])
|
||||
self.assertAlmostEqual(d[0]["gtt_gb"], 112.0)
|
||||
self.assertIn(d[0]["pci_id"], setup.STRIX_HALO_PCI_IDS)
|
||||
|
||||
def test_gtt_never_exceeds_the_ram(self):
|
||||
fake_gpu(self.root, 0, 110501, 80, 128, 0x1586, 512 << 20, 200 * GIB) # a bogus 200 GiB GTT
|
||||
g = setup.amd_gpus(str(self.root))[0]
|
||||
self.assertAlmostEqual(g["shared_gb"], AURORA_RAM_GB - setup.UMA_OS_LEFT_GB)
|
||||
|
||||
def test_no_gtt_file_means_half_the_ram(self):
|
||||
fake_gpu(self.root, 0, 110501, 80, 128, 0x1586, 2 * GIB, 0)
|
||||
g = setup.amd_gpus(str(self.root))[0]
|
||||
self.assertAlmostEqual(g["shared_gb"], AURORA_RAM_GB / 2)
|
||||
|
||||
def test_big_carve_out(self):
|
||||
fake_gpu(self.root, 0, 110501, 80, 128, 0x1586, 96 * GIB, 24 * GIB) # 96 GB carve-out, 32 GB left
|
||||
with mock.patch.object(setup, "ram_gb", return_value=30.0):
|
||||
g = setup.amd_gpus(str(self.root))[0]
|
||||
self.assertAlmostEqual(g["dedicated_gb"], 96.0)
|
||||
self.assertAlmostEqual(g["vram_gb"], 96.0 + 24.0)
|
||||
self.assertAlmostEqual(setup.low_ram_vram(g), 96.0) # that memory is extra to the RAM
|
||||
notes = setup.strix_halo_notes(g, 30.0)
|
||||
self.assertTrue(any(n.startswith("!") and "carve-out" in n for n in notes))
|
||||
|
||||
def test_small_carve_out(self):
|
||||
fake_gpu(self.root, 0, 110501, 80, 128, 0x1586, 512 << 20, 60 * GIB) # 512 MB carve-out
|
||||
g = setup.amd_gpus(str(self.root))[0]
|
||||
self.assertAlmostEqual(g["dedicated_gb"], 0.5)
|
||||
|
||||
|
||||
class OtherChips(LinuxBase):
|
||||
"""Synthetic KFD nodes: gfx_target_version as the kernel reports it."""
|
||||
|
||||
def one(self, ver, pci, vram, gtt=0):
|
||||
root = Path(tempfile.mkdtemp(dir=self.root))
|
||||
fake_gpu(root, 0, ver, 64, 128, pci, vram, gtt)
|
||||
return setup.amd_gpus(str(root))[0]
|
||||
|
||||
def test_strix_point(self):
|
||||
g = self.one(110500, 0x150E, 512 << 20, 60 * GIB)
|
||||
self.assertEqual(g["arch"], "gfx1150")
|
||||
self.assertFalse(setup.is_strix_halo(g) or g.get("uma"))
|
||||
self.assertIn("gfx1150", setup.amd_problem(g))
|
||||
self.assertIn("not Strix Halo", setup.amd_problem(g))
|
||||
self.assertIn("890M", g["name"])
|
||||
|
||||
def test_krackan(self):
|
||||
g = self.one(110502, 0x1114, 512 << 20, 30 * GIB)
|
||||
self.assertEqual(g["arch"], "gfx1152")
|
||||
self.assertFalse(g.get("uma"))
|
||||
self.assertIn("gfx1152", setup.amd_problem(g))
|
||||
self.assertIn("860M", g["name"])
|
||||
|
||||
def test_phoenix_hawk_point(self):
|
||||
g = self.one(110003, 0x15BF, 512 << 20, 30 * GIB)
|
||||
self.assertEqual(g["arch"], "gfx1103")
|
||||
self.assertFalse(g.get("uma"))
|
||||
self.assertIn("gfx1103", setup.amd_problem(g))
|
||||
self.assertIn("780M", g["name"])
|
||||
|
||||
def test_discrete_cards(self):
|
||||
for ver, arch, pci, vram in ((110000, "gfx1100", 0x744C, 24), (110001, "gfx1101", 0x747E, 16),
|
||||
(110002, "gfx1102", 0x7480, 8), (120001, "gfx1201", 0x7550, 16),
|
||||
(100300, "gfx1030", 0x73BF, 16)):
|
||||
g = self.one(ver, pci, vram * GIB, 32 * GIB)
|
||||
self.assertEqual(g["arch"], arch)
|
||||
self.assertFalse(g.get("uma"), arch)
|
||||
self.assertFalse(setup.is_strix_halo(g), arch)
|
||||
self.assertAlmostEqual(g["vram_gb"], vram) # a card's VRAM is not changed
|
||||
self.assertEqual(setup.low_ram_vram(g), vram)
|
||||
self.assertEqual(setup.amd_problem(g) is None, arch != "gfx1102", arch)
|
||||
|
||||
|
||||
class DualGpu(LinuxBase):
|
||||
def test_strix_halo_with_a_discrete_card(self):
|
||||
cpu_node(self.root, 0)
|
||||
fake_gpu(self.root, 1, 110501, 80, 128, 0x1586, 2 * GIB, 112 * GIB, None, 1)
|
||||
fake_gpu(self.root, 2, 110000, 192, 129, 0x744C, 24 * GIB, 16 * GIB, "AMD Radeon RX 7900 XTX", 2)
|
||||
g = setup.amd_gpus(str(self.root))
|
||||
self.assertEqual([(x["index"], x["arch"]) for x in g], [(0, "gfx1151"), (1, "gfx1100")])
|
||||
self.assertTrue(g[0]["uma"] and not g[1].get("uma"))
|
||||
self.assertTrue(g[0]["vram_gb"] > g[1]["vram_gb"]) # 114 GB of unified memory vs 24
|
||||
self.assertEqual(min(g, key=setup.amd_rank)["arch"], "gfx1100") # the card with its own memory
|
||||
self.assertEqual([x["arch"] for x in setup.amd_parse_gpus("all", g)], ["gfx1100", "gfx1151"])
|
||||
self.assertEqual([x["arch"] for x in setup.amd_parse_gpus("0,1", g)], ["gfx1151", "gfx1100"])
|
||||
self.assertEqual(sorted(a for a in {x["arch"] for x in g}), ["gfx1100", "gfx1151"]) # compiled for both if split
|
||||
# two TheRock families: a split needs a system ROCm (rocm_root says so); one card does not
|
||||
self.assertNotEqual(setup.ROCM_INDEXES["gfx1100"], setup.ROCM_INDEXES["gfx1151"])
|
||||
|
||||
def test_strix_halo_with_strix_point_is_impossible_but_not_confused(self):
|
||||
cpu_node(self.root, 0)
|
||||
fake_gpu(self.root, 1, 110500, 32, 128, 0x150E, 512 << 20, 30 * GIB)
|
||||
fake_gpu(self.root, 2, 110501, 80, 129, 0x1586, 2 * GIB, 112 * GIB)
|
||||
g = setup.amd_gpus(str(self.root))
|
||||
self.assertEqual([x["arch"] for x in g], ["gfx1150", "gfx1151"])
|
||||
self.assertEqual([bool(setup.amd_problem(x)) for x in g], [True, False])
|
||||
self.assertEqual([bool(x.get("uma")) for x in g], [False, True])
|
||||
usable = [x for x in g if setup.amd_problem(x) is None]
|
||||
self.assertEqual(min(usable, key=setup.amd_rank)["index"], 1)
|
||||
|
||||
def test_two_strix_halo_ranked_by_index(self):
|
||||
fake_gpu(self.root, 0, 110501, 80, 128, 0x1586, 2 * GIB, 112 * GIB)
|
||||
fake_gpu(self.root, 1, 110501, 80, 129, 0x1586, 2 * GIB, 112 * GIB)
|
||||
g = setup.amd_gpus(str(self.root))
|
||||
self.assertEqual(min(g, key=setup.amd_rank)["index"], 0)
|
||||
|
||||
|
||||
class WindowsDetection(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.win = setup.WIN
|
||||
setup.WIN = True
|
||||
p = mock.patch.object(setup, "ram_gb", return_value=96.0)
|
||||
p.start()
|
||||
self.addCleanup(p.stop)
|
||||
self.addCleanup(lambda: setattr(setup, "WIN", self.win))
|
||||
|
||||
def adapters(self):
|
||||
return ([{"name": "AMD Radeon(TM) 8060S Graphics", "pnp": r"PCI\VEN_1002&DEV_1586&SUBSYS_1C3E1D05&REV_C1\4&2",
|
||||
"ram": 4294967295}],
|
||||
[{"DriverDesc": "AMD Radeon(TM) 8060S Graphics",
|
||||
"MatchingDeviceId": r"PCI\VEN_1002&DEV_1586&REV_C1", "HardwareInformation.qwMemorySize": 4 * GIB,
|
||||
"DriverVersion": "32.0.21013.1000"}])
|
||||
|
||||
def test_strix_halo(self):
|
||||
ad, reg = self.adapters()
|
||||
g = setup.amd_gpus_windows(ad, reg)
|
||||
self.assertEqual(len(g), 1)
|
||||
self.assertEqual((g[0]["arch"], g[0]["pci_id"]), ("gfx1151", 0x1586))
|
||||
self.assertIsNone(setup.amd_problem(g[0]))
|
||||
self.assertTrue(g[0]["uma"])
|
||||
self.assertAlmostEqual(g[0]["dedicated_gb"], 4.0) # the registry's carve-out
|
||||
self.assertAlmostEqual(g[0]["shared_gb"], 48.0) # Windows: half the RAM
|
||||
self.assertAlmostEqual(g[0]["vram_gb"], 52.0)
|
||||
self.assertEqual(g[0]["name"], "AMD Radeon(TM) 8060S Graphics")
|
||||
|
||||
def test_strix_halo_and_a_7900_xtx(self):
|
||||
ad, reg = self.adapters()
|
||||
ad.append({"name": "AMD Radeon RX 7900 XTX", "pnp": r"PCI\VEN_1002&DEV_744C&SUBSYS_1&REV_C8\4&3", "ram": 0})
|
||||
reg.append({"DriverDesc": "AMD Radeon RX 7900 XTX", "MatchingDeviceId": r"PCI\VEN_1002&DEV_744C&REV_C8",
|
||||
"HardwareInformation.qwMemorySize": 24 * GIB, "DriverVersion": "32.0.21013.1000"})
|
||||
g = setup.amd_gpus_windows(ad, reg)
|
||||
self.assertEqual([x["arch"] for x in g], ["gfx1151", "gfx1100"])
|
||||
self.assertTrue(g[0]["uma"] and not g[1].get("uma"))
|
||||
self.assertEqual(min(g, key=setup.amd_rank)["arch"], "gfx1100")
|
||||
|
||||
def test_other_integrated_radeons(self):
|
||||
for did, name, arch in ((0x150E, "AMD Radeon(TM) 890M Graphics", "gfx1150"),
|
||||
(0x1114, "AMD Radeon(TM) 860M Graphics", "gfx1152"),
|
||||
(0x15BF, "AMD Radeon(TM) 780M Graphics", "gfx1103")):
|
||||
ad = [{"name": name, "pnp": rf"PCI\VEN_1002&DEV_{did:04X}&REV_C1\4&2", "ram": 512 << 20}]
|
||||
g = setup.amd_gpus_windows(ad, [])[0]
|
||||
self.assertEqual(g["arch"], arch)
|
||||
self.assertFalse(g.get("uma"))
|
||||
self.assertIsNotNone(setup.amd_problem(g))
|
||||
|
||||
def test_hip_listing_of_strix_halo(self):
|
||||
"""Once the HIP engine is installed the cards are numbered as HIP lists them; the carve-out still comes from the
|
||||
registry, and an APU's HIP figure never lowers the GPU's memory."""
|
||||
ad, reg = self.adapters()
|
||||
text = "device 0: AMD Radeon(TM) 8060S Graphics\n arch gfx1151, 64.0 GiB\ndevice 1: AMD Radeon RX 7900 XTX\n arch gfx1100, 24.0 GiB\n"
|
||||
hip = setup.hip_devices(text=text)
|
||||
self.assertEqual([x["arch"] for x in hip], ["gfx1151", "gfx1100"])
|
||||
with mock.patch.object(setup, "hip_devices", return_value=hip), \
|
||||
mock.patch.object(setup, "amd_gpus_windows", return_value=setup.amd_gpus_windows(ad, reg)):
|
||||
g = setup.amd_gpus_win()
|
||||
self.assertTrue(g[0]["uma"])
|
||||
self.assertAlmostEqual(g[0]["dedicated_gb"], 4.0)
|
||||
self.assertGreaterEqual(g[0]["vram_gb"], 64.0)
|
||||
self.assertFalse(g[1].get("uma"))
|
||||
self.assertAlmostEqual(g[1]["vram_gb"], 24.0)
|
||||
|
||||
|
||||
class WindowsZip(unittest.TestCase):
|
||||
"""get_prebuilt_hip never installs a zip with no code for the card; for a Strix Halo it says why and what to do."""
|
||||
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.tmp.cleanup)
|
||||
self.root = Path(self.tmp.name)
|
||||
self.warnings: list[str] = []
|
||||
for p in (mock.patch.object(setup, "ROOT", self.root), mock.patch.object(setup, "warn", self.warnings.append),
|
||||
mock.patch.object(setup, "say", lambda *a, **k: None), mock.patch.object(setup, "ok", lambda *a, **k: None),
|
||||
mock.patch.object(setup, "download", self.fake_download),
|
||||
mock.patch.object(setup.urllib.request, "urlopen", lambda *a, **k: io.BytesIO(b"")),
|
||||
mock.patch.object(setup, "hip_runtime_beside_exe", lambda eng: None)):
|
||||
p.start()
|
||||
self.addCleanup(p.stop)
|
||||
self.archs = ["gfx1100", "gfx1101", "gfx1102", "gfx1200", "gfx1201", "gfx1030"] # the 0.1.39 zip
|
||||
|
||||
def fake_download(self, url, dest, label=""):
|
||||
with zipfile.ZipFile(dest, "w") as z:
|
||||
z.writestr("BUILD.json", json.dumps({"source": "prebuilt", "backend": "hip", "platform": "windows-x64",
|
||||
"version": "0.1.40", "archs": self.archs, "lib_dirs": []}))
|
||||
z.writestr(setup.EXE, "x")
|
||||
|
||||
def halo(self):
|
||||
return {"index": 0, "name": setup.AMD_NAMES["gfx1151"], "vram_gb": 52.0, "arch": "gfx1151", "uma": True,
|
||||
"dedicated_gb": 4.0, "shared_gb": 48.0, "vendor": "amd", "driver": "amd"}
|
||||
|
||||
def test_zip_without_gfx1151_is_refused_with_the_reason(self):
|
||||
self.assertIsNone(setup.get_prebuilt_hip("https://example.invalid/", self.halo()))
|
||||
self.assertEqual(len(self.warnings), 1)
|
||||
msg = self.warnings[0]
|
||||
self.assertIn("no gfx1151 code", msg)
|
||||
self.assertIn("docs/STRIX_HALO.md", msg)
|
||||
self.assertIn("build_windows.bat", msg)
|
||||
self.assertFalse((self.root / "engine" / "strata-windows-x64-hip.zip").exists()) # dropped
|
||||
self.assertFalse((self.root / "engine" / setup.EXE).exists()) # nothing installed
|
||||
|
||||
def test_zip_with_gfx1151_is_installed(self):
|
||||
self.archs = self.archs + ["gfx1151"]
|
||||
eng = setup.get_prebuilt_hip("https://example.invalid/", self.halo())
|
||||
self.assertEqual(eng, self.root / "engine")
|
||||
self.assertEqual(self.warnings, [])
|
||||
meta = json.loads((eng / "BUILD.json").read_text(encoding="utf-8"))
|
||||
self.assertIn("gfx1151", meta["archs"])
|
||||
|
||||
def test_a_7900_xtx_still_takes_the_old_zip(self):
|
||||
g = {"index": 0, "name": "x", "vram_gb": 24.0, "arch": "gfx1100", "vendor": "amd", "driver": "amd"}
|
||||
self.assertIsNotNone(setup.get_prebuilt_hip("https://example.invalid/", g))
|
||||
|
||||
def test_windows_build_script_lists_gfx1151(self):
|
||||
bat = (ROOT / "tools/hip/build_windows.bat").read_text(encoding="utf-8")
|
||||
m = re.search(r'if not defined STRATA_HIP_ARCHS set "STRATA_HIP_ARCHS=([^"]+)"', bat)
|
||||
self.assertIn("gfx1151", m.group(1).split(";"))
|
||||
self.assertTrue({"gfx1100", "gfx1101", "gfx1102", "gfx1200", "gfx1201", "gfx1030"} <= set(m.group(1).split(";")))
|
||||
|
||||
|
||||
class Recommendation(unittest.TestCase):
|
||||
def halo(self, carve=2.0):
|
||||
return {"arch": "gfx1151", "uma": True, "dedicated_gb": carve, "shared_gb": 100.0, "vram_gb": carve + 100.0}
|
||||
|
||||
def test_ud_iq4_xs_with_enough_memory(self):
|
||||
self.assertEqual((setup.STRIX_HALO_FAMILY, setup.STRIX_HALO_MODEL), ("unsloth", "UD-IQ4_XS"))
|
||||
self.assertIn(setup.STRIX_HALO_MODEL, setup.MODELS)
|
||||
self.assertIn(setup.STRIX_HALO_FAMILY, setup.FAMILIES)
|
||||
self.assertTrue(setup.strix_halo_recommends(self.halo(), AURORA_RAM_GB))
|
||||
self.assertTrue(setup.strix_halo_recommends(self.halo(), 128.0))
|
||||
self.assertTrue(setup.strix_halo_recommends(self.halo(32.0), 60.0)) # 32 GB carve-out + 60 GB RAM
|
||||
self.assertFalse(setup.strix_halo_recommends(self.halo(), 62.0)) # a 64 GB box: no recommendation
|
||||
self.assertFalse(setup.strix_halo_recommends(self.halo(), 30.0))
|
||||
self.assertFalse(setup.strix_halo_recommends({"arch": "gfx1100", "vram_gb": 24.0}, 256.0))
|
||||
self.assertFalse(setup.strix_halo_recommends({"arch": "gfx1150", "vram_gb": 0.5}, 256.0))
|
||||
|
||||
def test_the_recommended_model_is_a_regular_choice_on_amd(self):
|
||||
m = setup.MODELS[setup.STRIX_HALO_MODEL]
|
||||
self.assertFalse(m.get("nvidia_only"))
|
||||
self.assertFalse(m.get("experimental"))
|
||||
|
||||
def test_notes_are_recommendations(self):
|
||||
win = setup.WIN
|
||||
try:
|
||||
setup.WIN = False
|
||||
g = {**self.halo(), "shared_gb": 60.0, "vram_gb": 62.0}
|
||||
notes = setup.strix_halo_notes(g, AURORA_RAM_GB)
|
||||
joined = "\n".join(notes)
|
||||
self.assertIn("docs/STRIX_HALO.md", joined)
|
||||
self.assertIn("UD-IQ4_XS", joined)
|
||||
self.assertTrue(any(n.startswith("!") and "ttm.pages_limit" in n for n in notes)) # a small GTT: a warning
|
||||
self.assertIn("changes no host setting", joined)
|
||||
big = {**self.halo(), "shared_gb": 112.0, "vram_gb": 114.0}
|
||||
self.assertFalse(any(n.startswith("!") for n in setup.strix_halo_notes(big, AURORA_RAM_GB)))
|
||||
finally:
|
||||
setup.WIN = win
|
||||
|
||||
def test_hipblaslt_table_for_gfx1151(self):
|
||||
t = setup.hipblaslt_table("gfx1151", [], 100401)
|
||||
self.assertIsNotNone(t)
|
||||
self.assertEqual(t.name, "gfx1151-hipblaslt-100401.txt")
|
||||
|
||||
|
||||
class LowRamUsesTheCarveOutOnly(unittest.TestCase):
|
||||
def test_apu_memory_is_not_double_counted(self):
|
||||
halo = {"arch": "gfx1151", "uma": True, "dedicated_gb": 2.0, "shared_gb": 112.0, "vram_gb": 114.0, "index": 0}
|
||||
card = {"arch": "gfx1100", "vram_gb": 24.0, "index": 0}
|
||||
self.assertEqual(setup.low_ram_vram(halo), 2.0)
|
||||
self.assertEqual(setup.low_ram_vram(card), 24.0)
|
||||
# a 32 GB-RAM Strix Halo: the smallest model is not "made to fit" by counting the GPU's shared memory as extra
|
||||
self.assertFalse(setup.low_ram_fits("IQ1_M", 24.0, setup.low_ram_vram(halo)))
|
||||
self.assertTrue(setup.low_ram_fits("IQ1_M", 24.0, 40.0)) # a 40 GB dedicated card does
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user