Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
setup: arch-exact iGPU text (gfx1103 is not Strix Halo), warn on a missing render group or /dev/kfd access, engine names it instead of blaming another program; troubleshooting entry for Windows AMD driver resets
Niko12219993c622091e
diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.mdindex bea6135cc..941390ffd 100644--- a/docs/TROUBLESHOOTING.md+++ b/docs/TROUBLESHOOTING.md@@ -151,6 +151,35 @@ and a `TEMP`/`TMP` folder the engine cannot create files in (AMD's runtime compifiles). If you start `strata.exe` by hand, fix them yourself: `set HIP_PATH=`, and point `TEMP` and `TMP` at a normalfolder such as `C:\Temp`.+**Windows AMD: the driver resets (VIDEO_ENGINE_TIMEOUT_DETECTED / screen flicker / the engine dies mid-answer).**+Windows gives a GPU about 2 seconds to answer; when a graphics card does not, it resets the driver (a TDR): the screen+flickers, the engine dies, and the Event Viewer shows `VIDEO_ENGINE_TIMEOUT_DETECTED` (#613, with #579 and #541 on+Linux). Strata 0.1.39 and newer say "the GPU stopped responding" in the log. It was seen with KV streaming on+(`--kv-resident 32768`, which setup turns on from 64K context) while reading a long prompt on a gfx1201 card. Try these+in order, one at a time, and tell us what changed:+1. **Send us the evidence.** The last ~80 lines of `strata-<model>.log` in the Strata folder (the server window shows+ the same lines), your AMD driver version (AMD Software > System), your card and Windows version, the Strata+ version, and the exact steps (context size, how long the prompt was, which app sent it). If Windows wrote a+ dump, the newest `.dmp` in `C:\Windows\LiveKernelReports\WATCHDOG` (or `C:\Windows\Minidump`) helps; it holds no+ chats, only the driver state.+2. **Find the step that hangs:** add `"STRATA_PF_STEP_SYNC": "1"` to the `"env"` block of `strata-<model>.json`+ and restart. The prompt path then waits for the GPU after each step and logs any step over 250 ms, so the log names+ the step. It is slower; use it to diagnose, then take it out.+3. **`"STRATA_KV_HOST_DMA": "1"`** in the same `"env"` block: no GPU kernel writes the RAM copy of the K/V during a+ prompt, it is copied by DMA instead. Same answers.+4. **No KV streaming:** run setup again and pick 32K context (or remove `--kv-resident` and its number from+ `"args"` in the JSON, with a context that fits the VRAM).+5. **A smaller prompt chunk:** change `--prefill` in `"args"` (for example `--prefill 512`): each GPU launch then does+ less work between two checks by Windows. Prompts are read more slowly.+6. **Optional, your decision: give Windows more time (`TdrDelay`).** The default is 2 seconds. In the registry,+ `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers`, a DWORD `TdrDelay` of `10` (seconds)+ lets a long GPU job finish before Windows resets the driver; restart the PC. It hides the symptom and does not fix+ a GPU that has really hung, and a hung GPU then freezes the screen for those 10 seconds. Strata changes no Windows+ setting itself; to undo it, delete the value.+7. **Driver:** use the newest AMD Software release for your card (Adrenalin, not a Windows Update driver) and restart+ after installing. If it started after a driver update, tell us both versions; going back one version is a fair+ test.+**Large pinned host allocations fail on ROCm although RAM is free.**See [AMD_HIP.md](AMD_HIP.md#model-and-serving-configuration): the mapped expert mode avoids the full pinned arena.diff --git a/setup.py b/setup.pyindex 14d982ca3..b192dfd00 100644--- a/setup.py+++ b/setup.py@@ -40,6 +40,7 @@ from __future__ import annotationsimport argparseimport ctypes+import globimport hashlibimport jsonimport math@@ -1788,7 +1789,47 @@ STRIX_HALO_MIN_GB = 80 # UD-IQ4_XS keeps all of its experts in memory frdef 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+ return is_strix_halo(gpu) and bool(gpu.get("uma")) and ram + gpu.get("dedicated_gb", 0.0) >= STRIX_HALO_MIN_GB+++def amd_device_access_problem(dev="/dev", access=os.access, listing=glob.glob) -> str | None:+ """Linux AMD: /dev/kfd and the render nodes must be readable and writable by this user (the render / video groups).+ None when they are, else a sentence for the user. A missing /dev/kfd is not this problem (no driver / no ROCm)."""+ kfd = os.path.join(dev, "kfd")+ if not os.path.exists(kfd):+ return None+ bad = [kfd] if not access(kfd, os.R_OK | os.W_OK) else []+ bad += [n for n in sorted(listing(os.path.join(dev, "dri", "renderD*"))) if not access(n, os.R_OK | os.W_OK)]+ if not bad:+ return None+ return (f"this user cannot open {', '.join(bad)}: ROCm will find no GPU and the engine will fail with 'no ROCm-capable "+ "device' although nothing else holds the GPU. Add your user to the render and video groups: "+ "sudo usermod -aG render,video $USER, then log out and in again")+++def gfx1103_notes(gpu, ram) -> list[str]:+ """What setup tells the owner of a Radeon 780M / 760M / 740M (Phoenix / Hawk Point, gfx1103, unified memory): never+ the Strix Halo text, which is about another chip (gfx1151). Opt-in only (STRATA_EXPERIMENTAL_GFX1103=1)."""+ notes = [f" Radeon 780M / 760M class (gfx1103, Ryzen 7040 / 8040): the CPU and the GPU share one memory pool ({ram:.0f} GB "+ f"seen by the 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."]+ notes.append(" " + ("The engine is compiled here for gfx1103" if not WIN else "This GPU has no ready-made Windows engine")+ + " (experimental opt-in, STRATA_EXPERIMENTAL_GFX1103=1; measured on one machine, not validated on a real "+ "card): see docs/AMD_HIP.md. This is not a Strix Halo.")+ 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 "+ "default is about half of the RAM). The kernel option ttm.pages_limit raises it; setup changes no "+ "host setting - a bigger model needs the room, a smaller one runs as it is")+ return notes+++def igpu_notes(gpu, ram) -> list[str]:+ """The unified-memory notes for exactly this chip: Strix Halo (gfx1151) or the gfx1103 opt-in, nothing else."""+ if is_strix_halo(gpu):+ return strix_halo_notes(gpu, ram)+ if gfx_arch_is(gpu.get("arch"), "gfx1103"):+ return gfx1103_notes(gpu, ram)+ return []def strix_halo_notes(gpu, ram) -> list[str]:@@ -4683,6 +4724,10 @@ def main() -> int:for g in amd: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 WIN and (amd or amd_pci_devices()): # a warning only: recommend, never force+ acc = amd_device_access_problem()+ if acc:+ warn(acc)if not amd and not WIN: # the KFD topology is empty: name a Strix Halo the kernel seesfor d in amd_pci_devices():if d["pci_id"] in STRIX_HALO_PCI_IDS:@@ -4716,9 +4761,12 @@ def main() -> int: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']}, {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)")+ f"{gpu['arch']} (AMD: docs/{'STRIX_HALO' if is_strix_halo(gpu) else 'AMD_HIP'}.md)")+ if WIN and str(gpu.get("arch") or "").startswith("gfx12"): # only a pointer; no default changes+ say(" If Windows resets the AMD driver (VIDEO_ENGINE_TIMEOUT_DETECTED, flicker, the engine dies mid-answer): "+ "docs/TROUBLESHOOTING.md, \"Windows AMD: the driver resets\"")if gpu.get("uma"):- for line in strix_halo_notes(gpu, ram_gb()):+ for line in igpu_notes(gpu, ram_gb()):(warn if line.startswith("!") else say)(line.lstrip("!"))else:if not found:diff --git a/src/program/generate.cpp b/src/program/generate.cppindex a78d08860..e59c12c91 100644--- a/src/program/generate.cpp+++ b/src/program/generate.cpp@@ -2615,6 +2615,23 @@ int main(int argc, char** argv) {// #486: the arena is the first large allocation and its size does not depend on the context, so what is// missing is held by something else: say how much was freecudaGetLastError();+#if (defined(STRATA_USE_HIP) || defined(STRATA_HIP_GFX906)) && !defined(_WIN32)+ // HIP sees no device at all and /dev/kfd exists but this user cannot open it: the missing render / video group,+ // not another program holding the memory (0 MiB of 0 MiB would blame the wrong thing)+ {+ int n_hip = 0;+ if ((cudaGetDeviceCount(&n_hip) != cudaSuccess || n_hip < 1) && ::access("/dev/kfd", F_OK) == 0 &&+ ::access("/dev/kfd", R_OK | W_OK) != 0) {+ cudaGetLastError();+ std::fprintf(stderr, "strata generate: no GPU is visible (%s) and this user cannot open /dev/kfd "+ "(permission denied): it is not another program holding the GPU. Add your user to "+ "the render and video groups - sudo usermod -aG render,video $USER - then log out "+ "and in again+", cudaGetErrorString(ce));+ return 1;+ }+ }+#endifsize_t free_b = 0, total_b = 0;cudaMemGetInfo(&free_b, &total_b);std::fprintf(stderr, "strata generate: cudaMalloc(%llu) for the weight arena failed (%s): %llu MiB of %llu "diff --git a/tools/test_setup_amd.py b/tools/test_setup_amd.pyindex 07f68d749..1bc1fbf58 100644--- a/tools/test_setup_amd.py+++ b/tools/test_setup_amd.py@@ -465,5 +465,60 @@ class HipRuntimeBesideExe(unittest.TestCase):self.assertEqual(list(Path(d).iterdir()), [])+class DeviceAccess(unittest.TestCase):+ """Linux AMD: /dev/kfd and the render nodes must be openable by the user; setup warns, never refuses."""++ def dev(self, d, kfd=True, nodes=("renderD128",)):+ root = Path(d)+ (root / "dri").mkdir()+ if kfd:+ (root / "kfd").write_text("")+ for n in nodes:+ (root / "dri" / n).write_text("")+ return str(root)++ def test_accessible_is_silent(self):+ with tempfile.TemporaryDirectory() as d:+ self.assertIsNone(setup.amd_device_access_problem(self.dev(d), access=lambda p, m: True))++ def test_no_kfd_is_not_this_problem(self):+ with tempfile.TemporaryDirectory() as d:+ self.assertIsNone(setup.amd_device_access_problem(self.dev(d, kfd=False), access=lambda p, m: False))++ def test_kfd_denied_names_the_fix(self):+ with tempfile.TemporaryDirectory() as d:+ msg = setup.amd_device_access_problem(self.dev(d), access=lambda p, m: not p.endswith("kfd"))+ self.assertIn("kfd", msg)+ self.assertNotIn("renderD128", msg)+ self.assertIn("sudo usermod -aG render,video $USER", msg)+ self.assertIn("log out and in", msg)++ def test_render_node_denied(self):+ with tempfile.TemporaryDirectory() as d:+ msg = setup.amd_device_access_problem(self.dev(d), access=lambda p, m: "renderD" not in p)+ self.assertIn("renderD128", msg)+ self.assertNotIn("/kfd", msg)++ def test_engine_names_the_permission_not_another_program(self):+ src = (Path(setup.__file__).resolve().parent / "src/program/generate.cpp").read_text(encoding="utf-8")+ i = src.index("cannot open /dev/kfd")+ guard = src[src.rindex("#if", 0, i):i]+ self.assertIn("cudaGetDeviceCount", guard)+ self.assertIn('access("/dev/kfd", R_OK | W_OK)', guard)+ self.assertIn("STRATA_USE_HIP", guard) # CUDA builds keep the "another program" text+ self.assertIn("another program (or an engine that is still exiting)", src)+++class TdrPointer(unittest.TestCase):+ def test_setup_points_windows_gfx12_to_the_entry(self):+ src = Path(setup.__file__).read_text(encoding="utf-8")+ self.assertIn('WIN and str(gpu.get("arch") or "").startswith("gfx12")', src)+ doc = (Path(setup.__file__).resolve().parent / "docs/TROUBLESHOOTING.md").read_text(encoding="utf-8")+ self.assertIn("Windows AMD: the driver resets", doc)+ for env in ("STRATA_PF_STEP_SYNC", "STRATA_KV_HOST_DMA"):+ self.assertIn(env, doc)+ self.assertIn(env, (Path(setup.__file__).resolve().parent / "src/prefill/prefill.cpp").read_text(encoding="utf-8"))++if __name__ == "__main__":unittest.main()diff --git a/tools/test_setup_strix_halo.py b/tools/test_setup_strix_halo.pyindex 9baf3bf80..86cbf50c9 100644--- a/tools/test_setup_strix_halo.py+++ b/tools/test_setup_strix_halo.py@@ -473,5 +473,46 @@ class LowRamUsesTheCarveOutOnly(unittest.TestCase):self.assertTrue(setup.low_ram_fits("IQ1_M", 24.0, 40.0)) # a 40 GB dedicated card does+class IgpuTextIsArchExact(unittest.TestCase):+ """The owner's rule: setup never takes one AMD iGPU for another. gfx1103 (Radeon 780M / 760M) gets its own text,+ never the Strix Halo (gfx1151) lines; gfx1151 keeps its."""++ def gpu(self, arch, name):+ return {"arch": arch, "name": name, "uma": True, "dedicated_gb": 2.0, "shared_gb": 30.0, "vram_gb": 32.0}++ def test_gfx1103_never_gets_strix_halo_text(self):+ for win in (False, True):+ with mock.patch.object(setup, "WIN", win):+ text = chr(10).join(setup.igpu_notes(self.gpu("gfx1103", "AMD Radeon 780M Graphics"), 61.0))+ self.assertIn("gfx1103", text)+ self.assertIn("STRATA_EXPERIMENTAL_GFX1103=1", text)+ for bad in ("gfx1151", "Ryzen AI Max", "STRIX_HALO", "Recommended model"):+ self.assertNotIn(bad, text)+ self.assertNotIn("Strix Halo (gfx1151", text)+ self.assertNotIn("compiled here for gfx1151", text)++ def test_gfx1151_keeps_strix_halo_text(self):+ with mock.patch.object(setup, "WIN", False):+ text = chr(10).join(setup.igpu_notes(self.gpu("gfx1151", "AMD Radeon 8060S"), 121.0))+ self.assertIn("Strix Halo (gfx1151, Ryzen AI Max)", text)+ self.assertIn("compiled here for gfx1151", text)+ self.assertIn("docs/STRIX_HALO.md", text)+ self.assertNotIn("gfx1103", text)++ def test_other_chips_get_nothing(self):+ for a in ("gfx1150", "gfx1152", "gfx1100", "gfx1201"):+ self.assertEqual(setup.igpu_notes(self.gpu(a, "x"), 64.0), [])++ def test_no_strix_halo_model_recommendation_for_gfx1103(self):+ g = self.gpu("gfx1103", "AMD Radeon 780M Graphics")+ self.assertFalse(setup.strix_halo_recommends(g, 128.0))+ self.assertTrue(setup.strix_halo_recommends(self.gpu("gfx1151", "x"), 128.0))++ def test_setup_prints_notes_through_the_exact_helper(self):+ src = Path(setup.__file__).read_text(encoding="utf-8")+ self.assertIn("igpu_notes(gpu, ram_gb())", src)+ self.assertNotIn("strix_halo_notes(gpu, ram_gb())", src)++if __name__ == "__main__":unittest.main()