What is the difference between permutation invariance and equivariance for a graph model?
answer
- does the output move or stay put
- graph-level answer versus per-node answer
- relabel the atoms, then compare
- one stays identical, one reorders
basics
~20 sPermutation invariance means relabelling the nodes leaves the output unchanged, which is what a single graph-level prediction requires. Equivariance means the output moves with the relabelling: per-node predictions keep their values but come back in the new node order.
solid answer
~50 sRenumbering a graph's nodes produces the same graph described differently, so behaviour under that renumbering is a design requirement. Write the relabelling as a permutation applied to the node feature matrix and applied consistently to the structure. A function is **invariant** if the output is unchanged afterwards, and **equivariant** if the output is the same values permuted the same way. The task fixes which you need: predicting one solubility number for a molecule must be invariant, since relabelling the atoms cannot change the molecule; predicting a partial charge for every atom must be equivariant, since each charge must stay with its atom. In practice message-passing layers are equivariant — each node's update uses its own features and an order-free combination of its neighbours — and a graph-level answer comes from pooling those node vectors with an order-free operation, which turns equivariance into invariance at the last step.
go deeper
Learn the two words and one example of each: a whole-graph prediction must not change when nodes are renumbered, while a per-node prediction must be reordered along with them.
Explain that the permutation is applied to the features and the structure together, and say where each property comes from: shared per-node weights plus order-free neighbour combination give equivariance, a final order-free pooling gives invariance.
Show you would verify it — a permutation test in the suite — and be able to argue down canonical sorting and relabelling augmentation as substitutes, naming ties, instability and the factorial size of the ordering space.
Own the call about when a symmetry should be built in versus learned, and when to break it deliberately for positional or temporal signal, accepting the sensitivity that introduces across the whole modelling stack.
## Why the question exists at all A graph carries no canonical node order. If you load the same molecule from two files and the atoms come out in a different sequence, you have one molecule and two descriptions. Every array-based encoding must pick *some* order to write rows in, so the encoding contains an arbitrary choice the graph itself does not contain. Invariance and equivariance are the two precise statements of "the model must not be fooled by that arbitrary choice". ## The two definitions Let a relabelling be a permutation that reorders the nodes. Applying it means reordering the rows of the node feature matrix and applying the *same* reordering to the structure — for an adjacency matrix, both its rows and its columns; for an edge list, rewriting every stored id through the new numbering. - **Invariant function.** The output is unchanged: `f(permuted graph) = f(graph)`. One number, one class label, one embedding of the whole graph. - **Equivariant function.** The output is permuted the same way: `f(permuted graph) = permute(f(graph))`. One row of output per node, still attached to the right node. Invariance is not a weaker or stronger form of equivariance applied carelessly; they answer different questions. Invariance is what you want when the output has no node index. Equivariance is what you want when it does. ## Which does your task need? Match the symmetry to the shape of the label. - **Graph-level label — invariance.** A single predicted solubility for a small molecule. Relabelling the atoms 1..N differently must return the identical number; if it does not, the model is reading the file order, and file order is not chemistry. - **Node-level label — equivariance.** A predicted partial charge for every atom. The set of charges must be unchanged, but each must travel with its atom. An "invariant" per-node output would be an outright bug: it would return the charges in the original positions after you had relabelled, silently attaching each prediction to the wrong atom. - **Pair-level label — equivariance over pairs.** A link score for the pair (i, j) must follow the pair through the relabelling. Aggregate a set of such scores into one count and you are back to an invariant quantity. ## How models are actually built The standard construction is a stack of equivariant layers followed by, when needed, one invariant step. Each layer transforms every node with the *same* shared weights — a per-node transform is automatically equivariant, since it never looks at the row index — and combines each node's neighbours with an operation that does not depend on the order the neighbours are listed in. Composing equivariant layers gives an equivariant network, so a node-level head can sit on top and inherit the property. For a graph-level answer, one order-free pooling over all node vectors collapses the per-node dimension. Because pooling ignores order, the composition is invariant. Note that invariance is obtained *last*: build the network equivariant and pool once, rather than trying to make each layer invariant, which would destroy per-node identity in the first layer and leave nothing to pass messages between. ## Two tempting non-solutions **Canonical ordering.** "Sort the nodes by degree, then any fixed-size model is fine." Ties are pervasive — a regular graph has every node at the same degree — so the sort is not well defined, and a tie-break by a secondary feature is unstable: a tiny change to one feature can reshuffle the whole encoding, so a model trained on it sees a discontinuity. Genuine graph canonicalisation is expensive and brittle for exactly the same reason. **Augmentation.** "Train on many random relabellings and the model learns invariance." It learns an approximation, at the cost of spending capacity and data on a symmetry that could have been built in for free, and a graph with N nodes has up to N factorial orderings — you cannot cover that space by sampling. ## Testing it The check is cheap and belongs in your test suite. Draw a random permutation, apply it to the node features **and** consistently to the edge list, run the model, and compare. For an invariant output the values must match within floating-point tolerance; for an equivariant output, apply the inverse permutation to the result and compare against the unpermuted run. Permuting the features while forgetting the edges is the classic broken test: it changes the graph, so a mismatch proves nothing. ## When you break invariance on purpose Sometimes you add information that is not permutation-symmetric — a positional or structural encoding, a designated root node, an ordering that genuinely exists in the data such as time. That is a legitimate design choice, but it must be a choice: you are declaring that the extra ordering is real signal, not an artefact of how the file was written.
- Which symmetry does a link-prediction score for a node pair need?Equivariance over pairs: the score belongs to the pair, so after relabelling it must appear at the relabelled pair with the same value. Only when you reduce many such scores to a single quantity — a count of predicted links, an average score for the whole graph — do you obtain something invariant.
- How would you write a test that your model is permutation invariant?Sample a random permutation, apply it to the node feature rows and rewrite every id in the edge list through the same mapping, then run the model twice and compare outputs within a floating-point tolerance. For a per-node head, undo the permutation on the output before comparing. Permuting features without the edges tests nothing.
- Why build equivariant layers and pool once at the end, rather than making every layer invariant?An invariant first layer would collapse the graph to a single vector immediately, leaving no per-node state for later layers to exchange. Equivariant layers keep one vector per node so information can travel along edges over several rounds; a single order-free pooling at the end converts the result to an invariant graph-level answer.
- When is deliberately breaking permutation invariance the right call?When an ordering is genuine signal rather than a file artefact — timestamps on an event graph, a designated root in a parse tree, or added structural encodings that help the model distinguish graphs it otherwise could not. Make it explicit: you are asserting the extra information is real, and you accept sensitivity to it.
Reshuffling a class roster does not change the class average — that is invariance. Each student's own grade still has to follow them to their new line on the list — that is equivariance.
saying these in an interview costs you the question
- Uses invariant and equivariant as interchangeable words
- Says per-node outputs should be unchanged by relabelling
- Claims sorting nodes by degree is a clean canonical fix
- Permutes node features but not the edges when testing
- Thinks invariance means throwing away node features
- Believes random-relabelling augmentation gives exact invariance