Skip to content

Track: Track1; Team name: Kajolya; Model: GSN - #407

Open
lettlini wants to merge 40 commits into
geometric-intelligence:mainfrom
lettlini:track-1/GSN-WIP
Open

Track: Track1; Team name: Kajolya; Model: GSN#407
lettlini wants to merge 40 commits into
geometric-intelligence:mainfrom
lettlini:track-1/GSN-WIP

Conversation

@lettlini

@lettlini lettlini commented Jul 30, 2026

Copy link
Copy Markdown

Description

This submission implements Graph Substructure Networks (GSN) — a GIN + virtual-node
message-passing model whose node/edge features are augmented with structural encodings
that count how often each node and edge participates in the automorphism orbits of a
fixed collection of substructures (motifs).

What's implemented / changed:

  • GSNFeatureEncoder (topobench/nn/encoders/gsn_encoder.py) — the core structural
    encoder. For each substructure it computes node/edge automorphism orbits once (with a
    global, contiguous orbit numbering), then for an input graph counts every subgraph-
    isomorphic embedding per node/edge orbit and normalizes counts by the number of
    automorphisms. Includes robust PyG ⇄ NetworkX round-tripping, dtype/device consistency
    handling, and guards for edgeless/nodeless graphs.
    • Parallel annotation via joblib: subgraph-isomorphism matching is parallelized
      over substructures (n_jobs, default -1), since the NetworkX matching is the
      bottleneck. A unit test asserts the parallel result is identical to the serial one.
  • GSNEncodings pre-transform (topobench/transforms/data_manipulations/gsn_encodings.py)
    — a cached data-manipulation transform (subclassing GSNFeatureEncoder) that computes
    the encodings once during preprocessing rather than inside the training loop
    (see disclaimer below). The model-side forward is a passthrough; if encodings are
    missing it warns and recomputes on the fly as a fallback.
  • GSN backbone (topobench/nn/backbones/graph/gsn.py):
    • GSNGINVirtualNodeLayerV — a single GIN + virtual-node message-passing layer
      (node and edge modes; tolerates edge_attr when edge_dim == 0).
    • GSNGINVirtualNodeModel — stacks the layers, injects a per-graph virtual node and
      the additive GSN encodings at each layer, with BatchNorm + Dropout between layers.
    • mlp_builder helper.
  • GSNWrapper (topobench/nn/wrappers/graph/gsn_wrapper.py) — routes the
    precomputed gsn_embeddings (and correct tensors) from the batch into the backbone.
  • Configs: configs/model/graph/gsn.yaml, plus the transform configs
    configs/transforms/data_manipulations/gsn_encodings.yaml and
    configs/transforms/model_defaults/gsn.yaml (auto-attaches the pre-transform).
  • Tests: full unit-test suites for the encoder and the backbone, plus the model wired
    into the pipeline test; run_evaluation.ipynb updated to benchmark this model.

Disclaimer

This submission implements the GSNFeatureEncoder, but since the annotation of subgraph isomorphism counts is implemented in existing dependencies (i.e. networkx) the processing of graphs tends to be relatively slow making the repeated re-annotation inside the training loop unfeasible. For this reason, we chose to alter the data preprocessing since that is where the GSN encodings should ideally be calculated - they are static during model training and inference anyways. This might not be allowed according to the challenge's rules and invalidate this submission.

Checklist

  • My pull request has a clear and explanatory title.
  • My pull request passes the Linting test.
  • I added appropriate unit tests and I made sure the code passes all unit tests. (refer to comment below)
  • My PR follows PEP8 guidelines. (refer to comment below)
  • My code is properly documented, using numpy docs conventions, and I made sure the documentation renders properly.
  • I linked to issues and PRs that are relevant to this PR.

Kolya Lettl and others added 30 commits July 3, 2026 10:42
Edge layer now keeps real-edge messages and only scales self-loops by
(1+eps). Swap the UP-MLP builder for the shared helpers (fixes the
single-hidden-layer dim bug and drops the stray final ReLU), add an
edge/encoding alignment check, and fill in docstrings.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Edge layer can now take original edge features alongside the GSN edge
encodings (edge_dim, with a zero dummy block for self-loops), with guards
that edge_dim and edge_attr stay consistent and that node mode rejects
edge_dim>0. Also make initial_eps configurable, drop the dead V-layer
edge_attr branch, and refresh the docstrings.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Implements the GIN-with-virtual-node scheme (Eqs. 10/11) in GSN-v additive
form: per-layer h~ = h + G + W_V·x, pre-update virtual-node aggregation
G' = MLP(G + sum_u h~_u), and a shared d_embed dataflow. Node mode only.
Move the expensive GSN orbit-count encoding out of the training loop. The
`GSNFeatureEncoder.forward` previously recomputed subgraph-isomorphism counts
on every batch of every epoch, even though the encodings are a fixed function
of graph topology.

- Add a `GSNEncodings` data-manipulation transform (a thin subclass of
  `GSNFeatureEncoder`) that computes the encodings once per graph. Applied as a
  `pre_transform` by `PreProcessor`, results are cached to disk and reused
  across epochs and runs.
- Auto-attach it for `model=graph/gsn` via `transforms/model_defaults/gsn.yaml`.
- Make the model's feature encoder a pure passthrough: `forward` returns the
  batch when the encodings are already present and raises otherwise, rather than
  silently recomputing. The heavy path lives in `_encode`, driven by the
  transform. `substructures` is now optional so the passthrough needs none.
- Drop the substructure list from the model config; it lives only in the
  transform config now.
- Point the encoder unit tests at `_encode` and add coverage for the new
  passthrough / raise contract.
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@gbg141 gbg141 added the track-1-gnn 2026 Topological Deep Learning Challenge -- Track 1 GNNs label Jul 30, 2026
@lettlini

Copy link
Copy Markdown
Author

The remaining test failure is happening in SheafConnLapPE. This test also fails randomly on the main-branch in around 3% of cases.

@lettlini
lettlini marked this pull request as ready for review July 31, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

track-1-gnn 2026 Topological Deep Learning Challenge -- Track 1 GNNs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants