Add relation-aware graph transformer signals#674
Draft
yliu2-sc wants to merge 2 commits into
Draft
Conversation
zfan3-sc
reviewed
Jun 17, 2026
| self-attention path. ``"edge_type_bilinear"`` adds a learned | ||
| per-edge-type bilinear term for sampled directed graph edges. This | ||
| changes attention weights, not value/message content. | ||
| relation_value_mode: Optional relation-aware value augmentation strategy. |
Collaborator
There was a problem hiding this comment.
Discussed offline that we can leave relation_value_mode out of this PR.
zfan3-sc
approved these changes
Jun 18, 2026
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.
Scope of work done
This PR adds opt-in relation-aware attention logits to the GiGL Graph Transformer without enabling the graph-edge hard attention mask path.
relation_attention_mode="edge_type_bilinear"toGraphTransformerEncoderLayer.(num_relations, num_heads, head_dim, head_dim).(batch_idx, query_pos, key_pos, relation_idx)coordinates.source -> targetinto attention coordinates asquery=target,key=source.heterodata_to_graph_transformer_input.GraphTransformerEncoderfrom sortededge_type_to_feat_dim_map.Explicitly out of scope:
Implementation notes
Default behavior remains unchanged unless
relation_attention_mode="edge_type_bilinear"is configured.Relation-aware logits initialize to zero, preserving baseline outputs at initialization.
Sparse relation coordinates are built before relation identity is lost in
to_homogeneous().The main attention path still uses PyTorch SDPA. This PR only adds sparse relation logit bias before SDPA.
Where is the documentation for this feature?: N/A for this draft. I can add docs/changelog notes once we settle the final public interface names.
Did you add automated tests or write a test plan?
Added unit coverage in:
tests/unit/nn/graph_transformer_test.pytests/unit/transforms/graph_transformer_test.pyLocal checks run:
python3 -m py_compile gigl/nn/graph_transformer.py gigl/transforms/graph_transformer.py tests/unit/nn/graph_transformer_test.py tests/unit/transforms/graph_transformer_test.py.venv/bin/ruff check --fix --config pyproject.toml gigl/nn/graph_transformer.py gigl/transforms/graph_transformer.py tests/unit/nn/graph_transformer_test.py tests/unit/transforms/graph_transformer_test.py.venv/bin/ruff format --config pyproject.toml gigl/nn/graph_transformer.py gigl/transforms/graph_transformer.py tests/unit/nn/graph_transformer_test.py tests/unit/transforms/graph_transformer_test.pygit diff --check