mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #1135] k8v4: deterministic token repetition on sequential generation (RTX 5090, 0.1.40) — byte-identical across two quants #475
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#475
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 @gravitomagnetic on GitHub (Oct 6, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1135
Follow-up to my field report in #711 (comment 6016065570) — filing as an issue so it can be tracked.
Setup: RTX 5090 32 GB, Strata 0.1.40 source build, Qwen3.8-Flash-Next MoE (12 QSA layers), 1M ctx YaRN×4,
--kv-resident 32768,--mtp --spec 4,--batch 2 --batch-mtp, vision on, driver 595.91.07, CUDA 13.4. A/B:--kv int8vs--kv k8v4, fresh engine start per leg, temperature 0,enable_thinking: false.Symptom: under k8v4, the decode probe "Count from 1 to 300, one number per line" repeats each integer:
Runs of four appear around 10–13. Deterministic at temp 0.
The sharpest clue: the corrupted output is byte-identical between IQ3_S and Q2_0 — two substrates sharing nothing about their weights (1.94 vs 1.32 MiB experts, different quantization). The only shared component is the k8v4 KV path, so the repetition is introduced by the value quantization/dequant itself, not by model weights or random distortion. That signature reads like a systematic grid/scale bias rather than inherent 4-bit noise — potentially fixable.
What is NOT affected: needle-in-haystack exact recall at ~200K tokens passes on both legs (keys stay INT8-exact, retrieval survives). Cold prefill is ~flat (−3%). Decode is actually +30–33% (98→130 IQ3_S, 151→197 Q2_0). So this is specifically short-range sequential generation — plausibly the recency signal in the value payload of the most recent cells ("what did I just emit").
Repro: the harness is in my last comment on #711; probes are cold-prefill / counting / needle. Single run per leg; the artifact reproduced identically in both quants' runs, so it is not a one-off.
Question for you: is this the expected distortion of rotated Q4_0 values at 32,768 resident cells, or worth a look at the dequant scale rounding? If expected, a line in the k8v4 docs ("avoid for enumeration/structured-output seats; retrieval unaffected") would help users choose.
Not tested yet: whether code, JSON, or other structured outputs show the same doubling.
@taxah92 commented on GitHub (Oct 6, 2026):
A second data point, from the opposite side of the kernel table: the artifact does not reproduce on Volta. This is also the Volta evidence the 0.1.40 release notes ask for ("we now have a P100 for sm_60, but not Volta").
Rig: Tesla V100 SXM2 16 GB (sm_70), CUDA 12.4 distro toolkit, Ubuntu 26.04, EPYC 7532, one GPU, no layer split. Stock
v0.1.40.1tree plus two local patches: a build guard for CUDA <12.5 invmm.cpp, and our copy of the k8v4 batch host-mirror fix from #1169 — neither touches the Q4_0 value dequant, and #1169 is a different failure (stale parked state, not repetition).Config: Qwen3.8-Flash-Next IQ3_S (same quant as your first lane),
--max-context 1048576 --rope-scaling yarn --rope-scale 4,--kv k8v4 --kv-resident 32768,--mtp --spec 3 --suffix-draft 3, no--batch, conversation parking on.Probe: "Count from 1 to 300, one number per line", temperature 0,
enable_thinking: false,max_tokens 900: counted 1..220+ clean, stopped by the token limit (finish=length), zero consecutive repeats, strict +1 sequence. Your artifact starts at the second number, so 220 clean numbers is a solid negative here.What differs from your box: sm_70 vs sm_120 (different k8v4 dequant/attention paths),
--spec 3vs 4, no batch slots, 1M YaRN vs ~200K. IQ3_S is the shared constant — consistent with your conclusion that the bias is in the value path, not the weights; it just seems not to reach argmax on the Volta kernels. Worth checking whether it is sm_120-specific or needs the spec-4/batch interaction.Caveat: same limitation as your report — only the counting probe was characterized here; code/JSON structured output under k8v4 on this rig is still under observation in real agent traffic.
@gravitomagnetic commented on GitHub (Oct 6, 2026):
Cross-referencing #1188: our box is a second sm_120 positive, and their isolation matrix explains the part we couldn't.
Our #1135 runs had
--kv-resident 32768active in every leg — so both broken rows here (IQ3_S, Q2_0, RTX 5090) sit in exactly the cell #1188 identifies as the trigger: k8v4 + streaming, not k8v4 alone. Their row 3 (k8v4,--kv-resident 0, byte-identical to int8) predicts something we can test on this box and hadn't considered: the same k8v4 decode speedup with no repetition, if the streaming path is the bug. And their q4_0-clean row kills my "4-bit value payload is inherently blurry" framing — the pointer/payload asymmetry story was the wrong axis; it's the streamed-V dequant on Blackwell kernels.Also adopting their extra symptom: short factual answers going verbose (16-32 tokens vs 6) — we only characterized the counting probe, and our needle recall passing at 200K matches their "needle: pass" rows exactly. Retrieval intact, generation degenerate, across both reports.
Plan on this 5090: run k8v4 with
--kv-resident 0(max-context lowered to fit) as a fourth leg — if clean, we confirm #1188's isolation on sm_120 hardware independently of their 5080, and the suspect narrows to the streamed k8v4 kernel path shared by both Blackwell cards, with @taxah92's clean Volta rows pinning it to sm_120 specifically. Will post the leg here.@gravitomagnetic commented on GitHub (Oct 6, 2026):
Follow-up as promised: ran the #1188 row-3 cross-check on this 5090 (sm_120) — k8v4 with
--kv-resident 0is clean. The bug tracks the streamed path, not the format.Leg config: IQ3_S,
--kv k8v4 --kv-resident 0 --max-context 262144 --rope-scale 1(YaRN dropped since 262K needs no scaling), same probes as our first table, greedy,enable_thinking:false:--kv-resident 0(now)1 2 2 3 3 4 4…degenerateRed, Blue, Green) — #1188's verbose-16-32 symptom absentSo on sm_120: k8v4 format alone = clean; k8v4 +
--kv-resident= the deterministic repetition from #1135/#1188. Combined with @taxah92's clean Volta rows (streaming ON, sm_70), the suspect is the streamed k8v4 dequant/attention path on Blackwell kernels specifically.One config consequence worth stating: the +30% decode we measured this morning was entangled with the buggy path. Turning streaming off fixes the repetition but costs ~1,400 expert slots (full KV at 262K lives in VRAM) and decode drops to 91 t/s — below int8+streamed (98). So today's honest ranking on a 32 GB sm_120 card at long context: int8 + streamed remains the best config; k8v4's speed win only exists in the configuration that's broken. If the streamed-k8v4 kernel bug gets fixed, 130 t/s + 22.8% less KV RAM becomes available and we flip immediately — happy to re-run this exact leg on any candidate build.
Raw JSON:
kv_nostream_k8v4_20261006_1236.json(lane: RTX 5090, driver 595.91.07, CUDA 13.4, 0.1.40 source build).@Niko1221 commented on GitHub (Oct 7, 2026):
Fixed in 0.1.40.2: same cause as #1188 (K8V4 with --kv-resident lost the cells the batched append wrote). Credit to Benjamin Larsson (PR #1264). Please retest.
@gravitomagnetic commented on GitHub (Oct 8, 2026):
Update from the 5090 reference machine: Benjamin's #1264 fix is in 0.1.40.2, and we've now re-run the k8v4 leg properly (interleaved protocol, 3 matched pairs, engine 0.1.41).
The fix verifies on sm_120: count-to-300 clean (zero repeats, 3/3), needle recall at 200K 3/3, no crash-loop.
But the perf case from our Oct 6 table was an artifact of the bug itself — the repeated tokens (
2 2 3 3 4 4…) were accepted by MTP speculation nearly for free, inflating the broken k8v4 leg. With the fix, on our config: decode ties int8 within noise (256-tok greedy 202.4/203.0/202.6 vs 201.8/200.5/199.8 tok/s), the 2.8 GiB pinned-RAM saving buys +146 expert slots (8310-8311 vs 8164-8165) which add nothing measurable at ~90% hit, and the streaming path costs a consistent ~3% on 200K prefill (59.8-59.9 s vs 57.9-58.1 s). int8 stays our daily KV.Full tables + protocol note (blocked runs drift ~30% by the last leg — interleave at small n) in bench PR #1592, folder
bench/results/2026-10-08-community-rtx5090-1m-agent-interleaved/.@dany4ok commented on GitHub (Nov 6, 2026):
Community benchmark: INT8 vs Q4_0 vs K8/V4 on Gyro-S / RTX 5070 Ti
Hardware: Windows 10, NVIDIA RTX 5070 Ti (16 GB VRAM), 32 GB RAM, Ryzen 7 7700X. Software/config: Strata engine 0.1.57, Qwen3.8-Flash-Next Gyro-S, one request at a time (
parallel=1), max context 131072,--spec 4,--kv-resident 32768, VRAM reserve 512 MiB. Tests were sequential realcodex exectasks, not synthetic API-only tests. Each variant ran for at least 60 seconds including load/benchmark; K8/V4 active benchmark was 122.34 s.K8/V4 included three real Codex tasks: short 15.85 s, read-only tool 46.33 s, and long generation 52.92 s, for 122.34 s active benchmark time.
Cache and prompt switching
Conclusions
K8/V4 provided the most expert-cache capacity and slightly higher raw decode, but 58 MiB free VRAM is too close to paging/instability on this 16 GB card. Q4_0 improved memory headroom but showed no clear real-client wall-time win. INT8 was selected and restored as the final stable configuration.
Codex returned exit code 0. Reproduction caveats: non-fatal missing-model-metadata fallback warning and non-fatal GitHub Copilot MCP authentication warning. This is a community benchmark; happy to rerun a tighter interleaved A/B protocol if useful.
@dany4ok commented on GitHub (Nov 6, 2026):
Additional benchmark context from the same session
These are earlier real-task measurements on the same RTX 5070 Ti / 32 GB RAM system. They are included as context for task switching and throughput, including the analysis of the apparent ~8-second delay.
One request vs two concurrent requests
Context, speculation and VRAM tests
Prompt size and queue effects
The apparent ~8-second delay
IDLE_S = 30seconds andMAX_WAIT_S = 300seconds. The apparent values around 8 seconds were the time needed by the preceding request to finish, not an artificial 8-second sleep.Guard and task-switch experiments
IDLE_S=30andMAX_WAIT_S=300.parallel=1; an isolated gate test measured request B waiting about 0.22 s behind a 0.25 s request A./api/native/operationsload API, avoiding an independent engine that the host could not see.Baseline and reproducibility details
--kv int8,--spec 4,--kv-resident 32768,--vram-reserve-mib 512, one request (parallel=1), no--batch 2, and no--batch-mtp.codex execsequentially with read-only sandbox tasks. The model metadata fallback warning and GitHub Copilot MCP authentication warning were non-fatal; benchmark tasks returned code 0.Takeaway
For this hardware, the largest practical gains came from keeping one active request, preserving/reusing the prompt prefix, avoiding unnecessary context growth, and preventing queue/paging pressure. Raw decode speed alone did not predict the end-to-end Codex task time.