[GH-ISSUE #5248] [Other] Accept Unsloth's swap-in engram tables (BF16/Q8_0/Q5_1/IQ4_NL) instead of only the bundled one #3122

Open
opened 2026-11-07 14:38:14 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @simlu on GitHub (Nov 4, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5248

Area

[Other] (anything else, including setup and installation)

What do you want to do?

Unsloth now publishes the Qwen3.8-Flash-Next n-gram / PLE table as standalone GGUFs
(https://huggingface.co/unsloth/Qwen3.8-Flash-Next-GGUF/tree/main/engram), so a quant can be
run with a different table than the one it ships with ("Mix N Match Engrams":
https://unsloth.ai/docs/models/qwen3.8-next#mix-n-match-engrams). The docs page even names the
combinations: UD-Q4_K_XL with the Q8_0 table, and — the case I need — Q8_0 / UD-Q5_K_XL /
UD-Q6_K_XL with the BF16 table. I want Strata to support picking that table as a first-class
option instead of only the table the chosen quant bundles.

Who needs it and why:

  • Anyone running Q8_0 (or UD-Q5_K_XL / UD-Q6_K_XL) who wants the lossless n-gram table.
    Those three sets all bundle the Q8_0 table (setup.py's pins show shard ...-00003-of-00006
    is the same bytes, size 54,400,261,312 and SHA-256 34efd79a..., in all three). Unsloth's
    engram/README measures that table at relative RMSE 0.0053 vs the checkpoint; BF16 is 0 (the
    checkpoint's own table). The only file that ships the BF16 table today is the full BF16 model
    (355 GB) — a table swap gets it on a 236 GB file set instead.
  • Bandwidth/disk cases in the other direction (UD-Q4_K_XL + Q8_0 table saves the 28.8 GB IQ4_NL
    shard — Unsloth's own example). The table slot per quant is fixed (engram README): 3 of 6 for
    UD-Q5_K_XL/UD-Q6_K_XL/Q8_0, 4 of 4 for UD-Q2_K_XL/UD-IQ3_XXS/UD-Q3_K_XL/UD-IQ4_XS/UD-Q4_K_XL,
    3 of 3 for UD-IQ1_S/UD-IQ1_M/UD-Q2_0/UD-IQ2_XS, 3 of 8 for BF16.

The good news: nothing on the engine side is missing. src/kernels/ngram.cpp's kPleFormats
already reads BF16 ("the checkpoint's own table at full precision, 320-byte rows; self-describing"),
Q8_0, Q5_1, Q5_0, Q4_0 and IQ4_NL, and ple_format_for_type() picks the format from the table
tensor's GGUF type. With a native multi-shard set the engine finds the table shard itself by tensor
name (per_layer_token_embd.weight, src/program/generate.cpp, "--ple-gguf defaults to the shard
that holds the PLE table"). I verified this at tag v0.2.9 (docker image 0.2.9-cuda13, engine
0.1.55) and it is unchanged on main apart from the #4671 memlock fix.

What is missing is the installer/pinning layer around it. Proposal (opt-in per CONTRIBUTING;
nothing on the default path changes):

  1. A choice in setup / strata launch (and a docker env, e.g. PLE_TABLE: bf16|q8_0|q5_1|iq4_nl,
    default = the quant's bundled table). When a non-default table is chosen, setup fetches the
    matching engram/Qwen3.8-Flash-Next-engram-<TYPE>.gguf_file from
    unsloth/Qwen3.8-Flash-Next-GGUF, verifies it against pinned size + SHA-256, stamps
    split.no/split.count for the chosen quant's slot (exactly the two uint16 header values
    engram/set_split.py rewrites; without the stamp the loader refuses with invalid split file idx), names it as the quant's table shard, and keeps it as that set's table from then on.
    Suggested pins from the Hub's LFS pointers (fetched 2026-11-04):
    • BF16 102,400,491,712 B sha256:fd191dd766b7b9616bc648dad1d9dec7bff7cf0a6d27cb2c9edcde9be2aef966
    • Q8_0 54,400,261,312 B sha256:e3d76a2747c1fe53e3420d1bb7fd9593aafd03035fee4926317db80ad5c5296a
    • Q5_1 38,400,184,512 B sha256:6eabff6df91df62f802d0c7185512c776d705dd73679a8f65cfb0a7843480e26
    • IQ4_NL 28,800,138,432 B sha256:69b4700f0109c9013571156b77cb758b758114412b3d545ebc43f08e25c15d79
  2. Run-config bookkeeping: record the chosen table type + digest in the model's registry/run config
    (and in the finish-mark line next to sha256 ...), so "Check Files" and the step-5 verification
    check the table against the chosen pin instead of the bundled quant's pin — today the only
    way a swapped shard passes is verify_sha256(..., own=True)'s generic "may be another version
    or a fine-tune, so check a few answers" warning, which reads like a suspected broken file.
  3. Size/fit awareness: download_gb (MODELS["Q8_0"] = 188.2 -> 236.2 with BF16), the free-disk
    estimate in step 5, and the automatic --ple-io ram rule (ram >= MODELS[model].ram_gb + table_gb + 16) should use the chosen table's size. The engine part already reads the real file;
    the setup-side numbers do not follow a swap. A one-line plan/launch note like "n-gram table:
    BF16 (102.4 GB), read from SSD" would make the RAM consequence visible before the first start.
  4. The --model-path / "files already here" half: when a shard that holds per_layer_token_embd.weight
    parses as a whole GGUF but its tensor type is one of kPleFormats (and the size matches
    rows x row-bytes for that type), say "n-gram table: BF16 (not this quant's bundled Q8_0 table)"
    instead of the generic wrong-SHA warning, and let a finish mark stick for it — today that path
    writes no mark, so a --gguf-dir table with its own digest is re-hashed on every launch
    (102 GB each time), while a stale .done carrying the old bundled hash is trusted forever.

Docs: a short section in docs/QUANTS.md (or the engram equivalent) + the PLE_TABLE row in
docs/DOCKER.md's env table.

Trade-offs I see: one extra pinned artifact per table type (4 files, same repo, LFS oids above);
a table mismatch can no longer be caught by SHA alone, so the type/rows/size pre-check matters;
and the --ple-io ram headroom question for BF16 on 256 GB PCs (136 + 102.4 + 16 GB threshold —
right at the edge), which setup already decides per machine, so no new default is proposed.

Alternative if a full option is out of scope: officially document the manual swap (stamped file
renamed into the set + --model-path) as supported in DOCKER.md/QUANTS.md, and fix the two rough
edges above (the "possibly damaged" wording for a recognized table type, and the missing finish
mark that causes the 102 GB re-hash on every launch).

What do you do today instead?

I assemble the mixed set by hand, exactly as Unsloth's engram/README prescribes, and hand it to
Strata through --model-path / docker MODEL_PATH:

hf download unsloth/Qwen3.8-Flash-Next-GGUF \
  --include "engram/*BF16*" "engram/set_split.py" --local-dir .
python engram/set_split.py engram/Qwen3.8-Flash-Next-engram-BF16.gguf_file 3 6
mv Q8_0/Qwen3.8-Flash-Next-Q8_0-00003-of-00006.gguf     Q8_0/engram-Q8_0.bak
mv Q8_0/Qwen3.8-Flash-Next-Q8_0-00003-of-00006.gguf.done Q8_0/engram-Q8_0.bak.done
mv engram/Qwen3.8-Flash-Next-engram-BF16.gguf_file \
   Q8_0/Qwen3.8-Flash-Next-Q8_0-00003-of-00006.gguf

then point the container at the folder (MODEL_PATH=/data/models/qwen38/..., MODEL: Q8_0,
FAMILY: unsloth). Per the source (see above), check_shards' exact-single-tensor-length rule
passes for the standalone table (self-consistent: 192 B header + 320,001,536 x 320 B =
102,400,491,712), and the table format is read from the tensor type at load.

Three rough edges on the installer side:

  • Either keep the old .done mark of the bundled shard: its pinned-hash early-return makes setup
    trust the swapped 102 GB file forever (no hash, no warning — but "Check Files" is then blind to
    the real table file).
  • Or drop the mark and take verify_sha256(own=True)'s warning path on every container start:
    "...is not the published file (SHA-256 fd191d..., expected 34efd7...) but it is a complete GGUF
    file, so Strata uses it as it is" plus a full 102 GB re-hash on every launch, because that path
    never writes a finish mark (a :ro model folder makes it worse; Control 0.2.10 keeps marks for
    read-only model folders outside the folder — b3c39091 — but the current 0.2.9-cuda13 image
    predates it).
  • And setup's --ple-io ram auto-decision silently flips on the swap: the Q8_0 table needs
    136 + 54.4 + 16 = 206.4 GB MemTotal (inside this box's budget -> table pinned in RAM), the
    BF16 table needs 136 + 102.4 + 16 = 254.4 GB (above it -> streamed from NVMe), with no plan
    line saying the table changed residence.

Reproduction / verification status, per CONTRIBUTING: the engine-reads-BF16 and installer-behavior
claims above are verified by reading the source at tag v0.2.9 and origin/main
(src/kernels/ngram.cpp kPleFormats + ple_format_for_type; src/program/generate.cpp PLE-shard
discovery; setup.py verify_sha256 own path, check_shards #657, --ple-io ram rule,
MODELS["Q8_0"] pins; docker/entrypoint.sh MODEL_PATH -> --model-path). The runtime boot of
this mix on my rig (docker ghcr.io/niko1221/strata:0.2.9-cuda13, engine 0.1.55, Linux,
4x RTX 3090 24 GB, 256 GB RAM, Q8_0 + BF16 table, CONTEXT=262144, KV=fp16, VISION=on) is
not run yet — I will attach the first-boot log and the exact setup warning lines to this issue
when I do.

Originally created by @simlu on GitHub (Nov 4, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/5248 ### Area [Other] (anything else, including setup and installation) ### What do you want to do? Unsloth now publishes the Qwen3.8-Flash-Next n-gram / PLE table as standalone GGUFs (https://huggingface.co/unsloth/Qwen3.8-Flash-Next-GGUF/tree/main/engram), so a quant can be run with a different table than the one it ships with ("Mix N Match Engrams": https://unsloth.ai/docs/models/qwen3.8-next#mix-n-match-engrams). The docs page even names the combinations: `UD-Q4_K_XL` with the Q8_0 table, and — the case I need — `Q8_0` / `UD-Q5_K_XL` / `UD-Q6_K_XL` with the **BF16** table. I want Strata to support picking that table as a first-class option instead of only the table the chosen quant bundles. Who needs it and why: - Anyone running `Q8_0` (or `UD-Q5_K_XL` / `UD-Q6_K_XL`) who wants the lossless n-gram table. Those three sets all bundle the Q8_0 table (setup.py's pins show shard `...-00003-of-00006` is the same bytes, size 54,400,261,312 and SHA-256 34efd79a..., in all three). Unsloth's engram/README measures that table at relative RMSE 0.0053 vs the checkpoint; BF16 is 0 (the checkpoint's own table). The only file that ships the BF16 table today is the full BF16 model (355 GB) — a table swap gets it on a 236 GB file set instead. - Bandwidth/disk cases in the other direction (UD-Q4_K_XL + Q8_0 table saves the 28.8 GB IQ4_NL shard — Unsloth's own example). The table slot per quant is fixed (engram README): 3 of 6 for UD-Q5_K_XL/UD-Q6_K_XL/Q8_0, 4 of 4 for UD-Q2_K_XL/UD-IQ3_XXS/UD-Q3_K_XL/UD-IQ4_XS/UD-Q4_K_XL, 3 of 3 for UD-IQ1_S/UD-IQ1_M/UD-Q2_0/UD-IQ2_XS, 3 of 8 for BF16. The good news: nothing on the engine side is missing. `src/kernels/ngram.cpp`'s `kPleFormats` already reads BF16 ("the checkpoint's own table at full precision, 320-byte rows; self-describing"), Q8_0, Q5_1, Q5_0, Q4_0 and IQ4_NL, and `ple_format_for_type()` picks the format from the table tensor's GGUF type. With a native multi-shard set the engine finds the table shard itself by tensor name (`per_layer_token_embd.weight`, `src/program/generate.cpp`, "--ple-gguf defaults to the shard that holds the PLE table"). I verified this at tag v0.2.9 (docker image `0.2.9-cuda13`, engine 0.1.55) and it is unchanged on main apart from the #4671 memlock fix. What is missing is the installer/pinning layer around it. Proposal (opt-in per CONTRIBUTING; nothing on the default path changes): 1. A choice in setup / `strata launch` (and a docker env, e.g. `PLE_TABLE: bf16|q8_0|q5_1|iq4_nl`, default = the quant's bundled table). When a non-default table is chosen, setup fetches the matching `engram/Qwen3.8-Flash-Next-engram-<TYPE>.gguf_file` from `unsloth/Qwen3.8-Flash-Next-GGUF`, verifies it against pinned size + SHA-256, stamps `split.no`/`split.count` for the chosen quant's slot (exactly the two uint16 header values `engram/set_split.py` rewrites; without the stamp the loader refuses with `invalid split file idx`), names it as the quant's table shard, and keeps it as that set's table from then on. Suggested pins from the Hub's LFS pointers (fetched 2026-11-04): - BF16 102,400,491,712 B sha256:fd191dd766b7b9616bc648dad1d9dec7bff7cf0a6d27cb2c9edcde9be2aef966 - Q8_0 54,400,261,312 B sha256:e3d76a2747c1fe53e3420d1bb7fd9593aafd03035fee4926317db80ad5c5296a - Q5_1 38,400,184,512 B sha256:6eabff6df91df62f802d0c7185512c776d705dd73679a8f65cfb0a7843480e26 - IQ4_NL 28,800,138,432 B sha256:69b4700f0109c9013571156b77cb758b758114412b3d545ebc43f08e25c15d79 2. Run-config bookkeeping: record the chosen table type + digest in the model's registry/run config (and in the finish-mark line next to `sha256 ...`), so "Check Files" and the step-5 verification check the table against the **chosen** pin instead of the bundled quant's pin — today the only way a swapped shard passes is `verify_sha256(..., own=True)`'s generic "may be another version or a fine-tune, so check a few answers" warning, which reads like a suspected broken file. 3. Size/fit awareness: `download_gb` (MODELS["Q8_0"] = 188.2 -> 236.2 with BF16), the free-disk estimate in step 5, and the automatic `--ple-io ram` rule (`ram >= MODELS[model].ram_gb + table_gb + 16`) should use the chosen table's size. The engine part already reads the real file; the setup-side numbers do not follow a swap. A one-line plan/launch note like "n-gram table: BF16 (102.4 GB), read from SSD" would make the RAM consequence visible before the first start. 4. The `--model-path` / "files already here" half: when a shard that holds `per_layer_token_embd.weight` parses as a whole GGUF but its tensor type is one of `kPleFormats` (and the size matches rows x row-bytes for that type), say "n-gram table: BF16 (not this quant's bundled Q8_0 table)" instead of the generic wrong-SHA warning, and let a finish mark stick for it — today that path writes no mark, so a `--gguf-dir` table with its own digest is re-hashed on **every** launch (102 GB each time), while a stale `.done` carrying the old bundled hash is trusted forever. Docs: a short section in docs/QUANTS.md (or the engram equivalent) + the `PLE_TABLE` row in docs/DOCKER.md's env table. Trade-offs I see: one extra pinned artifact per table type (4 files, same repo, LFS oids above); a table mismatch can no longer be caught by SHA alone, so the type/rows/size pre-check matters; and the `--ple-io ram` headroom question for BF16 on 256 GB PCs (136 + 102.4 + 16 GB threshold — right at the edge), which setup already decides per machine, so no new default is proposed. Alternative if a full option is out of scope: officially document the manual swap (stamped file renamed into the set + `--model-path`) as supported in DOCKER.md/QUANTS.md, and fix the two rough edges above (the "possibly damaged" wording for a recognized table type, and the missing finish mark that causes the 102 GB re-hash on every launch). ### What do you do today instead? I assemble the mixed set by hand, exactly as Unsloth's engram/README prescribes, and hand it to Strata through `--model-path` / docker `MODEL_PATH`: ```bash hf download unsloth/Qwen3.8-Flash-Next-GGUF \ --include "engram/*BF16*" "engram/set_split.py" --local-dir . python engram/set_split.py engram/Qwen3.8-Flash-Next-engram-BF16.gguf_file 3 6 mv Q8_0/Qwen3.8-Flash-Next-Q8_0-00003-of-00006.gguf Q8_0/engram-Q8_0.bak mv Q8_0/Qwen3.8-Flash-Next-Q8_0-00003-of-00006.gguf.done Q8_0/engram-Q8_0.bak.done mv engram/Qwen3.8-Flash-Next-engram-BF16.gguf_file \ Q8_0/Qwen3.8-Flash-Next-Q8_0-00003-of-00006.gguf ``` then point the container at the folder (`MODEL_PATH=/data/models/qwen38/...`, `MODEL: Q8_0`, `FAMILY: unsloth`). Per the source (see above), `check_shards`' exact-single-tensor-length rule passes for the standalone table (self-consistent: 192 B header + 320,001,536 x 320 B = 102,400,491,712), and the table format is read from the tensor type at load. Three rough edges on the installer side: - Either keep the old `.done` mark of the bundled shard: its pinned-hash early-return makes setup trust the swapped 102 GB file forever (no hash, no warning — but "Check Files" is then blind to the real table file). - Or drop the mark and take `verify_sha256(own=True)`'s warning path on every container start: "...is not the published file (SHA-256 fd191d..., expected 34efd7...) but it is a complete GGUF file, so Strata uses it as it is" plus a full 102 GB re-hash on every launch, because that path never writes a finish mark (a `:ro` model folder makes it worse; Control 0.2.10 keeps marks for read-only model folders outside the folder — b3c39091 — but the current 0.2.9-cuda13 image predates it). - And setup's `--ple-io ram` auto-decision silently flips on the swap: the Q8_0 table needs 136 + 54.4 + 16 = 206.4 GB MemTotal (inside this box's budget -> table pinned in RAM), the BF16 table needs 136 + 102.4 + 16 = 254.4 GB (above it -> streamed from NVMe), with no plan line saying the table changed residence. Reproduction / verification status, per CONTRIBUTING: the engine-reads-BF16 and installer-behavior claims above are **verified by reading the source at tag v0.2.9 and origin/main** (`src/kernels/ngram.cpp` `kPleFormats` + `ple_format_for_type`; `src/program/generate.cpp` PLE-shard discovery; `setup.py` `verify_sha256` own path, `check_shards` #657, `--ple-io ram` rule, `MODELS["Q8_0"]` pins; `docker/entrypoint.sh` `MODEL_PATH` -> `--model-path`). The runtime boot of this mix on my rig (docker `ghcr.io/niko1221/strata:0.2.9-cuda13`, engine 0.1.55, Linux, 4x RTX 3090 24 GB, 256 GB RAM, `Q8_0` + BF16 table, `CONTEXT=262144`, `KV=fp16`, `VISION=on`) is not run yet — I will attach the first-boot log and the exact setup warning lines to this issue when I do.
Author
Owner

@github-actions[bot] commented on GitHub (Nov 4, 2026):

Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

  • Fill in "Area".

Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

<!-- gh-comment-id:6641137641 --> @github-actions[bot] commented on GitHub (Nov 4, 2026): Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing: - [ ] Fill in "Area". Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment `/reopen`. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

@github-actions[bot] commented on GitHub (Nov 4, 2026):

Thanks, this follows the format now.

<!-- gh-comment-id:6641262928 --> @github-actions[bot] commented on GitHub (Nov 4, 2026): Thanks, this follows the format now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#3122
No description provided.