Skip to content

Photonic sudoku: what carries the recurrence — classical, quantum, or both - #53

Draft
giodefelice-agents wants to merge 9 commits into
claude/sudoku-experiment-optyx-lyi6mpfrom
claude/sudoku-photonic-lyi6mp
Draft

giodefelice-agents wants to merge 9 commits into
claude/sudoku-experiment-optyx-lyi6mpfrom
claude/sudoku-photonic-lyi6mp

Conversation

@giodefelice-agents

@giodefelice-agents giodefelice-agents commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

> Your next task is to solve the same sudoku dataset using photonic channels instead of qubits. Each cell is interpreted as a small recurrent linear optical circuit with one or two photons injected at each time step. Open a separate PR for this experiment. Again, let's be efficient in our use of the GPU. The previous experiment should help us narrow down the choice of dimensions for the ansatz and the unroll length, so that we run few tailored experiments on the GPU, making sure the contraction is doable beforehand.

> Try to do it without classical feedforward , purely quantum, and if that doesn't work then you can try by controlling the unitary with the classical outcomes. Three models to bencark: only classical loop, only quantum loop, both classical and quantum loop. Max two runs each if you don't get the result, so we don't use too much gpu

> Let's run only the purely quantum model. Both the memory and the messages should be coherent (quantum links), and for the prediction we can use a photon counting measurement, possibly followed by some local classical post-processing. Go ahead and run this experiment on the modal GPUs

> How can we scale up the pure quantum photonic experiment? The number of parameters seems too low to hope to solve the task, at the same time the contractions need to be doable on the GPU, could truncation help?

Stacked on the qubit sudoku experiment (#52). Same architecture (one box per cell, row, column, square), same 192/64 dataset, two recurrent ticks, exact contraction; every channel is now linear optics: Givens meshes in the Clements layout, one or two fresh photons injected per tick, photon counting. Full report in examples/sudoku/README_photonic.md; raw histories committed as JSON.

Benchmark: what carries the recurrence

loop model init params cell acc grids solved
classical only measured messages and memory, feedforward meshes structured 648 1.000 64/64
classical only same, learned from scratch random 984 0.793 0.062
both coherent memory interfering with injected photons, measured messages random 872 0.637 0
quantum only coherent links, counters + learned local post-processing random 109 0.541 0

Chance is 0.25. The ordering is monotone in how much measurement sits in the loop — the same pattern as the born-vs-measured qubit families of #52. For scale: the CMap GNN (discopy#416) stands at 12,980 params / 0.993 / 0.936; the qubit families of #52 solve at 4,492 and 1,592.

The measured model carries a certified linear-optical solver

The mesh layout is a sorting network, so firing comparators at π/2 realises any controlled mode permutation. The exact solver is a closed-form angle setting of the trainable ansatz (photonic.solver_photonic): cells route their two photons to the modes indexed by the memory digit, and each constraint's single photon walks the subset automaton of the all-different constraint — which fits on exactly eight modes, live states plus parked rejects — reaching the accept mode iff the four claims are distinct. Certified by decoding 16/16 held-out puzzles before training; trained from the broadcast plumbing with random constraint logic it solves everything within 100 steps at 648 parameters.

The purely quantum model (as specified in the third prompt)

Coherent message and memory modes (doubled wires), no feedforward anywhere; cells are seven-mode interferometers with two injected photons, constraints interfere their four port modes with one injected photon on a fifth, traced-out mode; the only measurement is counting the two prediction modes, followed by a trainable 4×4 classical post-processing. Amplitudes are collision-free boson amplitudes via differentiable Ryser permanents.

Its full map does not contract exactly — width 2^40 at two ticks even decomposed to beamsplitter level, measured on CPU before any GPU spend — so it trains and evaluates on the local light-cone maps (width 2^18). Without the ancilla and post-processing it sits at chance (two runs); with them it reaches 0.541 at two ticks and 109 parameters and 0.359 at three ticks — twice chance from two-photon interference alone, but far from solving.

Scaling the quantum loop (fourth prompt): parameters are not the bottleneck

The photonic-scaled family grows parameters only in directions that leave the contraction width untouched: internal vacuum ancillas inside each box (cells 7 → 11–12 modes, constraints 5 → 8, traced out — a structured non-unitary channel), complex phased-Givens meshes, more sweeps, and fixed pure-loss channels of transmittivity 0.95 on every coherent link (per instruction: fixed, ≥ 0.9). With no ancillas, real angles and no loss it reduces exactly to the pure family, verified to 1e-16 (check_scaled.py). Four runs at two ticks on the local light cones:

config params cell acc (final / best)
pure baseline, 7/5 modes 109 0.506 / 0.541
11/8 modes, 4 complex sweeps, lossless 680 0.463 / 0.479
same + fixed loss η = 0.95 680 0.459 / 0.516
12/8 modes, 8 complex sweeps, lossless 1,520 0.482 / 0.502
same, 8,000 steps at half the rate 1,520 0.396 / 0.406

The plateau does not move. An order of magnitude more parameters, non-unitary ancilla channels and mild decoherence on the links all land within noise of the 109-parameter model; training longer lands lower. What limits the purely coherent model is its structure, not its parameter count: a passive linear-optical loop with counting only at the predictions has no nonlinearity inside the recurrence — exactly what the measured families get from their counters. On truncation: Fock cutoff 2 on the message wires was the one width-side scaling planned, but its doubled cell tensor (dim-9 message legs) is a 4.4 GB dense array before contraction, out of reach of the A100 training loop — its budget slot went to the bigger-mesh run instead (noted deviation).

GPU budget

Two runs per model plus the four-run scaling ladder on Modal A100s; all dimensions fixed by #52's width measurements, every contraction width probed and every family verified or smoke-tested on CPU first. (One batch was interrupted by the workspace spend limit and rerun after it was raised; the classical-loop structured run converged on CPU during the outage.)

Contributions

  • examples/sudoku/photonic.py — the measured family: sorting-network meshes, feedforward angle banks, permutation routing, the all-different subset automaton on eight modes, solver certificate and structured init.
  • examples/sudoku/photonic_quantum.py — the coherent families: collision-free amplitude tables by batched Ryser permanents, the purely quantum cell/constraint tensors with traced ancilla and learned counter post-processing, the mixed family with a coherent two-mode memory.
  • examples/sudoku/photonic_scaled.py — the scaled coherent family: per-input-column amplitudes, internal vacuum ancillas, complex meshes, fixed pure-loss channels; check_scaled.py verifies the exact reduction to the pure family and trace preservation of the loss channels.
  • contraction.py — the four families wired into the shared exact-contraction trainer, with per-config evaluation batching.
  • results_photonic*.json, results_pure.json, results_scaled*.json — raw metric histories of every reported run.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GRttRw1nfYw86K7h4bfMRx


Generated by Claude Code

claude added 9 commits August 14, 2026 18:49
Stacked on the sudoku experiment of the previous PR; claim the
photonic-ansatz point.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GRttRw1nfYw86K7h4bfMRx
Cells route two injected photons by feedforward-controlled Givens
meshes, constraints walk one photon through the subset automaton of
the all-different constraint on eight modes; the closed-form angles
decode held-out puzzles exactly at 648 to 984 parameters. Add the
purely quantum family (coherent message and memory modes, collision
free amplitudes by Ryser's formula) and the mixed family with a
coherent two-mode memory interfering with the injected photons.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GRttRw1nfYw86K7h4bfMRx
Amplitude sanity: the single-photon block of the collision-free table
is exactly the mesh unitary and bunching leaks at most unit norm. The
purely quantum family trains on the local light-cone maps -- its
full-map contraction is width 2^40 even at the beamsplitter level --
while the measured and mixed families keep the established full-map
regime.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GRttRw1nfYw86K7h4bfMRx
The prediction counting pattern feeds a trainable local classical map
started at the identity, and each constraint interferes its four port
modes with one injected photon on a fifth mode traced out at the end --
a non-unitary passive channel, still with no feedforward anywhere.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GRttRw1nfYw86K7h4bfMRx
The measured linear-optical model solves all held-out grids at 648
parameters (certified solver, trained constraint logic) and reaches
0.793 from scratch; the mixed model with a coherent memory reaches
0.637; the purely quantum model with coherent links, counters and
learned post-processing reaches 0.541 at 109 parameters on the local
light cones -- twice chance from two-photon interference alone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GRttRw1nfYw86K7h4bfMRx
Scale the pure family without touching contraction width: internal
traced vacuum ancillas (cells 7 -> 11 modes, constraints 5 -> 8),
complex phased-Givens meshes, more sweeps, and fixed pure-loss
channels (eta >= 0.9) folded into the coherent write legs. Amplitudes
are computed per input column so twelve-mode boxes stay cheap; with no
ancillas, real angles and no loss the family reduces exactly to
photonic-pure, verified to 1e-16 by check_scaled.py along with
trace preservation of the loss channels.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GRttRw1nfYw86K7h4bfMRx
680 parameters lossless: 0.463 cell accuracy; 680 with fixed loss
eta 0.95: 0.459; 1,520 parameters (twelve-mode cells, eight sweeps):
0.482 -- none beating the 109-parameter pure baseline of 0.541.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GRttRw1nfYw86K7h4bfMRx
Run four (1,520 parameters, 8,000 steps at half the rate) lands at
0.396; the best scaled run stays within noise of the 109-parameter
pure baseline. README and TODO updated with the scaling table and
the conclusion that the coherent loop's structure, not its parameter
count, is what limits the purely quantum model.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GRttRw1nfYw86K7h4bfMRx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants