Repository navigation
Pack DeepSeek V4.1 Metal candidate masks - #1383
Draft
forest1040 wants to merge 1 commit into
Draft
forest1040 wants to merge 1 commit into
forest1040 wants to merge 1 commit into
Conversation
Use one bit per candidate block and copy packed carry rows directly. Preserve candidate IDs and logits on M3 Ultra while reducing the tracked Metal peak by 496 MiB at 128 Ki context and 2.42 GiB at 640 Ki allocated context.
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.
Pack DeepSeek V4.1 Metal candidate masks into one bit per candidate block. The bit order matches the existing compact carry format, and carry operations can copy packed mask rows directly. The Metal score filter and candidate-list builder accept the packed representation. CUDA and ROCm continue to use the existing dense representation.
This addresses remaining mask storage in ds4's prefill path. The related llama.cpp change removes other graph intermediates. ds4 already filters scores in place and reuses a 32-row score tile.
Measurements
Mac Studio M3 Ultra 512 GiB and
DeepSeek-V4.1-Flash-1017-IQ2_XXS-Q2_K-imatrix.gguf. The 128 Ki rows show the median of two runs on this branch with dense and packed masks. The 640 Ki row is one run per mode with a 32 Ki-token input. Memory is the static context-buffer plan reported byds4-bench. The model mmap and OS page cache are separate.For a direct comparison, unmodified upstream
b3f5018ran at 812.19 and 777.00 prefill tok/s, and 39.05 and 38.95 decode tok/s, at the two 128 Ki frontiers. Each frontier generates 16 tokens. The 64 Ki prefill figure measures the second 32 Ki tokens.Verification and reproduction