Repository navigation
metal : optimize Gated DeltaNet prefill with 8-lane SIMD subgroups - #33645
Open
semenishinDmitry wants to merge 1 commit into
Open
semenishinDmitry wants to merge 1 commit into
semenishinDmitry wants to merge 1 commit into
Conversation
Assisted-by: Codex
6 tasks
This branch has not been deployed
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
Add an eight-lane SIMD specialization for FP32 Metal Gated DeltaNet prefill. Each 32-lane SIMD group processes four independent state rows, reducing GPU time on Apple M5.
Additional information
The specialization handles 128-wide state rows with a scalar gate, one sequence, one state snapshot, and no replay. It requires aligned vector accesses, a 32-lane pipeline, and a physical GDN sequence length of at least 128 tokens. Other inputs use the existing Metal kernel.
oMLX documents the eight-lane mapping. Issue #30287 describes a related four-lane GGML implementation on M5 Max. oMLX kernel · #30287
Benchmarks and validation
Compared with upstream
59b716523f1ba73be12a9f0f51eb4c072b7fa523on Apple M5. Ranges show the median speedup in each of two paired sessions.On Qwen3.5-0.8B Q4_K_M with a 2,048-token prompt and microbatch size 512, median TTFT went from 455.6 to 421.1 ms.
llama-benchprefill throughput improved by 3.6% and 12.1% in the two sessions. All 30 paired greedy continuations matched. Decode throughput varied across sessions.The candidate passed 101/101 Metal GDN tests against the CPU reference. Pipeline logs confirmed the eight-lane kernel ran in the fused GDN+CPY case at 129 tokens. Perplexity over 5,100 evaluated tokens was 8.1056 ± 0.32792 on upstream and 8.1056 ± 0.32791 on the candidate.
Debug and Release CTest each passed 24/24. Unfiltered backend CI aborted on a Metal Flash Attention assertion for a 257-entry K/V row list, reproduced on both clean upstream and the candidate. With the two affected fixtures excluded, Metal passed 21,638/21,638 backend cases.
Requirements
Written with Codex