[codex] Add Metal TurboQuant KV cache#124
Draft
Chedrian07 wants to merge 2 commits into
Draft
Conversation
added 2 commits
May 14, 2026 09:09
Add PolarQuant/WHT turbo3 and turbo4 KV cache storage, selected-row dequant for indexed attention, and live server verification/benchmark coverage.
Owner
|
Not sure what's the point of that. Turbo quants, especially in an already compressed KV cache that carries "more" signal per row, is going likely to have some degradation effect. And deepseek v4 KV cache is already compact. I don't believe TQ here is a good idea. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DS4_KV_TURBO=3andDS4_KV_TURBO=4) using PolarQuant/WHT packed rows instead of materialized FP8 compressed attention rows.DS4_METAL_DECODE_INDEXER_TOP_Kfor fast non-quality runs.Why
Long-context Metal sessions spend a large amount of memory on compressed KV rows. TurboQuant reduces that footprint while keeping decode on the sparse indexed attention path instead of expanding the whole compressed cache every token. The selected-row decode path keeps the default 512-row behavior for quality and lets experiments lower the decode top-k without changing the API.
Local results
M4 Max,
--ctx 384000, prompt 22204 tokens, decode 128 tokens:A deterministic needle-retrieval probe passed for Turbo4 top-k 512, 256, 128, and 64. One longer 44k-token sequential benchmark run hit a transient Metal GPU hang during Turbo4 prefill; repeated 22k-token Turbo4 runs and server cache validation passed.
Validation
make -B ds4.o ds4_metal.o ds4_server.o ds4_test.o ds4 ds4-server ds4_test./ds4_test --metal-kernels./ds4_test --serverDS4_VERIFY_COMPARE=0 DS4_VERIFY_CTX=8192 DS4_VERIFY_KV_DIR=/tmp/ds4-kv-turbo4-pr-smoke DS4_VERIFY_OUT_DIR=/tmp/ds4-turbo4-pr-smoke tests/verify_turbo_server.sh --primary 4 --no-compare --no-benchgit diff --check