Sudoku experiment: recurrent quantum channels solve 4x4 sudoku below the CMap GNN parameter budget - #52
Draft
giodefelice-agents wants to merge 6 commits into
Conversation
Stacked on the interaction module of #16; claim the Modal setup point. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GRttRw1nfYw86K7h4bfMRx
One box per cell, row, column and square as in optyx.interaction, exact batched Cotengra/JAX contraction of the unrolled protocol, hand-coded solver certificates for the classical and quantum families, and the Modal app running the sweep on GPUs. Work around and report #51. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GRttRw1nfYw86K7h4bfMRx
The born-family scores match a brute-force simulation of the protocol, classical bit channels double to elementwise squares, and the quantum permutation-circuit solver decodes held-out puzzles exactly. Local structures with unpaired boundary ports extend the unroll-depth axis past the exact-contraction limit of the full map. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GRttRw1nfYw86K7h4bfMRx
strip_exponent's per-step renormalisation exploded the XLA graph; at two ticks the raw scores sit near 1e34, well inside float64, so the trainer contracts plainly by default. The entrypoint moves to modal_sweep.py after its previous name kept serving a stale mount. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GRttRw1nfYw86K7h4bfMRx
An XOR ladder of ten conditional layers broadcasts the cell memory and a single generalised multi-controlled flip computes the all-different verdict, so the trainable quantum ansatz contains the solver at cell depth ten and constraint depth one -- certified by decoding held-out puzzles exactly. Structured initialisations start from this plumbing with random constraint logic, against the vanishing gradient signal of fully random channels seen in the first pilots. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GRttRw1nfYw86K7h4bfMRx
The quantum family solves all 64 held-out grids at 4,492 parameters (and at 5,536 across three seeds); from random initialisation it reaches 0.951 cell accuracy and 84.4% grids solved at 6,347. The classical stochastic ablation solves at 1,592. The CMap GNN of discopy#416 stands at 0.993 and 0.936 with 12,980 parameters. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GRttRw1nfYw86K7h4bfMRx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
> Check out #16. The aim of this task is to scale up the experiments on modal GPUs to try to reach a good accuracy at the sudoku task. Open a new PR "sudoku experiment" , the aim is to learn to solve 4x4 sudokus with optyx.interaction. There is a reference notebook in a previous commit of the PR above. The point of comparison is discopy/discopy#416. We want to solve the task using fewer parameters than the CMap GNN. The architecture is the same: one box per cell, per column, per row and per box. You can use the quimb/cotengra setup for GPU computation. Test different ansatze and unroll depths, progressively increasing the number of parameter. Report your results in the PR description.
> That's good but I want the experiment to be genuinely quantum. The classical stochastic channel should be learnable with a quantum model too.
Stacked on #16, whose
optyx.interactionmodule defines the architecture. Experiments ran on Modal A100s (examples/sudoku/modal_sweep.py); raw metric histories are committed as JSON next to the scripts, andexamples/sudoku/README.mdcarries the full report.Results
Held-out evaluation on 64 puzzles (per-cell accuracy on hidden cells / fraction of grids fully solved), two recurrent ticks, exact contraction:
The quantum model is genuinely quantum: each cell is a ten-qubit orthogonal conditional-rotation circuit whose two-qubit private memory stays coherent between ticks while its digit messages and prediction are measured; each constraint is a nine-qubit measure-and-prepare channel whose measured verdict register (dimension
feedback) indexes what it writes back. By Stinespring this family contains every classical stochastic channel; the classical family is its decohered ablation.What made the difference against the reference notebook's null result
solver_cores), the same solver as permutation circuits (solver_quantum), and — strongest — as an explicit angle setting of the trainable conditional-rotation ansatz itself (solver_angles: the cell is an XOR ladder, the constraint's all-different flag is a single conditional layer, i.e. a generalised multi-controlled flip). Each decodes 16/16 held-out puzzles. The reference notebook had no such certificate, and its 26.6% ceiling was an expressivity problem.chi=4compression. One dimension-four digit wire per cell–constraint incidence (instead of two qubit wires per direction) and port-factored constraint writes (rank-feedbackverdict hyperedges) bring the two-tick contraction width from 2^52 down to 2^16–2^20, batched over puzzles with Cotengra paths on JAX float64. Widths at 3+ ticks are 2^50+ even with kahypar — measured and documented; two ticks suffice.feedback=1(constraints unable to respond to their reads) sits at chance; the fully coherentbornfamily of the reference notebook stays at chance — decoherence on the message wires is what makes the landscape trainable. Theexplog-space parameterisation of the same classical tensors plateaus below 50%.Progressive parameter ladder (structured init, 800 steps)
Contributions
examples/sudoku/experiment.py— dataset (288-grid corpus, 256 distinct solutions, 192/64 split before masking, uniquely solvable eight-clue puzzles), theinteractionstructure (one box per cell, row, column, square), the three ansatz families and the three solver certificates.examples/sudoku/contraction.py— exact batched contraction of the unrolled protocol (one open-leg contraction per readout cell), box tensors per family, and the training loop; local light-cone structures for unroll depths beyond the exact-contraction limit.examples/sudoku/verify.py— ties the trainer to optyx: the structure is the combinatorial data of a genuineinteraction.CMap, born-family scores match a brute-force simulation of the protocol fixed byCMap.step, and classical bit-wire channels double to the elementwise square of their kraus map.examples/sudoku/modal_sweep.py— the Modal app (image with this branch of optyx and the JAX GPU stack; smoke test contracts aninteraction.CMapunrolling on the GPU throughcontract_tensor).examples/sudoku/results_*.json— raw metric histories of every reported run.Channel.double()is broken for plain array kraus boxes (Box.conjugate()swaps dom/cod; classical doubling andget_kraus().to_tensor()mis-assemble on unequal arities).examples/is outsidetestpaths, so CI does not run any of this. Every point ofTODO.mdis checked.🤖 Generated with Claude Code
https://claude.ai/code/session_01GRttRw1nfYw86K7h4bfMRx
Generated by Claude Code