Add per-edge-type value/message transform to Graph Transformer encoder#696
Draft
zfan3-sc wants to merge 1 commit into
Draft
Add per-edge-type value/message transform to Graph Transformer encoder#696zfan3-sc wants to merge 1 commit into
zfan3-sc wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional relation-aware message channel to
GraphTransformerEncoderLayer, run in parallel with self-attention, controlled by a newrelation_message_modeargument. This is the message-passing analog of HGT's per-relation value transform (v_rel) / per-edge-type GATv2 weights, applied sparsely over sampled graph edges.Three modes:
"none"(default): behavior identical to the existing layer."edge_type_linear": for every sampled directed edge, adds a per-edge-type linear transform of the source token, mean-aggregated per (target, relation), into the attention residual."edge_type_attention": replaces the mean with a per-head softmax over each target's relation neighbors, scored HGT-style from the layer's own query/key projections with per-(relation, head) transforms and priors.Key properties:
seq^2; never materializes an(seq, seq)tensor, so the scaled-dot-product attention path and its memory profile are unaffected.relation_attention_mode).Changes
gigl/nn/graph_transformer.py: newrelation_message_modearg, parameters, init/reset logic, and_compute_relation_messages/_compute_relation_attention_messages.tests/unit/nn/graph_transformer_test.py: coverage for zero-init parity, mean aggregation, uniform-score equivalence to mean mode, score concentration,num_relationsvalidation, and forward smoke tests.Test plan
pytest tests/unit/nn/graph_transformer_test.pyrelation_message_mode="none") are unaffected.Made with Cursor