Skip to content

Fix Laguna KV ring commits for oversized prefills#614

Open
christophsturm wants to merge 1 commit into
antirez:laguna-s2.1from
christophsturm:fix/laguna-prefill-kv-ring
Open

Fix Laguna KV ring commits for oversized prefills#614
christophsturm wants to merge 1 commit into
antirez:laguna-s2.1from
christophsturm:fix/laguna-prefill-kv-ring

Conversation

@christophsturm

Copy link
Copy Markdown

Laguna prefill attention stages all KV rows before committing them to its 512-row sliding-window ring. When a chunk exceeds that capacity, the existing kernel dispatches every token and races multiple writers onto each ring row, so older rows can survive and corrupt subsequent decoding.

Commit only the newest cache-capacity rows, cover a 1024-token prefill with a bit-exact Metal regression test, and bump the checkpoint payload ABI because earlier Laguna checkpoints may persist raced ring contents.

Tested on an Apple M4 Max with the Metal backend and Poolside Laguna S 2.1 Q4_K_M: make clean && make; ./ds4_test --metal-kernels; and ./ds4_test --server. The regression test reported 30,912 key and 30,464 value mismatches on the old kernel and zero mismatches with this fix.

Laguna prefill attention stages all KV rows before committing them to its 512-row sliding-window ring. When a chunk exceeds that capacity, the existing kernel dispatches every token and races multiple writers onto each ring row, so older rows can survive and corrupt subsequent decoding.

Commit only the newest cache-capacity rows, cover a 1024-token prefill with a bit-exact Metal regression test, and bump the checkpoint payload ABI because earlier Laguna checkpoints may persist raced ring contents.

Tested on an Apple M4 Max with the Metal backend and Poolside Laguna S 2.1 Q4_K_M: make clean && make; ./ds4_test --metal-kernels; and ./ds4_test --server. The regression test reported 30,912 key and 30,464 value mismatches on the old kernel and zero mismatches with this fix.
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