Primer

Volume IV · 04 · Composition

04 · Maps

Composition

Do A then B is BA, not AB. Order matters. That is why H then X is not X then H, and why layer order in a transformer is a real choice.

In English

Do A then B is not do B then A. Put on socks then shoes. Matrices are the same: BA means A first. That is why swapping two layers in a network (or two gates) changes the result.

Try this
Apply two maps. Swap their order. The landing arrow should move.
Keep this
Order matters. BA means A first.

Lab · order is data

BA = [[0, -2], [0.5, 0]]

vBAv

Matrix multiplication is function composition. BA means A first. There is no reason BA should equal AB, and in this lab it does not.

Circuits, transformer blocks, agent graphs: all composition. The algebra is why “swap two layers” is not a free rewrite.