Adding metal kernels for the gated delta nets. - #4020
Open
tpegolotti wants to merge 56 commits into
Open
Conversation
tpegolotti
marked this pull request as draft
August 5, 2026 21:20
tpegolotti
force-pushed
the
gated-delta-update
branch
from
August 7, 2026 08:03
5810e68 to
8861d85
Compare
tpegolotti
marked this pull request as ready for review
August 7, 2026 11:20
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.
Adding kernel support for the Gated Delta Net rule. The math follows the ICLR paper: https://arxiv.org/abs/2412.06464.
Changes
Added three kernels for the forward gated delta rule:
Added benchmark and test scripts. The test script also compares against the naive FLA implementation of the gated delta rule using PyTorch ops.
Models Tested
Additionally to the tests added, I validated the kernels by running
mlx_lm.evaluate --model <model> --tasks wikitext --num-shots 5 --max-tokens 2048on the following modelsmlx-community/Qwen3.5-9B-MLX-4bit,mlx-community/Qwen3.5-35B-A3B-8bit, andmlx-community/Qwen3.5-27B-4bit. In the following table, I report the "word_perplexity" value.As expected, they all match.
Performance
I give micro benchmarks on M1 Max and M5 Max. These can be obtained by running
python benchmarks/python/gated_delta_bench.py.As well as full end to end prompt processing measurements over the 3 models used for validation on the M5 Max.

Future work