Skip to content
sheaf-laplacian-coordination logo

Sheaf Laplacian Coordination

sheaf-laplacian-coordination

Sheaf neural network coordination via graph Laplacians for distributed consensus and harmonic inference. Use when coordinating multi-agent systems, building sheaf-aware GNNs, or implementing distributed consensus protocols.

plurigrid/asi0installs67stars

SKILL.md

Full skill instructions

Sheaf Laplacian Coordination

Trit: 0 (ERGODIC - coordinator) Color: Green (#26D826)

Overview

Implements sheaf neural network coordination using graph Laplacians for:

  • Distributed consensus via sheaf diffusion
  • Harmonic extension/​restriction operators
  • Spectral clustering on sheaf sections
  • Multi-agent coordination with vector space representations

Key Papers

Core Concepts

Sheaf Laplacian

The sheaf Laplacian generalizes the graph Laplacian by associating vector spaces to nodes and linear maps to edges:

L_F = D^\top D

where D is the coboundary operator:
(Df)_e = F_{e,t} f_t - F_{e,s} f_s

F_{e,v} : F(v) → F(e)  (restriction maps)

Diffusion Process

Sheaf diffusion for consensus:

\frac{dx}{dt} = -L_F x

At equilibrium: L_F x = 0 (harmonic sections)

In/​Out Degree Laplacians (Cooperative SNNs)

For directed graphs with cooperative behavior:

L_{in} = D_{in}^\top D_{in}   (gathering information)
L_{out} = D_{out}^\top D_{out} (conveying information)

API

Python Implementation

import torch
import torch.nn as nn

class SheafLaplacian(nn.Module):
    """Learnable sheaf Laplacian for graph coordination."""
    
    def __init__(self, num_nodes, stalk_dim, edge_index):
        super().__init__()
        self.num_nodes = num_nodes
        self.stalk_dim = stalk_dim
        self.edge_index = edge_index
        
        # Learnable restriction maps F_{e,v}
        num_edges = edge_index.shape[1]
        self.restriction_maps = nn.Parameter(
            torch.randn(num_edges, 2, stalk_dim, stalk_dim)
        )
    
    def build_laplacian(self):
        """Construct sheaf Laplacian from restriction maps."""
        L = torch.zeros(
            self.num_nodes * self.stalk_dim,
            self.num_nodes * self.stalk_dim
        )
        
        for e, (s, t) in enumerate(self.edge_index.T):
            F_es = self.restriction_maps[e, 0]  # Source restriction
            F_et = self.restriction_maps[e, 1]  # Target restriction
            
            # Add edge contribution to Laplacian
            # L[s,s] += F_es^T F_es, L[t,t] += F_et^T F_et
            # L[s,t] -= F_es^T F_et, L[t,s] -= F_et^T F_es
            
        return L
    
    def diffuse(self, x, steps=10, dt=0.1):
        """Run sheaf diffusion for consensus."""
        L = self.build_laplacian()
        for _ in range(steps):
            x = x - dt * (L @ x)
        return x
    
    def harmonic_extension(self, boundary_values, boundary_mask):
        """Extend boundary values harmonically."""
        L = self.build_laplacian()
        # Solve L_interior x_interior = -L_boundary x_boundary
        return solve_harmonic(L, boundary_values, boundary_mask)


class CooperativeSheafNN(nn.Module):
    """Cooperative SNN with in/​out degree control."""
    
    def __init__(self, in_dim, hidden_dim, out_dim, edge_index):
        super().__init__()
        self.sheaf = SheafLaplacian(
            num_nodes=edge_index.max() + 1,
            stalk_dim=hidden_dim,
            edge_index=edge_index
        )
        self.encoder = nn.Linear(in_dim, hidden_dim)
        self.decoder = nn.Linear(hidden_dim, out_dim)
        
        # Cooperative gates: control gather vs convey
        self.gather_gate = nn.Parameter(torch.ones(1))
        self.convey_gate = nn.Parameter(torch.ones(1))
    
    def forward(self, x, edge_index):
        h = self.encoder(x)
        
        # Cooperative diffusion
        h_diffused = self.sheaf.diffuse(h)
        
        # Apply cooperative gates
        h_out = self.gather_gate * h + self.convey_gate * h_diffused
        
        return self.decoder(h_out)

Julia Implementation (ACSets)

using Catlab, Catlab.CategoricalAlgebra

# Define sheaf schema
@present SchSheaf(FreeSchema) begin
    V::Ob  # Vertices (nodes)
    E::Ob  # Edges
    src::Hom(E, V)
    tgt::Hom(E, V)
    
    # Stalks as vector spaces
    F_V::AttrType  # Stalk at vertex
    F_E::AttrType  # Stalk at edge
    stalk_v::Attr(V, F_V)
    stalk_e::Attr(E, F_E)
end

@acset_type SheafGraph(SchSheaf)

function build_sheaf_laplacian(sg::SheafGraph, restrictions)
    """Build sheaf Laplacian from restriction maps."""
    n = nparts(sg, :V)
    d = size(restrictions[1], 1)  # Stalk dimension
    
    L = zeros(n * d, n * d)
    
    for e in parts(sg, :E)
        s = sg[e, :src]
        t = sg[e, :tgt]
        F_s, F_t = restrictions[e]
        
        # Add contributions
        si, ti = (s-1)*d+1:s*d, (t-1)*d+1:t*d
        L[si, si] += F_s' * F_s
        L[ti, ti] += F_t' * F_t
        L[si, ti] -= F_s' * F_t
        L[ti, si] -= F_t' * F_s
    end
    
    return L
end

function sheaf_diffusion(L, x0; steps=100, dt=0.01)
    """Run sheaf diffusion to reach harmonic section."""
    x = copy(x0)
    for _ in 1:steps
        x = x - dt * (L * x)
    end
    return x
end

GF(3) Triads

This skill participates in balanced triads:

sheaf-cohomology (-1) ⊗ sheaf-laplacian-coordination (0) ⊗ forward-forward-learning (+1) = 0 ✓
persistent-homology (-1) ⊗ sheaf-laplacian-coordination (0) ⊗ gay-mcp (+1) = 0 ✓

Use Cases

Multi-Agent Consensus

# Agents reach consensus via sheaf diffusion
agents = SheafLaplacian(num_agents=5, stalk_dim=16, topology=ring_graph)
initial_beliefs = torch.randn(5, 16)
consensus = agents.diffuse(initial_beliefs, steps=50)
# All agents now have aligned beliefs in harmonic section

Heterophilic GNN

# Handle graphs where connected nodes have different labels
model = CooperativeSheafNN(in_dim=32, hidden_dim=64, out_dim=10, edge_index=data.edge_index)
# Sheaf structure allows nodes to maintain distinct representations
# while still communicating through restriction maps

Distributed Optimization

# Decentralized optimization via sheaf Laplacian flow
def distributed_optimize(local_gradients, topology):
    sheaf = SheafLaplacian(topology)
    # Average gradients via harmonic extension
    global_gradient = sheaf.harmonic_extension(local_gradients)
    return global_gradient

Integration with Music-Topos

;; In parallel_color_fork.clj
(defn sheaf-coordinate-forks
  "Coordinate parallel color forks via sheaf diffusion"
  [forks topology]
  (let [sheaf (build-sheaf-laplacian forks topology)
        consensus (sheaf-diffuse sheaf (map :color forks))]
    (mapv #(assoc %1 :coordinated-color %2) forks consensus)))

See Also

  • sheaf-cohomology - Čech cohomology for local-to-global verification
  • open-games - Compositional game theory for agent coordination
  • acsets-algebraic-databases - Functorial databases underlying sheaf structure
  • forward-forward-learning - Local learning complementing sheaf diffusion

References

@article{hansen2020sheaf,
  title={Sheaf Neural Networks},
  author={Hansen, Jakob and Gebhart, Thomas},
  journal={arXiv:2012.06333},
  year={2020}
}

@article{bodnar2022neural,
  title={Neural Sheaf Diffusion},
  author={Bodnar, Cristian and Di Giovanni, Francesco and others},
  journal={arXiv:2202.04579},
  year={2022}
}

@article{ribeiro2025cooperative,
  title={Cooperative Sheaf Neural Networks},
  author={Ribeiro, André and others},
  journal={arXiv:2507.00647},
  year={2025}
}

More skills from plurigrid

cargo logo
plurigrid/asi

cargo

Rust package manager (36 subcommands).

67 0
View

Translate Figma nodes into production-ready code with 1:1 visual fidelity using the Figma MCP workflow (design context, screenshots, assets, and project-convention translation). Trigger when the user provides Figma URLs or node IDs, or asks to implement designs or components that must match Figma...

67 0
View

**Status**: 🌳 Production Ready (upstream in StringZilla v3+) **Type**: High-Performance String Operations / SIMD-Accelerated Text Processing **Principle**: Zero-copy views, SIMD/SWAR acceleration, deterministic hashing **Frame**: Cross-language interoperability (C, C++, Python, Rust, Go, Swift, ...

67 0
View
conformal-ga logo
plurigrid/asi

conformal-ga

Conformal Geometric Algebra (CGA) for circles, spheres, and Möbius transformations

67 0
View

Verifies code implements exactly what documentation specifies for blockchain audits. Use when comparing code against whitepapers, finding gaps between specs and implementation, or performing compliance checks for protocol implementations.

67 0
View
zig-systems logo
plurigrid/asi

zig-systems

Systems programming and performance optimization using Zig. Provides low-level abstractions, memory-safe compiled code, and performance benchmarking. Use for system-level operations, optimization, and interoperability with C/POSIX APIs.

67 0
View
soliton-detection logo
plurigrid/asi

soliton-detection

Topological soliton detection and agency bridge with anyonic fusion algebra for concept composition

67 0
View
paypal-mcp logo
plurigrid/asi

paypal-mcp

PayPal MCP server integration for invoices, payments, subscriptions, disputes, and transaction reporting via @paypal/mcp.

67 0
View
unison logo
plurigrid/asi

unison

Unison language - content-addressed functional programming with abilities for effects, distributed computing, and structural types. Use for pure functional code, effect management, distributed systems, and refactoring-safe codebases.

67 0
View
tasks-acset logo
plurigrid/asi

tasks-acset

Google Tasks management via TasksACSet. Transforms task operations into GF(3)-typed Interactions, routes to triadic queues, detects saturation for task-zero-as-condensed-state.

67 0
View
c logo
plurigrid/asi

c

World C Skill

67 0
View
syrup logo
plurigrid/asi

syrup

Syrup binary serialization for OCapN/CapTP wire format. Canonical encoding for capability messages.

67 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View