Repository navigation
CUDA: quantized GQA-3 dp4a+half2 banded decode & small-batch banded MMA for Inkling 2 - #407
danbunnell wants to merge 1 commit into
Conversation
GPU Verification Results (Linux x86_64, RTX 3090 24 GB
|
|
Thanks for this. I tested it on a B200 on top of our pin set (#399 tree, the published Mini GGUFs do not load on #386 alone), base = pin set, head = pin set plus this PR. Two correctness problems:
Numerics on the supported KV types: KLD 0.0021 to 0.0031 vs base at 8K and 32K with f16 and q8_0 KV (top-1 about 98%), exact at short contexts. PPL moves both ways, so it is rounding, but it is a change on every decode step past 4096 cells and there is no switch to turn it off. Speed (exclusive B200, 3 interleaved rounds, median):
The f16 small-batch case at 32K now runs So I would not pin this as is. A version that keeps the position consistent on every fallback path (or keeps the mask when the new kernel does not run), keeps the bias cap from producing more chunks than the graph can hold, adds test-backend-ops cases for the position input and padded KV, and has an env switch would be much easier to take. Note it also rewrites lines owned by #385 and #386, so it would have to land inside #386. |
…MA for Inkling 2 Builds on unslothai#386 (inkling2-attn-banded @ 06322ff) for quantized KV caches (Q8_0/Q4_0) at >= 4096 global context while leaving F16/BF16 KV and dense chunking limits untouched: - GQA-3 dp4a+half2 split-K single-token banded decode (fattn-banded.cu) with optional device q_pos (src[7]) so CUDA graphs stay valid across positions; also honored in CUDA scalar/split fallbacks and CPU reference (ops.cpp). - Quantized-KV-only routing for single-token banded decode (Q8_0/Q8_0, Q4_0/Q4_0, Q8_0/Q4_0) and small-batch banded MMA (2..32 tokens on >= 4K global caches), avoiding any F16/BF16 regression or dense kq_b spike. - O(1) amortized seq_contig_prefix() check for c0 == 0 sequences, with matching c0_zero predicate in llm_graph_input_mem_hybrid_iswa_rel::can_reuse(). - Preserves n_kq_bias_max = 1<<29 so multi-stream -kvu graphs do not exceed the node budget. - Adds GGML_CUDA_DISABLE_BANDED_DECODE=1 kill switch (bit-identical to base when set) and test-backend-ops cases for q_pos over padded KV (Q8_0, Q4_0, Q8_0/Q4_0, F16, BF16, Q5_1) and small-batch quantized banded MMA.
7e0186a to
888cc4e
Compare
|
Thanks for the detailed B200 review and catching every one of those issues. I've rebased onto
Verified zero-conflict merge + clean CUDA build on top of |
Summary
Builds on
#386(inkling2-attn-banded@06322ffb0) specifically for quantized KV caches (Q8_0/Q4_0) at>= 4096global context, leavingF16/BF16KV caches (handled by#413) and dense chunking limits (n_kq_bias_max = 1 << 29) completely untouched:dp4a + half2split-K banded decode (fattn-banded.cu):q_len == 1) with optional device-sideq_pos(src[7]viaggml_flash_attn_ext_banded_add_pos) so CUDA graphs stay valid across positions on paddedn_kv.src[7](q_pos) is now honored across every backend/fallback path: CUDAvec_gqa, CUDAf32_split&f32scalar fallbacks, and the CPU reference (ggml/src/ggml-cpu/ops.cpp), and validated inggml_cuda_flash_attn_ext_banded_supported+use_banded().inkling2.cpp, single-tokenbanded_decodeis gated strictly toQ8_0/Q8_0,Q4_0/Q4_0, andQ8_0/Q4_0global caches (c0 == 0,n_kv >= 4096), leavingF16andBF16KV untouched.2..32tokens on>= 4Kglobal KV):2..32-token batches on contiguous quantized global KV caches (>= 4096) to quantized banded MMA (min_q = 2), preventing multi-GiB densekq_bspikes on 24 GB GPUs at 256K/512K while leavingF16/BF16small batches (e.g., DSpark verify) untouched.n_kq_bias_max = 1 << 29and original chunk padding so multi-stream-kvugraphs never hit the node budget assertion.O(1)seq_contig_prefix()& exactcan_reuse()(llama-kv-cells.h,llama-kv-cache.cpp,llama-graph.cpp):O(1)check forc0 == 0sequences, with matchingc0_zeroandbanded_small_longchecks inllm_graph_input_mem_hybrid_iswa_rel::can_reuse()so sequences starting atc0 != 0keep graph reuse.GGML_CUDA_DISABLE_BANDED_DECODE=1disables both theinkling2.cpprouting and the CUDAvec_gqa/min_q = 2dispatch (bit-identical to base).test-backend-opscases forFLASH_ATTN_EXT_BANDED: deviceq_posover padded KV (mask == nullptr, tail pastq_posignored) forQ8_0,Q4_0,Q8_0/Q4_0,F16,BF16, andQ5_1, plusn_q = 2, 8quantized banded MMA atn_kv = 4096.Status
inkling2-attn-banded(06322ffb0), merges with zero conflicts ontob12635+#419(#411–#418), and compiles cleanly forsm_86(CUDA 13.3).test-backend-ops, KLD with kill switch on/off,bf16KV at 8K,-kvumulti-stream check, and#419vs#419 + #407benchmarks on RTX 3090) will be posted next.