llm-layer-distillation

I trained a Hyena convolution to copy one attention module in Qwen, then swapped it into the model to see what changed.

Qwen2.5-7B / one attention module

Qwen's 28 decoder blocks in a closed tower, with block 3 selected.Qwen's 28 decoder blocks in a closed tower, with block 3 selected.
Block inputInput RMS normAttentionOriginal modulePost-attention
RMS norm
MLPBlock outputResidual bypassesQwen · 28 blocks3InputFinal norm + readout
Drag to turn
Original QwenWith fitted Hyena

Qwen · 28 decoder blocks

How I trained it

I first saved the inputs and outputs of Qwen’s attention module. Qwen stayed frozen. Hyena learned from those pairs, with mean squared error measuring how far its output was from Qwen’s.

Saved attention input u trains Hyena to produce â. Saved Qwen target a and Hyena output â are compared with mean squared error. Feedback updates Hyena only. Outputs are captured before residual addition.

I trained on an AMD Instinct MI300X, with Qwen loaded in BF16. The run used 512 Wikipedia sequences: 358 for training, 77 for validation, and 77 for testing.

What did it learn?

Here are two saved test examples. Pick an example, then click a cell or move the controls to compare the same value in both outputs. The difference view shows where they disagree.

Saved test example: Qwen attention output, original Hyena output, and their difference.Left to right: token position. Top to bottom: channel. Blue is negative; red is positive. Qwen and Hyena share a scale; the difference has its own scale.

Both examples are from the test split. These saved outputs use the original checkpoint, before tuning.

Full replacement evaluation

Matching attention outputs is only part of the test. I put Hyena back into Qwen and checked next-token loss on the same 77 test sequences. Lower loss means the model assigns more probability to the correct next token.

Added next-token loss over Qwen: original Hyena +0.001409; tuned Hyena +0.000785.
The original replacement added 0.001409 to Qwen’s loss. After tuning, that fell to 0.000785. Both values are above unmodified Qwen.

Another 400 training steps reduced the added loss by 44.31%. The tuned model’s loss was 2.055492, compared with 2.054707 for unmodified Qwen. This check covered 12,521 next-token predictions, with the cache disabled.

Training and tuning curves
Original training and validation error over 3,200 optimizer steps.
Validation error selected the checkpoint at step 3,200.
Validation error during three tuning attempts at different learning rates.
All three attempts started from the same weights. Validation picked the run at 0.03× the original learning rates. Its test MSE was 4.79% lower.
Activation baselines
Original Hyena checkpoint beats zero-output and training-mean activation baselines.
Original checkpoint test MSE: Hyena 0.004062, zero output 0.008281, training mean 0.007078.