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++
PLE table as Q8_0 (Unsloth's UD-Q6_K_XL) + docs
Thomas Weaver9227973b36db
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 73b90ccb2..0fafe641b 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -1266,6 +1266,9 @@ if(STRATA_NATIVE_EXPERTS)if(STRATA_ENABLE_CUDA AND STRATA_BUILD_TESTS)add_executable(ple_q5_parity src/kernels/ple_q5_parity.cpp)target_link_libraries(ple_q5_parity PRIVATE strata_kernels strata_artifact ggml-base ${_strata_gpu_runtime_target})+ # Unsloth's UD-Q6_K_XL ships per_layer_token_embd as Q8_0 (170-B rows) - same check, different type+ add_executable(ple_q8_parity src/kernels/ple_q8_parity.cpp)+ target_link_libraries(ple_q8_parity PRIVATE strata_kernels strata_artifact ggml-base ${_strata_gpu_runtime_target})add_executable(q5_projection_parity src/kernels/q5_projection_parity.cpp)target_include_directories(q5_projection_parity PRIVATE ${_strata_gpu_include_directories})target_link_libraries(q5_projection_parity PRIVATE strata_kernels strata_artifact ggml-base ${_strata_gpu_runtime_target})diff --git a/docs/MODELS.md b/docs/MODELS.mdindex 1ffc87f5a..921b55db2 100644--- a/docs/MODELS.md+++ b/docs/MODELS.md@@ -142,6 +142,9 @@ NVIDIA GPU (no images yet). Details and measurements: [UD-Q4_K_XL](UNSLOTH_Q4.mdSTART-HERE.bat --setup --family unsloth --model UD-Q4_K_XL```+**Unsloth's 6-bit UD-Q6_K_XL** (experimental, not in setup's menu) trades more bytes per expert for less precision+loss against the same files: 169.2 GB together, its PLE table Q8_0 (read by the engine since 0.1.38). High RAM+machines run it without a RAM budget. Manual workflow: [UD-Q6_K_XL](UNSLOTH_Q6.md).### OrcaRouter Uncensored IQ3_XXSFor **OrcaRouter's Flash-Next Uncensored IQ3_XXS**, see the [manual compatibility setup](ORCA.md). It needs andiff --git a/docs/UNSLOTH_Q4.md b/docs/UNSLOTH_Q4.mdindex 5a87468e9..ccb05d95d 100644--- a/docs/UNSLOTH_Q4.md+++ b/docs/UNSLOTH_Q4.md@@ -289,6 +289,10 @@ whose header shows the same formats.- UD-Q4_K_XL and UD-IQ4_XS at revision `38bb39e` are targeted, and plain Q4_0 files ([above](#q4_0-files)). Otherquantizations use formats this engine may not have kernels for; the engine checks every layer's formats at startand refuses an unsupported one by name.++- UD-Q4_K_XL and UD-IQ4_XS at revision `38bb39e` are targeted. Other Unsloth quantizations use formats this engine may+ not have kernels for; the engine checks every layer's formats at start and refuses an unsupported one by name.+ (UD-Q6_K_XL of the same revision is documented separately: [UNSLOTH_Q6.md](UNSLOTH_Q6.md).)- Tests: the packer's synthetic 4-shard and conversion tests (`.venv/bin/python -m unittest discover -s tools -ptest_iq_pack.py`); CTests `gguf_split_test`, `expert_layout_test`, `native_expert_parity_*` (the three real expertformat pairs against ggml-cpu, the Q5_1 min term, Q8_0 rows, Q4_0/Q4_0 and Q4_0/Q4_1), `prefill_mmq_kquant_test` (with `-DSTRATA_MMQ_KQUANTS=ON`: thediff --git a/docs/UNSLOTH_Q6.md b/docs/UNSLOTH_Q6.mdnew file mode 100644index 000000000..7eb4b7136--- /dev/null+++ b/docs/UNSLOTH_Q6.md@@ -0,0 +1,107 @@+# Unsloth UD-Q6_K_XL (experimental)++**Experimental; manual workflow only — setup does not offer this model yet.** This is Unsloth's 6-bit file of the+same model the other packs use:+[unsloth/Qwen3.8-Flash-Next-GGUF, `UD-Q6_K_XL`, revision `38bb39e`](https://huggingface.co/unsloth/Qwen3.8-Flash-Next-GGUF/tree/38bb39ee97821de2c9009abb7e93950eec396e66/UD-Q6_K_XL).+Build it for engine 0.1.38 or newer (earlier engines read `per_layer_token_embd.weight` in IQ4_NL, Q5_0 or FP8 only,+below). UD-Q4_K_XL's manual workflow asks nothing of setup, and neither does this one.++## 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` (shards 1, 2, 6; the same shape as UD-Q4_K_XL):++- **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). UD-Q4_K_XL's downs were Q5_1 with a few Q8_0; here every down seen so far is Q8_0. Q6_K experts are native:+ the GPU multiplies them directly (`native_q6_k_mmvq_gpu`, multi-token prompt path too) 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. Not yet run on this file end to end (the+download was not finished when this was written); the packer's own tests cover the shard and conversion logic+(`.venv/bin/python -m unittest discover -s tools -p test_iq_pack.py`).++## The server++Like UD-Q4_K_XL's [config](UNSLOTH_Q4.md#the-server), with the Q6 paths and names. `--ple-gguf` is not needed: the+engine finds shard 3 by the table's name. On a machine whose RAM holds the ~110 GB of routed experts plus the rest+(499 GB total, ~325 GB free, measured on the machine this was written on), there is no RAM budget and no+`--expert-cache` gymnastics: drop `--resident-budget-gib` and `--expert-cache-device1` from the Q4 config. The+54.4 GB table is mmap'd (the default) — do not switch it to `--ple-io ram` unless the RAM really is there to lock+it. `mtp/rt` is the base model's draft layer as always.++```json+{+ "exe": "build/strata",+ "args": [+ "--pack", "packs/ud-q6_k_xl",+ "--native", "/path/to/Qwen3.8-Flash-Next-UD-Q6_K_XL-00001-of-00006.gguf",+ "--prefill", "auto", "--spec", "4", "--spec-min-p", "0.5",+ "--mtp", "mtp/rt", "--max-context", "8192"+ ],+ "cwd": ".",+ "tokenizer": "packs/ud-q6_k_xl/tokenizer",+ "model_name": "qwen3.8-flash-next-ud-q6_k_xl",+ "log": "strata-ud-q6_k_xl.log",+ "host": "127.0.0.1",+ "port": 8080+}+```++On 64 GB machines treat the Q4 numbers below as the starting point: the RAM budget matters the same way, and+everything it leaves out comes from the SSD, faster now per expert (Q6_K) and per table row (170 bytes).++## Status: what is verified and what is not++Verified here (test clone, Linux, NVIDIA GPU, source build):++- The six files' sizes and SHA-256 (HF tree API; shards 1, 2, 6 additionally against the downloaded blobs).+- The tensor inventory of shards 1, 2 and 6, read from the headers (`tools/gguf_reader.py`).+- Q8_0 PLE rows: `ple_reader_test --selftest` runs 90, 110 and 170-byte rows (all OK); `ple_q8_parity` on a+ synthetic Q8_0 table (`tools/ple_q8_fixture.py`) matches ggml's reference dequantizer bit for bit through both+ Mmap and Direct (`max_abs 0.000e+00`).+- Q6_K experts were already native (the CPU/GPU kernels and their parity tests predate this).++Not yet: a real decode run on the finished file (speed, quality against llama.cpp, the prompt path's behavior with+this table), the pack on the complete download, whether shards 4/5 put a layer boundary inside a layer. When the+download finishes: pack, start the server, and record the same measurements as+[UD-Q4_K_XL's](UNSLOTH_Q4.md#quality-against-llamacpp-on-the-same-file) before un-experimental-ing this.\ No newline at end of filediff --git a/include/strata/kernels/ngram.hpp b/include/strata/kernels/ngram.hppindex 842914760..9172556f5 100644--- a/include/strata/kernels/ngram.hpp+++ b/include/strata/kernels/ngram.hpp@@ -76,6 +76,9 @@ const PleFormatInfo* ple_format_for_type(const char* gguf_type_name);/// "IQ4_NL, Q5_0 or FP8 (I8)": the formats for an error message, built from the list.std::string ple_format_list();+inline constexpr int PLE_ROW_BYTES_Q8_0 = (PLE_HEAD_DIM / 32) * 34; // 170: a Q8_0 row (Unsloth's UD-Q6_K_XL)+inline constexpr int PLE_ROW_BYTES_MAX = PLE_ROW_BYTES_Q8_0;+/// The artifact's own hash constants, transcribed from `docs/gguf-dump-shard1.txt`:////// layer_multipliers = [23703573157769, 20109073645365, 8052911324071]diff --git a/include/strata/ngram/ple_reader.hpp b/include/strata/ngram/ple_reader.hppindex 2884817ef..11729f7d4 100644--- a/include/strata/ngram/ple_reader.hpp+++ b/include/strata/ngram/ple_reader.hpp@@ -58,7 +58,7 @@ public:/// validated GGUF parse (PleTable::open checks the table exactly fills the file from there)./// `io_thread` (default): a worker thread submits and reaps reads, so `issue` costs the caller no ReadFile/// calls. false: the caller's thread does it (A/B arm).- /// `row_bytes`: one row's size in the file (90 IQ4_NL, 160 FP8), at most one page.+ /// `row_bytes`: one row's size in the file (90 IQ4_NL, 110 Q5_0, 160 FP8, 170 Q8_0), at most one page.bool open(const std::string& path, uint64_t table_offset, uint64_t n_rows, uint32_t max_inflight,uint64_t cache_rows, std::string& err, bool io_thread = true, uint32_t row_bytes = ROW_BYTES);uint32_t row_bytes() const;diff --git a/src/kernels/ngram.cpp b/src/kernels/ngram.cppindex 4667745fb..374475931 100644--- a/src/kernels/ngram.cpp+++ b/src/kernels/ngram.cpp@@ -221,6 +221,19 @@ struct PleTable::Impl {float scale = 1.0f; // the FP8 table's one scaleuint32_t rb = PLE_ROW_BYTES; // bytes per rowvoid decode(const uint8_t* row, float* out160) const { fmt->dequant(row, scale, out160); }++ bool q8_0 = false; // Q8_0 rows (170 B): Unsloth's UD-Q6_K_XL ships the table as Q8_0+ bool fp8 = false; // F8_E4M3 rows (tools/ple_fp8_pack.py); else IQ4_NL+ float scale = 1.0f; // the FP8 table's one scale+ uint32_t rb = PLE_ROW_BYTES; // bytes per row+ void decode(const uint8_t* row, float* out160) const {+ if (fp8) fp8_e4m3_dequant_row(row, scale, out160);+ else if (q5_0)+ for (int b = 0; b < PLE_HEAD_DIM / 32; ++b) strata::dequantize_q5_0(row + (size_t) b * 22, out160 + b * 32);+ else if (q8_0)+ for (int b = 0; b < PLE_HEAD_DIM / 32; ++b) strata::dequantize_q8_0(row + (size_t) b * 34, out160 + b * 32);+ else iq4nl_dequant_row(row, out160);+ }};PleTable::PleTable() : impl_(new Impl) {}@@ -260,6 +273,16 @@ bool PleTable::open(const std::string& gguf_path, std::string& err, const PleIoOreturn false;}if (fmt->needs_scale) {++ // IQ4_NL (ISTA-DASLab's shard 2, the original's own GGUF), Q5_0 (#296: OrcaRouter's GGUF), Q8_0 (Unsloth's+ // UD-Q6_K_XL), or the FP8 table as shipped: I8 bytes marked strata.ple.format = f8_e4m3 with strata.ple.scale+ // (tools/ple_fp8_pack.py)+ impl_->fp8 = false;+ impl_->q5_0 = std::strcmp(t->type_name(), "Q5_0") == 0;+ impl_->q8_0 = std::strcmp(t->type_name(), "Q8_0") == 0;+ impl_->rb = impl_->q5_0 ? (PLE_HEAD_DIM / 32) * 22+ : impl_->q8_0 ? (PLE_HEAD_DIM / 32) * 34 : PLE_ROW_BYTES;+ if (std::strcmp(t->type_name(), "I8") == 0) {const MetaValue* f = impl_->file->get("strata.ple.format");const MetaValue* s = impl_->file->get("strata.ple.scale");if (f == nullptr || f->s != "f8_e4m3" || s == nullptr || !(s->num() > 0.0)) {@@ -268,6 +291,12 @@ bool PleTable::open(const std::string& gguf_path, std::string& err, const PleIoOreturn false;}impl_->scale = (float) s->num();++ impl_->rb = PLE_ROW_BYTES_FP8;+ } else if (!impl_->q5_0 && !impl_->q8_0 && std::strcmp(t->type_name(), "IQ4_NL") != 0) {+ err = std::string("per_layer_token_embd.weight is ") + t->type_name() + ", not IQ4_NL, Q5_0, Q8_0 or FP8 (I8)";+ close();+ return false;}impl_->fmt = fmt;impl_->rb = fmt->row_bytes;@@ -409,11 +438,17 @@ void PleTable::close() {impl_->fmt = &ple_format_info(PleFormat::IQ4_NL);impl_->scale = 1.0f;impl_->bytes_read = 0;++ impl_->q5_0 = false;+ impl_->q8_0 = false;+ impl_->fp8 = false;}bool PleTable::is_open() const { return impl_->data != nullptr || impl_->reader.is_open(); }bool PleTable::locked() const { return impl_->locked; }const char* PleTable::format() const { return impl_->fmt->name; }++const char* PleTable::format() const { return impl_->fp8 ? "F8_E4M3" : impl_->q5_0 ? "Q5_0" : impl_->q8_0 ? "Q8_0" : "IQ4_NL"; }PleIo PleTable::mode() const { return impl_->mode; }uint64_t PleTable::rows() const { return impl_->n_rows; }uint64_t PleTable::bytes_read() const { return impl_->bytes_read; }diff --git a/src/kernels/ple_q8_parity.cpp b/src/kernels/ple_q8_parity.cppnew file mode 100644index 000000000..899e6f2ec--- /dev/null+++ b/src/kernels/ple_q8_parity.cpp@@ -0,0 +1,79 @@+// Real-artifact Q8_0 PLE rows against ggml's reference dequantizer.+// The PLE table in Unsloth's UD-Q6_K_XL GGUF ships as Q8_0 (170-B rows) rather than IQ4_NL; this+// mirrors ple_q5_parity.cpp so the Q8_0 read path is checked the same way, through BOTH I/O modes+// (Mmap and Direct) like ple_fp8_parity does.+#define NOMINMAX+#include "strata/artifact/gguf_reader.hpp"+#include "strata/kernels/ngram.hpp"+#include "ggml.h"++#include <algorithm>+#include <cmath>+#include <cstdio>+#include <cstring>+#include <string>+#include <vector>++int main(int argc, char** argv) {+ if (argc != 2) {+ std::fprintf(stderr, "usage: ple_q8_parity <gguf-containing-ple>\n");+ return 2;+ }+ strata::GgufFile gguf(argv[1]);+ const auto* tensor = gguf.find("per_layer_token_embd.weight");+ if (!tensor || tensor->type != 8 || tensor->shape.size() != 2 || tensor->shape[0] != 160) {+ std::fprintf(stderr, "expected Q8_0 PLE [160, N]\n");+ return 2;+ }+ const auto* traits = ggml_get_type_traits(GGML_TYPE_Q8_0);+ const uint8_t* bytes = gguf.tensor_data(*tensor);+ double max_abs_all = 0.0;+ size_t rows_checked = 0;+ for (const int direct : {0, 1}) {+ strata::kernels::PleIoOptions options;+ options.mode = direct ? strata::kernels::PleIo::Direct : strata::kernels::PleIo::Mmap;+ strata::kernels::PleTable table;+ std::string err;+ if (!table.open(argv[1], err, options)) {+ std::fprintf(stderr, "%s\n", err.c_str());+ return 1;+ }+ if (std::strcmp(table.format(), "Q8_0") != 0) {+ std::fprintf(stderr, "format() = %s, expected Q8_0\n", table.format());+ return 1;+ }+ rows_checked = (size_t) table.rows();+ // The real table's row 20000003 (the first head's vocab edge) only exists in a table that big; a+ // small synthetic fixture stands in for it so the same binary checks both.+ const uint32_t probes[] = {0, 1, 12345,+ table.rows() > 20000004 ? 20000003u : (uint32_t) (table.rows() / 2),+ (uint32_t) (table.rows() - 1)};+ double max_abs = 0.0;+ for (uint32_t row : probes) {+ float got[160], want[160];+ table.read_row(row, got);+ traits->to_float(bytes + (size_t) row * 170, want, 160);+ for (int i = 0; i < 160; ++i)+ max_abs = std::max(max_abs, (double) std::fabs(got[i] - want[i]));+ }+ uint32_t rows[16];+ for (int i = 0; i < 16; ++i) rows[i] = probes[i % 5];+ float batch[16 * 160];+ if (!table.issue(rows) || !table.collect(batch, err)) {+ std::fprintf(stderr, "collect: %s\n", err.c_str());+ return 1;+ }+ for (int h = 0; h < 16; ++h) {+ float want[160];+ traits->to_float(bytes + (size_t) rows[h] * 170, want, 160);+ for (int i = 0; i < 160; ++i)+ max_abs = std::max(max_abs, (double) std::fabs(batch[h * 160 + i] - want[i]));+ }+ if (direct) std::printf("Direct: ");+ else std::printf("Mmap: ");+ std::printf("%zu rows, max_abs %.3e\n", rows_checked, max_abs);+ max_abs_all = std::max(max_abs_all, max_abs);+ }+ std::printf("Q8_0 PLE: max_abs %.3e %s\n", max_abs_all, max_abs_all <= 1e-6 ? "PASS" : "FAIL");+ return max_abs_all <= 1e-6 ? 0 : 1;+}\ No newline at end of filediff --git a/src/ngram/ple_reader_test.cpp b/src/ngram/ple_reader_test.cppindex 920847083..41366f066 100644--- a/src/ngram/ple_reader_test.cpp+++ b/src/ngram/ple_reader_test.cpp@@ -242,6 +242,11 @@ void all_formats_round_trip(const std::string& dir) {// row_bytes: ng::ROW_BYTES (90, IQ4_NL) is the production default; 110 (#296, OrcaRouter's Q5_0 PLE rows) is// run too, through the exact same generic row_bytes path -- nothing here is IQ4_NL-specific, so a second row// size run here is the correctness evidence for lifting ngram.cpp's "Q5_0 PLE requires --ple-io mmap" refusal.++// row_bytes: ng::ROW_BYTES (90, IQ4_NL) is the production default; 110 (#296, OrcaRouter's Q5_0 PLE rows) and+// 170 (Unsloth's UD-Q6_K_XL Q8_0 PLE rows) are run too, through the exact same generic row_bytes path --+// nothing here is IQ4_NL-specific, so extra row sizes run here are the correctness evidence for lifting+// ngram.cpp's format-specific refusals.int selftest(const std::string& dir, uint32_t rb) {const uint32_t N = 500000; // 45 MB: large enough for thousands of distinct pagesconst std::string path = dir + "/ple_reader_selftest_" + std::to_string(rb) + ".bin";@@ -457,9 +462,13 @@ int main(int argc, char** argv) {// same generic row_bytes path -- see the comment on selftest().all_formats_round_trip(dir); // every format of k::ple_formats(), both readers, vs its dequantizerif (g_fail != 0) return 1;++ // ng::ROW_BYTES (90, IQ4_NL, production default), 110 (#296, OrcaRouter's Q5_0 PLE rows) and 170+ // (Unsloth's UD-Q6_K_XL Q8_0 PLE rows) through the same generic row_bytes path -- see the comment on+ // selftest().const int r90 = selftest(dir, ng::ROW_BYTES);const int r110 = selftest(dir, 110);- return r90 != 0 ? r90 : r110;+ return r90 != 0 ? r90 : r110 != 0 ? r110 : selftest(dir, 170);}if (!make_path.empty()) { // a big synthetic table, for timing --ple-io ram's fault-infor (int i = 0; i < k::ple_format_count(); ++i) {diff --git a/tools/ple_q8_fixture.py b/tools/ple_q8_fixture.pynew file mode 100644index 000000000..22d2e4212--- /dev/null+++ b/tools/ple_q8_fixture.py@@ -0,0 +1,59 @@+#!/usr/bin/env python3+"""tools/ple_q8_fixture.py - a small synthetic PLE table as Q8_0 in a one-tensor GGUF.++Built for the Q8_0 PLE path (Unsloth's UD-Q6_K_XL ships per_layer_token_embd as Q8_0, 170-B rows)+so ple_q8_parity can run without the real 54-GB shard 3. The bytes are random with a fixed seed:+every Q8_0 block decodes as d * int8, so ANY bytes are valid input, and the point of the parity test+is that Strata's dequantizer agrees with ggml's reference on whatever is there.++ python tools/ple_q8_fixture.py --out /tmp/ple_q8.gguf [--rows 131072] [--seed 7]++Validate the file with tools/gguf_reader.py first; then+ ple_q8_parity /tmp/ple_q8.gguf+"""+import argparse+import pathlib+import struct++import numpy as np++BLOCK = 34 # Q8_0: f16 scale + 32 int8+DIM = 160 # PLE_HEAD_DIM: the fast axis, one row = 5 blocks+++def main() -> None:+ ap = argparse.ArgumentParser()+ ap.add_argument('--out', required=True)+ ap.add_argument('--rows', type=int, default=131072) # >= 16 for gather_batch, small enough to be quick+ ap.add_argument('--seed', type=int, default=7)+ args = ap.parse_args()++ rng = np.random.default_rng(args.seed)+ n_block = args.rows * (DIM // 32)+ d = rng.uniform(-0.001, 0.001, n_block).astype(np.float16)+ # small scales and int8 values: products stay in exact-float range, no NaN/inf edge cases+ qs = rng.integers(-128, 128, (n_block, 32), dtype=np.int8)+ data = np.empty(n_block * BLOCK, dtype=np.uint8)+ view = data.view(np.uint8).reshape(n_block, BLOCK)+ view[:, 0:2] = d.view(np.uint8).reshape(n_block, 2)+ view[:, 2:] = qs.view(np.uint8)+ assert data.size == args.rows * DIM // 32 * BLOCK++ name = b'per_layer_token_embd.weight'+ buf = bytearray()+ buf += struct.pack('<4sIQQ', b'GGUF', 3, 1, 0) # magic, version, 1 tensor, 0 metadata kv+ buf += struct.pack('<Q', len(name)) + name # tensor name (v3: uint64 length)+ buf += struct.pack('<IQQI', 2, DIM, args.rows, 8) # n_dims, shape [160, rows], type Q8_0, offset 0+ hlen = len(buf)+ pad = (-len(buf)) % 32 # data_start is alignment-padded (default 32)+ buf += b'\0' * pad+ buf += data.tobytes()+ out = pathlib.Path(args.out)+ out.write_bytes(bytes(buf))+ # the tensor must fill the file from data_start exactly: PleTable asserts it when alone in its shard+ assert out.stat().st_size == len(buf) == hlen + pad + data.size+ print(f'{out}: {args.rows} rows x {DIM} elems x {BLOCK}+0 B blocks = {data.size} B data, header {pad + 4 + len(name) + 4 + 16 + 4 + 8} B (pad {pad})')+++if __name__ == '__main__':+ main()\ No newline at end of file