Repository navigation
Qwen3.6: opt-in int8 K/V cache and single staging buffer - #2742
ggeorgovassilis wants to merge 2 commits into
Conversation
Quantize the resident K/V cache of the Qwen3.6 path (src/qwen35/q36_engine.cu) from fp32 to q8_0 (32 int8 codes + one fp16 scale per block) when --kv int8 is passed; the default --kv fp32 path is byte-identical. Adds the quantize/ dequantize primitive (include/strata/kernels/q36_kv_q8.hpp, src/kernels/cuda/q36_kv_q8.cu) and a GPU parity test (src/kernels/q36_kv_q8_parity.cpp). Implements docs/Q36_INT8_KV.md. Measured on an RTX 4060 Max-Q Laptop 8GB / Ryzen 7 7735HS / 62GB with Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf (see docs/Q36_INT8_KV.md): - greedy decode is bit-for-bit identical to fp32 on short and long prompts; the 248,320-logit dump on the long prompt differs by at most 0.79. - the context window doubles: fp32 16,384 vs int8 32,768 (the 131,072 target is not reachable; the ceiling is dense weights + expert-streaming staging + the attention-score buffer, not K/V). - decode is ~4% slower at 4K (16.0 -> 15.4 tok/s); prefill unchanged. CUDA verified; the HIP build of the shared source is still to be run. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- STRATA_Q36_SINGLE_STAGE=1 halves the streamed-prompt staging VRAM (one buffer instead of two double-buffered) - STRATA_Q36_NO_MMQ=1 is now numeric (MMQ stays on by default) - STRATA_Q36_PLACE_DEBUG logs the staging allocation - shrink the attention-scores buffer (256 -> 64 MB) when the staging buffers only just miss, so placement still succeeds Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Thanks — but this overlaps almost entirely with an older PR, #2698 (TorBere, opened the evening before this one): the same Both heads are based on 10 conflict hunks, all in The overlap is semantic, not only textual — the two use different formats and different strategies:
The different group size means a different cache layout, so at most one of the two can land as-is. What in this PR does not overlap, and is independent of the K/V format: I'm happy to close this one and let #2698 carry the K/V cache, re-opening the staging/placement work as a PR of its own — or to keep this one and let #2698 close instead. @TorBere, which do you prefer? Whichever lands should probably keep the parity test and the design note from here: #2698 has neither, and its measurement is on a different card (RTX 3060 12 GB) from the 8 GB ceiling this one was written around. |
|
Thanks for the pull request. We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to review properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected. To reopen it takes about two minutes:
The rules are in CONTRIBUTING.md. |
Title
Qwen3.6: opt-in int8 K/V cache and single staging buffer
Summary
Two opt-in improvements to the Qwen3.6-35B-A3B own-engine path, both off by default so the default path stays byte-identical to the last release:
--kv int8— roughly 4x smaller K/V cache (~44 KiB/token fp32 -> ~11 KiB/token int8), so an 8 GB card doubles its context (16K -> 32K).STRATA_Q36_SINGLE_STAGE=1— halves the prompt-streaming staging VRAM (one buffer instead of two double-buffered).What changed
CMakeLists.txt— build wiring for the new q8_0 K/V kernels.include/strata/kernels/q36_kv_q8.hpp— new int8 K/V kernel interface.src/kernels/cuda/q36_kv_q8.cu— CUDA q8_0 K/V cache kernel.src/kernels/q36_kv_q8_parity.cpp— CPU reference kernel for parity testing.src/qwen35/q36_engine.cu— the--kv int8engine path;STRATA_Q36_SINGLE_STAGE=1(single staging buffer), numericSTRATA_Q36_NO_MMQ,STRATA_Q36_PLACE_DEBUG, and an attention-scores-buffer shrink (256 -> 64 MB) so staging placement still succeeds on tight VRAM.docs/Q36_INT8_KV.md— design note with the measured numbers.docs/DETAILS.md— links the new section into the table of contents.Extra Notes
--kv int8defaults to--kv fp32, which is byte-identical to the previous release.docs/Q36_INT8_KV.md.