Skip to content

Track: Track2; Team name: TopoCoop; Model: Cellular Transformer - #371

Open
magoflaco wants to merge 6 commits into
geometric-intelligence:mainfrom
magoflaco:track2-ct-topocoop
Open

Track: Track2; Team name: TopoCoop; Model: Cellular Transformer#371
magoflaco wants to merge 6 commits into
geometric-intelligence:mainfrom
magoflaco:track2-ct-topocoop

Conversation

@magoflaco

@magoflaco magoflaco commented Jul 7, 2026

Copy link
Copy Markdown

Model

This PR implements the Cellular Transformer (CT) as a Track 2 (TNN) backbone for the TDL Challenge 2026.

Rubén Ballester, Pablo Hernández-García, Mathilde Papillon, Claudio Battiloro, Nina Miolane, Tolga Birdal, Carles Casacuberta, Sergio Escalera, Mustafa Hajij.
Attending to Topological Spaces: The Cellular Transformer. 2024.
Paper: https://arxiv.org/abs/2405.14094

The Cellular Transformer generalizes transformers to cell complexes: cells of ranks 0/1/2 exchange information through pairwise cellular attention (Eq. (2)) restricted to the neighborhood structure of the complex — upper adjacency within rank 0, lower adjacencies within ranks 1–2, and non-signed incidences across adjacent ranks (Eq. (3), Section 4.2.1) — with prenorm transformer layers (Appendix A) and topological positional encodings combined via ConcatPE (Eq. (4)).

There is no public reference implementation of this paper; the architecture was implemented from the paper's equations. All docstrings reference the specific equations/sections they implement.

What is included

Component Path
Backbone (attention, layers, RWPe, preprocessing) topobench/nn/backbones/cell/cellular_transformer.py
Wrapper topobench/nn/wrappers/cell/cellular_transformer_wrapper.py
Config, CT(𝒜ˢ, RWPe) variant (default) configs/model/cell/cellular_transformer.yaml
Config, CT(𝒜ˢ, zero) ablation variant configs/model/cell/cellular_transformer_zero_pe.yaml
Unit tests (100% line coverage of both new modules) test/nn/backbones/cell/test_cellular_transformer.py
Pipeline test test/pipeline/test_pipeline.py
Evaluation results (official notebook output) 2026_tdl_challenge/results.json

Implementation notes (modifications allowed to respect TopoBench computational requirements):

  • The sparse pairwise attention variant 𝒜ˢ is implemented (attention restricted to neighboring cells, realized as masked softmax over the support of the neighborhood matrices). The dense variants attend over all cell pairs and are not tractable under TopoBench's block-diagonal batching of complexes; sparsity also keeps attention correctly block-diagonal across batched samples.
  • Positional encodings: the local RWPe (Appendix C.1) computed per rank from the within-rank neighborhood matrices, plus the zero-PE ablation baseline (Table 2). The global encodings (BSPe/RWBSPe) require barycentric subdivision preprocessing and are left as future work.
  • Input encoding and pooling/readout are delegated to TopoBench's AllCellFeatureEncoder and standard readout (global add pooling over rank-0 signals, matching the paper's experimental setup).

Evaluation

2026_tdl_challenge/run_evaluation.ipynb was run on a Kaggle P100 GPU with MODEL_CONFIG = "cell/cellular_transformer" (72 runs: 12 grid settings × 3 seeds × 2 tasks, full OOD evaluation, graphs lifted to cell complexes via the cycle lifting; 6.9 h wall time; 465,883 parameters, ≈5.0 s/epoch). The generated results.json is committed.

Highlights: community-detection accuracy averages 0.64 under high homophily and 0.28 under severe heterophily (20 classes). On triangle counting — the task probing higher-order structure — the CT reaches a mean MSE/triangles of 0.51, roughly half of what we measured for a strong Track 1 GNN baseline (Co-GNN, 0.93) under the identical pipeline: direct evidence that rank-2 cells give the model explicit access to the cycle structure the task asks about.

Note on the notebook integrity check: current main ships a stale expected_hash that fails on a clean clone (#330). Only the expected_hash cell (above the # UNIQUE_HASH_MARKER, i.e. in the user-editable region) was updated to the SHA-256 of the untouched protected cells; all cells from the marker onward are byte-identical to main.

Tests

  • test/nn/backbones/cell/test_cellular_transformer.py: 11 tests covering the backbone (both PE variants, empty rank-2 complexes, gradient flow through all attention routes, masked-attention semantics, RWPe correctness on a known graph, row normalization, invalid-argument handling); 100% line coverage of both new modules.
  • test/pipeline/test_pipeline.py: end-to-end training on graph/MUTAG of the upstream models plus both CT variants (with graph→cell cycle lifting).

Result figures

In-distribution test performance across the 12 GraphUniverse grid settings (mean ± std over 3 seeds):

Community detection (accuracy):

Community detection accuracy heatmap

Triangle counting (MSE / total triangles):

Triangle counting MSE heatmap

OOD delta plots (OOD − in-distribution), by training homophily level

OOD low homophily, community detection
OOD mid homophily, community detection
OOD high homophily, community detection
OOD low homophily, triangle counting
OOD mid homophily, triangle counting
OOD high homophily, triangle counting

magoflaco and others added 3 commits July 5, 2026 18:26
Implements the Cellular Transformer (Ballester et al., 2024,
arXiv:2405.14094) as a cell-domain backbone with:
- Sparse pairwise cellular attention (Eq. (2)) over the neighborhood
  structure of the complex: rank-0 upper adjacency, rank-1/2 lower
  adjacencies and cross-rank incidences (Eq. (3), Section 4.2.1)
- Prenorm transformer layers with per-rank LayerNorm, residual
  aggregation over attention routes and feed-forward blocks (Appendix A)
- ConcatPE preprocessing (Eq. (4)) with random walk positional
  encodings (RWPe, Appendix C.1) and a zero-PE ablation variant
- CellularTransformerWrapper and Hydra configs for the CT(A^s, RWPe)
  and CT(A^s, zero) variants
- Unit tests with 100% coverage of the new modules and pipeline test

No public reference implementation exists; the architecture is
implemented from the paper equations. Dense attention variants are
omitted as they do not scale under block-diagonal batching
(modification allowed to respect computational requirements).

Co-authored-by: marcoschmmath <171987457+marcoschmmath@users.noreply.github.com>
Produced by 2026_tdl_challenge/run_evaluation.ipynb with
MODEL_CONFIG=cell/cellular_transformer on a Kaggle P100 GPU
(72 runs: 12 grid settings x 3 seeds x 2 tasks, full OOD evaluation,
graphs lifted to cell complexes via the cycle lifting; 8.9h wall time).

Co-authored-by: marcoschmmath <171987457+marcoschmmath@users.noreply.github.com>
- Document the ConcatPE interpretation (single joint projection per
  rank, vs SumPE) and the on-the-fly RWPe computation rationale
- Add invariance tests: masked-softmax normalization (attention output
  is a convex combination of value vectors) and block-diagonal
  batching equivalence (no cross-complex attention leakage)
- Drop an unnecessary tensor clone in the layer residual path
- Remove the unused pe_steps entry from the zero-PE variant config

Co-authored-by: marcoschmmath <171987457+marcoschmmath@users.noreply.github.com>
@cursor

cursor Bot commented Jul 7, 2026

Copy link
Copy Markdown

Bugbot is not enabled for this team, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@levtelyatnikov levtelyatnikov added the track-2-tnn 2026 Topological Deep Learning Challenge -- Track 2 TNNs label Jul 8, 2026
marcoschmmath and others added 3 commits July 17, 2026 14:45
…e matmuls

Issue: CellularTransformer.forward() called random_walk_pe() on every single
forward pass — every batch, every epoch — even though adjacency_0,
coadjacency_1 and coadjacency_2 are fixed per complex. Each call performs
pe_steps sequential sparse-sparse matrix products; by step 6–8 the
intermediates are near-dense, making this a major hot-path cost.

Fix: move RWPE computation into a one-time data transform
(CellRandomWalkPE) that runs during PreProcessor caching. The computed
tensors (rwpe_0, rwpe_1, rwpe_2) are attached to each Data object,
cached to disk by TopoBench's existing preprocessor, and batched
alongside the complexes. The backbone now reads them directly instead
of recomputing.

Changes:
1. New transform: topobench/transforms/data_manipulations/cell_random_walk_pe.py
2. Hydra config: configs/transforms/data_manipulations/cell_random_walk_pe.yaml
3. Register in experiment: configs/experiment/hopse_g_gnn_cell.yaml
4. Thread through wrapper: CellularTransformerWrapper extracts rwpe_* and
   passes them to the backbone
5. Read in backbone: CellularTransformer.forward uses precomputed PE when
   available, with an on-the-fly fallback for backward compatibility

Impact: RWPE is now computed once per graph (pre-training) instead of
once per batch per epoch. This is likely the single biggest wall-clock
win for the cellular transformer backbone.
Corrects the previous commit so the optimization actually takes effect
in the TopoBench pipeline:

- Move CellRandomWalkPE from transforms/feature_liftings/ to
  transforms/data_manipulations/ following the manipulation
  conventions (BaseTransform.forward, auto-registration in TRANSFORMS)
- Rewrite its config with the transform_name/transform_type schema
  consumed by DataTransform (the previous _target_-style config was
  never picked up by the pipeline)
- Wire the transform for this model via
  configs/transforms/model_defaults/cellular_transformer.yaml
  (lifting + manipulation, SANN pattern) so get_default_transform
  applies it automatically, including in the challenge evaluation;
  pe_steps stays in sync with the backbone via config interpolation
- Revert the unrelated configs/experiment/hopse_g_gnn_cell.yaml edit
  (out of scope for this PR and incompatible with the HOPSE backbone)
- Add tests: CellRandomWalkPE unit tests and a backbone equivalence
  test pinning precomputed == on-the-fly encodings (100% coverage of
  backbone, wrapper and transform)
- Apply repo formatting (ruff) and file hygiene fixes

Co-authored-by: marcoschmmath <171987457+marcoschmmath@users.noreply.github.com>
Re-run of 2026_tdl_challenge/run_evaluation.ipynb on a Kaggle P100
with MODEL_CONFIG=cell/cellular_transformer at the current pipeline
(CellRandomWalkPE precompute transform active). Scientific metrics are
statistically identical to the previous run (max per-run accuracy
delta 0.004, GPU nondeterminism); computational-complexity metrics now
reflect the shipped code: 5.0 s/epoch mean (was 7.9), 6.86 h total
(was 8.93 h), 465,883 parameters.

Co-authored-by: marcoschmmath <171987457+marcoschmmath@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

track-2-tnn 2026 Topological Deep Learning Challenge -- Track 2 TNNs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants