Lab · QKV swaps and rewiring

Rewiring trained transformers

Twelve open-weight models, changed at inference with no retraining. First, one pair of query, key and value vectors is exchanged inside attention, in all layers, the first half or the last half. Then, with attention left alone, each layer runs its MLP before its attention, or the layers run in a different order. We read what the models generate, their next-token distributions and, for the swaps, the residual stream layer by layer.

What the residual stream shows

    Every model, every swap

    Measure

    Each model reads the same 8 wikitext articles (first 512 tokens each), teacher-forced, so every condition sees identical input and every number compares the same positions. The first position is left out. Darker cells are larger values, whatever the measure.

    One model, layer by layer

    Model
    Measure

    Layer 0 is the token embedding; layer n is the residual stream after decoder layer n. The shaded band marks the layers whose attention is swapped. Hover a chart to read values.

    What the swapped model predicts most often

    Next-token predictions, token by token

    Swapped