From ed7c7f339db64ae54bcbae93a26c93da9f2eedd3 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Wed, 14 Oct 2026 07:02:11 +0200 Subject: [PATCH 1/3] engine: a pack folder without native_experts.txt says so before the AVX-512 refusal (#2347) The refusal 'this CPU cannot run the expert kernel' belongs to the canonical Q2_0 pack. An NVFP4, i-quant or Unsloth pack is a native pack (native_experts.txt in the --pack folder) and its rows have AVX2 kernels, but a config whose --pack points at the wrong folder reads like a CPU that is too old. On a CPU without AVX-512 the engine now says the file is missing, and where it sits when it is one level down (/pack). --- src/program/generate.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/program/generate.cpp b/src/program/generate.cpp index ba00f94d..770468e0 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -2896,8 +2896,27 @@ int main(int argc, char** argv) { } } // the canonical Q2_0 pack's CPU kernels are AVX-512 only; a native pack runs on AVX2 CPUs as well - if (!native_pack) strata::kernels::cpu::cpu_require_expert_support(); - else if (!strata::kernels::cpu::cpu_avx512_ok()) + if (!native_pack) { + // #2347: an NVFP4 / i-quant / Unsloth pack IS a native pack and runs on an AVX2 CPU (its rows have AVX2 + // kernels). This refusal is the canonical Q2_0 pack's, reached when the --pack folder has no + // native_experts.txt - a hand-written config pointing --pack at the wrong folder reads as "this CPU is too + // old". Say so before the refusal, and where the file is when it sits one level down (a pack/ subfolder). + if (!strata::kernels::cpu::cpu_features().usable()) { + std::error_code ec; + const std::filesystem::path pk(o.pack); + std::fprintf(stderr, "strata generate: %s has no native_experts.txt, so it is read as the canonical Q2_0 " + "pack, whose CPU kernel needs AVX-512.\n" + " An NVFP4, i-quant or Unsloth pack has that file in the folder given as --pack " + "and runs on an AVX2 CPU as well;\n", + o.pack.c_str()); + if (std::filesystem::exists(pk / "pack" / "native_experts.txt", ec)) + std::fprintf(stderr, " it is in %s: use that folder as --pack.\n", (pk / "pack").generic_string().c_str()); + else + std::fprintf(stderr, " if this is one of those packs, the folder is incomplete or the wrong one " + "(setup writes it; run setup again).\n"); + } + strata::kernels::cpu::cpu_require_expert_support(); + } else if (!strata::kernels::cpu::cpu_avx512_ok()) std::fprintf(stderr, "strata generate: this CPU has no AVX-512: the expert kernels run on %s " "(multi-token for the i-quant gate/up rows)\n", !strata::kernels::cpu::cpu_avx2_ok() From e8b20f2a6ee204e4a720a2059ee82f84b5e58aba Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Wed, 14 Oct 2026 07:14:11 +0200 Subject: [PATCH 2/3] setup: NVFP4 on a CPU without AVX-512 is offered, with a note on what its CPU rows are (#2347) The menu never hid NVFP4 on an AVX2 CPU; the engine runs a native pack's rows on AVX2 kernels that are bit-equal to ggml's. The NVFP4 menu line and the install step now say, on a CPU with AVX2 and no AVX-512, that the CPU's share of the experts runs on AVX2 rows (measured about as fast when memory-bound, up to ~12% slower on 4-token windows). A note only: nothing is refused or capped. tools/test_setup_menu.py: 2 tests. --- setup.py | 22 ++++++++++++++++++---- tools/test_setup_menu.py | 14 ++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 2d9681e0..a5b8c759 100644 --- a/setup.py +++ b/setup.py @@ -2312,12 +2312,24 @@ def nvfp4_card_note(gpu) -> str: return "runs, but UD-IQ4_XS is faster on this card" -def family_menu_note(family: str, hip: bool, gpu) -> str: - """The card- and RAM-dependent tail of a family's line in the model menu.""" +def nvfp4_cpu_note(avx2: bool, avx512: bool) -> str: + """What the NVFP4 menu line and the install step say about this CPU (#2347). Its experts that stay on the CPU run + on AVX-512 rows when the CPU has them, else on AVX2 rows (bit-equal to ggml's AVX2 dot). Measured (docs/NVFP4.md): + per core the AVX2 rows are ~10% slower, and on a whole pool that reads DRAM the two are the same speed up to two + tokens a window (Ryzen 7 255: 58.9 vs 58.7 GB/s) and ~12% apart at four. A note only: nothing is refused.""" + if avx512 or not avx2: + return "" # no AVX2 at all: the older-CPU build's own warning says it + return ("this CPU has no AVX-512, so NVFP4's CPU rows run on AVX2: about as fast when memory-bound, up to ~12% " + "slower on 4-token windows") + + +def family_menu_note(family: str, hip: bool, gpu, avx2: bool = True, avx512: bool = True) -> str: + """The card-, CPU- and RAM-dependent tail of a family's line in the model menu.""" if family == "nvfp4": d = MODELS["NVFP4"] + cpu = nvfp4_cpu_note(avx2, avx512) return (f" [{nvfp4_card_note(gpu)}; {d['download_gb']:.0f} GB download, ~{d['ram_gb']} GB of RAM keeps every " - "expert in RAM]") + "expert in RAM" + (f"; {cpu}" if cpu else "") + "]") if family == "unsloth" and hip: return " [UD-IQ4_XS is the 4-bit choice on AMD and Intel cards; NVFP4 runs on NVIDIA only]" return "" @@ -6261,7 +6273,7 @@ def main() -> int: 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_menu_note(f, hip, gpu) + + family_menu_note(f, hip, gpu, avx2, avx512) + (f" (recommended for Strix Halo: {STRIX_HALO_MODEL})" if f == rec_fam and rec_fam != fams[0] else "")) for j, f in enumerate(OWN_PATH_FAMILIES, len(fams) + 1): # families with an engine path of their own d = OWN_PATH_FAMILIES[f] @@ -6280,6 +6292,8 @@ def main() -> int: warn(f"--gguf-dir does not apply to {fam['title']}: its files are ready-made packs, not GGUF shards") a.gguf_dir = None ok(f"model: {fam['title']}") + if fam.get("ready") and nvfp4_cpu_note(avx2, avx512): # #2347: a note (the AVX2 rows work), not a refusal + warn(nvfp4_cpu_note(avx2, avx512)) if fam.get("license"): say(f" Its license: {fam['license']}") say() diff --git a/tools/test_setup_menu.py b/tools/test_setup_menu.py index 1fc52279..5150250f 100644 --- a/tools/test_setup_menu.py +++ b/tools/test_setup_menu.py @@ -49,6 +49,20 @@ class Nvfp4Note(unittest.TestCase): self.assertIn("runs, but UD-IQ4_XS is faster on this card", line, arch) self.assertNotIn("native FP4", line) + def test_an_avx2_cpu_is_told_its_rows_but_not_refused(self): # #2347 + line = setup.family_menu_note("nvfp4", False, {"arch": 120}, avx2=True, avx512=False) + self.assertIn("no AVX-512", line) + self.assertIn("AVX2", line) + self.assertIn("native FP4 on this card", line) # the card part is unchanged + self.assertTrue(setup.nvfp4_cpu_note(True, False)) + + def test_an_avx512_cpu_and_a_cpu_without_avx2_get_no_cpu_note(self): + self.assertEqual(setup.nvfp4_cpu_note(True, True), "") + self.assertEqual(setup.nvfp4_cpu_note(False, False), "") # the older-CPU build says its own piece + line512 = setup.family_menu_note("nvfp4", False, {"arch": 120}) + self.assertNotIn("AVX", line512) + self.assertEqual(line512, setup.family_menu_note("nvfp4", False, {"arch": 120}, avx2=True, avx512=True)) + def test_the_line_gives_the_download_and_the_ram_need(self): line = setup.family_menu_note("nvfp4", False, {"arch": 120}) d = setup.MODELS["NVFP4"] From 37f2941fc271fb1c74c522c3487b5d3cfb5fcf61 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Wed, 14 Oct 2026 09:45:10 +0200 Subject: [PATCH 3/3] docs/NVFP4.md: the CPU rows on a CPU without AVX-512 (AVX2 rows bit-equal to ggml's, measured on three CPUs) (#2347) --- docs/NVFP4.md | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/docs/NVFP4.md b/docs/NVFP4.md index 1179afc1..c52c98a9 100644 --- a/docs/NVFP4.md +++ b/docs/NVFP4.md @@ -168,8 +168,14 @@ busiest experts, max|x|/rms 4 median and 9 at most. The errors: `src/kernels/cpu/nvfp4_avx512.cpp` computes the CPU pool's NVFP4 rows in 512-bit lanes. Each 64-value block is decoded once for every token of a verify window: `vpdpbusd` on |E2M1| codes, with the sign moved onto the activation. The arithmetic is ggml-cpu's `ggml_vec_dot_nvfp4_q8_0`, with the float additions ordered differently -(worst 4.5e-7 relative, `nvfp4_avx512_parity`). `STRATA_NO_NVFP4_512=1` falls back to ggml-cpu, which is also the -path of CPUs without AVX-512. +(worst 4.5e-7 relative, `nvfp4_avx512_parity`). `STRATA_NO_NVFP4_512=1` falls back to ggml-cpu. + +A CPU without AVX-512 (Zen 1-3, Intel Core 4th-10th and 12th-14th gen, Core Ultra, Xeon E5 v3/v4) runs the same rows in 256-bit lanes +(`src/kernels/cpu/nvfp4_avx2.cpp`): ggml's AVX2 arithmetic step for step, so every row is bit-equal to ggml-cpu's +(`nvfp4_cpu_parity`, 0 of 1280x9 / 2560x9 rows differ on a Ryzen 5 5600X, a Ryzen 7 255 and a Core Ultra 7 265). +`STRATA_NO_NVFP4_256=1` falls back to ggml-cpu. An NVFP4 pack is a native pack (its folder holds `native_experts.txt`), +so the engine starts on such a CPU; the AVX-512 requirement belongs to the canonical Q2_0 pack only (#2347: a `--pack` +folder without `native_experts.txt` is read as that pack, and the engine now says so before it refuses). | tokens | ggml-cpu | AVX-512 | speedup | |---|---|---|---| @@ -179,6 +185,22 @@ path of CPUs without AVX-512. These are one expert's gate+up (1280 rows of 2560, cache-resident). The pool itself is bound by DRAM. +The pool in DRAM terms (`nvfp4_avx512_parity --bw THREADS TOKENS`: 1536 experts, 4.2 GB, GB/s of weights read; tokens = tokens an +expert serves in one verify window, 1-2 in decode): + +| CPU (threads) | kernel | 1 thread, 1 tok | all cores, 1 tok | 2 tok | 4 tok | +|---|---|---|---|---|---| +| Ryzen 7 255, Zen 4 (8) | AVX-512 | 15.4 | 58.6 | 57.6 | 47.7 | +| | AVX2 rows | 13.9 | 58.9 | 58.1 | 42.1 | +| | ggml-cpu | 12.6 | 58.7 | 44.8 | 22.4 | +| Ryzen 5 5600X, Zen 3, DDR4-3200 (6) | AVX2 rows | 12.1 | 42.2 | 41.5 | 30.1 | +| | ggml-cpu | 10.4 | 42.9 | 30.9 | 15.5 | +| Core Ultra 7 265, DDR5-5600 (20) | AVX2 rows | 16.0 | 74.2 | 73.0 | 60.6 | +| | ggml-cpu | 10.3 | 74.1 | 62.7 | 37.1 | + +Without AVX-512 a core reads ~10% slower (13.9 vs 15.4 GB/s), but a pool that reads DRAM runs at the same rate up to two tokens a +window and ~12% below at four. The CPU's memory decides, not its vector width. + ## Other GPUs Only the optional `w4a4` needs Blackwell. The default `w4a8` is ggml's int8 MMQ (sm_75 and up), and decode uses the