Skip to content

slimAttn: conditioning, not invertibility, and the V-cache direction - #28

Open
Kayvan-Zahiri wants to merge 1 commit into
OpenMachine-ai:mainfrom
Kayvan-Zahiri:docs/conditioning-and-v-cache
Open

slimAttn: conditioning, not invertibility, and the V-cache direction#28
Kayvan-Zahiri wants to merge 1 commit into
OpenMachine-ai:mainfrom
Kayvan-Zahiri:docs/conditioning-and-v-cache

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown
Contributor

The paper says V-from-K needs W_K invertible, and that a zero determinant is
unlikely. True, but that isn't what decides whether the inverse is usable.
large-v3's cross-attention has cond(W_K) median 1.4e7, max 5.2e9. The
determinant is nowhere near zero and reconstructing V from K in every layer
still loses the model at fp32, relative logit error 0.54.

So this adds the other direction: cache V, get K back through
W_VK = inv(W_V) W_K. There cond(W_V) tops out at 4.5e6 and the error drops to
0.0059. Which direction is better varies by layer, and the split moves with model
size: 3 of 4 in tiny, 9 of 12 in small, 21 of 24 in medium, 31 of 32 in large-v3.

The V bias has to come off first. On Whisper, skipping it is wrong by over 100%,
so the equation carries the subtraction.

I avoided numbering these. Option 1 and 2 already mean multiplication order in
eq 7, and K-cache vs X-cache in table 5. Went with K-cache and V-cache. Renumber
if you want.

Numbers from slimAttn_whisper.py. Builds clean with tectonic, 18 pages, no new
warnings or overfull boxes.

The text says reconstructing V from K needs W_K invertible, and that a
determinant of exactly 0 is unlikely. Both hold, but invertibility is not
what separates a usable inverse from an unusable one. In large-v3's
decoder cross-attention cond(W_K) has a median of 1.4e7 and reaches
5.2e9, with a determinant nowhere near zero, and reconstructing V from K
in every layer loses the model at fp32: relative logit error 0.54.

Adds the mirror direction, caching V and reconstructing K through
W_VK = inv(W_V) W_K, which halves the cache the same way. cond(W_V) peaks
at 4.5e6 there, three orders lower, and caching V takes the error from
0.54 to 0.0059.

Notes the V-projection bias explicitly. On Whisper, K = V W_VK without
subtracting b_V is wrong by more than 100%, so the equation carries the
subtraction and points at the appendix's bias removal.

Which direction wins is per layer, and the mix moves with model size:
V-cache is better in 3 of 4 layers in tiny, 9 of 12 in small, 21 of 24 in
medium, 31 of 32 in large-v3. That is the argument for deciding per layer
rather than per model.

States the limit of the criterion: cond * eps is 619 for the K-cache and
0.53 for the V-cache at fp32 while the per-layer choice measures 5.9e-3,
so conditioning orders the choice but overstates the error.

Called K-cache and V-cache rather than numbered: Option 1 and Option 2
already mean multiplication order in eq 7 and, separately, K-cache vs
X-cache in table 5.
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.

1 participant