Md. Asif Uddin
    I.14.X08

    Message passing with an edge list

    shape▲△△

    Store the paw graph as an edge index: a 2×E2\times E array whose columns are (source, target) pairs. How large is EE for message passing in both directions, and with self-loops? Implement Ax\mat A\vec x for x=(1,2,3,4)\vec x=(1,2,3,4) as a gather followed by a scatter-add, and give the shape of each intermediate.

    Hint

    An undirected edge sends messages both ways, so it is stored twice.

    Solution

    The paw has 44 undirected edges. Stored in both directions they give E=8E=8 columns; adding one self-loop per node gives 1212.

    The gather reads the source of each column: with features of width dd it produces an E×dE\times d array of messages, here 8×18\times1. The scatter-add sends each message to its target and sums by target, producing n×dn\times d, here 4×14\times1. The result is (5,4,7,3)(5,4,7,3), the same as Ax\mat A\vec x in I.14.B01, and it never forms the 4×44\times4 matrix.

    Two details matter in practice. The scatter must add, not assign: node 33 has three incoming messages, and assignment would keep one of them, the mistake I.11.T2 warned against for overlapping windows. And the order of additions is not fixed on parallel hardware, so results can differ in the last bits from run to run, though never in a way that depends on the labelling.

    Draws on