So I'm trying to write PyTorch code that performs the single-head computation, so you get some input vectors, attention mechanism/linear transformations, some output vectors.
Then I tried to re-use the same matrices by splitting them up into submatrices and get the same output vectors by using a 2-head attention approach. If I'm not mistaken, you should be able to just concatenate the outputs together.
The dimensions were correct, so output of single head and output of multi-head had the same dimensions, making me believe that multi-head is just better for performance reasons but not really different if we talk about input and output.
However, the output values were not the same despite both using the same matrix.
Is multi-head now inherently different from single head or how can I have an example compute the exact same input and output using single head and multi-head? I thought it should be possible if you re-use the same matrices but I was wrong...