mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #586] [CLOSED] ple: read the PLE table at full BF16 precision (opt-in, alongside FP8) #2709
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2709
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/586
Author: @constantindjonkam
Created: 10/3/2026
Status: ❌ Closed
Base:
main← Head:pr/5-ple-bf16-optin📝 Commits (1)
36f829dple: read the n-gram table at full BF16 precision📊 Changes
9 files changed (+320 additions, -132 deletions)
View changed files
📝
CMakeLists.txt(+1 -1)📝
include/strata/artifact/gguf_reader.hpp(+1 -1)📝
include/strata/kernels/ngram.hpp(+17 -5)📝
src/kernels/ngram.cpp(+30 -5)📝
src/kernels/ple_fp8_parity.cpp(+1 -1)📝
src/ngram/ple_reader_test.cpp(+110 -0)📝
src/program/generate.cpp(+1 -1)📝
tools/ple_fp8_pack.py(+9 -118)➕
tools/ple_table_pack.py(+150 -0)📄 Description
What
Add a BF16 PLE table as an opt-in alternative to the FP8 one. This is an addition, not a
replacement: FP8 stays the default path, nothing about its behaviour changes, and the existing
tools/ple_fp8_pack.pyentry point keeps working.A bfloat16 is the top half of a float32, so widening one is a shift — exact for every value, normal or
not. The checkpoint ships the table in F8_E4M3 (2.66% off per row) and in BF16 (the source of record), so
this reads the source instead of an approximation of it. Disk is the price: 102 GB against 51 GB.
What it does not do
--ple-ggufis unchanged; a table that is not a BF16 one takesexactly the path it took before. The only edit outside the reader and the packer is a comment.
ple_fp8_pack.py. That file is kept as a shim over the renamedple_table_pack.py, because it is the only way to get a non-IQ4_NL table and command lines alreadyexist against it.
The measurement the previous review asked for
I built the FP8 table from
Qwen/Qwen3.8-Flash-Next-FP8with the tool inmain— 33 shards, 52.3 GB ofsafetensors, packed to 51.2 GB
f8_e4m3— and compared it against BF16 and against the IQ4_NL default.Teacher-forcing, decided from the dumps rather than from the text. Window row 0 is
P(next token | everything before pos), so two arms' rows at the same position are comparable only whileboth have emitted the same tokens. That is decidable without a reference transcript: walk the windows in
order and stop at the first position where the greedy argmax differs. Every earlier row provably saw an
identical context.
An earlier version of this harness tried to align on the generated text and was wrong in an instructive
way: the engine writes timing lines to stdout too, so it compared log lines, called a bit-identical
control arm divergent, and compared post-divergence rows at equal positions — producing a KL of 19, which
reports that two contexts differ, not that two tables are 19 nats apart.
Control first
8 prompts, 585 to 37K tokens,
--pcie-frac 0 --adapt-swaps 0so residency is fixed and the table is theonly variable:
The control is exactly zero at the median and the 95th percentile, with a single window out of 1701 above
it. So the BF16 row is a real difference — its median is about twice the control's worst window — and so
is IQ4_NL's, at roughly twice BF16's.
The number that matters for a table choice
Verify windows of identical greedy output before the first disagreement, and how many of the 8 prompts
produced byte-identical output:
FP8 and BF16 are not interchangeable. They disagree within about four verify windows — roughly 16
generated tokens — on every prompt tried. This is not a tail-logits curiosity; the table choice changes
the text.
And the practical result for a stock install: IQ4_NL is about twice as far from FP8 as BF16 is, in both
median and p95. Going IQ4_NL → FP8 recovers more than going FP8 → BF16 does.
What this does not show, stated plainly
Different is not better. This measures how far apart the tables are, not which answers are better:
BF16 is the checkpoint's exact values, so it is "more correct" only by construction, and nothing here is a
quality benchmark. A perplexity number against a labelled set would answer the actual question and is not
included. On the previous review's evidence — BF16-vs-FP8 median KL 0.00087 against a 0.00080 noise floor,
for twice the disk — FP8 remains the sensible default, and I am not claiming otherwise.
Two limits on the numbers themselves: the teacher-forced sample is small (30 and 53 windows) precisely
because the arms diverge early, so the p95 rests on few points; and one control window of 1701 differs
(0.00577), so the floor is not a hard zero.
Cost
None measurable. Same sweep, same card, 256 output tokens per cell, cold — IQ4_NL 90 B rows against BF16
320 B rows:
Within ±2.3% over a 25x range with the sign flipping. 16 rows/token is dwarfed by streaming 47 GB of
experts over PCIe.
The reader
BF16 rows are 320 B rather than 160, and widening assembles the little-endian bytes explicitly rather than
reinterpreting memory, so it does not depend on host endianness. No scale is read: the values carry
themselves. The direct reader already takes the table's own row size, so BF16 reads unbuffered like FP8
instead of falling back to the mapped path.
Tested in
ple_reader_test --selftestfor the patterns a lossy path breaks on — subnormals, ±inf, both NaNencodings — plus a synthetic BF16 GGUF round-tripping identically through Direct and Mmap. Both claims
were mutation-checked after the 0.1.38 rebase: widening by
>>instead of<<fails on the firstsubnormal, and a 160 B row width fails the round-trip.
Which to use
tools/ple_fp8_pack.py(orple_table_pack.py).approximation of them, and has the disk.
disk allows.
The table streams (
--ple-io direct, never resident; the row cache is ~90 MB at the default), so this isdisk and not RAM — but 51 GB or 102 GB has to exist.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.