Skip to content

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++

Quant yardstick: tools/quant_quality.py (teacher-forced top-1 agreement and KL against Q8_0 on a fixed 5x1000-token set) and tools/quant_formats.py (per-role tensor formats from GGUF headers, local or HF range requests)

Niko12210d3553fc8f11
diff --git a/.gitattributes b/.gitattributes
index 466d97e84..bd4b5d527 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -7,3 +7,6 @@ bench/prompts/** -text
# copies of real packs' native_experts.txt, parsed byte for byte by tests/core/expert_layout_test.cpp
tests/data/native_experts/** -text
+
+# the quant yardstick's text set: tokenized byte for byte (set.ids.json), never convert its line endings
+data/quant_quality/** -text
diff --git a/data/quant_quality/v1/agent.txt b/data/quant_quality/v1/agent.txt
new file mode 100644
index 000000000..cbfb5d231
--- /dev/null
+++ b/data/quant_quality/v1/agent.txt
@@ -0,0 +1,113 @@
+<|im_start|>system
+You are a coding agent working in the user's repository. You can call tools to read files, search the code and run commands. Keep changes small and explain what you did.<|im_end|>
+<|im_start|>user
+The test `test_parse_duration` fails since yesterday's merge. Can you find out why and fix it?<|im_end|>
+<|im_start|>assistant
+<think>
+I should run the failing test first to see the actual error message, then look at the function it tests.
+</think>
+
+<tool_call>
+{"name": "run_command", "arguments": {"command": "python -m pytest tests/test_time_utils.py -k test_parse_duration -q"}}
+</tool_call><|im_end|>
+<|im_start|>user
+<tool_response>
+F [100%]
+=================================== FAILURES ===================================
+_____________________________ test_parse_duration ______________________________
+
+ def test_parse_duration():
+ assert parse_duration("90s") == 90
+ assert parse_duration("5m") == 300
+> assert parse_duration("1h30m") == 5400
+E ValueError: invalid duration: '1h30m'
+
+tests/test_time_utils.py:14: ValueError
+1 failed, 11 deselected in 0.21s
+</tool_response><|im_end|>
+<|im_start|>assistant
+<think>
+Single units work but a combined value fails. Let me read the parser.
+</think>
+
+<tool_call>
+{"name": "read_file", "arguments": {"path": "src/time_utils.py", "start_line": 1, "end_line": 40}}
+</tool_call><|im_end|>
+<|im_start|>user
+<tool_response>
+import re
+
+_UNITS = {"s": 1, "m": 60, "h": 3600, "d": 86400}
+_PART = re.compile(r"^(\d+)([smhd])$")
+
+
+def parse_duration(text: str) -> int:
+ """Parse a duration like '90s', '5m' or '1h30m' into seconds."""
+ text = text.strip().lower()
+ if not text:
+ raise ValueError("empty duration")
+ m = _PART.match(text)
+ if m is None:
+ raise ValueError(f"invalid duration: {text!r}")
+ return int(m.group(1)) * _UNITS[m.group(2)]
+</tool_response><|im_end|>
+<|im_start|>assistant
+<think>
+The regex is anchored at both ends and matches exactly one number-unit pair, so "1h30m" can never match. The docstring promises combined values. Let me check git history to see what the merge changed.
+</think>
+
+<tool_call>
+{"name": "run_command", "arguments": {"command": "git log -p -n 1 -- src/time_utils.py | head -40"}}
+</tool_call><|im_end|>
+<|im_start|>user
+<tool_response>
+commit 4e1b9c2f7a0d (Merge branch 'cleanup-regex')
+ Simplify duration parsing
+
+-_PART = re.compile(r"(\d+)([smhd])")
++_PART = re.compile(r"^(\d+)([smhd])$")
+@@ def parse_duration(text: str) -> int:
+- total = 0
+- pos = 0
+- for m in _PART.finditer(text):
+- if m.start() != pos:
+- raise ValueError(f"invalid duration: {text!r}")
+- total += int(m.group(1)) * _UNITS[m.group(2)]
+- pos = m.end()
+- if pos != len(text):
+- raise ValueError(f"invalid duration: {text!r}")
+- return total
++ m = _PART.match(text)
++ if m is None:
++ raise ValueError(f"invalid duration: {text!r}")
++ return int(m.group(1)) * _UNITS[m.group(2)]
+</tool_response><|im_end|>
+<|im_start|>assistant
+The cleanup merge replaced the loop over all number-unit pairs with a single anchored match, so only one unit per string is accepted now. I will restore the loop, which also rejects garbage between the parts.
+
+<tool_call>
+{"name": "edit_file", "arguments": {"path": "src/time_utils.py", "old": "_PART = re.compile(r\"^(\\d+)([smhd])$\")", "new": "_PART = re.compile(r\"(\\d+)([smhd])\")"}}
+</tool_call><|im_end|>
+<|im_start|>user
+<tool_response>
+OK: 1 replacement in src/time_utils.py
+</tool_response><|im_end|>
+<|im_start|>assistant
+<tool_call>
+{"name": "edit_file", "arguments": {"path": "src/time_utils.py", "old": " m = _PART.match(text)\n if m is None:\n raise ValueError(f\"invalid duration: {text!r}\")\n return int(m.group(1)) * _UNITS[m.group(2)]", "new": " total = 0\n pos = 0\n for m in _PART.finditer(text):\n if m.start() != pos:\n raise ValueError(f\"invalid duration: {text!r}\")\n total += int(m.group(1)) * _UNITS[m.group(2)]\n pos = m.end()\n if pos != len(text):\n raise ValueError(f\"invalid duration: {text!r}\")\n return total"}}
+</tool_call><|im_end|>
+<|im_start|>user
+<tool_response>
+OK: 1 replacement in src/time_utils.py
+</tool_response><|im_end|>
+<|im_start|>assistant
+<tool_call>
+{"name": "run_command", "arguments": {"command": "python -m pytest tests/test_time_utils.py -q"}}
+</tool_call><|im_end|>
+<|im_start|>user
+<tool_response>
+............ [100%]
+12 passed in 0.19s
+</tool_response><|im_end|>
+<|im_start|>assistant
+All 12 tests in `tests/test_time_utils.py` pass again. The cause was the `cleanup-regex` merge: it anchored the pattern with `^...$` and replaced the loop with one `match`, so a duration with several parts such as `1h30m` was rejected. I restored the previous loop, which sums every number-unit pair and still raises `ValueError` for text between or after the parts (for example `1h x30m`). You may want to add a test for that rejection case so the next simplification does not drop it.<|im_end|>
diff --git a/data/quant_quality/v1/code.txt b/data/quant_quality/v1/code.txt
new file mode 100644
index 000000000..6a92d3d98
--- /dev/null
+++ b/data/quant_quality/v1/code.txt
@@ -0,0 +1,125 @@
+"""Minimal GGUF v3 header reader - no ggml, no gguf-py.
+
+Written because the `gguf` PyPI package cannot open this artifact: its `GGMLQuantizationType`
+enum has no member for type 42 (`Q2_0`), which is newer than the library. That is itself a P0.S6
+finding - the format this engine is specialized for is ahead of the standard tooling.
+
+This is the reference implementation for `src/artifact/` (architecture §15: "GGUF v3 reader (mmap,
+no ggml dependency)"). It parses the header only; tensor data is never read.
+"""
+from __future__ import annotations
+
+import dataclasses
+import pathlib
+import struct
+from typing import Any
+
+GGUF_MAGIC = 0x46554747 # "GGUF" little-endian
+
+# ggml_type values. 42 = Q2_0, the GSQ-RCO routed-expert encoding, absent from gguf-py as of 0.19.
+GGML_TYPES: dict[int, str] = {
+ 0: "F32", 1: "F16", 2: "Q4_0", 3: "Q4_1", 4: "Q4_2", 5: "Q4_3", 6: "Q5_0", 7: "Q5_1",
+ 8: "Q8_0", 9: "Q8_1", 10: "Q2_K", 11: "Q3_K", 12: "Q4_K", 13: "Q5_K", 14: "Q6_K",
+ 15: "Q8_K", 16: "IQ2_XXS", 17: "IQ2_XS", 18: "IQ3_XXS", 19: "IQ1_S", 20: "IQ4_NL",
+ 21: "IQ3_S", 22: "IQ2_S", 23: "IQ4_XS", 24: "I8", 25: "I16", 26: "I32", 27: "I64",
+ 28: "F64", 29: "IQ1_M", 30: "BF16", 31: "Q4_0_4_4", 32: "Q4_0_4_8", 33: "Q4_0_8_8",
+ 34: "TQ1_0", 35: "TQ2_0", 36: "IQ4_NL_4_4", 37: "IQ4_NL_4_8", 38: "IQ4_NL_8_8",
+ 39: "MXFP4", 40: "NVFP4", 41: "Q4_0_8_8", 42: "Q2_0",
+}
+
+# GGUF metadata value type ids
+GGUF_META = {
+ 0: ("u8", 1), 1: ("i8", 1), 2: ("u16", 2), 3: ("i16", 2), 4: ("u32", 4), 5: ("i32", 4),
+ 6: ("f32", 4), 7: ("bool", 1), 8: ("string", None), 9: ("array", None),
+ 10: ("u64", 8), 11: ("i64", 8), 12: ("f64", 8),
+}
+
+# ggml block geometry for the encodings this model uses: (block elements, bytes per block)
+# This is what makes a per-tensor byte count checkable, and it is the contract the kernels share.
+BLOCK_GEOMETRY: dict[str, tuple[int, int]] = {
+ "F32": (1, 4), "F16": (1, 2), "BF16": (1, 2), "F64": (1, 8),
+ "Q4_0": (32, 18), "Q4_1": (32, 20), "Q5_0": (32, 22), "Q5_1": (32, 24),
+ "Q8_0": (32, 34), "Q8_1": (32, 36),
+ "Q2_K": (256, 84), "Q3_K": (256, 110), "Q4_K": (256, 144), "Q5_K": (256, 176),
+ "Q6_K": (256, 210), "Q8_K": (256, 292),
+ "IQ2_XXS": (256, 66), "IQ2_XS": (256, 74), "IQ3_XXS": (256, 98), "IQ1_S": (256, 50),
+ "IQ4_NL": (32, 18), "IQ3_S": (256, 110), "IQ2_S": (256, 82), "IQ4_XS": (256, 136),
+ "IQ1_M": (256, 56), "Q2_0": (64, 18), "MXFP4": (32, 17), "NVFP4": (64, 36),
+}
+
+
+class TensorInfo:
+ name: str
+ shape: list[int]
+ type_id: int
+ type_name: str
+ offset: int
+
+ @property
+ def elements(self) -> int:
+ n = 1
+ for d in self.shape:
+ n *= d
+ return n
+
+ def expected_bytes(self) -> int | None:
+ geom = BLOCK_GEOMETRY.get(self.type_name)
+ if geom is None:
+ return None
+ block_elems, block_bytes = geom
+ if self.elements % block_elems:
+ return None
+ return self.elements // block_elems * block_bytes
+
+
+class GGUFFile:
+ def __init__(self, path: pathlib.Path):
+ self.path = pathlib.Path(path)
+ self.metadata: dict[str, Any] = {}
+ self.tensors: list[TensorInfo] = []
+ self.version = 0
+ self.alignment = 32
+ with self.path.open("rb") as fh:
+ self._parse(fh)
+ self.data_start = self._data_start
+
+ # ------------------------------------------------------------------ internals
+ def _parse(self, fh) -> None:
+ magic = struct.unpack("<I", fh.read(4))[0]
+ if magic != GGUF_MAGIC:
+ raise ValueError(f"{self.path.name}: not a GGUF file (magic {magic:#x})")
+ self.version, n_tensors, n_kv = struct.unpack("<IQQ", fh.read(20))
+ if self.version != 3:
+ raise ValueError(f"{self.path.name}: GGUF v{self.version}, this reader handles v3")
+ for _ in range(n_kv):
+ key = self._str(fh)
+ self.metadata[key] = self._value(fh)
+ for _ in range(n_tensors):
+ name = self._str(fh)
+ (n_dims,) = struct.unpack("<I", fh.read(4))
+ shape = list(struct.unpack(f"<{n_dims}Q", fh.read(8 * n_dims)))
+ type_id, offset = struct.unpack("<IQ", fh.read(12))
+ self.tensors.append(TensorInfo(name, shape, type_id,
+ GGML_TYPES.get(type_id, f"type{type_id}"), offset))
+ align = self.metadata.get("general.alignment")
+ if isinstance(align, int) and align:
+ self.alignment = align
+ pos = fh.tell()
+ self._data_start = (pos + self.alignment - 1) // self.alignment * self.alignment
+
+ def _str(self, fh) -> str:
+ (n,) = struct.unpack("<Q", fh.read(8))
+ return fh.read(n).decode("utf-8", "replace")
+
+ def _value(self, fh):
+ (t,) = struct.unpack("<I", fh.read(4))
+ name, size = GGUF_META[t]
+ if name == "string":
+ return self._str(fh)
+ if name == "array":
+ (et,) = struct.unpack("<I", fh.read(4))
+ (count,) = struct.unpack("<Q", fh.read(8))
+ ename, esize = GGUF_META[et]
+ if ename == "string":
+ return [self._str(fh) for _ in r
\ No newline at end of file
diff --git a/data/quant_quality/v1/docs.txt b/data/quant_quality/v1/docs.txt
new file mode 100644
index 000000000..e73393f86
--- /dev/null
+++ b/data/quant_quality/v1/docs.txt
@@ -0,0 +1,56 @@
+## What is in the file
+
+Six shards, 169,165,382,688 bytes (169.2 GB) together ([sizes and SHA-256 from the HF tree API](https://huggingface.co/api/models/unsloth/Qwen3.8-Flash-Next-GGUF/tree/38bb39ee97821de2c9009abb7e93950eec396e66/UD-Q6_K_XL);
+shards 1, 2 and 6 were also checked bit for bit against their Hugging Face LFS hashes after download). Shard 1 holds
+only metadata; shard 2 only the output head (`output.weight`, `output_hc_*`, all Q8_0 but `output_hc_norm`, F32);
+shard 3 is exactly the PLE table, nothing else.
+
+| File | Bytes | SHA-256 |
+| --- | --- | --- |
+| `Qwen3.8-Flash-Next-UD-Q6_K_XL-00001-of-00006.gguf` | 10,946,624 | `8bdc6bad55b6699f46f60708829932ff4018d7ac9bd309c388534fa31753bdb7` |
+| `Qwen3.8-Flash-Next-UD-Q6_K_XL-00002-of-00006.gguf` | 682,434,912 | `494ca4ed3dbf97bc28da88af3890b8877b9032f909812d00c0526a9ca5e91d2e` |
+| `Qwen3.8-Flash-Next-UD-Q6_K_XL-00003-of-00006.gguf` | 54,400,261,312 | `34efd79a80a1ce540a517a5d56171924b66ce1c38b04c904f17ad6d8ef17cf20` |
+| `Qwen3.8-Flash-Next-UD-Q6_K_XL-00004-of-00006.gguf` | 49,814,108,512 | `0ea4b599880a5a52fcd9c188ba1443f646c69c96571904ddbd6a79246a01a997` |
+| `Qwen3.8-Flash-Next-UD-Q6_K_XL-00005-of-00006.gguf` | 49,419,317,344 | `9948e81ae8368144b135a7403d8c0f2cf9a6c2f9f692313865855b2832e696c9` |
+| `Qwen3.8-Flash-Next-UD-Q6_K_XL-00006-of-00006.gguf` | 14,838,313,984 | `e4ae255234f42b18012f6d6eec5bf615b57479b7e0a0233c47436a321ffeec3f` |
+
+Formats, read from the shard headers with `tools/gguf_reader.py` (all six shards verified: shard 4 = blocks 0-20,
+520 tensors, shard 5 = blocks 20-41, 530 tensors, and per layer the types above):
+
+- **Routed experts:** `ffn_gate_exps` and `ffn_up_exps` are Q6_K (seen in every layer of shard 6: blocks 41-47);
+ `ffn_down_exps` is Q8_0 (per layer 891.3 MB at 640×2560×512, against Q6_K's 688.1 MB at 2560×640×512 for gate or
+ up). Gate and up are Q6_K in 47 of 48 layers and Q8_0 in layer 2; down is Q8_0 in every layer (the pack's
+ `native_experts.txt`: 47 rows of ggml types 14/8, and layer 2 is 8/8). Q6_K gate/up is native: the
+ engine multiplies them directly on the GPU in every path check below, and the CPU has the ggml block layout (210
+ bytes per 256 elements); the per-role layout in `native_experts.txt` v4 handles shards whose boundaries cut
+ through a layer like UD-Q4_K_XL's layer 11 case does.
+- **Everything else:** attention and shared-expert projections, SSM, hyper-connections, the PLE key/value, the token
+ embedding and the output head are Q8_0, or F32/BF16 where the engine reads floats — the same pattern
+ [UD-Q4_K_XL](UNSLOTH_Q4.md) handles with `tools/iq_pack.py --compat-bf16`.
+- **The PLE table** (`per_layer_token_embd.weight`, [160, 320001536]): **Q8_0**, its own shard 3. A row is
+ 5 blocks of 32 elements at 34 bytes = 170 bytes, and the whole table is 54.4 GB, against the 28.8 GB IQ4_NL of
+ UD-Q4_K_XL. Engine 0.1.38 reads Q8_0 rows natively: `PleTable` accepts the type, the row reader is already
+ parameterized by bytes-per-row (its selftest runs 90, 110 and 170 byte rows), and no GPU kernel changes —
+ `gather` outputs floats. (UD-Q4_K_XL's table is IQ4_NL; the FP8 table of [tools/ple_fp8_pack.py](../tools/ple_fp8_pack.py)
+ needs the original checkpoint, which this file is not a substitute for. Converting this Q8_0 table to FP8 would
+ trade table precision away for 6% smaller rows; Q8_0 read directly has none that conversion's error.)
+
+Q6_K gate/up costs 210 bytes per 256 elements, against Q4_K's 144, so the routed experts' share of the file grows
+about 45% per element read; expected decode speed accordingly lower than UD-Q4_K_XL's on the same hardware. The
+table row gather grows 170/90 = 1.89x over IQ4_NL.
+
+## The pack (by hand)
+
+Same workflow as [UD-Q4_K_XL](UNSLOTH_Q4.md#the-pack-by-hand), from the repository root:
+
+```sh
+.venv/bin/python tools/iq_pack.py \
+ --gguf /path/to/Qwen3.8-Flash-Next-UD-Q6_K_XL-00001-of-00006.gguf \
+ --out packs/ud-q6_k_xl --compat-bf16
+```
+
+**`--compat-bf16` is required** for the same reason as there (the 195 small Q8_0 projections the engine reads as
+BF16). Do not add `--experts-bin`; the experts stay in the GGUF files. Built here end to end on this file
+(`packs/ud-q6_k_xl`, the packer's own tests cover the shard and conversion logic via
+`.venv/bin/python -m unittest discover -s tools -p test_iq_pack.py`): 1079 tensors indexed, 303 served natively, 460
+tensors converted (26
\ No newline at end of file
diff --git a/data/quant_quality/v1/english.txt b/data/quant_quality/v1/english.txt
new file mode 100644
index 000000000..f4b5b49f3
--- /dev/null
+++ b/data/quant_quality/v1/english.txt
@@ -0,0 +1,17 @@
+The lighthouse at the end of the northern breakwater had been automated for almost forty years, but the town still sent someone out to it every Thursday. Nobody remembered who had made the rule, and nobody had ever written it down. It was simply understood that on Thursday afternoon, when the ferry had left and the fish market had been hosed clean, one person would walk the length of the stone pier, unlock the iron door with the key that hung behind the counter of the harbour office, climb the hundred and twelve steps, and look.
+
+For most of that time the person had been Margaret Hale, who ran the chandlery and claimed she needed the exercise. When her knees finally gave out, the key passed to her grandson Tomas, who was fourteen and considered the whole business a waste of a perfectly good afternoon. He said so, loudly, for the first three weeks. On the fourth Thursday a storm came in early from the west, and he found himself at the top of the tower watching a small sailing boat fight its way past the outer rocks with a torn jib and nobody visibly at the helm.
+
+He did what his grandmother had told him to do, which was nothing dramatic. He wrote down the time, the direction of the wind, the name painted on the stern, and the fact that he could see only one person on deck. Then he walked back down the hundred and twelve steps, crossed the pier with his hood pulled tight, and told the harbour master, who telephoned the lifeboat station. The boat was towed in an hour later. Its skipper, a retired schoolteacher who had been sailing alone from the islands, had broken his wrist when the boom swung across and had been steering with his feet.
+
+The story was in the local paper the following week, and Tomas was embarrassed by it, mostly because the photograph showed him in his school uniform. What stayed with him was something else. On the walk back along the pier that evening, the harbour master had told him that the automated light had worked perfectly the whole time. It had turned, it had flashed its pattern, and it had done exactly what it was built to do. The light could warn a boat away from the rocks, but it could not notice that a boat was in trouble. Only a person could do that, and only if a person was there to look.
+
+People in the town sometimes talk about that rule now as though it had been a clever piece of planning, a deliberate safeguard against the limits of machines. Tomas does not think it was anything of the kind. He thinks it began because somebody missed the old keeper and could not quite bring themselves to stop going out to the tower, and that it continued because nobody wanted to be the one to end it. Habits are like that. They outlast their reasons, and every so often, without anyone planning it, they find a new one.
+
+He is twenty-six now and works as an engineer on the offshore wind farm that you can see from the top of the lighthouse on a clear day: two hundred white turbines standing in rows on the horizon, each one watched by sensors that report vibration, temperature and blade pitch to a control room in another country. The systems are very good. They catch almost everything. He still goes out to the tower on Thursdays when he is home, climbs the steps, and looks.
+
+Ask him why, and he will tell you a story that has nothing to do with lighthouses. In his second year on the wind farm, a monitoring system flagged a slow rise in the temperature of a gearbox on one of the turbines at the far end of the array. The rise was small, well inside the limits, and the software ranked it as low priority. It would have been looked at during the next scheduled visit, six weeks later. A technician on the maintenance boat, passing the turbine on another job, noticed that the nacelle sounded different, a faint grinding note under the usual hum, and asked the skipper to stop. When they opened the gearbox they found a bearing that was a few days from failing. Replacing it cost a morning. Replacing the gearbox after the bearing failed would have cost a month and the price of a small house.
+
+The technician was not cleverer than the software. She had simply been there, close enough to hear, and curious enough to ask for the boat to stop. The data had shown the same problem; it had just not shown it loudly enough for anyone to care. Tomas thinks about that often. Every system he has worked on has been very good at measuring the things its designers expected to go wrong, and much less good at the things nobody expected. The gap between the two is where people still earn their keep, not by doing the machine's job better than the machine, but by noticing when the job itself has quietly changed.
+
+So on Thursdays, when he can, he walks out along the pier. The stone is worn smooth in a line down the middle where generations of boots have gone the same way. The iron door still sticks in wet weather. The view from the top has changed more in the last ten years than in the hundred before, and he likes to see it for himself.
diff --git a/data/quant_quality/v1/multilingual.txt b/data/quant_quality/v1/multilingual.txt
new file mode 100644
index 000000000..f7748fdfd
--- /dev/null
+++ b/data/quant_quality/v1/multilingual.txt
@@ -0,0 +1,116 @@
+Strata lässt **[Qwen3.8-Flash-Next](https://huggingface.co/Qwen/Qwen3.8-Flash-Next)** auf einem normalen PC laufen.
+Das ist ein großes, kluges KI-Modell, das sonst meist einen Server braucht. Es chattet, schreibt Code, versteht
+Bilder und arbeitet mit deinen Apps und Coding-Agents zusammen. Nichts verlässt deinen PC.
+
+## Wie schnell ist es?
+
+Wir haben es auf zwei ganz normalen Gaming-PCs gemessen. Ein Token ist etwa ¾ eines Wortes.
+
+- **Schreibt Antworten:** wie schnell die Antwort in einem kurzen Chat erscheint. 60 Tokens pro Sekunde sind
+ schneller, als du lesen kannst.
+- **Liest deinen Prompt:** wie schnell es aufnimmt, was du schickst (hier ein Dokument, Code oder Chatverlauf mit
+ 32K Tokens).
+
+<table>
+<tr><th>NVIDIA: RTX 5070 (12 GB), Ryzen 5 7600, 64 GB RAM</th><th>AMD: RX 9070 XT (16 GB), Ryzen 9 3900X, 47 GB RAM</th></tr>
+<tr><td>
+
+| Größe | Schreibt Antworten | Liest deinen Prompt |
+| --- | ---: | ---: |
+| **Q2_0** | 94 Tokens/s | 2,650 Tokens/s |
+| **IQ2_XS** | 79 Tokens/s | 2,090 Tokens/s |
+| **IQ3_XXS** | 62 Tokens/s | 1,750 Tokens/s |
+| **IQ3_S** | 53 Tokens/s | 1,620 Tokens/s |
+| **Coder** | 55 Tokens/s | 2,180 Tokens/s |
+
+</td><td>
+
+| Größe | Schreibt Antworten | Liest deinen Prompt |
+| --- | ---: | ---: |
+| **Q2_0** | 60 Tokens/s | 1,160 Tokens/s |
+| **IQ2_XS** | 52 Tokens/s | 1,110 Tokens/s |
+| **Coder** | 44 Tokens/s | 1,420 Tokens/s |
+
+</td></tr>
+</table>
+
+NVIDIA: Q2_0 mit Engine 0.1.36, die anderen Zeilen mit 0.1.26 (4K Antworten, 32K Prompts). Die vollständigen
+Tabellen stehen in [DETAILS.md](docs/DETAILS.md#speed-measured). Eine Karte mit mehr VRAM ist schneller: Eine
+RTX 3090 (24 GB) sollte etwa 100-140 Tokens pro Sekunde schreiben. Lange Chats un
+
+Strata fait tourner **[Qwen3.8-Flash-Next](https://huggingface.co/Qwen/Qwen3.8-Flash-Next)** sur un PC normal. C'est
+un grand modèle d'IA, très capable, qui demande d'habitude un serveur. Il discute, écrit du code, lit des images et
+fonctionne avec vos applications et vos agents de code. Rien ne quitte votre PC.
+
+## Quelle est sa vitesse ?
+
+Nous l'avons mesurée sur deux PC de jeu ordinaires. Un token correspond à environ ¾ d'un mot.
+
+- **Écrit les réponses :** la vitesse à laquelle la réponse s'affiche dans une courte discussion. 60 tokens par seconde, c'est plus rapide que votre lecture.
+- **Lit votre prompt :** la vitesse à laquelle il absorbe ce que vous envoyez (ici un document, du code ou un historique de discussion de 32K tokens).
+
+<table>
+<tr><th>NVIDIA : RTX 5070 (12 Go), Ryzen 5 7600, 64 Go de RAM</th><th>AMD : RX 9070 XT (16 Go), Ryzen 9 3900X, 47 Go de RAM</th></tr>
+<tr><td>
+
+| Taille | Écrit les réponses | Lit votre prompt |
+| --- | ---: | ---: |
+| **Q2_0** | 94 tokens/s | 2,650 tokens/s |
+| **IQ2_XS** | 79 tokens/s | 2,090 tokens/s |
+| **IQ3_XXS** | 62 tokens/s | 1,750 tokens/s |
+| **IQ3_S** | 53 tokens/s | 1,620 tokens/s |
+| **Coder** | 55 tokens/s | 2,180 tokens/s |
+
+</td><td>
+
+| Taille | Écrit les réponses | Lit votre prompt |
+| --- | ---: | ---: |
+| **Q2_0** | 60 tokens/s | 1,160 tokens/s |
+| **IQ2_XS** | 52 tokens/s | 1,110 tokens/s |
+| **Coder** | 44 tokens/s | 1,420 tokens/s |
+
+</td></tr>
+</table>
+
+NVIDIA : Q2_0 avec le moteur 0.1.36, les autres lignes ave
+
+Strata を使うと、**[Qwen3.8-Flash-Next](https://huggingface.co/Qwen/Qwen3.8-Flash-Next)** を一般的な PC で動かせます。
+通常はサーバーを必要とする大規模で高性能な AI モデルで、チャットやコードの生成、画像の読み取りができます。
+アプリやコーディングエージェントとも連携でき、データは PC の外に送信されません。
+
+## どのくらい速い?
+
+一般的なゲーミング PC 2 台で速度を測定しました。英語の場合、1 トークンはおよそ ¾ 語に相当します。
+
+- **生成速度:** 短いチャットで回答を生成する速度です。毎秒 60 トークンなら、人が読むよりも速く文章が表示されます。
+- **プロンプトの読み込み:** 入力した内容を読み込む速度です。ここでは、文書やコード、チャット履歴など 32K トークン分を読み込ませています。
+
+<table>
+<tr><th>NVIDIA: RTX 5070 (12 GB), Ryzen 5 7600, 64 GB RAM</th><th>AMD: RX 9070 XT (16 GB), Ryzen 9 3900X, 47 GB RAM</th></tr>
+<tr><td>
+
+| モデルサイズ | 生成速度 | プロンプトの読み込み |
+| --- | ---: | ---: |
+| **Q2_0** | 94 tokens/s | 2,650 tokens/s |
+| **IQ2_XS** | 79 tokens/s | 2,090 tokens/s |
+|
+
+Strata 能在普通电脑上运行 **[Qwen3.8-Flash-Next](https://huggingface.co/Qwen/Qwen3.8-Flash-Next)**。这是一个又大又聪明的
+AI 模型,通常要用服务器才能跑。它能聊天、写代码、看图片,还能配合你的应用和编程智能体一起工作。所有数据都留在你的电脑上。
+
+## 速度有多快?
+
+我们在两台普通的游戏电脑上做了测试。一个 token 大约相当于 ¾ 个英文单词。
+
+- **写回答:** 短对话中回复出现的速度。每秒 60 个 token 已经比你的阅读速度还快。
+- **读提示:** 读入你发送内容的速度(这里是一份 32K token 的文档、代码或聊天记录)。
+
+<table>
+<tr><th>NVIDIA:RTX 5070(12 GB)、Ryzen 5 7600、64 GB 内存</th><th>AMD:RX 9070 XT(16 GB)、Ryzen 9 3900X、47 GB 内存</th></tr>
+<tr><td>
+
+| 规格 | 写回答 | 读提示 |
+| --- | ---: | ---: |
+| **Q2_0** | 94 tokens/s | 2,650 tokens/s |
+| **IQ2_XS** | 79 tokens/s | 2,090 tokens/s |
+| **IQ3_XXS**
\ No newline at end of file
diff --git a/data/quant_quality/v1/set.ids.json b/data/quant_quality/v1/set.ids.json
new file mode 100644
index 000000000..f487b6495
--- /dev/null
+++ b/data/quant_quality/v1/set.ids.json
@@ -0,0 +1 @@
+{"version": "v1", "seg_tokens": 1000, "segments": [{"name": "code", "ids": [12237, 85286, 54802, 19913, 343, 18, 4108, 6396, 471, 874, 50285, 980, 11, 874, 50285, 1644, 2195, 88, 13, 271, 34447, 1521, 279, 1510, 13985, 1644, 63, 5187, 1828, 6129, 4021, 1724, 411, 35426, 25, 1141, 1510, 21563, 2581, 42750, 1954, 900, 63, 198, 8746, 682, 874, 4314, 364, 913, 220, 19, 17, 27718, 48, 17, 62, 15, 63, 681, 864, 369, 24733, 1056, 279, 6522, 13, 2844, 369, 4924, 264, 387, 15, 782, 21, 198, 64919, 471, 279, 3443, 411, 4560, 369, 26208, 364, 369, 8047, 314, 279, 5129, 5224, 286, 13, 271, 1919, 369, 279, 5604, 7873, 364, 1510, 3431, 53683, 20123, 14, 63, 318, 77646, 16137, 16, 20, 25, 328, 21563, 19913, 343, 18, 6396, 318, 76, 2117, 11, 198, 2083, 50285, 980, 23285, 61406, 1049, 68434, 279, 4108, 1132, 26, 15167, 795, 369, 2496, 1301, 13, 198, 12237, 198, 1445, 1259, 20409, 548, 1120, 31144, 271, 464, 795, 8588, 198, 464, 51372, 198, 464, 1968, 198, 1445, 18904, 1120, 5586, 271, 21563, 19913, 47540, 283, 220, 15, 87, 19, 21, 20, 20, 19, 22, 19, 22, 220, 653, 328, 21563, 19913, 1, 2545, 12692, 1068, 271, 2, 50285, 980, 1756, 2663, 13, 220, 19, 17, 283, 1167, 17, 62, 15, 11, 279, 34100, 48, 12, 7146, 46, 69764, 17830, 517, 10845, 11, 26334, 494, 50285, 1644, 2195, 88, 430, 314, 220, 15, 13, 16, 24, 13, 198, 21563, 2581, 24973, 25, 6249, 18078, 11, 592, 60, 283, 313, 198, 262, 220, 15, 25, 328, 37, 18, 17, 487, 220, 16, 25, 328, 37, 16, 21, 487, 220, 17, 25, 328, 48, 19, 62, 15, 487, 220, 18, 25, 328, 48, 19, 62, 16, 487, 220, 19, 25, 328, 48, 19, 62, 17, 487, 220, 20, 25, 328, 48, 19, 62, 18, 487, 220, 21, 25, 328, 48, 20, 62, 15, 487, 220, 22, 25, 328, 48, 20, 62, 16, 487, 198, 262, 220, 23, 25, 328, 48, 23, 62, 15, 487, 220, 24, 25, 328, 48, 23, 62, 16, 487, 220, 16, 15, 25, 328, 48, 17, 9802, 487, 220, 16, 16, 25, 328, 48, 18, 9802, 487, 220, 16, 17, 25, 328, 48, 19, 9802, 487, 220, 16, 18, 25, 328, 48, 20, 9802, 487, 220, 16, 19, 25, 328, 48, 21, 9802, 487, 198, 262, 220, 16, 20, 25, 328, 48, 23, 9802, 487, 220, 16, 21, 25, 328, 59865, 17, 62, 5955, 50, 487, 220, 16, 22, 25, 328, 59865, 17, 6645, 50, 487, 220, 16, 23, 25, 328, 59865, 18, 62, 5955, 50, 487, 220, 16, 24, 25, 328, 59865, 16, 1063, 487, 220, 17, 15, 25, 328, 59865, 19, 1548, 43, 487, 198, 262, 220, 17, 16, 25, 328, 59865, 18, 1063, 487, 220, 17, 17, 25, 328, 59865, 17, 1063, 487, 220, 17, 18, 25, 328, 59865, 19, 6645, 50, 487, 220, 17, 19, 25, 328, 40, 23, 487, 220, 17, 20, 25, 328, 40, 16, 21, 487, 220, 17, 21, 25, 328, 40, 18, 17, 487, 220, 17, 22, 25, 328, 40, 21, 19, 487, 198, 262, 220, 17, 23, 25, 328, 37, 21, 19, 487, 220, 17, 24, 25, 328, 59865, 16, 1203, 487, 220, 18, 15, 25, 328, 19278, 16, 21, 487, 220, 18, 16, 25, 328, 48, 19, 62, 15, 62, 19, 62, 19, 487, 220, 18, 17, 25, 328, 48, 19, 62, 15, 62, 19, 62, 23, 487, 220, 18, 18, 25, 328, 48, 19, 62, 15, 62, 23, 62, 23, 487, 198, 262, 220, 18, 19, 25, 328, 51, 48, 16, 62, 15, 487, 220, 18, 20, 25, 328, 51, 48, 17, 62, 15, 487, 220, 18, 21, 25, 328, 59865, 19, 1548, 43, 62, 19, 62, 19, 487, 220, 18, 22, 25, 328, 59865, 19, 1548, 43, 62, 19, 62, 23, 487, 220, 18, 23, 25, 328, 59865, 19, 1548, 43, 62, 23, 62, 23, 487, 198, 262, 220, 18, 24, 25, 328, 28463, 11361, 19, 487, 220, 19, 15, 25, 328, 35125, 11361, 19, 487, 220, 19, 16, 25, 328, 48, 19, 62, 15, 62, 23, 62, 23, 487, 220, 19, 17, 25, 328, 48, 17, 62, 15, 487, 198, 92, 271, 2, 54802, 19913, 10836, 869, 913, 13746, 198, 21563, 19913, 57818, 283, 313, 198, 262, 220, 15, 25, 3376, 84, 23, 487, 220, 16, 681, 220, 16, 25, 3376, 72, 23, 487, 220, 16, 681, 220, 17, 25, 3376, 84, 16, 21, 487, 220, 17, 681, 220, 18, 25, 3376, 72, 16, 21, 487, 220, 17, 681, 220, 19, 25, 3376, 84, 18, 17, 487, 220, 19, 681, 220, 20, 25, 3376, 72, 18, 17, 487, 220, 19, 681, 198, 262, 220, 21, 25, 3376, 69, 18, 17, 487, 220, 19, 681, 220, 22, 25, 3376, 2554, 487, 220, 16, 681, 220, 23, 25, 3376, 889, 487, 2168, 681, 220, 24, 25, 3376, 1595, 487, 2168, 681, 198, 262, 220, 16, 15, 25, 3376, 84, 21, 19, 487, 220, 23, 681, 220, 16, 16, 25, 3376, 72, 21, 19, 487, 220, 23, 681, 220, 16, 17, 25, 3376, 69, 21, 19, 487, 220, 23, 681, 198, 92, 271, 2, 50285, 980, 2424, 16547, 364, 279, 3107, 56373, 411, 1558, 5533, 25, 318, 4425, 5255, 11, 5639, 791, 2424, 8, 198, 2, 1061, 369, 1092, 3520, 264, 791, 2308, 3677, 4763, 1698, 1716, 470, 11, 321, 424, 369, 279, 4954, 279, 61369, 4191, 13, 198, 38637, 57038, 83072, 25, 6249, 16793, 11, 13992, 18078, 11, 514, 4891, 283, 313, 198, 262, 328, 37, 18, 17, 763, 318, 16, 11, 220, 19, 681, 328, 37, 16, 21, 763, 318, 16, 11, 220, 17, 681, 328, 19278, 16, 21, 763, 318, 16, 11, 220, 17, 681, 328, 37, 21, 19, 763, 318, 16, 11, 220, 23, 681, 198, 262, 328, 48, 19, 62, 15, 763, 318, 18, 17, 11, 220, 16, 23, 681, 328, 48, 19, 62, 16, 763, 318, 18, 17, 11, 220, 17, 15, 681, 328, 48, 20, 62, 15, 763, 318, 18, 17, 11, 220, 17, 17, 681, 328, 48]}, {"name": "docs", "ids": [550, 3437, 369, 303, 279, 999, 271, 40087, 71590, 11, 220, 16, 21, 24, 11, 16, 21, 20, 11, 18, 23, 17, 11, 21, 23, 23, 5639, 318, 16, 21, 24, 13, 17, 18295, 8, 3658, 11406, 51368, 321, 21050, 12, 17, 20, 21, 494, 279, 48855, 4757, 5165, 9251, 2349, 1074, 71, 34098, 1509, 6616, 10195, 19652, 14, 10545, 67194, 43765, 16451, 18, 13, 23, 12, 23129, 12, 5666, 11668, 38, 19913, 60854, 14, 18, 23, 5876, 18, 24, 2059, 24, 22, 23, 17, 16, 442, 17, 66, 24, 15, 15, 24, 12163, 22, 68, 24, 18, 24, 20, 15, 92520, 18, 24, 21, 68, 21, 21, 14, 4505, 27325, 21, 9802, 6645, 43, 1174, 198, 898, 2271, 220, 16, 11, 220, 17, 321, 220, 21, 998, 1048, 9770, 2612, 364, 2612, 2272, 836, 462, 34098, 18036, 436, 8225, 48570, 1238, 4003, 553, 92071, 220, 16, 9687, 198, 3138, 10836, 26, 50319, 220, 17, 1132, 279, 2468, 1901, 27718, 2911, 24354, 7561, 1510, 2911, 1469, 66, 44272, 7561, 660, 1167, 23, 62, 15, 694, 1510, 2911, 1469, 66, 18601, 7561, 426, 18, 17, 1174, 198, 898, 552, 220, 18, 369, 6681, 279, 387, 841, 1898, 11, 4161, 745, 13, 271, 91, 2793, 735, 29041, 735, 21050, 12, 17, 20, 21, 735, 198, 91, 12091, 735, 12091, 735, 12091, 735, 198, 91, 1510, 48, 16451, 18, 13, 23, 12, 23129, 12, 5666, 12, 4505, 27325, 21, 9802, 6645, 43, 12, 15, 15, 15, 15, 16, 8404, 12, 15, 15, 15, 15, 21, 75021, 1644, 63, 735, 220, 16, 15, 11, 24, 19, 21, 11, 21, 17, 19, 735, 1510, 23, 65, 7385, 21, 13458, 20, 20, 65, 21, 21, 24, 24, 69, 19, 21, 69, 21, 15, 22, 15, 23, 23, 17, 24, 24, 18, 17, 529, 19, 15, 16, 23, 67, 22, 565, 24, 8670, 18, 15, 24, 66, 18, 23, 23, 20, 18, 19, 3510, 18, 16, 22, 20, 18, 82800, 22, 63, 735, 198, 91, 1510, 48, 16451, 18, 13, 23, 12, 23129, 12, 5666, 12, 4505, 27325, 21, 9802, 6645, 43, 12, 15, 15, 15, 15, 17, 8404, 12, 15, 15, 15, 15, 21, 75021, 1644, 63, 735, 220, 21, 23, 17, 11, 19, 18, 19, 11, 24, 16, 17, 735, 1510, 19, 24, 19, 895, 19, 290, 18, 1932, 69, 24, 22, 8635, 17, 23, 3131, 23, 23, 2492, 18, 23, 24, 15, 65, 23, 23, 22, 22, 65, 24, 15, 18, 17, 69, 24, 15, 24, 23, 16, 17, 67, 15, 15, 66, 15, 20, 17, 21, 64, 24, 895, 20, 68, 24, 16, 67, 17, 68, 63, 735, 198, 91, 1510, 48, 16451, 18, 13, 23, 12, 23129, 12, 5666, 12, 4505, 27325, 21, 9802, 6645, 43, 12, 15, 15, 15, 15, 18, 8404, 12, 15, 15, 15, 15, 21, 75021, 1644, 63, 735, 220, 20, 19, 11, 19, 15, 15, 11, 17, 21, 16, 11, 18, 16, 17, 735, 1510, 18, 19, 90450, 22, 24, 64, 23, 15, 64, 16, 341, 20, 19, 15, 64, 20, 16, 22, 64, 20, 67, 20, 21, 16, 22, 16, 24, 17, 19, 65, 21, 21, 341, 16, 66, 18, 23, 65, 15, 19, 66, 24, 15, 19, 69, 16, 22, 327, 21, 67, 23, 797, 16, 22, 9500, 17, 15, 63, 735, 198, 91, 1510, 48, 16451, 18, 13, 23, 12, 23129, 12, 5666, 12, 4505, 27325, 21, 9802, 6645, 43, 12, 15, 15, 15, 15, 19, 8404, 12, 15, 15, 15, 15, 21, 75021, 1644, 63, 735, 220, 19, 24, 11, 23, 16, 19, 11, 16, 15, 23, 11, 20, 16, 17, 735, 1510, 15, 12150, 19, 65, 20, 24, 24, 23, 23, 15, 64, 20, 64, 20, 17, 69, 4243, 24, 66, 16, 23, 23, 4494, 16, 19, 19, 18, 69, 21, 19, 21, 66, 21, 24, 66, 24, 21, 20, 22, 16, 24, 15, 19, 613, 8670, 21, 64, 22, 24, 17, 19, 21, 64, 15, 16, 64, 24, 24, 22, 63, 735, 198, 91, 1510, 48, 16451, 18, 13, 23, 12, 23129, 12, 5666, 12, 4505, 27325, 21, 9802, 6645, 43, 12, 15, 15, 15, 15, 20, 8404, 12, 15, 15, 15, 15, 21, 75021, 1644, 63, 735, 220, 19, 24, 11, 19, 16, 24, 11, 18, 16, 22, 11, 18, 19, 19, 735, 1510, 24, 24, 19, 23, 68, 23, 16, 5734, 23, 18, 21, 23, 16, 19, 19, 65, 16, 18, 20, 64, 22, 19, 15, 18, 67, 23, 66, 15, 69, 17, 9500, 24, 64, 21, 66, 17, 69, 24, 69, 21, 24, 17, 18, 16, 18, 23, 21, 20, 23, 20, 20, 65, 17, 23, 18, 17, 68, 21, 24, 21, 66, 24, 63, 735, 198, 91, 1510, 48, 16451, 18, 13, 23, 12, 23129, 12, 5666, 12, 4505, 27325, 21, 9802, 6645, 43, 12, 15, 15, 15, 15, 21, 8404, 12, 15, 15, 15, 15, 21, 75021, 1644, 63, 735, 220, 16, 19, 11, 23, 18, 23, 11, 18, 16, 18, 11, 24, 23, 19, 735, 1510, 68, 19, 5734, 17, 20, 20, 17, 18, 19, 69, 19, 17, 65, 16, 23, 15, 16, 17, 69, 21, 67, 21, 92520, 20, 12849, 21, 16, 20, 65, 20, 22, 19, 22, 24, 65, 22, 68, 15, 64, 15, 17, 18, 18, 66, 19, 22, 19, 18, 21, 64, 18, 17, 16, 27063, 732, 18, 69, 63, 735, 271, 43121, 11, 1301, 494, 279, 50319, 6881, 440, 1510, 15449, 4691, 70, 1644, 21614, 6971, 63, 318, 528, 4590, 71590, 23185, 25, 50319, 220, 19, 283, 9714, 220, 15, 12, 17, 15, 11, 198, 20, 17, 15, 74451, 11, 50319, 220, 20, 283, 9714, 220, 17, 15, 12, 19, 16, 11, 220, 20, 18, 15, 74451, 11, 321, 791, 6000, 279, 4346, 3294, 1590, 271, 12, 2972, 49, 17978, 11312, 64700, 1510, 529, 77, 52954, 2615, 1630, 63, 321, 1510, 529, 77, 7980, 2615, 1630, 63, 513, 1167, 21, 9802, 318, 27392, 303, 1396, 6000, 314, 50319, 220, 21, 25, 9714, 220, 19, 16, 12, 19, 22, 1174, 198]}, {"name": "english", "ids": [760, 324, 55965, 506, 279, 809, 314, 279, 17631, 1387, 12615, 995, 978, 26606, 364, 4409, 34227, 1578, 11, 694, 279, 6092, 1990, 3106, 4184, 680, 310, 424, 1396, 7548, 13, 35254, 25624, 852, 995, 1801, 279, 5728, 11, 321, 18022, 995, 3397, 5158, 424, 1441, 13, 1049, 557, 4777, 15513, 421, 383, 7548, 12967, 11, 948, 279, 49813, 995, 2047, 321, 279, 7397, 2981, 995, 978, 304, 18988, 4101, 11, 799, 1637, 1000, 4088, 279, 2984, 314, 279, 9506, 21268, 11, 14617, 279, 10679, 5817, 440, 279, 1328, 421, 17750, 4661, 279, 5373, 314, 279, 72103, 4998, 11, 24562, 279, 7493, 321, 28279, 7123, 11, 321, 1353, 13, 271, 2381, 1379, 314, 421, 854, 279, 1637, 995, 978, 36306, 63918, 11, 852, 10298, 279, 509, 429, 75, 702, 321, 11324, 1292, 4221, 279, 9856, 13, 3095, 1024, 29528, 5326, 6348, 680, 11, 279, 1328, 5642, 310, 1024, 63634, 84907, 11, 852, 557, 60163, 321, 6306, 279, 4220, 2478, 264, 11939, 314, 264, 13542, 1603, 12967, 13, 1216, 1018, 748, 11, 52039, 11, 364, 279, 1118, 2250, 5381, 13, 1848, 279, 11400, 7548, 264, 13071, 3571, 303, 3988, 494, 279, 9422, 11, 321, 551, 1669, 5387, 506, 279, 1844, 314, 279, 20618, 9799, 264, 2526, 48345, 14882, 4226, 1141, 1560, 3162, 279, 15484, 22317, 440, 264, 20496, 492, 564, 321, 18022, 70524, 506, 279, 32647, 13, 271, 1465, 1467, 1092, 780, 36919, 995, 3125, 1384, 310, 635, 11, 864, 557, 4161, 21100, 13, 1216, 5947, 1441, 279, 854, 11, 279, 4944, 314, 279, 9662, 11, 279, 803, 23235, 383, 279, 55618, 11, 321, 279, 2029, 421, 551, 1362, 1436, 1132, 799, 1637, 383, 9249, 13, 4844, 551, 14428, 1142, 1441, 279, 7493, 321, 28279, 7123, 11, 26164, 279, 21268, 440, 780, 26338, 12854, 9990, 11, 321, 3125, 279, 72103, 7110, 11, 852, 7712, 734, 19083, 279, 2199, 36516, 7803, 13, 561, 14882, 557, 15348, 290, 303, 449, 6258, 2843, 13, 11116, 10390, 692, 11, 264, 20922, 2812, 22635, 852, 995, 978, 48345, 7249, 494, 279, 28053, 11, 995, 10548, 780, 31111, 948, 279, 28774, 67490, 3808, 321, 995, 978, 31117, 440, 780, 7303, 13, 271, 760, 3255, 557, 303, 279, 2136, 5392, 279, 2614, 1936, 11, 321, 84907, 557, 46523, 539, 424, 11, 9712, 1521, 279, 9994, 8280, 1384, 303, 780, 2812, 13398, 13, 3437, 19013, 440, 1384, 557, 2414, 745, 13, 1848, 279, 4088, 1142, 3055, 279, 21268, 421, 11129, 11, 279, 72103, 7110, 995, 3125, 1384, 421, 279, 26606, 3000, 995, 6237, 13542, 279, 4220, 854, 13, 1049, 995, 6316, 11, 424, 995, 67474, 1141, 5215, 11, 321, 424, 995, 2725, 6681, 1092, 424, 557, 5617, 310, 635, 13, 561, 3000, 1362, 8543, 264, 14882, 3023, 494, 279, 22317, 11, 694, 424, 1362, 524, 5125, 421, 264, 14882, 557, 303, 11914, 13, 8020, 264, 1637, 1362, 635, 421, 11, 321, 1132, 413, 264, 1637, 557, 1017, 310, 1353, 13, 271, 15450, 303, 279, 6092, 6807, 2963, 883, 421, 5728, 1381, 430, 3384, 424, 995, 978, 264, 26802, 6365, 314, 8842, 11, 264, 43472, 46370, 2272, 279, 13001, 314, 12282, 13, 84907, 1503, 524, 1683, 424, 557, 3977, 314, 279, 2993, 13, 1216, 15028, 424, 5820, 1521, 17540, 13235, 279, 2235, 51624, 321, 1362, 524, 4847, 4300, 5402, 310, 2842, 2019, 680, 310, 279, 20618, 11, 321, 421, 424, 8308, 1521, 18022, 4674, 310, 381, 279, 799, 310, 809, 424, 13, 27934, 1159, 513, 1040, 421, 13, 2302, 680, 4119, 836, 7715, 11, 321, 1396, 748, 3428, 11, 1973, 5316, 8842, 424, 11, 781, 1423, 264, 491, 799, 13, 271, 1465, 369, 16570, 52616, 1381, 321, 4138, 430, 449, 22839, 383, 279, 37126, 9662, 8520, 421, 488, 628, 1436, 494, 279, 1844, 314, 279, 324, 55965, 383, 264, 2708, 1834, 25, 1330, 7493, 4022, 73090, 10932, 303, 6761, 383, 279, 32946, 11, 1754, 799, 14936, 539, 24296, 421, 1830, 46219, 11, 9039, 321, 24052, 9361, 310, 264, 2444, 2956, 303, 2361, 3046, 13, 561, 5757, 513, 1546, 1603, 13, 2302, 2213, 4409, 4156, 13, 1216, 1990, 5601, 680, 310, 279, 20618, 383, 79833, 13382, 948, 551, 369, 2046, 11, 73797, 279, 7123, 11, 321, 5686, 13, 271, 25337, 1384, 3069, 11, 321, 551, 668, 3184, 488, 264, 3255, 421, 682, 4161, 310, 635, 440, 324, 21204, 19154, 13, 733, 780, 2018, 1007, 383, 279, 9662, 8520, 11, 264, 16070, 1785, 59144, 264, 6103, 9704, 303, 279, 9039, 314, 264, 94496, 383, 799, 314, 279, 73090, 506, 279, 2944, 809, 314, 279, 1287, 13, 561, 9704, 557, 2526, 11, 1575, 4613, 279, 13001, 11, 321, 279, 3061, 20364, 424, 430, 3238, 10304, 13, 1049, 1000, 599, 978, 6749, 506, 2261, 279, 1727, 13145, 3814, 11, 4590, 5381, 2843, 13, 357, 51715, 383, 279, 13017, 14882, 11, 11946, 279, 62970, 383, 2361, 2531, 11, 13293, 421, 279, 164840, 6502, 33172, 2086, 11, 264, 36334, 16365, 5020, 1172, 279, 13087, 2696, 11, 321, 4439, 279, 10390, 692, 310, 2842, 13, 3095, 781, 8660, 279, 94496, 781, 1669, 264, 17504, 421, 557, 264, 2342, 2756, 494, 20738, 13, 997, 46333, 424, 2695, 264, 6353, 13, 997, 46333, 279, 94496, 1238, 279, 17504, 4490, 1000, 599, 2695, 264, 2182, 321, 279, 3240, 314, 264, 2526, 3626, 13, 271, 760, 51715, 557, 524, 26802, 261, 1056, 279, 3061, 13, 2838, 995, 4777, 978, 1017, 11, 3160, 3213, 310, 6512, 11, 321, 21520, 3213, 310, 2466, 364, 279, 14882, 310, 2842, 13, 561, 795, 995, 6625, 279, 1788, 3377, 26, 424, 995, 1066, 524, 6625, 424, 52039, 3213, 364, 5316, 310, 2373, 13, 84907, 15028, 883, 421, 3428, 13, 6983, 1785, 551, 682, 6237, 383, 682, 978, 1546, 1603, 506, 28043, 279, 2433, 1141, 24990, 3481, 310, 708, 4808, 11, 321, 1691, 2599, 1603, 506, 279, 2433, 18022, 3481, 13, 561, 12558, 1881, 279, 1330, 369, 1332, 1208, 1990, 7005, 836, 2426, 11, 524, 539, 3604, 279, 5484, 579, 2531, 2577, 1056, 279, 5484, 11, 694, 539, 59291, 948, 279, 2531, 4924, 682, 28599, 5324, 13, 271, 4272, 383, 79833, 13382, 11, 948, 551, 628, 11]}, {"name": "multilingual", "ids": [2495, 450, 71234, 176217, 48, 16451, 18, 13, 23, 12, 23129, 12, 5666, 9251, 2349, 1074, 71, 34098, 1509, 6616, 43765, 16451, 43765, 16451, 18, 13, 23, 12, 23129, 12, 5666, 31230, 6993, 16927, 224986, 6464, 197102, 13, 198, 31538, 5810, 4227, 198214, 11, 19611, 48473, 189164, 12, 4312, 598, 11, 6407, 91957, 161691, 15008, 8162, 182720, 13, 8963, 77477, 294, 11, 205397, 5927, 11, 229411, 198, 33, 20143, 1962, 192900, 5280, 188474, 31926, 1962, 46472, 6481, 70, 779, 51592, 13, 83430, 82, 2652, 41759, 49188, 188474, 6464, 13, 271, 550, 41201, 56104, 5810, 1477, 30, 271, 46445, 17104, 1477, 6993, 39124, 37521, 224986, 29469, 12, 4716, 82, 18184, 37525, 13, 17530, 9372, 5810, 74905, 220, 65121, 34913, 90283, 287, 13, 271, 12, 2972, 29140, 154563, 92503, 64700, 12981, 56104, 2659, 63538, 303, 16927, 211571, 12485, 200366, 13, 220, 21, 15, 56212, 453, 47584, 27923, 12223, 198, 220, 195937, 11, 10396, 3717, 72621, 63615, 13, 198, 12, 2972, 43, 13051, 188474, 57491, 64700, 12981, 56104, 1477, 6993, 54854, 2421, 11, 557, 3717, 5521, 839, 267, 318, 164509, 4227, 157536, 11, 5927, 12030, 12485, 415, 94388, 5280, 198, 220, 220, 18, 17, 42, 56212, 553, 271, 20353, 29, 198, 10948, 1721, 337, 29028, 28392, 25, 220497, 220, 20, 15, 22, 15, 318, 16, 17, 18295, 681, 89540, 220, 20, 220, 22, 21, 15, 15, 11, 220, 21, 19, 18295, 21360, 510, 337, 1721, 337, 29, 55771, 25, 27255, 220, 24, 15, 22, 15, 59781, 318, 16, 21, 18295, 681, 89540, 220, 24, 220, 18, 24, 15, 15, 55, 11, 220, 19, 22, 18295, 21360, 510, 337, 1419, 371, 29, 198, 10948, 1721, 1251, 29, 271, 91, 178297, 735, 238791, 92503, 735, 436, 13051, 188474, 57491, 735, 198, 91, 12091, 735, 12091, 25, 735, 12091, 25, 735, 198, 91, 2972, 48, 17, 62, 15, 332, 735, 220, 24, 19, 56212, 2600, 735, 220, 17, 11, 21, 20, 15, 56212, 2600, 735, 198, 91, 2972, 59865, 17, 6645, 50, 332, 735, 220, 22, 24, 56212, 2600, 735, 220, 17, 11, 15, 24, 15, 56212, 2600, 735, 198, 91, 2972, 59865, 18, 62, 5955, 50, 332, 735, 220, 21, 17, 56212, 2600, 735, 220, 16, 11, 22, 20, 15, 56212, 2600, 735, 198, 91, 2972, 59865, 18, 1063, 332, 735, 220, 20, 18, 56212, 2600, 735, 220, 16, 11, 21, 17, 15, 56212, 2600, 735, 198, 91, 2972, 34120, 332, 735, 220, 20, 20, 56212, 2600, 735, 220, 17, 11, 16, 23, 15, 56212, 2600, 735, 271, 510, 1251, 1721, 1251, 29, 271, 91, 178297, 735, 238791, 92503, 735, 436, 13051, 188474, 57491, 735, 198, 91, 12091, 735, 12091, 25, 735, 12091, 25, 735, 198, 91, 2972, 48, 17, 62, 15, 332, 735, 220, 21, 15, 56212, 2600, 735, 220, 16, 11, 16, 21, 15, 56212, 2600, 735, 198, 91, 2972, 59865, 17, 6645, 50, 332, 735, 220, 20, 17, 56212, 2600, 735, 220, 16, 11, 16, 16, 15, 56212, 2600, 735, 198, 91, 2972, 34120, 332, 735, 220, 19, 19, 56212, 2600, 735, 220, 16, 11, 19, 17, 15, 56212, 2600, 735, 271, 510, 1251, 1419, 371, 29, 198, 510, 1938, 29, 271, 45, 28392, 25, 1167, 17, 62, 15, 5280, 7943, 220, 15, 13, 16, 13, 18, 21, 11, 2659, 37402, 9625, 22126, 5280, 220, 15, 13, 16, 13, 17, 21, 318, 19, 42, 92503, 11, 220, 18, 17, 42, 17058, 12389, 553, 8148, 162946, 6231, 198, 8320, 15212, 62663, 303, 498, 82835, 50, 20668, 9251, 13715, 14, 82835, 50, 20668, 2, 19755, 32848, 38012, 553, 49584, 189202, 5280, 17966, 18588, 1354, 5810, 195937, 25, 49584, 198, 5182, 55, 220, 18, 15, 24, 15, 318, 17, 19, 18295, 8, 49214, 74905, 220, 16, 15, 15, 12, 16, 19, 15, 56212, 453, 47584, 27923, 181737, 13, 84697, 882, 1798, 632, 271, 2495, 450, 19092, 216660, 176217, 48, 16451, 18, 13, 23, 12, 23129, 12, 5666, 9251, 2349, 1074, 71, 34098, 1509, 6616, 43765, 16451, 43765, 16451, 18, 13, 23, 12, 23129, 12, 5666, 31230, 1668, 632, 6464, 4472, 13, 351, 16811, 198, 354, 6453, 79653, 293, 6, 5681, 11, 24111, 12506, 11, 7528, 59006, 293, 6, 221400, 632, 208450, 13, 7305, 243195, 11, 85388, 3717, 1970, 11, 12647, 909, 5167, 1778, 198, 20812, 399, 785, 9462, 24449, 8098, 1778, 24449, 12636, 401, 1970, 13, 215329, 808, 16343, 647, 14487, 6464, 13, 271, 550, 176591, 1725, 796, 183208, 907, 271, 63611, 324, 46450, 2305, 10529, 322, 7639, 1668, 24739, 6464, 401, 48852, 47021, 16766, 13, 1188, 3817, 7618, 3656, 47288, 220, 65121, 293, 21372, 3724, 13, 271, 12, 2972, 25933, 35768, 3424, 190724, 170592, 1147, 183208, 3656, 175873, 1147, 86333, 274, 78502, 11720, 6652, 5992, 71388, 9915, 13, 220, 21, 15, 10885, 1298, 184286, 11, 272, 16811, 5346, 72931, 1649, 14487, 29579, 13, 198, 12, 2972, 66621, 14487, 9640, 170592, 1147, 183208, 3656, 175873, 3687, 15110, 1323, 3633, 1649, 8740, 57519, 9825, 318, 3266, 632, 2128, 11, 3717, 1970, 5724, 632, 187282, 401, 9915, 401, 220, 18, 17, 42, 10885, 553, 271, 20353, 29, 198, 10948, 1721, 337, 29028, 28392, 535, 220497, 220, 20, 15, 22, 15, 318, 16, 17, 5805, 681, 89540, 220, 20, 220, 22, 21, 15, 15, 11, 220, 21, 19, 5805, 401, 21360, 510, 337, 1721, 337, 29, 55771, 535, 27255, 220, 24, 15, 22, 15, 59781, 318, 16, 21, 5805, 681, 89540, 220, 24, 220, 18, 24, 15, 15, 55, 11, 220, 19, 22, 5805, 401, 21360, 510, 337, 1419, 371, 29, 198, 10948, 1721, 1251, 29, 271, 91, 196281, 735, 240637, 3424, 190724, 735, 36983, 14487, 9640, 735, 198, 91, 12091, 735, 12091, 25, 735, 12091, 25, 735, 198, 91, 2972, 48, 17, 62, 15, 332, 735, 220, 24, 19, 10885, 2600, 735, 220, 17, 11, 21, 20, 15, 10885, 2600, 735, 198, 91, 2972, 59865, 17, 6645, 50, 332, 735, 220, 22, 24, 10885, 2600, 735, 220, 17, 11, 15, 24, 15, 10885, 2600, 735, 198, 91, 2972, 59865, 18, 62, 5955, 50, 332, 735, 220, 21, 17, 10885, 2600, 735, 220, 16, 11, 22, 20, 15]}, {"name": "agent", "ids": [248045, 8678, 198, 2523, 513, 264, 10505, 8057, 3133, 303, 279, 1156, 579, 12182, 13, 1394, 628, 1562, 7141, 310, 1301, 3425, 11, 2624, 279, 1970, 321, 1542, 10966, 13, 13262, 4203, 2526, 321, 10033, 1092, 488, 1467, 13, 248046, 198, 248045, 846, 198, 760, 1228, 1510, 1877, 20394, 24647, 63, 14107, 2394, 13278, 579, 10562, 13, 2885, 488, 1423, 680, 3069, 321, 4884, 424, 30, 248046, 198, 248045, 74455, 198, 248068, 198, 40, 1220, 1542, 279, 20738, 1228, 1118, 310, 1436, 279, 4880, 1412, 1876, 11, 1179, 1353, 506, 279, 709, 424, 6813, 13, 198, 248069, 271, 248058, 198, 4754, 591, 763, 328, 5917, 10494, 487, 328, 15889, 763, 5046, 5454, 763, 328, 12305, 471, 76, 26864, 6813, 12333, 2914, 16799, 6971, 471, 74, 1228, 20394, 24647, 471, 80, 29958, 198, 248059, 248046, 198, 248045, 846, 198, 248066, 198, 37, 21641, 498, 16, 15, 15, 4, 60, 198, 2960, 8442, 32009, 48956, 34589, 410, 198, 7443, 40015, 62, 1228, 20394, 24647, 42390, 40015, 271, 262, 687, 1228, 20394, 24647, 4406, 198, 285, 1992, 4563, 24647, 437, 24, 15, 82, 871, 606, 220, 24, 15, 198, 285, 1992, 4563, 24647, 437, 20, 76, 871, 606, 220, 18, 15, 15, 198, 29, 950, 1992, 4563, 24647, 437, 16, 71, 18, 15, 76, 871, 606, 220, 20, 19, 15, 15, 198, 36, 950, 14953, 25, 8060, 7836, 25, 359, 16, 71, 18, 15, 76, 6, 271, 23095, 12333, 2914, 16799, 6971, 25, 16, 19, 25, 14953, 198, 16, 4490, 11, 220, 16, 16, 48600, 2140, 303, 220, 15, 13, 17, 16, 82, 198, 248067, 248046, 198, 248045, 74455, 198, 248068, 198, 10570, 7896, 944, 694, 264, 10539, 869, 14107, 13, 6558, 728, 1301, 279, 6518, 13, 198, 248069, 271, 248058, 198, 4754, 591, 763, 328, 851, 2378, 487, 328, 15889, 763, 5046, 2267, 763, 328, 3431, 34093, 16799, 6971, 487, 328, 2388, 6325, 763, 220, 16, 11, 328, 400, 6325, 763, 220, 19, 15, 3307, 198, 248059, 248046, 198, 248045, 846, 198, 248066, 198, 464, 311, 271, 87662, 283, 5046, 82, 763, 220, 16, 11, 328, 76, 763, 220, 21, 15, 11, 328, 71, 763, 220, 18, 21, 15, 15, 11, 328, 67, 763, 220, 23, 21, 19, 15, 15, 92, 198, 27360, 283, 311, 18351, 2515, 83501, 11189, 67, 10, 2299, 58, 3445, 15518, 2387, 3, 871, 1358, 727, 4563, 24647, 7008, 25, 592, 8, 1411, 514, 25, 198, 262, 4071, 14048, 264, 7836, 1040, 359, 24, 15, 82, 504, 359, 20, 76, 6, 466, 359, 16, 71, 18, 15, 76, 6, 1083, 6283, 71483, 198, 262, 1414, 283, 1414, 16674, 973, 14344, 363, 198, 262, 413, 524, 1414, 25, 198, 285, 4673, 14953, 437, 3092, 7836, 871, 198, 262, 295, 283, 696, 32379, 10749, 7008, 8, 198, 262, 413, 295, 369, 2168, 25, 198, 285, 4673, 14953, 925, 1, 11469, 7836, 25, 313, 1272, 0, 81, 54084, 198, 262, 460, 514, 1212, 5982, 7, 16, 578, 348, 696, 1797, 14059, 11722, 5982, 7, 17, 7025, 198, 248067, 248046, 198, 248045, 74455, 198, 248068, 198, 760, 19567, 369, 74483, 506, 2107, 10029, 321, 8798, 6681, 799, 1324, 58533, 6505, 11, 748, 328, 16, 71, 18, 15, 76, 1, 628, 2496, 2353, 13, 561, 4479, 889, 20021, 10539, 2663, 13, 6558, 728, 1716, 15865, 3712, 310, 1436, 1092, 279, 10562, 5324, 13, 198, 248069, 271, 248058, 198, 4754, 591, 763, 328, 5917, 10494, 487, 328, 15889, 763, 5046, 5454, 763, 328, 12513, 1433, 471, 79, 471, 77, 220, 16, 1137, 2212, 34093, 16799, 6971, 735, 1901, 471, 19, 15, 29958, 198, 248059, 248046, 198, 248045, 846, 198, 248066, 198, 16899, 220, 19, 68, 16, 65, 24, 66, 17, 69, 22, 64, 15, 67, 318, 50346, 8602, 359, 53380, 12, 25543, 837, 198, 262, 59176, 1386, 7836, 21621, 271, 67677, 32379, 283, 311, 18351, 2515, 1, 11189, 67, 10, 2299, 58, 3445, 15518, 2387, 871, 198, 94081, 32379, 283, 311, 18351, 2515, 83501, 11189, 67, 10, 2299, 58, 3445, 15518, 2387, 3, 871, 198, 18611, 687, 4563, 24647, 7008, 25, 592, 8, 1411, 514, 25, 198, 12, 262, 2702, 283, 220, 15, 198, 12, 262, 1097, 283, 220, 15, 198, 12, 262, 364, 295, 303, 696, 32379, 2571, 1947, 7008, 1590, 198, 12, 285, 413, 295, 4801, 363, 931, 1097, 25, 198, 12, 309, 4673, 14953, 925, 1, 11469, 7836, 25, 313, 1272, 0, 81, 54084, 198, 12, 285, 2702, 1373, 514, 1212, 5982, 7, 16, 578, 348, 696, 1797, 14059, 11722, 5982, 7, 17, 7025, 198, 12, 285, 1097, 283, 295, 4911, 363, 198, 12, 262, 413, 1097, 931, 2343, 7008, 1590, 198, 12, 285, 4673, 14953, 925, 1, 11469, 7836, 25, 313, 1272, 0, 81, 54084, 198, 12, 262, 460, 2702, 198, 10, 262, 295, 283, 696, 32379, 10749, 7008, 8, 198, 10, 262, 413, 295, 369, 2168, 25, 198, 10, 285, 4673, 14953, 925, 1, 11469, 7836, 25, 313, 1272, 0, 81, 54084, 198, 10, 262, 460, 514, 1212, 5982, 7, 16, 578, 348, 696, 1797, 14059, 11722, 5982, 7, 17, 7025, 198, 248067, 248046, 198, 248045, 74455, 198, 760, 20635, 10562, 12215, 279, 6136, 888, 660, 1324, 58533, 13139, 440, 264, 3074, 74483, 2353, 11, 748, 1132, 799, 4821, 791, 886, 369, 11330, 1381, 13, 353, 668, 14519, 279, 6136, 11, 864, 1048, 57409, 25053, 1881, 279, 5306, 13, 271, 248058, 198, 4754, 591, 763, 328, 3468, 2378, 487, 328, 15889, 763, 5046, 2267, 763, 328, 3431, 34093, 16799, 6971, 487, 328, 787, 763, 8728, 32379, 283, 311, 18351, 2515, 2037, 12883, 3312, 67, 10, 2299, 58, 3445, 15518, 2387, 56749, 871, 487, 328, 902, 763, 8728, 32379, 283, 311, 18351, 2515, 2037, 7, 3312, 67, 10, 2299, 58, 3445, 15518, 2387, 60592, 29958, 198, 248059, 248046, 198, 248045, 846, 198, 248066, 198, 3793, 25, 220, 16, 13329, 303, 2212, 34093, 16799, 6971, 198, 248067, 248046, 198, 248045, 74455, 198, 248058, 198, 4754, 591, 763, 328, 3468, 2378, 487, 328, 15889, 763, 5046, 2267, 763, 328, 3431, 34093, 16799, 6971, 487, 328, 787, 763, 328, 262, 295, 283, 696]}]}
\ No newline at end of file
diff --git a/tools/quant_formats.py b/tools/quant_formats.py
new file mode 100644
index 000000000..367934b65
--- /dev/null
+++ b/tools/quant_formats.py
@@ -0,0 +1,154 @@
+#!/usr/bin/env python3
+"""Per-layer tensor formats of a (sharded) GGUF, read from the headers only (docs/QUANTS.md).
+
+ python tools/quant_formats.py PATH-OR-GLOB [...] local shards (any shard; all are read)
+ python tools/quant_formats.py --hf REPO REV DIR [--json OUT] Hugging Face: HTTP range requests on each shard's
+ header, nothing else is downloaded
+
+Prints, per role (routed gate / up / down, shared expert, attention, SSM, hyper-connections, indexer, PLE, embedding,
+head): the formats and the layers each one covers, and the bytes; then the routed experts layer by layer.
+"""
+from __future__ import annotations
+
+import argparse
+import glob
+import io
+import json
+import pathlib
+import re
+import sys
+import urllib.request
+
+sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
+import gguf_reader as G # noqa: E402
+
+ROLES = [
+ ("routed gate", r"ffn_gate_exps"), ("routed up", r"ffn_up_exps"), ("routed down", r"ffn_down_exps"),
+ ("shared expert", r"ffn_(gate|up|down)_shexp\.weight"), ("router", r"ffn_gate_inp"),
+ ("attention", r"attn_(q|k|v|qkv|gate|output)\.weight"), ("SSM", r"ssm_(alpha|beta|out)\.weight"),
+ ("hyper-connections", r"hc_(attn|ffn)_(up|down|inject)\.weight"), ("indexer", r"indexer\.(q|k)_proj"),
+ ("PLE key/value", r"ple_(key|value)\.weight"), ("PLE table", r"^per_layer_token_embd"),
+ ("token embedding", r"^token_embd"), ("output head", r"^output(_hc_(up|down))?\.weight"),
+]
+
+
+class RangeFile(io.RawIOBase):
+ """A read-only, forward-reading file over HTTP range requests (4 MiB at a time)."""
+
+ CHUNK = 4 << 20
+
+ def __init__(self, url: str):
+ self.url, self.pos, self.buf, self.buf_at = url, 0, b"", 0
+
+ def _fill(self, need_to: int) -> None:
+ while self.buf_at + len(self.buf) < need_to:
+ start = self.buf_at + len(self.buf)
+ req = urllib.request.Request(self.url, headers={"Range": f"bytes={start}-{start + self.CHUNK - 1}"})
+ data = urllib.request.urlopen(req, timeout=120).read()
+ if not data:
+ raise EOFError(self.url)
+ self.buf += data
+
+ def read(self, n: int = -1) -> bytes:
+ self._fill(self.pos + n)
+ off = self.pos - self.buf_at
+ out = self.buf[off:off + n]
+ self.pos += len(out)
+ return out
+
+ def tell(self) -> int:
+ return self.pos
+
+
+class Header(G.GGUFFile):
+ def __init__(self, name: str, fh): # noqa: D107 (reuses GGUFFile's parser on any file-like)
+ self.path = pathlib.Path(name)
+ self.metadata, self.tensors, self.version, self.alignment = {}, [], 0, 32
+ self._parse(fh)
+
+
+def hf_headers(repo: str, rev: str, d: str) -> list[Header]:
+ tree = json.load(urllib.request.urlopen(f"https://huggingface.co/api/models/{repo}/tree/{rev}/{d}", timeout=60))
+ out = []
+ for e in sorted(tree, key=lambda e: e["path"]):
+ if e["type"] == "file" and e["path"].endswith(".gguf"):
+ url = f"https://huggingface.co/{repo}/resolve/{rev}/{e['path']}"
+ out.append(Header(e["path"], RangeFile(url)))
+ return out
+
+
+def ranges(layers: list[int]) -> str:
+ layers = sorted(layers)
+ out, i = [], 0
+ while i < len(layers):
+ j = i
+ while j + 1 < len(layers) and layers[j + 1] == layers[j] + 1:
+ j += 1
+ out.append(str(layers[i]) if i == j else f"{layers[i]}-{layers[j]}")
+ i = j + 1
+ return ", ".join(out)
+
+
+def summarize(heads: list[Header]) -> dict:
+ roles: dict[str, dict[str, dict]] = {}
+ per_layer: dict[int, dict[str, str]] = {}
+ for h in heads:
+ for t in h.tensors:
+ m = re.match(r"blk\.(\d+)\.", t.name)
+ layer = int(m.group(1)) if m else -1
+ for role, pat in ROLES:
+ if re.search(pat, t.name):
+ r = roles.setdefault(role, {}).setdefault(t.type_name, {"layers": set(), "bytes": 0, "n": 0})
+ r["layers"].add(layer)
+ r["bytes"] += t.expected_bytes() or 0
+ r["n"] += 1
+ if role.startswith("routed"):
+ per_layer.setdefault(layer, {})[role.split()[1]] = t.type_name
+ break
+ return {"roles": roles, "per_layer": per_layer}
+
+
+def render(name: str, s: dict) -> str:
+ lines = [f"### {name}", "", "| Role | Format | Layers | Tensors | GiB |", "|---|---|---|---:|---:|"]
+ for role, _ in ROLES:
+ for ty, r in sorted(s["roles"].get(role, {}).items(), key=lambda kv: -kv[1]["bytes"]):
+ lay = "-" if r["layers"] == {-1} else ranges([x for x in r["layers"] if x >= 0])
+ lines.append(f"| {role} | {ty} | {lay} | {r['n']} | {r['bytes'] / 2**30:.2f} |")
+ exp = sum(r["bytes"] for role in ("routed gate", "routed up", "routed down")
+ for r in s["roles"].get(role, {}).values())
+ lines += ["", f"Routed experts: {exp / 2**30:.1f} GiB.", ""]
+ combos: dict[tuple, list[int]] = {}
+ for layer, d in s["per_layer"].items():
+ combos.setdefault((d.get("gate"), d.get("up"), d.get("down")), []).append(layer)
+ lines += ["| Routed gate / up / down | Layers |", "|---|---|"]
+ for (g, u, dn), lay in sorted(combos.items(), key=lambda kv: -len(kv[1])):
+ lines.append(f"| {g} / {u} / {dn} | {ranges(lay)} |")
+ return "\n".join(lines) + "\n"
+
+
+def main() -> int:
+ ap = argparse.ArgumentParser()
+ ap.add_argument("paths", nargs="*")
+ ap.add_argument("--hf", nargs=3, metavar=("REPO", "REV", "DIR"))
+ ap.add_argument("--name")
+ ap.add_argument("--json")
+ a = ap.parse_args()
+ if a.hf:
+ heads = hf_headers(*a.hf)
+ name = a.name or a.hf[2]
+ else:
+ files = sorted({p for g in a.paths for p in glob.glob(g)})
+ heads = [G.GGUFFile(pathlib.Path(p)) for p in files]
+ name = a.name or (pathlib.Path(files[0]).parent.name if files else "?")
+ s = summarize(heads)
+ sys.stdout.write(render(name, s))
+ if a.json:
+ js = {"roles": {r: {t: {"layers": sorted(v["layers"]), "bytes": v["bytes"], "n": v["n"]}
+ for t, v in d.items()} for r, d in s["roles"].items()},
+ "per_layer": {str(k): v for k, v in sorted(s["per_layer"].items())}}
+ pathlib.Path(a.json).write_text(json.dumps(js, indent=1))
+ return 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())
diff --git a/tools/quant_quality.py b/tools/quant_quality.py
new file mode 100644
index 000000000..eb53e6f36
--- /dev/null
+++ b/tools/quant_quality.py
@@ -0,0 +1,273 @@
+#!/usr/bin/env python3
+"""The quant quality yardstick (MODEL-UPDATE.md, Phase 0): teacher-forced top-1 agreement and KL of a quant against
+Q8_0, on one fixed text set (data/quant_quality/v1: code, docs, English, other languages, an agent transcript).
+
+ python tools/quant_quality.py ids --tokenizer DIR [--set data/quant_quality/v1] [--out set.ids.json]
+ tokenizes the set (each segment cut to --seg-tokens, default 1000) - the ids file is committed with the set
+ (data/quant_quality/v1/set.ids.json), so a box without the tokenizer scores the same positions
+ python tools/quant_quality.py run --config CFG.json --out RUN.tsv [--ids set.ids.json] [--env K=V ...] [--gpu-experts]
+ one `strata --serve` engine (the config's exe and args), every segment one request whose tokens are all read
+ through the decode windows (--short-read), where STRATA_LOGPOS / STRATA_LOGPOS_TOPK=64 write, per position,
+ the log-probability of the text's next token and the 64 most likely tokens. Fixed: the experts on the CPU
+ (one VRAM slot, --expert-cache 1: the verify windows need a profile-filled tier, so the config must have
+ --expert-profile; --gpu-experts: 1500 slots), no expert adaptation, no PCIe share, no suffix drafts, no prompt
+ cache, FP16 K/V, STRATA_ROUTE_TAIL_SKIP=0, STRATA_PREFILL_CPU_SHARE=0. RUN.tsv + RUN.tsv.seg.json (line ranges).
+ python tools/quant_quality.py compare REF.tsv RUN.tsv [...] (REF = the Q8_0 run)
+ per segment and overall: top-1 agreement (same argmax), mean / p99 KL(REF || RUN) over REF's 64 most likely
+ tokens (both renormalized to that set; a token RUN does not list gets RUN's 64th log-probability), and the
+ perplexity of the text under each.
+
+The RUN.tsv rows are the engine's STRATA_LOGPOS format: pos, target id, logp(target), argmax id, logp(argmax),
+argmax==target, logp(<|im_end|>), logp(target without <|im_end|>), then 64 `id:logp` fields (natural log).
+"""
+from __future__ import annotations
+
+import argparse
+import json
+import math
+import os
+import pathlib
+import subprocess
+import sys
+import time
+
+HERE = pathlib.Path(__file__).resolve().parent
+SET_DIR = HERE.parent / "data" / "quant_quality" / "v1"
+SEGMENTS = ["code", "docs", "english", "multilingual", "agent"]
+TOPK = 64
+FIXED = ["--expert-cache", "1", "--adapt-every", "100000", "--pcie-frac", "0", "--suffix-draft", "0",
+ "--prompt-cache", "0", "--kv", "fp16"]
+FIXED_ENV = {"STRATA_ROUTE_TAIL_SKIP": "0", "STRATA_PREFILL_CPU_SHARE": "0", "STRATA_PCIE_FRAC_DEFAULT": "old"}
+# config args the yardstick replaces (value-taking) or drops (flags)
+DROP_VALUE = {"--expert-cache", "--adapt-every", "--pcie-frac", "--suffix-draft", "--prompt-cache", "--max-context",
+ "--prefill", "--prompt-cache-every", "--short-read", "--conversation-cache-mib", "--eos-ids",
+ "--resident-budget-gib", "--kv", "--kv-resident"}
+DROP_FLAG = {"--serve", "--vision", "--resident-experts", "--resident-cpu-experts"}
+
+
+# ------------------------------------------------------------------------------------------------ ids
+def cmd_ids(a) -> int:
+ sys.path.insert(0, str(HERE))
+ import strata_tokenizer as ST # noqa: E402
+ tp = pathlib.Path(a.tokenizer)
+ vocab = json.loads((tp / "vocab.json").read_text(encoding="utf-8"))
+ toks = [None] * len(vocab)
+ for t, i in vocab.items():
+ toks[i] = t
+ tok = ST.Tokenizer(toks, (tp / "merges.txt").read_text(encoding="utf-8").split("\n"),
+ json.loads((tp / "token_type.json").read_text()))
+ segs = []
+ for name in SEGMENTS:
+ text = (pathlib.Path(a.set) / f"{name}.txt").read_text(encoding="utf-8")
+ ids = tok.encode(text, parse_special=(name == "agent"))
+ if len(ids) < a.seg_tokens:
+ raise SystemExit(f"{name}: only {len(ids)} tokens (< {a.seg_tokens})")
+ segs.append({"name": name, "ids": ids[:a.seg_tokens]})
+ print(f"{name}: {len(ids)} tokens, kept {a.seg_tokens}")
+ out = pathlib.Path(a.out or (pathlib.Path(a.set) / "set.ids.json"))
+ out.write_text(json.dumps({"version": pathlib.Path(a.set).name, "seg_tokens": a.seg_tokens, "segments": segs}))
+ print(f"wrote {out}")
+ return 0
+
+
+# ------------------------------------------------------------------------------------------------ run
+def mem_available_gb() -> float:
+ try:
+ for line in open("/proc/meminfo"):
+ if line.startswith("MemAvailable:"):
+ return int(line.split()[1]) / 1048576
+ except OSError:
+ pass
+ return float("inf")
+
+
+def engine_args(cfg: dict, gpu_experts: bool, seg_tokens: int) -> list[str]:
+ base, out, i = list(cfg["args"]), [], 0
+ while i < len(base):
+ x = base[i]
+ if x in DROP_FLAG:
+ i += 1
+ continue
+ if x in DROP_VALUE:
+ i += 2
+ continue
+ out.append(x)
+ i += 1
+ fixed = list(FIXED)
+ if gpu_experts:
+ fixed[1] = "1500"
+ return [cfg["exe"], "--serve", *out, *fixed, "--max-context", str(seg_tokens + 512),
+ "--short-read", str(seg_tokens + 64), "--prefill", "512"]
+
+
+def cmd_run(a) -> int:
+ cfg = json.load(open(a.config, encoding="utf-8-sig"))
+ st = json.load(open(a.ids))
+ out = pathlib.Path(a.out).resolve()
+ out.parent.mkdir(parents=True, exist_ok=True)
+ if out.exists():
+ out.unlink()
+ env = dict(os.environ)
+ env.update(cfg.get("env", {}))
+ if cfg.get("lib_dirs"):
+ env["LD_LIBRARY_PATH"] = ":".join(cfg["lib_dirs"] + [env.get("LD_LIBRARY_PATH", "")])
+ env.update(FIXED_ENV)
+ for kv in a.env or []:
+ k, _, v = kv.partition("=")
+ env[k] = v
+ env["STRATA_LOGPOS"] = str(out)
+ env["STRATA_LOGPOS_TOPK"] = str(TOPK)
+ if mem_available_gb() < a.min_free_gb:
+ raise SystemExit(f"only {mem_available_gb():.0f} GB available (< {a.min_free_gb}): not starting an engine")
+ args = engine_args(cfg, a.gpu_experts, st["seg_tokens"])
+ if a.wrap:
+ args = a.wrap.split() + args
+ errf = open(str(out) + ".stderr.txt", "w")
+ print("engine:", " ".join(args), flush=True)
+ p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=errf, text=True,
+ cwd=cfg.get("cwd"), env=env, bufsize=1)
+ for line in p.stdout:
+ if line.startswith("READY"):
+ break
+ else:
+ raise SystemExit(f"the engine ended before READY (exit {p.wait()}); see {out}.stderr.txt")
+ segs, info = [], []
+
+ def lines() -> int:
+ return sum(1 for _ in open(out)) if out.exists() else 0
+
+ for s in st["segments"]:
+ n0, t0 = lines(), time.time()
+ p.stdin.write("GEN 1 " + ",".join(map(str, s["ids"])) + "\n")
+ p.stdin.flush()
+ done = None
+ for line in p.stdout:
+ if line.startswith(("DONE", "ERR")):
+ done = line.strip()
+ break
+ if done is None or not done.startswith("DONE") or "nonfinite" in done:
+ p.kill()
+ raise SystemExit(f"{s['name']}: the engine answered {done!r}; see {out}.stderr.txt")
+ n1 = lines()
+ segs.append({"name": s["name"], "first_line": n0, "end_line": n1})
+ info.append(f"{s['name']}: {n1 - n0} positions, {time.time() - t0:.1f} s")
+ print(info[-1], flush=True)
+ if n1 - n0 < len(s["ids"]) // 2:
+ p.kill()
+ raise SystemExit(f"{s['name']}: only {n1 - n0} positions were scored (the prompt took the batched path?)")
+ p.stdin.write("QUIT\n")
+ p.stdin.flush()
+ try:
+ p.wait(timeout=600)
+ except subprocess.TimeoutExpired:
+ p.kill()
+ errf.close()
+ err = pathlib.Path(str(out) + ".stderr.txt").read_text(errors="replace")
+ cache = [l for l in err.splitlines() if "expert cache" in l][:3]
+ pathlib.Path(str(out) + ".seg.json").write_text(json.dumps({"segments": segs, "config": a.config,
+ "args": args, "env": a.env or [],
+ "expert_cache_lines": cache}, indent=1))
+ return 0
+
+
+# ------------------------------------------------------------------------------------------------ compare
+def read_run(path: str) -> dict:
+ rows = open(path).read().splitlines()
+ segs = json.load(open(path + ".seg.json"))["segments"]
+ out = {}
+ for s in segs:
+ d = {}
+ for line in rows[s["first_line"]:s["end_line"]]:
+ f = line.split("\t")
+ if len(f) < 8 + TOPK:
+ continue
+ d[int(f[0])] = (int(f[1]), float(f[2]), int(f[3]), [(int(x), float(y)) for x, y in
+ (z.split(":") for z in f[8:8 + TOPK])])
+ out[s["name"]] = d
+ return out
+
+
+def compare(ref: dict, run: dict) -> dict:
+ res, allk, tot = {}, [], {"n": 0, "agree": 0, "nll_r": 0.0, "nll_a": 0.0, "kl": 0.0}
+ for name, rr in ref.items():
+ ra = run.get(name, {})
+ pos = sorted(set(rr) & set(ra))
+ n = agree = 0
+ kls, nll_r, nll_a = [], 0.0, 0.0
+ for q in pos:
+ tr, lr, topr, kr = rr[q]
+ ta, la, topa, ka = ra[q]
+ if tr != ta:
+ raise SystemExit(f"{name} pos {q}: target {tr} != {ta} (not the same text)")
+ n += 1
+ agree += topr == topa
+ nll_r -= lr
+ nll_a -= la
+ da = dict(ka)
+ floor = min(b for _, b in ka)
+ pr = [math.exp(b) for _, b in kr]
+ pa = [math.exp(da.get(i, floor)) for i, _ in kr]
+ sr, sa = sum(pr), sum(pa)
+ kls.append(sum((x / sr) * math.log((x / sr) / (y / sa)) for x, y in zip(pr, pa) if x > 0))
+ allk += kls
+ if n:
+ res[name] = {"positions": n, "top1": agree / n, "kl": sum(kls) / n,
+ "ppl_ref": math.exp(nll_r / n), "ppl": math.exp(nll_a / n)}
+ tot["n"] += n
+ tot["agree"] += agree
+ tot["nll_r"] += nll_r
+ tot["nll_a"] += nll_a
+ tot["kl"] += sum(kls)
+ n = max(tot["n"], 1)
+ allk.sort()
+ res["all"] = {"positions": tot["n"], "top1": tot["agree"] / n, "kl": tot["kl"] / n,
+ "kl_p99": allk[int(0.99 * (len(allk) - 1))] if allk else float("nan"),
+ "ppl_ref": math.exp(tot["nll_r"] / n), "ppl": math.exp(tot["nll_a"] / n)}
+ return res
+
+
+def cmd_compare(a) -> int:
+ ref = read_run(a.ref)
+ print(f"reference: {a.ref}")
+ print(f"{'run':40s} {'segment':13s} {'pos':>5s} {'top1':>7s} {'KL':>8s} {'KL p99':>8s} {'PPL':>7s} {'PPL ref':>7s}")
+ allres = {}
+ for path in a.runs:
+ r = compare(ref, read_run(path))
+ allres[path] = r
+ for seg, v in r.items():
+ if seg != "all" and not a.segments:
+ continue
+ print(f"{pathlib.Path(path).name[:40]:40s} {seg:13s} {v['positions']:5d} {100 * v['top1']:6.2f}% "
+ f"{v['kl']:8.5f} {v.get('kl_p99', float('nan')):8.4f} {v['ppl']:7.3f} {v['ppl_ref']:7.3f}")
+ if a.json:
+ pathlib.Path(a.json).write_text(json.dumps(allres, indent=1))
+ return 0
+
+
+def main() -> int:
+ ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
+ sub = ap.add_subparsers(dest="cmd", required=True)
+ p = sub.add_parser("ids")
+ p.add_argument("--tokenizer", required=True)
+ p.add_argument("--set", default=str(SET_DIR))
+ p.add_argument("--seg-tokens", type=int, default=1000)
+ p.add_argument("--out")
+ p = sub.add_parser("run")
+ p.add_argument("--config", required=True)
+ p.add_argument("--out", required=True)
+ p.add_argument("--ids", default=str(SET_DIR / "set.ids.json"))
+ p.add_argument("--env", action="append")
+ p.add_argument("--gpu-experts", action="store_true", help="--expert-cache 1500 instead of one slot (the experts on the GPU kernels)")
+ p.add_argument("--min-free-gb", type=float, default=16)
+ p.add_argument("--wrap", help="a command prefix for the engine, e.g. 'systemd-run --user --scope -p MemoryMax=200G'")
+ p = sub.add_parser("compare")
+ p.add_argument("ref")
+ p.add_argument("runs", nargs="+")
+ p.add_argument("--segments", action="store_true")
+ p.add_argument("--json")
+ a = ap.parse_args()
+ return {"ids": cmd_ids, "run": cmd_run, "compare": cmd_compare}[a.cmd](a)
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())