Traversal-Invariant Positional Encoding for Serialized Graphs
Krish Mody ⋅ Sridhar Radhakrishnan ⋅ Chandra N Sekharan
Abstract
Graphs serialized for sequence Transformers admit multiple depth-first traversals, causing positional encodings to change even when the underlying graph is unchanged. We introduce TRACE (Tree+Cycle Positional Encoding), a drop-in method for graph-aware serializations preserving token-to-node alignment. TRACE combines DFS ancestor-path features with graph-derived cycle membership and canonical intra-ring positions. We show that DFS spanning trees are root-independent for acyclic graphs but may differ for cyclic graphs. Under consistent ring selection, the cycle component provides a traversal-independent anchor without guaranteeing invariance of the combined encoding. Across molecular re-rootings, TRACE achieves mean embedding cosine similarity of $0.977 \pm 0.029$ ($n=24{,}960$) and reduces fixed-checkpoint prediction-logit changes by $41.0\%$ relative to sinusoidal PE. On ZINC-12K regression, TRACE achieves test MAE of $0.359 \pm 0.007$ versus $0.596 \pm 0.021$ for sinusoidal PE (three seeds, trained from scratch). Under comparable pretraining, TRACE performs similarly to Graphormer on BBBP but trails it on BACE and Tox21. Synthetic structural tasks and substructure attribution provide complementary evidence of the utility of cycle-derived positional signals.
Successful Page Load