Track: Track1; Team name: howyadoin; Model: DSNN - #412
Open
dario-loi wants to merge 4 commits into
Open
Conversation
Introduces Directed Sheaf Neural Network support in TopoBench, including the new `dsnn` backbone, modular `dsnn_utils`, four graph model configs (`dsnn`, `dsnn_degree`, `dsnn_ortho`, `dsnn_general`), API docs wiring, and extensive theorem-driven unit tests. It also updates the pipeline smoke models to include DSNN variants and adds the TDL challenge notebook/media plus evaluation notebook defaulting to `graph/dsnn_degree` so direction-aware behavior can be exercised on undirected benchmark data.
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
test_encoder_treats_a_batch_as_a_disjoint_union[degree-general] failed on CI at atol=1e-5 while passing locally. The claim is about the operator being block diagonal across components, but the general family reaches block_inv_sqrt, whose eigh returns an arbitrary basis on a degenerate degree block. The reassembled matrix function is basis independent; the route to it is not, so the residual is LAPACK dependent (~1e-6 locally, ~1e-5 on CI) and straddled the float32 tolerance. Running the comparison in float64 drops the residual to ~1e-15 for all nine parametrizations, so atol=1e-9 leaves ~6 orders of headroom and the test measures block structure instead of a float32 error budget. Claude-Session: https://claude.ai/code/session_01SYfSJxn4fWBAt1YhmW8riB
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.
Track
Track 1 — Graph Neural Networks (GNNs)
Team Name
howyadoin
Model
Directed Sheaf Neural Network (DSNN)
Status
Ready for review
Summary
This PR contributes a TopoBench-native implementation of the Directed Sheaf$d$ -dimensional stalk to every node and edge, glue them with learned
Neural Network (DSNN) by Fiorini et al. (ICLR 2026). Sheaf Neural Networks
attach a
restriction maps, and diffuse features with $L^{\mathcal{F}} =
\delta^{\top}\delta$. That operator cannot see edge direction, because it is
invariant to the orientation chosen per edge.
DSNN removes that blindness with a single factor (Definition 1). The stalks
become complex, and one of each edge's two restriction maps picks up a
unit-modulus phase read off the binary adjacency,
The resulting directed sheaf Laplacian
$(\Re(X) \Vert \Im(X))$ .
$L^{\tilde{\mathcal{F}}} = \tilde{\delta}^{}\tilde{\delta}$ is complex
Hermitian and positive semidefinite (Thm 1); its normalization has spectrum in
$[0, 2]$ (Thm 2); and it specializes to the real sheaf Laplacian when the graph
is undirected (Thm 3), to the Magnetic Laplacian for a trivial sheaf and, at
$q = 1/4$, to the Sign-Magnetic Laplacian (Thm 4), which it factorizes as
$\hat{B}\hat{B}^{}$ (Thm 5). Features are diffused by Eq. 8 and read out as
The Thm 4 correspondence carries the scaling App. C hedges about, and the$\Gamma(u)$ $A_{s,uv} = 1/2$ . The factor vanishes on an
docstring and tests are explicit about it: on a digon-free digraph this
operator is twice the Magnetic Laplacian, since Eq. 3 sums over
while MagNet gives a one-way arc
all-digon graph, and on a mixed graph the operator equals the Magnetic
Laplacian built on the binary symmetrized adjacency.
Implementation
topobench/nn/backbones/graph/dsnn.py(DSNNEncoder), withthe operator split across seven modules under
dsnn_utils/:laplacian_builders.py(the Eq. 2-3 assembly and the Eq. 5normalization, one builder per restriction-map family),
phase.py(Definition 1's charge and the induced orientations),
laplace.py(support symmetrization and the edge pairing),
complex_ops.py(thereal lifting of Appendix D, the complex ReLU of §3, complex dropout and
unwind),discrete_models.py(the Eq. 8 diffusion stack),sheaf_models.py(the learnedorthogonal.py(theretraction).
carries all the arithmetic, so autograd, scatter/gather and reduced
precision behave conventionally and the sparse helpers, which document
no complex support, are used inside their contract.
benchmarks:
configs/model/graph/dsnn.yaml(Diag-DSNN),dsnn_ortho.yaml(O(d)-DSNN) anddsnn_general.yaml(Gen-DSNN), plusdsnn_degree.yamlfor the induced orientation described below. Everynon-obvious value carries the paper grid (App. F) it comes from; where a
grid leaves the choice free we take the value already in
configs/model/graph/nsd.yaml, so a DSNN-vs-NSD comparison isolates theoperator and nothing else.
Hermitian-ness and a real diagonal (Thm 1), PSD by both quadratic form
and spectrum (Thm 1),
bound attained and a negative control that breaks it (Thm 2), collapse
to the repo's existing NSD builder on undirected input (Thm 3), the
Magnetic and Sign-Magnetic Laplacians against independently written
references (Thm 4), the
Eq. 8 update against a dense complex reference using an explicit
equivariance, and an overfit check on a task only directions reveal.
223 tests in
test/nn/backbones/graph/test_dsnn.py.graph/dsnnandgraph/dsnn_degreeadded totest/pipeline/test_pipeline.py, so CI exercises both the real and thecomplex operator path end to end.
dsnnand all sevendsnn_utilsmodules(
docs/api/), mirroring the existingnsd/nsd_utilslayout.(12 settings
graph/dsnn_degree; the auto-generatedresults.jsonis included.run_evaluation.ipynbdiffers frommainin exactly one cell,MODEL_CONFIG, and the guard hash in cell 6 still matchesexpected_hash.The undirected-benchmark problem, and what we did about it
Every graph dataset in TopoBench, and every graph GraphUniverse generates, is$A = A^{\top}$ , so
undirected. On undirected input
for every$q$ . This is Theorem 3, and it is exact rather than approximate: the
operator is bitwise identical across the whole charge grid, its imaginary part
is identically zero, and DSNN reduces to real Neural Sheaf Diffusion. Run as
provided, the model's headline contribution is unreachable and the
qentry inits config does nothing.
2026_tdl_challenge/dsnn_directionality.ipynbestablishes three things aboutthat regime:
The claim is measured, not asserted. In float64 the deviation across the$10^{-16}$ but exactly zero, for all three families; the
charge grid is not
operator also equals the real sheaf Laplacian that TopoBench's own NSD port
builds from the same restriction maps. We additionally census GraphUniverse
and confirm every generated graph is undirected.
The paper's Figure 2 is reproduced at its exact scale. On the directed$n = 2500$ , $C = 5$ ), where node$q = 0$ , which Theorem 3 makes
stochastic block model of Appendix E (
features are in-degree plus out-degree and so carry no class signal, the
label is recoverable only from edge directions. DSNN with a non-zero charge
separates the communities; the same model at
exactly direction-blind sheaf diffusion, sits at chance, as does a
feature-only probe.
dsnn_degree.yamlreaches the directed regime. It derives an orientationfrom the lexicographic key (degree, neighbour-degree sum), orienting
are isomorphism invariants, so the model stays permutation equivariant,
unlike a tie-break on node index, which we also ship as
orientation="index"so the contrast is visible. This is an extensionrather than part of the paper, and it is labelled as such in the config
header, the module docstring and the notebook.
A phase derived from a graph distance is deliberately not offered: BFS layering$|\pi(b) - \pi(a)| \le 1$ on every edge, making
$L = U^{*}L^{\mathcal{F}}U$ a pure gauge transformation, isospectral with plain
forces
sheaf diffusion. What makes a phase genuinely directional is non-zero holonomy
around cycles, so on a tree no induced orientation can help. GraphUniverse runs
at average degree 1-2 in half the grid, which is close to tree-like, so we do
not expect
dsnn_degreeto gain much there.Notes on faithfulness
Deviations from the published definition, each flagged where it is
implemented:
worked example (
the printed formula and expose the other as
phase_sign. The notebook showsthat either reading satisfies Theorem 4 against the matching MagNet
convention, and that the two operators are conjugate and isospectral, so the
discrepancy does not have to be adjudicated to be handled. A consequence:
imaginary part for
duplicates at the first layer.
the nodes (shape
construction rather than by clipping.
add_lp/add_hpare not implemented. They are axes of the paper'shyperparameter grid (App. F) rather than part of Eq. 8, they are absent from
the NSD port already in TopoBench, and they are orthogonal to
directionality, which is what this model contributes.
edge_weightis accepted and ignored, because Definition 1 builds the phasefrom the binary adjacency.
its reverse with an
memory and would need hundreds of gigabytes at the scale of the Figure 2
reproduction. The sort-based replacement in
dsnn_utils/laplace.pyagreeswith it exactly wherever the reference can run, and also tolerates
self-loops, which trip the reference's edge-count assertion.
nsd_utilsisleft untouched.
Against the authors' implementation
We also read the reference code
(https://github.com/hakanaktas0/DSNN), which exposes several switches the paper
never mentions. Where it and the paper disagree we follow the paper, except in
one place where the reference is solving a real numerical problem:
We follow the reference on normalization, and it matters more than it looks.$\tilde{D}^{-1/2}$ needs a matrix inverse square root,$\tilde{D}^{-1/2}$ and jitter the blocks by $U(-0.001, 0.001)$
For the general family
and the backward pass of
eighdivides by eigenvalue gaps, so it isill-behaved on a degree block with repeated eigenvalues. Like the reference,
we detach
while training.
This is not cosmetic. On the DSBM of §7 ($n = 2500$ , mean degree 210, where
degree blocks are near-degenerate) Gen-DSNN scores 0.25 when the gradient is
routed through
eighand 0.96 when it is detached, same seed and protocol;Diag-DSNN reproduces 0.968 either way, since it is the general family alone
that has full degree blocks and so reaches that path. We report this because
the deviation is invisible in unit tests, since every theorem test passes
under both, and only shows up as a family that silently will not train.
test_block_normalization_survives_repeated_eigenvaluesandtest_degree_block_jitter_is_training_onlypin the behaviour down.Orthogonal maps use Cayley rather than the reference's Householder default,$SO(d)$ ,$O(d)$ is unreachable either way.
which needs the external
torch_householderpackage. Both land inso the reflection component of
The orthogonal family predicts$d(d-1)/2$ parameters, not the reference's
$d(d+1)/2$ : skew-symmetrizing $A = P - P^{\top}$ annihilates the diagonal, so
$d$ of those have identically zero gradient.
test_orthogonal_parameterization_has_no_dead_parameterspins this down.complex dropout drops whole entries where the reference defaults to
independent masks. The first keeps
unwind's two halves from beingduplicates at layer one; the second preserves the argument of surviving
entries.
The reference additionally learns a scalar weight per arc for the orthogonal$\deg(u) I_d$ of Eq. 3.
family. It is on by default there but appears nowhere in the paper, so we
keep the plain
One config choice to flag: stalk dimension$d = 2$ . The paper searches
$d \in {2, \dots, 5}$ (App. F); $d = 2$ divides the harness-pinned width of
64 exactly, so no hidden channel is lost to rounding, and it is the smallest
value that leaves orthogonal and general restriction maps non-trivial.
Benchmark
Grid run on
graph/dsnn_degree, the config whose complex path is live onundirected input; 72 runs, 18,077 parameters on community detection and 17,754
on triangle counting, ~1.0 s/train epoch.
results.json2026_tdl_challenge/outputs/2026-07-31_14-54-32/results.jsongraph/dsnn,dsnn_orthoanddsnn_generalship as configs but were not run:by Theorem 3 all three are exactly real on GraphUniverse, so their numbers
would be Neural Sheaf Diffusion with the Eq. 8 readout, not DSNN.
Reference
Fiorini, Aktas, Duta, Coniglio, Morerio, Del Bue, Liò, "Sheaves Reloaded: A
Directional Awakening," ICLR 2026.