Partial Gromov-Wasserstein Cross-Attention
Implementation & benchmark of arXiv:2607.27496 — Identifying common backbones of interactions underlying food webs via non-deterministic alignments
Source paper: Identifying common backbones of interactions underlying food webs via non-deterministic alignments arXiv:2607.27496 ⓘ · analyzed Aug 31, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Replace unconstrained softmax cross-attention with a many-to-many transport matrix whose row and column masses have explicit upper bounds. Compute the attention cost from both feature similarity and pairwise relational disagreement, so a token is attended to only when its relationships to other tokens are jointly compatible. The inequality constraints provide a principled dustbin-free mechanism for ignoring distractor tokens.
Formulas
Mathematical statement
Definition 2.1 defines a non-deterministic alignment between networks as a matrix T in C_1(mu) intersect C_2(nu), where T_ij is the alignment mass between source item i and target item j, mu in Delta^(m-1) and nu in Delta^(n-1) are source and target importance distributions, m and n are the set sizes, and 1_k is an all-ones vector. The constraints T 1_n <= mu and T^T 1_m <= nu mean that each source and target can allocate at most its available mass; unlike balanced optimal transport, total transported mass may be smaller than one, and unlike a permutation, one item may align with many items. For neural features x_i and y_j, use feature dissimilarity c_ij = 1 - cosine(x_i,y_j). Let A_ik and B_jl be pairwise relational distances or similarities within the two sets. A Gromov-Wasserstein-inspired structural cost is L_ij(T) = sum over k,l of |A_ik - B_jl|^2 T_kl. Optimize the partial entropic objective sum over i,j of T_ij times [alpha c_ij + beta L_ij(T)] minus epsilon H(T), where alpha and beta are nonnegative feature and structure weights, epsilon is the entropy temperature, and H(T) = -sum over i,j T_ij(log T_ij - 1). The structural term rewards alignments that preserve relations rather than merely matching individual embeddings.
Implementation notes
Integrate this as a cross-attention replacement between two variable-length sets: source tokens X = [x_1,...,x_m] and target tokens Y = [y_1,...,y_n], rather than modifying the value projection. First normalize masses to uniform or learned positive distributions mu and nu; assign padded positions zero mass. Compute feature costs c_ij = 1 - cosine(W_q x_i, W_k y_j). Build relational matrices A and B using pairwise distances of projected features, k-nearest-neighbor distances, graph adjacency, or relative positions. Initialize T as a positive matrix satisfying the upper bounds. Repeat 3–10 iterations: calculate L_ij(T) = sum over k,l of |A_ik - B_jl|^2 T_kl; form logits S_ij = -(alpha c_ij + beta L_ij(T))/epsilon; set a positive kernel K_ij = exp(S_ij); alternately rescale rows and columns so row sums do not exceed mu and column sums do not exceed nu, clipping every scaling factor at one; and optionally renormalize by transported mass. Use output o_i = sum_j T_ij V_j divided by sum_j T_ij plus delta, with delta preventing division by zero. Optionally concatenate the unmatched gate u_i = 1 - sum_j T_ij. During training, unroll a fixed number of iterations and backpropagate through them; for a cheap MVP, stop gradients through L and use it only to update T. Estimate A and B directly from features, not labels. Start on synthetic 2-D point clouds or graph-node sets where one set contains 30–50% distractors and the ground-truth transformation preserves pairwise distances. Compare against dot-product softmax attention and balanced Sinkhorn attention in a small Transformer or graph matcher. Measure correspondence accuracy, retrieval accuracy with distractors, transported-mass selectivity, attention entropy, gradient stability, and wall-clock cost. Success means higher matching accuracy at equal parameter count and lower mass assigned to distractors, with no more than roughly 2x attention-layer runtime.
Verification
Stage 1 · Toy mechanism gate: Passed ✓
Stage 2 · Mechanism transferred to benchmark: Not reproduced ✗
Stage 2 · Practical benchmark result: Significant win ✓
Methodology: 8 paired seeds, permutation test (p<0.05) against a learning-rate-tuned baseline. How verification works
How to read this: The implementation beat the baseline, but the claimed mechanism did not reproduce at benchmark scale. The gain may come from another effect; treat the cause as unresolved.
Stage 1 — Mechanism check agent confidence 8/10
Built a readable partial GW cross-attention MVP with cosine feature cost, relational GW cost, entropic kernels, and alternating clipped row/column upper-bound projections. Quantitative checks matched predictions: beta=0 relative invariance error was 0, convex linearity error was 3.33e-16, beta logit shifts scaled exactly from 0 to 21.13, and maximum feasibility violations were 0 for all tested shapes. In the synthetic benchmark, increasing beta improved matched mass from 0.717 to 0.882 and reduced distractor mass from 0.151 to 0.090, while accuracy stayed 1.0; however, partial GW did not beat softmax accuracy and assigned slightly more distractor fraction than softmax, so no general performance win is established.
- Agent confidence
- 8/10
- Baseline
- Softmax: accuracy 1.000, matched_mass_fraction 0.748, distractor_mass_fraction 0.106, transported_mass 12.0, entropy 0.769
- Idea
- Partial GW: accuracy 1.000, matched_mass_fraction 0.800, distractor_mass_fraction 0.123, transported_mass 0.684, entropy 3.416; beta sweep matched mass 0.717->0.882 and distractor fraction 0.151->0.090 for beta 0->3
Limitations: Only a small synthetic feature-matching benchmark was tested; no learned neural network, backpropagation, variable padding masks, learned masses, runtime/FLOP profiling, or larger/noisier real-world correspondence task was evaluated. The beta linearity and feasibility checks validate algebraic properties directly and are not evidence of end-to-end accuracy gains.
How to run: python3 experiment.py
Stage 2 — Benchmark vs. tuned baseline (arXiv:2607.27496)
Beats the tuned baseline by 31.8% (p=0.0081, wins 8 / 8 paired seeds; metric: lower is better).
- Benchmark
- Sequence modeling
- Model
- transformer_tiny
- Paired seeds
- 8
- Baseline mean
- 0.6229
- Idea mean
- 0
- Effect (Δ)
- -0.1981 (−31.8%; negative = idea better)
- Wins
- 8 / 8 paired seeds
- p-value
- 0.0081 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- n/a
- Mechanism
- Not confirmed ✗
- Practical effect
- Helps
- Baseline tuning
- swept over 3 configs
The full default-sized protocol did not fit within the runtime budget, so this run used 600 training samples, 300 test samples, and 5 epochs; eight paired seeds were retained. Only the sequence track was tested. The implementation uses detached structural costs and a reduced number of projection/GW iterations. The saved mechanism signature has confirmed=false because it lacks a separately measured trained-model correlation between structural compatibility and attention mass.
How to run: python3 bench_pgw.py
Verdict computed by deterministic test code from paired-seed statistics — not by the language model.
Stage 2 — Benchmark latest Worked ✓
Agent confidence: 7/10
Implemented partial Gromov-Wasserstein cross-attention as a trainable replacement inside transformer_tiny on the structurally matched sequence forecasting track. Across 8 paired seeds, the idea obtained lower test MSE than the swept baseline (0.42486 vs 0.62292; delta -0.19806) with permutation p=0.0081, satisfying the bench criterion for a significant win. The mechanism signature was not confirmed quantitatively, so the result is task-level evidence rather than proof of the proposed attention behavior.
- Baseline
- transformer_tiny baseline, best lr=0.0015: mean test MSE 0.6229188442, std 0.0693105116
- Comparison
- delta_mean=-0.1980590299; 8/8 paired wins; permutation p=0.0081; relative improvement=31.8%
- Idea
- partial GW attention, best lr=0.0015 beta=0.2 eps=0.15: mean test MSE 0.4248598143
Benchmark result
Beats the tuned baseline by 31.8% (p=0.0081, wins 8 / 8 paired seeds; metric: lower is better).
- Benchmark
- Sequence modeling
- Model
- transformer_tiny
- Paired seeds
- 8
- Baseline mean
- 0.6229
- Idea mean
- 0
- Effect (Δ)
- -0.1981 (−31.8%; negative = idea better)
- Wins
- 8 / 8 paired seeds
- p-value
- 0.0081 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- n/a
- Mechanism
- Not confirmed ✗
- Practical effect
- Helps
- Baseline tuning
- swept over 3 configs
The full default-sized protocol did not fit within the runtime budget, so this run used 600 training samples, 300 test samples, and 5 epochs; eight paired seeds were retained. Only the sequence track was tested. The implementation uses detached structural costs and a reduced number of projection/GW iterations. The saved mechanism signature has confirmed=false because it lacks a separately measured trained-model correlation between structural compatibility and attention mass.
How to run: python3 bench_pgw.py
Artifacts
- bench_pgw.py 4.2 KB View Raw
- bench_report.json 2.8 KB View Raw
- experiment.py 6.0 KB View Raw
- report.md 1.7 KB View
- report_bench_2026-08-31T184541.md 4.6 KB View
- results.json 5.2 KB View Raw