Skip to content

harden(kv): warn on silent rotation disable + document cache-shift constraint (#70, #71) - #75

Merged
geisten merged 1 commit into
mainfrom
harden/rotation-path-70-71
Jul 5, 2026
Merged

harden(kv): warn on silent rotation disable + document cache-shift constraint (#70, #71)#75
geisten merged 1 commit into
mainfrom
harden/rotation-path-70-71

Conversation

@geisten

@geisten geisten commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Two small robustness guards on the rotation / packed-INT4 path, from the #65 follow-ups.

#70 — when GEIST_KV_ROT (or the INT4 default) is active but a layer's head_dim is not a power of two (or > 512), the FWHT guard silently no-ops: packing/quant still run, so you get the unrotated (worse) cache with no signal. Now warns once at session creation, naming the head_dim. No currently-supported model (Gemma4 128/256/512, BitNet 128) triggers it — this is defensive for future unusual-head_dim archs. ponytail: note marks the geist_log_callback_t upgrade path (the arch layer has no log routing yet).

#71 — the rotation and packed INT4 store K post-RoPE and rotated; this is only correct because geist never re-bases cached positions (sliding window masks, doesn't re-RoPE). A future KV context-shift would silently corrupt the cache unless it un-rotates/unpacks before re-RoPE-ing. Documented atop kv_store.c and in ARCHITECTURE.md (llama.cpp#21038 had to add explicit cache-shift support for the same reason).

Closes #70, closes #71. No behavior change on supported models (verified: no spurious warning, generation unchanged).

🤖 Generated with Claude Code

…straint (#70, #71)

#70: when KV rotation is requested but a layer's head_dim is not a power of
two (<=512), the FWHT guard silently no-ops and you get the unrotated cache
with no signal. Warn once at session creation naming the head_dim. (No
currently-supported model triggers it; defensive for unusual-head_dim archs.)

#71: rotation + packed INT4 store K post-RoPE and rotated, safe only because
geist never re-bases cached positions. Document the constraint atop
kv_store.c and in ARCHITECTURE.md so a future KV context-shift feature does
not silently corrupt the cache (it must un-rotate/unpack before re-RoPE-ing).
@geisten
geisten merged commit 69d002e into main Jul 5, 2026
6 checks passed
@geisten
geisten deleted the harden/rotation-path-70-71 branch July 5, 2026 13:04
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.

Guard/document rotation + packed-INT4 vs future KV cache-shift Warn when rotation is silently disabled (non-pow2 head_dim)

1 participant