mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #3352] [Engine] Feature request: FP8 (E4M3) KV storage (--kv fp8) — same 1 B/value as int8, better on heavy-tailed K/V, rides the FP4/FP8 tensor cores we already build for sm_120a #1362
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#1362
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?
Originally created by @dsj027-collab on GitHub (Oct 20, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3352
Strata version: engine 0.1.47 (v0.2.2 serve layer), CUDA build, RTX PRO 6000 (sm_120), NVFP4 Flash-Next pack,
--kv int8, yarn, batch 1. (strata --version->strata 0.1.47)The main path's KV menu today is
fp16 | int8 | q4_0 | k8v4(generate.cpp:2968). We run--kv int8in production (RTX PRO 6000, sm_120, NVFP4 Flash-Next pack, 768K yarn3) and it works well; the ask is an FP8 (E4M3) option between int8 and k8v4:f8_0KV community experience is that it beats int8 at equal 1 B/value on outlier-heavy models.strata_mmq_w4a4), so the card's narrow-float tensor path is not a new dependency the way it was for Arc.docs/A770_SPEED_SPEC.mdlists fp8 among the KV formats "non-transferable from Infernix ... recorded so they are not retried". We read that as Arc-specific (no FP8 MMA there, and the QSA streaming layout is int8-first). If the reasoning was general rather than Arc-specific, we'd like to know; if it was Arc-specific, then on NVIDIA an FP8 QSA cell is ~1,056 B (same as int8) with a better error profile, and k8v4-style hybrids (fp8 K + q4_0 V) could go below 816 B/cell.We can measure it: KL against fp16 KV on real long-document traffic (150K-600K prompts), decode/prefill tok/s, and the KV-streaming hit rate at
--kv-resident 65536, on sm_120 — same protocol as our w4a8/w4a4 A/B. Happy to run a build behind an opt-in--kv fp8and post the numbers.@github-actions[bot] commented on GitHub (Oct 20, 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:
strata --version).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
@Niko1221 commented on GitHub (Oct 21, 2026):
Thanks, this is a clear request and the offer to measure on sm_120 is the useful part. We have not started it: it needs a new KV format in the streaming layout, not only a flag. Before that we would want your KL numbers against fp16 on long documents. If you build an opt-in
--kv fp8and post them (KL, decode and prefill tok/s, and--kv-residenthit rate), we will use them to decide. Which Strata version are you on?@Niko1221 commented on GitHub (Oct 22, 2026):
Thanks — following up: which Strata version are you on, and can you post the KL numbers against fp16 on long documents, plus decode/prefill tok/s and the --kv-resident hit rate, from an opt-in build? That's the evidence we'd use to decide.
@github-actions[bot] commented on GitHub (Oct 22, 2026):
Thanks, this follows the format now.
@dsj027-collab commented on GitHub (Oct 22, 2026):
Version: engine 0.1.47 (v0.2.2 serve layer), CUDA build, RTX PRO 6000 (sm_120), NVFP4 Flash-Next pack, 786K yarn3, batch 2,
--kv int8 --kv-resident 65536in production.We built the opt-in
--kv fp8and measured it. Headline: the data argues against the feature for this model family — details below so you can decide with them.What we built
FP8 (E4M3) as int8's exact byte layout with different code meaning: 1 B code + one FP16 scale per 64 values, 1,056 B/cell — no new streaming geometry, the movers/snapshots/host copies are byte-identical paths. The only format-specific sites are EN/DEcode:
scale = f16(amax/448), code =__nv_cvt_float_to_fp8(x/scale, SATFINITE, E4M3)(hardware cvt on sm_120)kKvFp8 = 4gets its own format number — same size as int8, different meaning, so a parked cache never cross-restores silently.Two correctness gates before trusting any number: (1) the int8 arm on the patched engine is byte-for-byte identical to the release engine's (
cmpon the harness output); (2) the kernel's quant→dequant round trip matches an independent numpy E4M3 simulation bit-for-bit across the full grid. Both pass.KL vs fp16 (your
tools/quant_quality.py, experts pinned to CPU, fixed shape)fp8 is 33–43× worse than int8 against the same fp16 reference, and its error compounds with context length (int8 KL 0.021→0.062 from 1K to 16K; fp8 0.89→2.05).
Why the premise failed (micro-simulation, bit-identical to the kernel)
E4M3 has a 3-bit mantissa: ~3–6% relative step on every value. int8's amax/127 is a fixed absolute step that beats it whenever the within-group (64 values) dynamic range is modest. Sweeping distributions: uniform → E4M3 MSE is 42× worse; Student-t(3) → E4M3 50× better; Gaussian + 50σ sink spikes → 16× better. Qwen3.8's QSA K/V (post-RoPE) sits in the narrow-range regime — the heavy tails that motivated the request are per-channel and get absorbed by the per-group scale, so int8's clip never bites and its finer typical-value resolution wins. The measured 43× ratio matches the simulated 42×.
Speed (production shape: 786K yarn3, batch 2, --kv-resident 65536, MTP spec 4; fp8@8007 vs int8@8005, same binary, 3 interleaved reps, idle box, cached=0 verified)
Prefill is identical (same compute path — this build dequantizes E4M3 to the same FP16 attention kernels as int8 via an exact 256-entry LUT; the issue's "rides the FP8 tensor cores" argument would need a separate FP8-MMA attention kernel, which this build deliberately does not contain). Streaming hit rate is unchanged, as expected from the identical byte layout.
Decode is 30–40% SLOWER with fp8, and the mechanism is worth noting: the MTP drafter runs on the same quantized KV, so E4M3's coarser codes degrade the drafter's predictions and the acceptance rate drops from ~80% to ~58–70%. So fp8-as-int8-layout costs quality, costs throughput via speculative acceptance, and saves no memory.
Recommendation
Don't adopt
--kv fp8for this model family — at the same 1 B/value, int8 is strictly better on quality here, and the quality premise doesn't survive measurement. If you want KV below 1 B/value,q4_0/k8v4remain the tools. We're fine with closing #3352 on this data; the ~300-line opt-in diff (dormant unless--kv fp8, existing formats byte-identical) is available as a reference implementation if anyone ever wants to try FP8-MMA attention on top of it.@Niko1221 commented on GitHub (Oct 26, 2026):
Thank you for the careful measurements. Your data on FP8 KV storage shows it is worse than int8 on quality and decode speed, with no memory saved, so we are not planning to add it. Thanks for taking the time to test it.