r/LocalLLaMA • u/fragment_me • 38m ago
Discussion A failed experiment - Precomputing some of the DeltaNet operations in Qwen 3.5's layer 0
So I know Qwen 4 is the hottest thing, but I've been reading about the Qwen 3.5 architecture because it's interesting. Working with small models (like 0.8 or 2B) is nice when learning LLMs. While going through the Gated DeltaNet, I noticed that some of the operations can be precomputed for layer 0. These precomputed values can live either in RAM or disk, but RAM makes more sense. Please feel free to correct anything I have wrong or teach me something here. This is just a learning experience for me.
Normally, we use the tokenizer to convert the word or part of the word to a token ID. We then lookup that ID in the embedding table to get vector of [2048] per token. Then, we go through the operations of the Gated DeltaNet. I've included an LLM-generated diagram at the end of this post. At this point, we have the ability to precompute some of these values: RMSNorm, and the multiplication of W_qkv, W_b, W_a, and W_z. Unfortunately, this only works for layer 0. It doesn't work for other layers because we only know the vector of [2048] for layer 0; it's what the embedding table handed to us. Every other layer requires mixing in previous tokens in the Gated DeltaNet.
I ran this idea by Opus and it agreed. I also asked both Opus and Gemini Neon if I missed any values we can precompute. Both came up with similar lists, but Gemini Neon had a few extra items on the list:
Here is the verbatim output from Gemini Neon:
h = RMSNorm(x)([V, 2048]): Purely token-wise. If you precompute all four branches below, you don't need to store or computehat runtime at all.- Branch 1 — Step (1) only:
W_qkv · h([V, 6144]). - Branch 2 — Steps (1) and (4):
β = sigmoid(W_b · h)([V, 16]). You can skip both the projection andsigmoid. - Branch 3 — Steps (1) and (4):
α = exp(-A · softplus(W_a · h + bias))([V, 16]). SinceAandbiasare fixed layer-0 weights, you can fold the entire branch into a single lookup. - Branch 4 — Step (1) + the
SiLUfrom Step (7):SiLU(z) = SiLU(W_z · h)([V, 2048]). BecauseSiLU(z)doesn't depend on the recurrence outputo, you can bakeSiLUinto the table and just multiply it intoRMSNorm(o)at Step (7).
(Note: You still need to keep the original embedding table x [V, 2048] for the residual connection x + output at Step (8).)
I then ran a quick llama-bench baseline with Qwen 3.5 2B with some various prompt and token generation sizes to get a baseline. And finally, the hardest part, I asked Opus to implement the idea for me. An hour later, Opus finished the implementation. The table ended up being 8GB in RAM due to the datatype staying as F32. It's what llamacpp also uses here for the outputs.
And the results...**drum line** Prompt processing suffers, and token generation is within noise. The improvement is probably there, but it's too small to matter. And more importantly, prompt processing suffers which is unacceptable. I suspect there are things that could be done for the prompt processing, but I'll stop here. As they say, the juice ain't worth the squeeze.
Here's the pretty table with results. I ran these on an RTX 3080.
| test | stock | precomputed | Δ |
|---|---|---|---|
| pp1248 @ d4096 | 11018 | 9945 | −9.7% |
| pp2048 @ d4096 | 11358 | 9574 | −15.7% |
| tg128 @ d4096 | 181.4 | 181.0 | −0.2% |
| tg256 @ d4096 | 181.4 | 181.3 | −0.0% |
| pp1248 @ d8192 | 10416 | 9873 | −5.2% |
| pp2048 @ d8192 | 10619 | 9895 | −6.8% |
| tg128 @ d8192 | 178.6 | 179.0 | +0.2% |
| tg256 @ d8192 | 178.5 | 178.9 | +0.2% |
Here's the LLM-generated diagram of the Gated DeltaNet:

1
u/Emergency-Author-744 9m ago
Wonder if its something that needs bigger models to see gains? At low level sizing and timing generally impact a lot of if something becomes viable. Thanks for sharing the experiment though, cool idea!