A complete wiring diagram of a brain circuit does not tell you what the circuit computes. Mapped synapses are noisy, some are missing, and many different wirings might produce the same behavior. This note asks the reverse question, and it can be tested: if we know what a circuit does, how much does that tell us about how it is wired? We propose a generative model over discrete wiring, meaning which neuron connects to which and with roughly how many synapses. It learns a prior from real fly connectomes and is then steered toward wirings that reproduce a known function, here the ring-shaped activity that tracks the fly's heading. The central measurement mirrors "sequence recovery" in protein design. We hide part of the real connectome, regenerate it, and ask whether knowing the function recovers the hidden synapses better than wiring statistics alone.
The generator is a discrete flow matching model. Such a model keeps each variable (here, each candidate synapse) in a finite set of states and learns, over a continuous time axis, the rates at which states jump from noise toward data. It has been shown to work for graphs (DeFoG) and for structure-to-sequence design in proteins (ADFLIP). It also has an exact way to steer sampling toward a reward (Discrete Guidance Matching). The function side comes from connectome-constrained circuit models. In From Synapses to Dynamics, the 439-neuron Drosophila head-direction circuit was tuned to a working ring attractor by fitting 57 cell-type gain parameters. Putting these together yields a distribution over wirings consistent with both anatomy and function, which no optimizer of a single parameter vector can provide.
Core Claim
Treat the circuit's dynamical function as a reward and use exact discrete guidance to sample wiring from a learned connectome prior. This turns structure-function mapping into a conditional inverse problem whose answer can be scored. On masked edges of the head-direction circuit, function-guided samples should recover held-out synapse states more accurately than unguided samples. The gain should be concentrated on the cell types the published ablations identified as functionally critical: Delta7 for forming the activity bump, P-EG for stabilizing heading, and Ring neurons for velocity range (From Synapses to Dynamics). Edges where guidance adds nothing are, by this operational definition, functionally unconstrained. Mapping that boundary is a direct, quantitative handle on the many-to-one problem that Computational Connectomics raises conceptually.
This is distinct from the closest existing work. BrainFlow maps structural to functional connectivity with a continuous flow over dense 116-region correlation matrices. It cannot emit discrete, directed, sparse synapses, and its authors report it needs large cohorts. AFR-Net routes functional demand over structure with deterministic Kirchhoff equations and generates nothing. DeFoG generates graphs but conditions on no dynamics. ADFLIP solves an inverse structure-to-sequence problem, but in proteins. The connectome-tuning and effectome work (From Synapses to Dynamics; The fly connectome reveals a path to the effectome) fits a single parameter set or a linear Jacobian on a fixed graph. None of them samples alternative wirings under a functional constraint.
Research Program
Representation. Each candidate synapse is a categorical variable with four states: none, weak (1–4 synapses), medium (5–19), and strong (20+). The bins are chosen once from the empirical count histogram.
Keeping the model tractable. Dense generation of all 439² ≈ 193,000 pairs is out of reach for DeFoG-style models, which have been run at N ≤ 100. We therefore generate only pairs that fall inside an anatomical envelope. A pair is in the envelope when its two cell types connect somewhere in the circuit and their arbors overlap; all other pairs are fixed at zero. This uses the extreme sparsity reported for FlyWire, about 0.01% of neuron pairs (effectome), as a structural prior rather than learning it. It is a partial answer to the O(N²) limitation, not a general solution, and we report the envelope's recall of true synapses as a hard ceiling on achievable recovery.
The prior. The denoiser is a graph transformer over neurons with cell-type and glomerulus-position node features and DeFoG's relative random-walk features. It predicts the clean state of each candidate edge from a partially masked graph, using the masking ("absorbing") path of Campbell et al..
A single connectome is a small training set. We obtain replicates in three ways. First, the head-direction system repeats across glomeruli and wedges, so its units serve as near-copies. Second, two independent reconstructions of different flies are available: the hemibrain (A Connectome of the Adult Drosophila Central Brain) and FlyWire (Neuronal wiring diagram of an adult brain). Third, we pretrain on other repeated columnar circuits from the FAFB optic lobe. We train on one reconstruction and test on the other, so recovery cannot come from memorizing a single fly.
The reward. We take the rate model of From Synapses to Dynamics, with synaptic weights set from binned counts times cell-type gains, and score a wiring by three terms:
$$r(G) = -\big[\,L_{\text{lin}}(G) + \lambda_1\,(w(G)-\pi/2)^2 + \lambda_2\,D(G)\,\big],$$
where $L_{\text{lin}}$ is that paper's linear consistency loss (bump velocity should match self-motion input), $w(G)$ is the activity bump width, and $D(G)$ is heading drift with no input. Gains are held at their fitted values in the main runs. In a variant, gains are re-fitted for a few steps per sample, so that wiring changes cannot be absorbed by the gains.
Guidance. Following Discrete Guidance Matching, we train a guidance network to predict the reward-weighted density ratio, using its Bregman-divergence loss on simulator-labeled samples drawn from the prior. This yields exact guided jump rates at one network evaluation per step. Guidance strength is swept so that results trace a curve from "anatomy only" to "function dominant."
Baselines
Cell-type stochastic block model. The naive reference samples each masked edge independently from the empirical state frequency of its (presynaptic type, postsynaptic type) pair. It uses the same envelope and the same training reconstruction. It encodes everything "cell types predict wiring" gives you, and any learned model must beat it to justify itself. No reported result was found on Lacuna for masked-edge recovery in fly connectomes, so this baseline sets the empirical floor.
Unguided discrete flow matching prior. This is the identical model with guidance off. It is the ablation that isolates the key ingredient. The difference between guided and unguided recovery is the information the function carries about the wiring, and it is the headline number.
Simulator-in-the-loop discrete MCMC. This is the strongest competitor. It is Metropolis-Hastings over masked edge states, targeting the unguided prior times exp(r) and initialized from prior samples. It is given exactly the same number of simulator calls that we spend generating labels for the guidance network, plus equal wall-clock time and tuning budget (proposal size and temperature swept on a validation split).
Taylor-guided sampling. This is first-order gradient guidance through a softened, differentiable version of the simulator. Wan et al. report that this kind of guidance blurs or fails on the multi-ring toy task while exact guidance does not, and that exact guidance samples 1.6x faster than earlier rate-based guidance (Discrete Guidance Matching).
Continuous relaxation. Edge strengths are optimized directly by gradient descent on $r$, starting from prior samples, and then re-binned. This is the per-edge analogue of the 57-gain fit.
What counts as beating them. The main metric is recovery: the fraction of held-out masked edges whose state is correctly predicted, reported overall and per cell type. We also report reward attained and sample diversity. Beating a baseline means higher recovery at matched or better reward, with non-overlapping confidence intervals across masking seeds and across the hemibrain-to-FlyWire swap. ADFLIP's gain over LigandMPNN on metal-ion sites, 75.73% versus 69.31% recovery (ADFLIP), gives a sense of what a meaningful conditioning gain looks like in an analogous inverse problem. It is not a target number for this task.
Why not just…?
Why not just fit the 57 cell-type gains, as the original paper did? That fit assumes the wiring is known and correct, and it returns one point. Our question is about the wiring itself: which unobserved or uncertain synapses the function pins down. The relaxation baseline is the closest extension of that approach to edges. If it matches our recovery, the honest conclusion is that a distribution adds nothing for completion, and the contribution narrows to uncertainty estimates, which we evaluate separately through calibration.
Why not just run MCMC with the simulator as the score? This is the real threat. On a 439-neuron circuit with a cheap rate model, well-tuned MCMC may match guided sampling on recovery. The equal-budget comparison settles it. If MCMC ties, the generator's value lies in amortization, meaning reuse across many masks, reward variants, and the second reconstruction without new simulator calls. We will measure that directly as the cost to reach a given recovery on the tenth new mask. If MCMC wins outright, we will report it.
Why not just use a continuous flow like BrainFlow on weight matrices and threshold? BrainFlow works on dense correlation matrices and learns from thousands of subjects. Here we have two connectomes and outputs that are sparse and directed. Thresholding also discards the "none" state that carries most of the anatomy. The relaxation baseline approximates this route at the level of single circuits.
Why not just filter unguided samples by reward? Rejection sampling is the trivial form of guidance. We report it at the same simulator budget. It should collapse when reward-satisfying wirings are rare under the prior, and the guidance-strength sweep will show where that happens.
Proposed Experiments and Decisive Checks
The primary experiment masks 10%, 30%, and 50% of in-envelope edges in the FlyWire head-direction circuit, using the prior and guidance network trained on the hemibrain, and then repeats with the roles swapped.
The decisive check is whether guidance raises recovery over the unguided prior. If guided recovery is no better, or improves only on edges the model of From Synapses to Dynamics is insensitive to, the claim fails. A specific prediction follows from that paper's ablations: gains should concentrate on Delta7 and P-EG edges, and edges between non-critical types should show near-zero gain.
A control rules out reward hacking. We guide with a deliberately wrong function: a ring attractor with the wrong bump width, or a model with Delta7 inhibition removed. This should lower recovery. If it does not, the guidance is exploiting the simulator rather than encoding biology.
We also test whether sampling noise matters. Toyoshima et al. found deterministic whole-brain models decay to flat activity without injected noise. We therefore score rewards with and without simulator noise and report whether guided wirings stay functional under noise.
As a secondary, harder generalization test, we apply the same pipeline to optic-lobe columns. There the reward is the agreement between simulated orientation tuning and dendritic orientation in the leaky integrate-and-fire model of Liew et al., which reports a mean difference of 13.7°. Columns there provide hundreds of replicates, which tests whether the prior, and not only the guidance, benefits from more data.
Across all settings we release the envelope recall, the per-cell-type recovery curves against guidance strength, and the samples. The resulting map of which synapses function determines, and which it leaves free, is the scientific deliverable regardless of which method wins.
References
- DeFoG: Discrete Flow Matching for Graph Generation
- All-atom inverse protein folding through discrete flow matching
- Discrete Guidance Matching: Exact Guidance for Discrete Flow Matching
- From Synapses to Dynamics: Obtaining Function from Structure in a Connectome Constrained Model of the Head Direction Circuit
- Computational Connectomics
- BrainFlow: A Holistic Pathway of Dynamic Neural System on Manifold
- Uncovering Latent Communication Patterns in Brain Networks via Adaptive Flow Routing
- The fly connectome reveals a path to the effectome
- Generative Flows on Discrete State-Spaces: Enabling Multimodal Flows with Applications to Protein Co-Design
- A Connectome of the Adult Drosophila Central Brain
- Neuronal wiring diagram of an adult brain
- Ensemble dynamics and information flow deduction from whole-brain imaging data
- Connectome-Based Modelling Reveals Orientation Maps in the Drosophila Optic Lobe