Skip to content

test(kv): measure KL by context depth; INT4 depth-stable, KIVI degrades (#69) - #76

Merged
geisten merged 1 commit into
mainfrom
test/long-context-kld-69
Jul 5, 2026
Merged

test(kv): measure KL by context depth; INT4 depth-stable, KIVI degrades (#69)#76
geisten merged 1 commit into
mainfrom
test/long-context-kld-69

Conversation

@geisten

@geisten geisten commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Closes #69.

Follow-up from #65: quality was measured only at a fixed length. bench_kv_quality's score_mode now splits mean KL(fp32||mode) at the sequence midpoint (early vs late positions), so 'near-lossless' can be checked as context grows. A longer document via argv[2] drives the full long-context run.

Result (BitNet-2b4t, 314 tokens, early = first ~156, late = last ~157):

mode KL early KL late trend
INT8 0.00190 0.00204 flat
INT4 0.01357 0.01194 flat
INT4+ROT 0.01042 0.00681 improves with depth
INT2 1.596 1.674 flat-ish
KIVI 0.12033 0.40269 3.3× worse with depth

Two findings:

  1. INT4 / INT4+ROT do not degrade with context depth — late KL ≤ early KL. Rotation is per-position independent and INT4 quant is per-token, so there's no error accumulation. Confirms the near-lossless claim holds as context grows.
  2. KIVI degrades markedly with depth (0.12 → 0.40): its per-channel 2-bit drain accumulates error across the 128-token groups. So the packed-INT4+ROT advantage over KIVI widens with context.

Caveat: this is a 314-token midpoint split, not a multi-thousand-token run — enough to show the trend (the KIVI drain fires ~token 128, so its depth-dependence is already visible), and the tooling now supports the full run via argv[2].

🤖 Generated with Claude Code

score_mode now reports mean KL(fp32||mode) separately for the first vs
second half of positions, so 'near-lossless' can be checked as context
grows. Rotation is per-position independent and INT4 quant is per-token,
so quality should be depth-independent — this makes it measurable. A
longer document via argv[2] drives the full long-context check.
@geisten
geisten merged commit 4fb98a3 into main Jul 5, 2026
6 checks passed
@geisten
geisten deleted the test/long-context-kld-69 branch July 5, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Verify long-context quality (KLD) for INT4 / rotation

1 participant