Experimental alpha. Expect breaking changes and major bugs. Your
feedback is much appreciated.
Transformer Block

One whole transformer layer in one machine: normalize, attend, add back; normalize, feed forward, add back. Stack them to make a GPT.

Shapes
A sequence [B×T×C] in, the same shape out.
Settings
- Heads: 1, 2, 4 or 8. 4 by default.
- Expand: 1, 2 or 4. 4 by default.
- Function: ReLU, GELU or SiLU. GELU by default.
Parameters
12 × C² + 9 × C with Expand at 4: about 50,000 at width 64.
In PyTorch
self.block1 = Block(C, heads=4, hidden=4 * C, act=gelu_tanh)x = self.block1(x)
Notes
Its picture shows the attention pattern of its first head, like the Attention Head's.
Making it
The Fabricator makes it from a photomask of Transformer Block: verify the spec on a Bench, or find a salvaged mask in the ruins, which makes it unfused. See The Bench and the Fabricator.

Residual