# malecns-operator **Can a fly's wiring play a memory game?** Show a smell, wait, show another, and ask: same or different? Here the fly is the MaleCNS v1.0 connectome of one male *Drosophila*, run as a steady-state rate model, with a small trained memory — a 16-unit GRU — attached outside it. Nothing about that memory is biological. The smells are 110 real odorants, entered as the receptor responses Hallem & Carlson (2006) measured, and the test uses odors the memory never trained on, arriving on olfactory receptor neurons it never saw. | question | answer | status | |---|---|---| | Can memory plus the real wiring tell same from different, on new odors and new neurons? | **yes: 0.724** accuracy (lower bound 0.705); **0.713** after eight blank frames | verdict, rules committed before the run | | Is that the wiring, rather than any network or the raw input? | **not decided.** The shuffled-wiring and input-only arms did not learn even on their own training distribution, so both comparisons are VOID | verdict | | Does the real wiring's lateral horn output carry "same odor" with no training at all? | a plain cosine similarity separates same from different at **AUC 0.947** on new odors and neurons; a shuffled seed at **0.514** | exploratory, after the verdicts | | What if the memory is handed the 23 receptor types directly? | 0.765 | reading, an oracle | [![Fly Memory Match: a card game replaying step 10's answers](docs/memory-match/preview.png)](https://hjkornn-phys.github.io/malecns-operator/memory-match/) **Play it:** [Fly Memory Match](https://hjkornn-phys.github.io/malecns-operator/memory-match/) ([한국어](https://hjkornn-phys.github.io/malecns-operator/memory-match/ko.html)), or open `docs/memory-match/index.html` locally. Cards arrive one at a time and three flies — the real brain, a shuffled brain, and a memory with no brain — say whether each matches the one before; you can play along. Every answer is a real benchmark item from step 10; the stream, the table and the flies are illustration. Built by `scripts/viz/export_memory_match.py`; the odor response values on the cards are CC BY-SA 4.0 (`docs/memory-match/LICENSE.md`). **Does the wiring matter?** [Three flies walk to a smell](https://hjkornn-phys.github.io/malecns-operator/surge/) ([한국어](https://hjkornn-phys.github.io/malecns-operator/surge/ko.html)), or open `docs/surge/index.html` locally. The real wiring, one with its connections scrambled but its degrees and synapse counts kept, and one that turns at random — same controller, same odours, same starting points, nothing trained. Scrambled wiring steers worse than random turning. Every track drawn is one of step 13's scored episodes. Built by `scripts/viz/export_surge.py`. In plain words: the wiring turns scattered receptor neurons into a pattern where the same odor looks the same, even through neurons never used in training, and the one shuffled wiring checked this way does not. The trained memory reads only part of what is there. The comparison that would make this a finding about the wiring has not been made properly yet, and why is written down in [Step 9](#step-9-a-memory-outside-the-connectome-a-taste-pilot), [Step 10](#step-10-the-memory-game-on-real-odors) and `METHOD.md`. Every number here was measured on one 8 GB Apple M1 laptop. Each question is decided by rules written into its script's docstring and committed before the run. The method those rules follow — what has to be measured before a threshold is chosen, what a result may claim, and the predictions registered before each run — lives in the files at the top of this repository, `METHOD.md` and `PREDICTIONS.md`. Predictions that turned out wrong are kept. ## How it got here The memory game is the tenth question asked of this network: fetch, filter, compact, solve, compare against a baseline, train a steady-state rate model, and score it against the real fly. The earlier questions, and what they left standing: **What holds** - The compacted network (`OR 1%`, half the baseline's edges) keeps the baseline's readout responses far better than random pruning of equal size — [Pipeline](#pipeline). - Training through the fixed point works: implicit gradients are correct and a second-order optimizer recovers known parameters — [Step 1](#step-1-does-training-through-the-fixed-point-work). - The untrained wiring says which antenna smelled an odor, from one stimulus and one fixed point with nothing trained: 0.715 on odors and receptor neurons never used to set its one centering scalar, against ten null seeds spanning 0.441 to 0.620 — [Step 11](#step-11-which-antenna-smelled-it). - With a time axis, the untrained wiring integrates about 2.4x more slowly than its degree-matched shuffles, uniformly across odors — a graph property, not an odor-specific rate code — [Step 12](#step-12-a-time-axis-on-olfaction). - Closing the loop, scrambled wiring steers WORSE than random turning: a fly on the real wiring reaches an odour source 0.135 of the time against 0.005–0.045 for five shuffled seeds and 0.120 for random turns — but the typical fly of either arm gets nowhere, so the composite verdict fails — [Step 13](#step-13-walking-to-the-smell). - The untrained wiring already carries taste identity to descending neurons, including from neurons never used in training; shuffled wiring does not — [Step 2a](#step-2a-can-taste-be-read-from-the-untrained-network). - Training on the taste task moves agreement with the real fly in the right direction, on the real wiring — balanced accuracy on the 149 held-out experimental outcomes goes 0.669 to 0.715 — but **the effect is six changed answers out of 149 and does not reach significance** (exact McNemar p = 0.219), so it is suggestive and not established — [Step 3](#step-3-does-the-trained-model-score-better-against-the-real-fly). - Three pheromone-receptor channels that look alike — all gustatory, all on legs and wings, all of similar size — are routed to different places by the wiring, by more than any of 20 degree-preserving rewirings, on both sensilla and on each side's neurons alone — [Step 7](#step-7-three-look-alike-pheromone-channels-are-routed-to-different-places). What those places *mean* is open: the readout sets used there turned out not to contain the ppk channels' published target, and that correction is recorded with the result. **What does not, and what is still open** - A first version of the memory game, on taste, passed every verdict against control arms that had learned nothing — caught after the run, recorded, and turned into the gate that step 10 uses and into a new rule in `METHOD.md` — [Step 9](#step-9-a-memory-outside-the-connectome-a-taste-pilot). - Similarity to the real fly is NOT established *for the untrained model*: on 149 experimental outcomes it scores near chance — [Result 1](#result-1-similarity-to-the-real-fly-could-not-be-established). Training moves it (Step 3) without closing the gap: 0.715 balanced accuracy is still a long way from reproducing the fly. - Whether compaction preserves *behaviour* is undecided. Three task sets have now tried and none could separate compaction from random pruning ([Result 2](#result-2-agreement-with-the-baseline), Step 2a rule R4, [Step 2a-mix](#step-2a-mix-a-harder-task-and-it-decided-nothing)). - Generalisation to held-out neurons holds for single tastes and breaks for mixtures, where the real wiring is no better than shuffled wiring. - A dark patch reaches the giant fiber with the right size tuning, sidedness and spatial pooling, but too weakly to clear the response threshold, and never reaches the jump muscle — [Step 4](#step-4-a-dark-patch-reaches-the-giant-fiber-and-stops-there). The obvious culprit, the electrical synapses this connectome does not carry, turned out not to be it: supplying them changes nothing, because the giant fiber's own response is already too small and this rate model has no spike to amplify it — [Step 5](#step-5-the-missing-gap-junctions-were-not-the-bottleneck). - Training barely moves the loss it is given. Step 2b's cross-fitted loss falls 4.5% against the 20% its rule asked for, and still buys a real held-out gain — [Step 2b](#step-2b-training-the-gains-on-the-taste-task). - Adding a time axis buys nothing for the escape pathway on its own. Approach speed moves the giant fiber by 2e-5 over a sixfold range, and no tau spread tried separated the wiring from its own shuffled null — [Step 8](#step-8-a-time-axis-buys-no-velocity-signal). ## Setup ```sh uv sync # base: numpy, pandas, pyarrow, scipy (Python 3.13) uv sync --extra torch # plus PyTorch with MPS; needed for steps 1 and 2 ``` Every script reads and writes the current directory, so all of them run from `data/`: ```sh cd data uv run --project .. python ../scripts/