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++
The GSQ-RCO Coder (256 of 512 experts): setup, profile, speeds (PR #54)
Niko122147a83696e994
diff --git a/README.md b/README.mdindex 77f5e0d44..0e13f9ebf 100644--- a/README.md+++ b/README.md@@ -29,6 +29,7 @@ Measured on an RTX 5070 (12 GB), a Ryzen 5 7600 and 64 GB of RAM:| **IQ2_XS** | 74 tokens/s | 60 tokens/s | 1,240 tokens/s || **IQ3_XXS** | 62 tokens/s | 46 tokens/s | 1,110 tokens/s || **IQ3_S** | 52 tokens/s | 41 tokens/s | 1,070 tokens/s |+| **Coder** (IQ1_M) | 51 tokens/s | 44 tokens/s | 1,300 tokens/s |- **Writes answers** = how fast the reply appears (tokens per second).- **Reads your prompt** = how fast it takes in what you send (long documents, code, chat history), measured on a@@ -58,11 +59,17 @@ lower the RAM needed.**The version:**- **Qwen3.8-Flash-Next** - the original.+- **[Coder](https://huggingface.co/ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-Coder-GGUF)** - ISTA-DASLab's coding+ version: half of the experts removed, keeping the ones that code, tool use and images need (91% of the full model's+ SWE-bench Verified score, 99% of LiveCodeBench, by its authors). One size (IQ1_M: its experts stored like IQ3_S):+ shard 1 is **29.6 GB**, so it fits a PC with **32 GB of RAM**, runs 262K context on 64 GB, and reads long prompts+ the fastest of all. Weaker outside coding.- **[Swift 1.5](https://huggingface.co/ukisai/Swift-1.5-Qwen3.8-Flash-Next-GSQ-RCO-GGUF)** - a fine-tune by UkisAIthat thinks much shorter before answering, so you get the answer sooner, with about the same quality. Same speed pertoken, and about the same RAM as the same size of the original (no IQ3_S). Its own license applies (see its page).-Not sure? Take **IQ2_XS**. You can add another one later with `START-HERE.bat --setup`.+Not sure? Take **IQ2_XS** - or the **Coder** if you mainly write code, or have 32-48 GB of RAM. You can add another+one later with `START-HERE.bat --setup`.## Installdiff --git a/bench/results/2026-09-28-coder/README.md b/bench/results/2026-09-28-coder/README.mdnew file mode 100644index 000000000..4afc192ce--- /dev/null+++ b/bench/results/2026-09-28-coder/README.md@@ -0,0 +1,44 @@+# The GSQ-RCO Coder (256 of 512 experts) on Strata++RTX 5070 12 GB, Ryzen 5 7600, 64 GB DDR5-5200, Windows 10. Engine 0.1.15 + PR #54 (the expert count from the model+file), the settings setup writes (`--prefill auto`, 8-bit KV above 4K, KV streaming from 64K, MTP, greedy, 256 tokens),+`data/expert-profile-coder.bin`, the same code-agent prompts as `2026-09-28-speed-0114`.++| | 1K | 4K | 32K | 64K | 128K | 262K |+| --- | ---: | ---: | ---: | ---: | ---: | ---: |+| Prompt, tokens/s | 599 | 1,152 | 1,298 | 1,350 | 1,266 | 1,034 |+| Output, tokens/s | 53.3 | 50.6 | 53.3 | 50.8 | 44.0 | 42.8 |+| Draft acceptance | 0.720 | 0.707 | 0.785 | 0.696 | 0.619 | 0.684 |+| Experts in VRAM | 2,570 | 2,615 | 2,418 | 2,382 | 2,326 | 2,208 |++Every run in [`matrix.json`](matrix.json). The 128K and 262K answers were read: coherent (they list and discuss the+files of the prompt).++## Why it is fast++The kept experts are stored like IQ3_S's (IQ2_S / IQ3_XXS / IQ3_S / IQ4_XS gate and up, IQ4_NL / Q2_0 down; "IQ1_M" is+the release's name for 1.89 bits per *original* parameter), so a token costs about what IQ3_S costs where the expert is+on the CPU. But there are half as many experts: the 23 GB of them pin completely (`cudaHostRegister` of the whole+arena), a 12 GB card holds ~20% of them instead of ~10%, and the prompt path streams half as many.++## The expert profile++`data/expert-profile-coder.bin` (48 x 256, all 12,288 pairs ranked): the shipped 48 x 512 ranking, each pair mapped to+its kept expert's new index through section 2 of the release's `tensor-allocation/*.rco-allocation.txt` (the kept+experts in their original order; gate, up and down agree on which were kept), pruned pairs dropped. 5,492 of the+shipped top 8,000 survive (as PR #54 found). With 2,537 slots on the 12 GB card, 72% of the expert reads of a 4K code+prompt hit the GPU - a wrong index mapping would give about the slot share, 21%.++## Images++The Coder ships the original's vision encoder (the same file). With `--vision` on the GPU it described a Strata+Monitor screenshot correctly, windows, labels and the numbers of the dashboard and the requests table (1,079 prompt+tokens with the image, 2,012 generated at ~50 tokens/s).++## The experimental speed projection++The vector was made from the full model's activations; the Coder has the same residual stream. On the Coder it loads+(41 layers steered), costs no measurable speed (47.7-55.7 tokens/s with it on or off), and both settings write correct+answers to three coding prompts. What it is for - fewer refusals - was not measured. (Two runs of the same prompt with+it off also differ after ~130-200 characters in serve mode, so this check cannot show how far it moves ordinary text;+the teacher-forced method of `2026-09-27-esp` needs the token-by-token prompt path, which native packs do not run.)diff --git a/bench/results/2026-09-28-coder/matrix.json b/bench/results/2026-09-28-coder/matrix.jsonnew file mode 100644index 000000000..2614ebc68--- /dev/null+++ b/bench/results/2026-09-28-coder/matrix.json@@ -0,0 +1,86 @@+[+ {+ "model": "CODER",+ "tier": "1k",+ "prompt_tokens": 1017,+ "exit": 0,+ "wall_s": 18.0,+ "prefill_tok_s": 599.05,+ "ttft_s": 2.54,+ "decode_tok_s": 53.33,+ "decoded": 256,+ "spec_accept": 0.72,+ "tokens_per_round": 2.86,+ "vram_slots": 2570+ },+ {+ "model": "CODER",+ "tier": "4k",+ "prompt_tokens": 3562,+ "exit": 0,+ "wall_s": 19.6,+ "prefill_tok_s": 1152.17,+ "ttft_s": 3.94,+ "decode_tok_s": 50.6,+ "decoded": 256,+ "spec_accept": 0.707,+ "tokens_per_round": 2.88,+ "vram_slots": 2615+ },+ {+ "model": "CODER",+ "tier": "32k",+ "prompt_tokens": 31566,+ "exit": 0,+ "wall_s": 40.7,+ "prefill_tok_s": 1297.8,+ "ttft_s": 25.17,+ "decode_tok_s": 53.34,+ "decoded": 256,+ "spec_accept": 0.785,+ "tokens_per_round": 3.02,+ "vram_slots": 2418+ },+ {+ "model": "CODER",+ "tier": "64k",+ "prompt_tokens": 64162,+ "exit": 0,+ "wall_s": 75.5,+ "prefill_tok_s": 1350.09,+ "ttft_s": 49.01,+ "decode_tok_s": 50.84,+ "decoded": 256,+ "spec_accept": 0.696,+ "tokens_per_round": 2.61,+ "vram_slots": 2382+ },+ {+ "model": "CODER",+ "tier": "128k",+ "prompt_tokens": 128478,+ "exit": 0,+ "wall_s": 121.5,+ "prefill_tok_s": 1266.31,+ "ttft_s": 102.95,+ "decode_tok_s": 44.03,+ "decoded": 256,+ "spec_accept": 0.619,+ "tokens_per_round": 2.33,+ "vram_slots": 2326+ },+ {+ "model": "CODER",+ "tier": "262k",+ "prompt_tokens": 259943,+ "exit": 0,+ "wall_s": 280.7,+ "prefill_tok_s": 1033.91,+ "ttft_s": 252.92,+ "decode_tok_s": 42.8,+ "decoded": 256,+ "spec_accept": 0.684,+ "tokens_per_round": 2.6,+ "vram_slots": 2208+ }+]\ No newline at end of filediff --git a/data/expert-profile-coder.bin b/data/expert-profile-coder.binnew file mode 100644index 000000000..4198aef8eBinary files /dev/null and b/data/expert-profile-coder.bin differdiff --git a/docs/DETAILS.md b/docs/DETAILS.mdindex ba50fcd6f..776f5a3d4 100644--- a/docs/DETAILS.md+++ b/docs/DETAILS.md@@ -24,6 +24,7 @@ measured with Swift 1.5's IQ2_XS, which runs at the original's speed.| **IQ2_XS** | 461 | 811 | 1,238 | 1,136 | 1,071 | 886 || **IQ3_XXS** | 415 | 770 | 1,108 | 1,065 | 1,015 | - || **IQ3_S** | 396 | 737 | 1,070 | 1,070 | 931 | - |+| **Coder** | 599 | 1,152 | 1,298 | 1,350 | 1,266 | 1,034 |### Output (tokens/s)@@ -33,6 +34,7 @@ measured with Swift 1.5's IQ2_XS, which runs at the original's speed.| **IQ2_XS** | 74.4 | 73.8 | 71.5 | 64.3 | 59.8 | 52.8 || **IQ3_XXS** | 60.3 | 62.1 | 51.4 | 50.0 | 45.8 | - || **IQ3_S** | 51.5 | 51.6 | 48.2 | 48.8 | 40.5 | - |+| **Coder** | 53.3 | 50.6 | 53.3 | 50.8 | 44.0 | 42.8 |Output speed depends on the text as well: speculative decoding runs faster when more of the drafted tokens areaccepted, so a different answer to the same prompt moves it by several percent. Run back to back on the 4K prompt,@@ -104,6 +106,23 @@ of [Qwen3.8-Flash-Next](https://huggingface.co/Qwen/Qwen3.8-Flash-Next).With 64 GB of RAM all three fit (close the browser for IQ3_XXS, and keep its context at 128K or less). With 48 GB only Q2_0 / IQ2_XS may fit. 32 GB is not enough.+### Or: the Coder (half the experts, for code)++**[Qwen3.8-Flash-Next GSQ-RCO Coder](https://huggingface.co/ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-Coder-GGUF)** is+ISTA-DASLab's expert-pruned release: 256 of each layer's 512 experts are kept (still 10 active per token), chosen with+RCO on code, agentic and vision calibration data; its authors report 91.3% of the full model's SWE-bench Verified and+98.7% of LiveCodeBench v6. One size, named IQ1_M for its 1.89 bits per *original* parameter; the kept experts are+stored like IQ3_S (IQ2_S-IQ4_XS gate/up, IQ4_NL/Q2_0 down). Shard 1 is 29.6 GB (experts: 23 GB of RAM), so it runs+on **32 GB of RAM**, and at 262K on 64 GB. Its shard 2 and its vision encoder are the original's files: with the+original installed, setup downloads only shard 1. Strata ships its expert profile (`data/expert-profile-coder.bin`,+the shipped ranking mapped onto the kept experts through the release's `rco-allocation.txt`: 72% of the expert+reads hit the GPU on a 12 GB card). Images work; the experimental speed projection loads and runs on it (it was made+for the full model).++```+START-HERE.bat --setup --family coder+```+### Or: Swift 1.5 (a fine-tune that thinks shorter)The setup's first question also offers **[Swift 1.5](https://huggingface.co/ukisai/Swift-1.5-Qwen3.8-Flash-Next-GSQ-RCO-GGUF)**,diff --git a/setup.py b/setup.pyindex 291804ee6..865a757a8 100644--- a/setup.py+++ b/setup.py@@ -70,6 +70,9 @@ MODELS = {"IQ3_S": {"about": "3.5-bit i-quant, the best quality (matches the full model), the slowest; needs a 64 GB PC ""with little else running", "download_gb": 83.6, "ram_gb": 62, "arena_gb": 50.3,"families": ("qwen",)},+ # the Coder release: 256 of the 512 experts kept (the ones code, tools and vision use), IQ2_S-IQ4_XS like IQ3_S+ "IQ1_M": {"about": "the Coder's only size: half the experts, stored like IQ3_S (3.5 bits)", "download_gb": 58.4,+ "ram_gb": 32, "arena_gb": 23.4, "families": ("coder",)},}CONTEXTS = [8192, 32768, 65536, 131072, 262144]# The model families: the same architecture, weights in the same three GSQ-RCO sizes, different files.@@ -87,6 +90,15 @@ FAMILIES = {"mmproj_hf": "https://huggingface.co/ukisai/Swift-1.5-Qwen3.8-Flash-Next-GSQ-RCO-GGUF/resolve/main/","mmproj": "mmproj-Swift-Qwen3.8-Flash-Next-BF16.gguf", "name": "swift-1.5","license": "Swift Open License 1.0: https://huggingface.co/ukisai/Swift-1.5-Qwen3.8-Flash-Next-GSQ-RCO-GGUF"},+ # ISTA-DASLab's expert-pruned release: half of each layer's experts removed, chosen for code, agentic tool use and+ # vision; its shard 2 (the n-gram table) and vision encoder are the original's files, shared with it+ "coder": {"title": "Qwen3.8-Flash-Next Coder", "by": "ISTA-DASLab's coding version",+ "about": "half the experts (code, tools, images kept): needs ~32 GB of RAM, faster; weaker outside coding",+ "hf": "https://huggingface.co/ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-Coder-GGUF/resolve/main/{q}/",+ "file": "Qwen3.8-Flash-Next-GSQ-RCO-{q}-0000{i}-of-00002.gguf", "tag": "coder-",+ "mmproj_hf": "https://huggingface.co/ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-Coder-GGUF/resolve/main/",+ "mmproj": "mmproj-Qwen3.8-Flash-Next-BF16.gguf", "name": "qwen3.8-flash-next-coder",+ "profile": "expert-profile-coder.bin"},}MMPROJ = "mmproj-Qwen3.8-Flash-Next-BF16.gguf"# EXPERIMENTAL, off by default (setup asks): a control vector shipped with the repository, see its README@@ -828,7 +840,7 @@ def choices_from_config(cfg_path: Path) -> dict:"""The setup answers a config was written with (family, size, context, KV, images, projection, network)."""cfg = json.loads(cfg_path.read_text(encoding="utf-8-sig"))tag = cfg_path.stem[len("strata-"):]- family = "swift" if tag.startswith("swift-") else "qwen"+ family = next((f for f, d in FAMILIES.items() if d["tag"] and tag.startswith(d["tag"])), "qwen")model = tag.split("-")[-1].upper()a = cfg.get("args", [])val = lambda k: a[a.index(k) + 1] if k in a and a.index(k) + 1 < len(a) else None # noqa: E731@@ -1038,11 +1050,11 @@ def main() -> int:cpu, avx2, avx512 = cpu_info()need = min(d["ram_gb"] for d in MODELS.values())if ram < need - 4 and not a.check:- # every model keeps ALL its experts in RAM (34+ GB); VRAM only holds a copy of the most-used ones, so a+ # 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- fail(f"RAM: {ram:.0f} GB - the smallest model (Q2_0 / IQ2_XS) needs about {need} GB",- "Strata keeps all of the model's experts in RAM (34-50 GB, whatever the GPU) and the GPU holds a copy "- "of the most-used ones: it needs 48 GB of RAM or more")+ fail(f"RAM: {ram:.0f} GB - the smallest model (the Coder) needs about {need} GB",+ "Strata keeps all of the model's experts in RAM (23-50 GB, whatever the GPU) and the GPU holds a copy "+ "of the most-used ones: it needs 32 GB of RAM or more (48 GB for the full model)")ok(f"RAM: {ram:.0f} GB" if ram >= need - 4 else f"RAM: {ram:.0f} GB (less than the {need} GB the smallest model needs)")ok(f"CPU: {cpu} ({'AVX-512' if avx512 else 'AVX2' if avx2 else 'no AVX2'})")if not avx2:@@ -1070,14 +1082,14 @@ def main() -> int:if fam.get("license"):say(f" Its license: {fam['license']}")say()- names = [m for m in MODELS if family in MODELS[m].get("families", FAMILIES)]+ names = [m for m in MODELS if family in MODELS[m].get("families", ("qwen", "swift"))]if a.model and a.model not in names:fail(f"{fam['title']} has no {a.model} model file", "choose one of: " + ", ".join(names))for i, m in enumerate(names, 1):d = MODELS[m]fit = "" if ram >= d["ram_gb"] else f" <- needs {d['ram_gb']} GB RAM, you have {ram:.0f}"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 else "1"+ 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]if ram < MODELS[model]["ram_gb"] - 4:fail(f"{model} needs about {MODELS[model]['ram_gb']} GB of RAM; this PC has {ram:.0f} GB",@@ -1122,7 +1134,7 @@ def main() -> int:# chosen here; with it loaded, the web app and the API switch it off per requestesp = Noneesp_choice = (a.experimental_speed_projection or "").strip()- if family == "qwen":+ if family in ("qwen", "coder"): # the Coder: the same model's residual streamif not esp_choice:say()say(" EXPERIMENTAL - speed projection: a small control vector applied while the model runs (layers 4-44).")@@ -1179,9 +1191,9 @@ def main() -> int:if s.exists() and done(s):ok(f"{s.name} already downloaded")continue- # the original's shard 2 is the same file for all three sizes: reuse one that is already here+ # the original's shard 2 is the same file for all its sizes and the Coder: reuse one that is already hereother = [p for p in Path(a.models_dir).glob("*/Qwen3.8-Flash-Next-GSQ-RCO-*-00002-of-00002.gguf") if done(p)]- if family == "qwen" and s.name.endswith("00002-of-00002.gguf") and other and not s.exists():+ if family in ("qwen", "coder") and s.name.endswith("00002-of-00002.gguf") and other and not s.exists():try:os.link(other[0], s)mark(s)@@ -1244,7 +1256,7 @@ def main() -> int:if ple is None:fail("the model has no per_layer_token_embd tensor (is this a Qwen3.8-Flash-Next GGUF?)")args = ["--pack", str(pack), "--native", str(shards[0]), "--ple-gguf", str(ple),- "--expert-profile", str(ROOT / "data" / "expert-profile.bin"), "--expert-cache", "auto",+ "--expert-profile", str(ROOT / "data" / fam.get("profile", "expert-profile.bin")), "--expert-cache", "auto","--prefill", "auto", "--spec", "4", "--spec-min-p", "0.5", "--mtp", str(rt),"--max-context", str(ctx)]if ctx > 8192:diff --git a/tools/make_profile.py b/tools/make_profile.pyindex df3e342ba..0f0238489 100644--- a/tools/make_profile.py+++ b/tools/make_profile.py@@ -9,6 +9,7 @@ The order: the base profile's ranking (default: the shipped data/expert-profile.traces used, most frequent first, then every pair still missing, interleaved across the layers.python tools/make_profile.py [TRACE ...] [--base data/expert-profile.bin | --no-base] [--out PATH]+ [--n-expert 256] (a pruned model: GSQ-RCO Coder keeps 256 of 512)A routing trace comes from a one-shot engine run with `--dump-routing FILE` (a prompt typical of your use; therouted experts of every layer and position are written). Point the model config's `--expert-profile` at the result.@@ -23,17 +24,17 @@ N_LAYER, N_EXPERT = 48, 512MAGIC, VERSION = b"STRP", 1-def read_profile(path):+def read_profile(path, n_expert=N_EXPERT):blob = Path(path).read_bytes()if blob[:4] != MAGIC:raise SystemExit(f"{path}: not a Strata profile")ver, nl, ne, slots, n = struct.unpack_from("<5I", blob, 4)- if (nl, ne) != (N_LAYER, N_EXPERT):- raise SystemExit(f"{path}: {nl}x{ne}, not {N_LAYER}x{N_EXPERT}")+ if (nl, ne) != (N_LAYER, n_expert):+ raise SystemExit(f"{path}: {nl}x{ne}, not {N_LAYER}x{n_expert}")return [struct.unpack_from("<HH", blob, 24 + 4 * i) for i in range(n)]-def read_trace(path):+def read_trace(path, n_expert=N_EXPERT):"""(layer, k, k expert ids, k weights) records, as `--dump-routing` writes them."""blob = Path(path).read_bytes()off, freq = 0, defaultdict(int)@@ -41,22 +42,22 @@ def read_trace(path):layer, k = struct.unpack_from("<ii", blob, off)off += 8for e in struct.unpack_from("<%di" % k, blob, off):- if 0 <= layer < N_LAYER and 0 <= e < N_EXPERT:+ if 0 <= layer < N_LAYER and 0 <= e < n_expert:freq[(layer, e)] += 1off += 8 * k # the ids and the weightsreturn freq-def write_profile(path, ranked):- table = [[-1] * N_EXPERT for _ in range(N_LAYER)]+def write_profile(path, ranked, n_expert=N_EXPERT):+ table = [[-1] * n_expert for _ in range(N_LAYER)]for slot, (layer, e) in enumerate(ranked):table[layer][e] = slotwith open(path, "wb") as f:- f.write(MAGIC + struct.pack("<5I", VERSION, N_LAYER, N_EXPERT, len(ranked), len(ranked)))+ f.write(MAGIC + struct.pack("<5I", VERSION, N_LAYER, n_expert, len(ranked), len(ranked)))for layer, e in ranked:f.write(struct.pack("<HH", layer, e))for layer in range(N_LAYER):- f.write(struct.pack("<%di" % N_EXPERT, *table[layer]))+ f.write(struct.pack("<%di" % n_expert, *table[layer]))def main():@@ -65,6 +66,7 @@ def main():ap.add_argument("--base", default=str(ROOT / "data" / "expert-profile.bin"), help="ranking to keep first")ap.add_argument("--no-base", action="store_true", help="rank by the traces only")ap.add_argument("--out", default=str(ROOT / "data" / "expert-profile.bin"))+ ap.add_argument("--n-expert", type=int, default=N_EXPERT, help="experts per layer (default 512)")a = ap.parse_args()ranked, seen = [], set()@@ -76,18 +78,19 @@ def main():seen.add(p)ranked.append(p)+ ne = a.n_expertif not a.no_base:- take(read_profile(a.base))+ take(read_profile(a.base, ne))n_base = len(ranked)freq = defaultdict(int)for t in a.traces:- for p, c in read_trace(t).items():+ for p, c in read_trace(t, ne).items():freq[p] += ctake(p for p, _ in sorted(freq.items(), key=lambda kv: (-kv[1], kv[0])))n_trace = len(ranked) - n_base- take((layer, e) for e in range(N_EXPERT) for layer in range(N_LAYER)) # the rest, across the layers- write_profile(a.out, ranked)- assert read_profile(a.out) == ranked, "the profile did not survive the round trip"+ take((layer, e) for e in range(ne) for layer in range(N_LAYER)) # the rest, across the layers+ write_profile(a.out, ranked, ne)+ assert read_profile(a.out, ne) == ranked, "the profile did not survive the round trip"print(f"wrote {a.out}: {len(ranked)} ranked pairs ({n_base} from the base, {n_trace} from the traces, "f"{len(ranked) - n_base - n_trace} filled in)")