[GH-ISSUE #729] KV int8 vs fp16 KLD compare at 240K context #331

Closed
opened 2026-11-04 01:42:02 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @jerry78424 on GitHub (Oct 4, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/729

The 2026-09-27 bench stopped at 8K and reported "int8 is indistinguishable from fp16".

Two questions were left open:

  1. Does that hold at long context?
  2. "Indistinguishable" was measured teacher-forced. Does it survive free generation, where each arm's
    own tokens feed its own KV and a single flipped near-tie makes the two texts diverge?

Setup

  • IQ3_S on an RTX 5090 32 GB / 192 GB RAM, engine 0.1.34 and re-run on 0.1.38 (results are bit-identical
    between the two versions on this path - the update did not change numerics here).
  • One 240,000-token document (15 repo docs + 6 large source files); 16 prefixes at 15K..240K.
  • Arms differ only in --kv fp16 vs --kv int8; fixed expert set (--expert-cache 7000 budget,
    --adapt-swaps 0), --prefill 8192, --kv-resident 0, --max-context 262144.
  • Measurement hygiene: each arm runs with fresh loaded model instance.

Method (native packs constrain the probe)

Native IQ packs leave the per-token --dump-logits loop before the dump site (--prefill 0 is refused;
69de404 made the empty file honest), so there is no per-position logit series. What exists instead:

  • Teacher-forced probe: STRATA_DUMP_FIRST_LOGITS - one full-vocab (248,320 f32) row at the last prompt
    position, i.e. the next-token distribution after attending over the entire batched-prefill KV.
    Verified byte-identical across reruns (temp-0 greedy, --spec 4 lossless).
  • Fork probe: the same arm with --max-new 32 --temperature 0 (generate mode defaults to temperature
    1.0 - pin it); the engine prints the generated token ids; the two arms' 32-token sequences are compared
    for the first differing token. Same prefill cost, so this is nearly free.

Distribution: no growth with depth, heavy tail at near-ties

Depth KL(int8‖fp16) JS Same top-1 Fork token (of 32)
15K 0.00026 5.5e-05 yes 22
30K 0.0018 3.0e-04 yes 19
45K 1.13 0.190 no 0
60K 0.00002 6e-06 yes 8
75K 0.0087 2.2e-03 yes 6
90K 0.00008 2.1e-05 yes 15
105K 0.00015 4.4e-05 yes 8
120K 0.00092 2.0e-04 yes 15
135K 0.047 8.5e-03 yes 4
150K 0.0005 9.8e-05 yes identical
165K 0.36 0.074 yes 20
180K 0.0019 4.4e-04 yes 6
195K 0.00007 1.6e-05 yes 3
210K 0.00005 1.4e-05 yes identical
225K 0.00006 1.8e-05 yes identical
240K 0.43 0.061 yes 10
  • Median KL ~1e-3 and no growth with depth: several 195K-240K points sit at ~6e-5, below the 8K mean
    of 0.114. The sqrt(d) averaging of K/V quantization noise holds out to 240K.
  • The three large points are high-entropy positions, not deep ones (45K flips the top-1 between two
    near-tied tokens; 165K has both arms at NLL > 10). Same heavy-tail shape as the 8K bench.

Free generation: the texts fork quickly anyway

13 of 16 depths fork within 32 greedy tokens (indices 0,3,4,6,6,8,8,10,15,15,19,20,22; median ~8);
3 identical (150K, 210K, 225K). The sharpest point: 195K forks at token 3 with a teacher-forced KL of
7e-5
- the average distribution is nearly untouched, yet along the generated path some step always has
a top-2 gap smaller than the int8 noise (a few percent flip probability per token).

What this does and does not say

  • Supported: int8 KV's per-step distribution shift is tiny and does not accumulate with context;
    aggregate quality (the 8K perplexity numbers) is unaffected. int8 staying the default is right.
  • Not supported: "the output is the same as fp16". At 240K scale a greedy continuation from the same
    prompt diverges within a handful of tokens at most positions. That is expected at near-ties (fp16 itself
    is a coin flip there).
  • Not measured: whether the diverged continuations are quality-equivalent (task-level eval, e.g. a
    needle bench at 240K, is the missing piece; the 9-27 needles only showed retrieval survives q4_0).

Limitations

One model (IQ3_S), one corpus, 16 points, one teacher-forced row per arm.
Fork indices bound the near-tie flip rate coarsely (n=32 steps per depth). Prompts were fed as raw token
ids (--tokens-file), so no chat template (jinja) was applied - the arms continue a raw token stream
with no template markers anywhere in the corpus, and the ChatML markers the model emitted in its outputs
are fully learned behavior, not echoes of the input. The degenerate outputs observed on both sides (an
endoftext repeat loop at 135K on the fp16 arm, a stray tool-call end at 75K) are partly artifacts of that
un-templated state and do not imply real-serving degeneracy. The probe needs
STRATA_DUMP_FIRST_LOGITS (a debug env hook); a first-class per-position dump path for native packs
would make this exact experiment much cheaper to repeat.

Originally created by @jerry78424 on GitHub (Oct 4, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/729 The [2026-09-27 bench](https://github.com/Niko1221/Strata/blob/main/bench/results/2026-09-27-kv-q4/README.md) stopped at 8K and reported "int8 is indistinguishable from fp16". Two questions were left open: 1. Does that hold at long context? 2. "Indistinguishable" was measured teacher-forced. Does it survive **free generation**, where each arm's own tokens feed its own KV and a single flipped near-tie makes the two texts diverge? ## Setup - IQ3_S on an RTX 5090 32 GB / 192 GB RAM, engine 0.1.34 and re-run on 0.1.38 (results are **bit-identical** between the two versions on this path - the update did not change numerics here). - One 240,000-token document (15 repo docs + 6 large source files); 16 prefixes at 15K..240K. - Arms differ only in `--kv fp16` vs `--kv int8`; fixed expert set (`--expert-cache 7000` budget, `--adapt-swaps 0`), `--prefill 8192`, `--kv-resident 0`, `--max-context 262144`. - Measurement hygiene: each arm runs with fresh loaded model instance. ## Method (native packs constrain the probe) Native IQ packs leave the per-token `--dump-logits` loop before the dump site (`--prefill 0` is refused; 69de404 made the empty file honest), so there is no per-position logit series. What exists instead: - **Teacher-forced probe**: `STRATA_DUMP_FIRST_LOGITS` - one full-vocab (248,320 f32) row at the last prompt position, i.e. the next-token distribution after attending over the entire batched-prefill KV. Verified byte-identical across reruns (temp-0 greedy, `--spec 4` lossless). - **Fork probe**: the same arm with `--max-new 32 --temperature 0` (generate mode defaults to temperature 1.0 - pin it); the engine prints the generated token ids; the two arms' 32-token sequences are compared for the first differing token. Same prefill cost, so this is nearly free. ## Distribution: no growth with depth, heavy tail at near-ties | Depth | KL(int8‖fp16) | JS | Same top-1 | Fork token (of 32) | |---:|---:|---:|---|---:| | 15K | 0.00026 | 5.5e-05 | yes | 22 | | 30K | 0.0018 | 3.0e-04 | yes | 19 | | 45K | **1.13** | 0.190 | **no** | 0 | | 60K | 0.00002 | 6e-06 | yes | 8 | | 75K | 0.0087 | 2.2e-03 | yes | 6 | | 90K | 0.00008 | 2.1e-05 | yes | 15 | | 105K | 0.00015 | 4.4e-05 | yes | 8 | | 120K | 0.00092 | 2.0e-04 | yes | 15 | | 135K | 0.047 | 8.5e-03 | yes | 4 | | 150K | 0.0005 | 9.8e-05 | yes | identical | | 165K | **0.36** | 0.074 | yes | 20 | | 180K | 0.0019 | 4.4e-04 | yes | 6 | | 195K | 0.00007 | 1.6e-05 | yes | 3 | | 210K | 0.00005 | 1.4e-05 | yes | identical | | 225K | 0.00006 | 1.8e-05 | yes | identical | | 240K | **0.43** | 0.061 | yes | 10 | - Median KL ~1e-3 and **no growth with depth**: several 195K-240K points sit at ~6e-5, below the 8K mean of 0.114. The sqrt(d) averaging of K/V quantization noise holds out to 240K. - The three large points are high-entropy **positions**, not deep ones (45K flips the top-1 between two near-tied tokens; 165K has both arms at NLL > 10). Same heavy-tail shape as the 8K bench. ## Free generation: the texts fork quickly anyway **13 of 16 depths fork within 32 greedy tokens** (indices 0,3,4,6,6,8,8,10,15,15,19,20,22; median ~8); 3 identical (150K, 210K, 225K). The sharpest point: **195K forks at token 3 with a teacher-forced KL of 7e-5** - the average distribution is nearly untouched, yet along the generated path some step always has a top-2 gap smaller than the int8 noise (a few percent flip probability per token). ## What this does and does not say - **Supported**: int8 KV's per-step distribution shift is tiny and does not accumulate with context; aggregate quality (the 8K perplexity numbers) is unaffected. int8 staying the default is right. - **Not supported**: "the output is the same as fp16". At 240K scale a greedy continuation from the same prompt diverges within a handful of tokens at most positions. That is expected at near-ties (fp16 itself is a coin flip there). - **Not measured**: whether the diverged continuations are quality-equivalent (task-level eval, e.g. a needle bench at 240K, is the missing piece; the 9-27 needles only showed retrieval survives q4_0). ## Limitations One model (IQ3_S), one corpus, 16 points, one teacher-forced row per arm. Fork indices bound the near-tie flip rate coarsely (n=32 steps per depth). Prompts were fed as raw token ids (`--tokens-file`), so **no chat template (jinja) was applied** - the arms continue a raw token stream with no template markers anywhere in the corpus, and the ChatML markers the model emitted in its outputs are fully learned behavior, not echoes of the input. The degenerate outputs observed on both sides (an endoftext repeat loop at 135K on the fp16 arm, a stray tool-call end at 75K) are partly artifacts of that un-templated state and do not imply real-serving degeneracy. The probe needs `STRATA_DUMP_FIRST_LOGITS` (a debug env hook); a first-class per-position dump path for native packs would make this exact experiment much cheaper to repeat.
Author
Owner

@BlueKingMuch commented on GitHub (Oct 6, 2026):

Thanks, this matches what I measured on a 4080 SUPER (IQ3_S, 0.1.38), with the same precautions: --expert-cache 7000 for every format so the experts sit in the same place, and fp16 run twice as a baseline (223 of 223 distributions bit-identical). KL to fp16 at 223 positions of three texts (code up to 120K, English up to 32K, German up to 16K):

KV KL (nats) top-1 differs VRAM per 128K vs int8
int8 0.0054 3 of 223 –
k8v4 0.0150 6 of 223 −0.37 GiB
q4_0 0.0174 10 of 223 −0.78 GiB
  • No build-up with length here either: on code, q4_0 has 0.0076 at 8-32K and 0.0146 above 64K (int8 0.0022 and 0.0054), and the rank correlation of KL with position is about 0. Up to 120K it's a plateau, like your int8 result at 240K.
  • The means are carried by a few hard positions (on code the median is nearly 0), like your three outliers.
  • The top-1 flips sit at near-ties: wherever int8 flipped (3 positions), q4_0 flipped too.
  • Most of q4_0's error is V (57-100% per text), so k8v4 barely helps (0.86× the KL of q4_0) for 42% more memory.
  • In real text (NLL of the actual next token) none of the three is measurably different from fp16.

About your fork at token 3 at 195K with a KL of 7e-5: there's a floor below which the format doesn't matter. In a q4_0 run with all cells held exact (contexts short enough to fit into the exact window I was testing), the result was as far from fp16 as int8 (0.0071 vs 0.0066 nats): the same values read by a different kernel, i.e. in a different summation order, move the distribution that much. So greedy continuations of any path other than fp16 will fork at the first near-tie; how far the distributions are apart says more than whether they fork.

<!-- gh-comment-id:6018200907 --> @BlueKingMuch commented on GitHub (Oct 6, 2026): Thanks, this matches what I measured on a 4080 SUPER (IQ3_S, 0.1.38), with the same precautions: `--expert-cache 7000` for every format so the experts sit in the same place, and fp16 run twice as a baseline (223 of 223 distributions bit-identical). KL to fp16 at 223 positions of three texts (code up to 120K, English up to 32K, German up to 16K): | KV | KL (nats) | top-1 differs | VRAM per 128K vs int8 | |---|---:|---:|---:| | int8 | 0.0054 | 3 of 223 | – | | k8v4 | 0.0150 | 6 of 223 | −0.37 GiB | | q4_0 | 0.0174 | 10 of 223 | −0.78 GiB | - No build-up with length here either: on code, q4_0 has 0.0076 at 8-32K and 0.0146 above 64K (int8 0.0022 and 0.0054), and the rank correlation of KL with position is about 0. Up to 120K it's a plateau, like your int8 result at 240K. - The means are carried by a few hard positions (on code the median is nearly 0), like your three outliers. - The top-1 flips sit at near-ties: wherever int8 flipped (3 positions), q4_0 flipped too. - Most of q4_0's error is V (57-100% per text), so k8v4 barely helps (0.86× the KL of q4_0) for 42% more memory. - In real text (NLL of the actual next token) none of the three is measurably different from fp16. About your fork at token 3 at 195K with a KL of 7e-5: there's a floor below which the format doesn't matter. In a q4_0 run with all cells held exact (contexts short enough to fit into the exact window I was testing), the result was as far from fp16 as int8 (0.0071 vs 0.0066 nats): the same values read by a different kernel, i.e. in a different summation order, move the distribution that much. So greedy continuations of any path other than fp16 will fork at the first near-tie; how far the distributions are apart says more than whether they fork.
Author
Owner

@Niko1221 commented on GitHub (Oct 7, 2026):

Thank you, this KLD data for int8 against fp16 KV at 240K is useful, and the bit-identical result between 0.1.34 and 0.1.38 is good to know. Closing as a report; a bench PR with the same numbers is welcome.

<!-- gh-comment-id:6037763876 --> @Niko1221 commented on GitHub (Oct 7, 2026): Thank you, this KLD data for int8 against fp16 KV at 240K is useful, and the bit-identical result between 0.1.34 and 0.1.38 is good to know. Closing as a report; a bench PR with the same numbers is welcome.
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#331
No description provided.