metal: deepseek v4 optimize token generation - #1
Closed
tarruda wants to merge 2 commits into
Closed
Conversation
Reduce DeepSeek V4 decode overhead with fused compressor and mask operations, avoid redundant Lightning Indexer work, and bound long-context attention by gathering only selected compressed keys. - Add DSV4_COMPRESS and DSV4_TOP_K_MASK with CPU references and capability probes. - Skip Lightning Indexer and TOP_K when every compressed row is selected. - Reuse sparse packing for deep single-token decode with dense fallbacks. - Test fused compression, mask construction, and compact Flash Attention. Assisted-by: Codex
Fuse compressor and attention-mask construction on Metal and keep long-context decode bounded by gathering only selected compressed keys. - Add kernels for DSV4_COMPRESS and DSV4_TOP_K_MASK. - Skip K and V loads for fully masked vector Flash Attention groups. - Extend DSV4_SPARSE_PACK with a parallel compressed-only decode mode. - Preserve compact F16 masks without intermediate conversions. Assisted-by: Codex
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.
Overview
Picking a couple of commits from my branch which improve DSv4 token generation
Additional information
This builds on ggml-org#26512 and will improve token generation and keep it more stable as context grows. Here's
-d 0,10000,20000,30000 -n 128 -p 2048 -b 2048 -ub 2048on a M1 Ultra:Requirements