[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

Closed
opened 2026-11-04 01:50:40 +07:00 by bsakaguchi · 6 comments
Owner

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 int8 in 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:

  1. Precision shape. int8 codes with an fp16 scale per 64 values put a fixed step on a heavy-tailed distribution — the outliers that matter most for attention scores are exactly what the clip and the uniform step hurt. E4M3's floating mantissa spends resolution where the values are, and llama.cpp's f8_0 KV community experience is that it beats int8 at equal 1 B/value on outlier-heavy models.
  2. The hardware is already in the build. The engine ships an FP4-MMA unit for sm_120a (strata_mmq_w4a4), so the card's narrow-float tensor path is not a new dependency the way it was for Arc.
  3. Honest note on the earlier rejection. docs/A770_SPEED_SPEC.md lists 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 fp8 and post the numbers.

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 int8` in 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: 1. **Precision shape.** int8 codes with an fp16 scale per 64 values put a fixed step on a heavy-tailed distribution — the outliers that matter most for attention scores are exactly what the clip and the uniform step hurt. E4M3's floating mantissa spends resolution where the values are, and llama.cpp's `f8_0` KV community experience is that it beats int8 at equal 1 B/value on outlier-heavy models. 2. **The hardware is already in the build.** The engine ships an FP4-MMA unit for sm_120a (`strata_mmq_w4a4`), so the card's narrow-float tensor path is not a new dependency the way it was for Arc. 3. **Honest note on the earlier rejection.** `docs/A770_SPEED_SPEC.md` lists 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 fp8` and post the numbers.
Author
Owner

@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:

  • Add the Strata version (Settings > About, or 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

<!-- gh-comment-id:6283413235 --> @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: - [ ] Add the Strata version (Settings > About, or `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](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

@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 fp8 and post them (KL, decode and prefill tok/s, and --kv-resident hit rate), we will use them to decide. Which Strata version are you on?

<!-- gh-comment-id:6308096118 --> @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 fp8` and post them (KL, decode and prefill tok/s, and `--kv-resident` hit rate), we will use them to decide. Which Strata version are you on?
Author
Owner

@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.

<!-- gh-comment-id:6337187763 --> @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.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 22, 2026):

Thanks, this follows the format now.

<!-- gh-comment-id:6346105328 --> @github-actions[bot] commented on GitHub (Oct 22, 2026): Thanks, this follows the format now.
Author
Owner

@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 65536 in production.

We built the opt-in --kv fp8 and 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:

  • quantize: scale = f16(amax/448), code = __nv_cvt_float_to_fp8(x/scale, SATFINITE, E4M3) (hardware cvt on sm_120)
  • dequantize: all 256 E4M3 codes are exact in FP16, so one 512 B table turns a code into its half image wherever the int8 path casts a byte — decode attention, the int8 prompt kernels, the split-decode kernel, the gather. The s8-IMMA kernel is gated off for fp8 (integer tensor cores have no E4M3 meaning).
  • snapshots/conversation cache: kKvFp8 = 4 gets 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 (cmp on 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)

set positions int8 top-1 / KL / KL p99 fp8 top-1 / KL / KL p99 PPL (ref)
official v1 (5×1000) 4,995 95.56% / 0.0208 / 0.239 63.08% / 0.889 / 6.88 int8 3.965 / fp8 8.53 (ref 3.970)
long docs (3×16K real Chinese tender docs, OCR text) 47,997 91.66% / 0.0617 / 0.824 38.66% / 2.054 / 7.37 int8 10.30 / fp8 35.86 (ref 9.375)

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)

case arm prefill tok/s (med) decode tok/s (med, all reps) MTP draft accepted KV-resident hit rate (med)
short (~0.6K) int8 610 192.9 (189.5/192.9/215.2) 82% 90.9%
short fp8 751 117.3 (105.6/117.3/117.7) 58% 92.9%
medium (~10K) int8 2,645 198.5 (181.2/198.5/199.3) 74% 90.9%
medium fp8 2,625 134.4 (142.3/126.4/134.4) 70% 92.9%
long (~150K) int8 3,958 176.2 (165.1/176.2/176.8) 79% 90.9%
long fp8 3,947 115.6 (112.5/115.6/120.7) 65% 92.9%

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 fp8 for 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/k8v4 remain 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.

<!-- gh-comment-id:6350365038 --> @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 65536` in production. We built the opt-in `--kv fp8` and 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: - quantize: `scale = f16(amax/448)`, code = `__nv_cvt_float_to_fp8(x/scale, SATFINITE, E4M3)` (hardware cvt on sm_120) - dequantize: all 256 E4M3 codes are **exact in FP16**, so one 512 B table turns a code into its half image wherever the int8 path casts a byte — decode attention, the int8 prompt kernels, the split-decode kernel, the gather. The s8-IMMA kernel is gated off for fp8 (integer tensor cores have no E4M3 meaning). - snapshots/conversation cache: `kKvFp8 = 4` gets 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 (`cmp` on 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) | set | positions | int8 top-1 / KL / KL p99 | fp8 top-1 / KL / KL p99 | PPL (ref) | |---|---|---|---|---| | official v1 (5×1000) | 4,995 | 95.56% / 0.0208 / 0.239 | 63.08% / **0.889** / 6.88 | int8 3.965 / fp8 8.53 (ref 3.970) | | long docs (3×16K real Chinese tender docs, OCR text) | 47,997 | 91.66% / 0.0617 / 0.824 | 38.66% / **2.054** / 7.37 | int8 10.30 / fp8 35.86 (ref 9.375) | 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) | case | arm | prefill tok/s (med) | decode tok/s (med, all reps) | MTP draft accepted | KV-resident hit rate (med) | |---|---|---|---|---|---| | short (~0.6K) | int8 | 610 | **192.9** (189.5/192.9/215.2) | 82% | 90.9% | | short | fp8 | 751 | **117.3** (105.6/117.3/117.7) | 58% | 92.9% | | medium (~10K) | int8 | 2,645 | **198.5** (181.2/198.5/199.3) | 74% | 90.9% | | medium | fp8 | 2,625 | **134.4** (142.3/126.4/134.4) | 70% | 92.9% | | long (~150K) | int8 | 3,958 | **176.2** (165.1/176.2/176.8) | 79% | 90.9% | | long | fp8 | 3,947 | **115.6** (112.5/115.6/120.7) | 65% | 92.9% | 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 fp8` for 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`/`k8v4` remain 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.
Author
Owner

@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.

<!-- gh-comment-id:6424516084 --> @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.
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#1362
No description provided.