This roadmap organizes the development of Weave around three auditing perspectives, followed by the integration work needed to unify the GUI editor with the simulation backend.
The highest priority. Every circuit Weave generates must faithfully implement the intended QEC protocol.
X-stabilizer gate sequence: Verified algebraically correct (H·H = I cancels between consecutive CNOTs). Optimized from per-CNOTH-CNOT-Hwrapping to singleH-CNOT-...-CNOT-Hbracket per check.Initialization and measurement bases: VerifiedR/Mfor z_memory andRX/MXfor x_memory match the intended bases.Detector record indexing: Allstim.target_recoffsets audited and verified correct for both experiments — first-round, comparison, and final detectors.: Fixed critical bug where logical operators were not in a symplectic basis for k > 1 codes. Added symplectic Gram-Schmidt pairing.OBSERVABLE_INCLUDEtargets: Fixed incompatibility with ldpc 2.x sparse returns.find_logicals()sparse matrix crashCrossing noise: Verified that qubit pairs in each crossing correctly correspond to Tanner graph edge endpoints.Circuit noise placement: Verified that post-CNOTPAULI_CHANNEL_2matches standard Stim conventions.
- TICK markers: The circuit does not use Stim
TICKinstructions to delineate time steps. Without TICKs, Stim cannot distinguish parallel from sequential gates, which affects error analysis, circuit visualization, and the detector error model structure. Adding TICKs requires defining a gate scheduling strategy. - CNOT scheduling: The current circuit applies all Z-check CNOTs sequentially, then all X-check CNOTs sequentially. For HP codes, gate ordering can introduce hook errors that reduce the effective distance. Investigate layer-by-layer or greedy scheduling to parallelize gates while preserving code distance.
- Idle noise: Qubits not participating in a gate during a given time step should still experience decoherence (
DEPOLARIZE1orPAULI_CHANNEL_1). Currently, single-qubit noise is applied once per round after all gates, regardless of how many time steps a qubit was idle. Requires TICK-based scheduling first.
Eager circuit generation:CSSCode.circuitis now a lazy property. Circuit is only generated on first access;embed()invalidates the cache and triggers regeneration on next access. No more double-build.Stale docstrings:HypergraphProductCodedocstring updated to reflectH1/H2matrix parameters.: Fixed to handle_reorder_matrixassumptionr1 > n1by iterating up tomax(n1, r1)instead of onlyn1.: ReplacedNoiseModeltype checknp.issubdtype(type(param), np.number)withisinstance(param, (int, float)). Changed fromasserttoraise ValueErrorfor proper error handling.GUI BFS queue: Replacedlist.pop(0)withcollections.deque.popleft()inCanvas._detect_connected_component.Type annotations: Migrated all source files fromtyping.List,typing.Tuple,typing.Optional,typing.Unionto built-in generics (list,tuple,X | None,X | Y).Build system: Migrated frompoetry-coretohatchlingas build backend. Moved test dependencies to[project.optional-dependencies].Testing coverage: Expanded from 30 to 109 tests (7 files). New coverage includes:- Steane code [[7,1,3]] circuit correctness (noiseless detectors, noisy DEM, logical validity).
- Lazy circuit generation and invalidation behavior.
- CSS condition violation detection.
- NoiseModel edge cases (zero, int input, wrong lengths for all channels).
- Code distance computation, asymmetric HP codes, reordering preservation of CSS condition.
Torus warning: Replacedprint()warning withwarnings.warn().
- Sparse matrices:
pcm.hypergraph_productuses dense NumPy arrays andnp.kron. For larger codes, switch toscipy.sparsefor the Kronecker products and parity-check storage.
- Crossing detection:
find_edge_crossingsis O(E²). For large Tanner graphs this becomes a bottleneck. Consider a sweep-line algorithm or spatial indexing (R-tree). - Circuit construction: Building Stim circuits by appending instruction-by-instruction is slow for large codes. Consider building the circuit from a string template or using Stim's
CircuitRepeatBlock.
The treatment of Tanner graph edge crossings as a source of correlated noise is the distinguishing feature of Weave. Directions to strengthen this:
- Parameterized crossing models: Allow different noise channels per crossing (e.g., weighted by geometric distance between the crossing qubits, or by the angle of intersection).
- Crossing-aware decoding: Feed crossing information into the decoder's error model so that belief propagation or MWPM can account for correlated errors.
- Embedding optimization: Implement heuristics (e.g., simulated annealing on node positions) to minimize the crossing number, directly reducing the code's effective noise floor.
- Distance-based crosstalk: Noise between qubit pairs as a continuous function of their Euclidean distance in the embedding. Closer qubits experience stronger correlated noise regardless of whether their edges cross. Could use an inverse-power-law or exponential decay model.
- Edge-length amplitude damping: Noise on each edge proportional to its geometric length in the embedding, modeling signal attenuation over longer physical connections. Longer wires in the layout incur more decoherence.
- Coherent errors: Stim is a Clifford simulator and cannot natively model coherent rotations. To support coherent errors, integrate with a density-matrix or state-vector simulator (e.g., Qiskit Aer, Cirq) for small codes, or develop a Pauli twirling approximation layer.
- Leakage: Model leakage as an additional qubit state. This requires extending the noise model and potentially the circuit representation beyond what Stim supports natively. One approach: a hybrid simulator that tracks leaked qubits separately.
- Non-Pauli correlated noise: Extend
PAULI_CHANNEL_2to arbitrary two-qubit channels via process matrices, then twirl to Pauli for Stim compatibility.
- Surface embeddings in the GUI: The
SurfaceABC andTorusimplementation already exist inweave/surface/but are not connected to the GUI. Steps:- Add a surface selector to the GUI (plane, torus, Klein bottle, genus-g surface).
- Replace the flat ℝ² canvas with a surface-aware coordinate system — for the torus, this means periodic boundary conditions on the canvas edges.
- For non-flat surfaces, add a 3D viewport (using Qt3D or VTK) alongside the 2D projection.
- Biplanar / multi-layer layouts: Some code families (e.g., bivariate bicycle codes) are naturally embedded on two planes connected by inter-layer edges. Support this as a special case of a product surface.
- Arbitrary parametric surfaces: Allow users to define a surface via a parametric map
(u, v) → (x, y, z)and metric tensor, then use geodesic calculations for edge routing and crossing detection on the surface.
- Chain complex framework: Generalize the code hierarchy from "two parity-check matrices HX, HZ" to a chain complex
C_n → C_{n-1} → ... → C_0with boundary maps. CSS codes are then=2case. This enables:- Higher-dimensional codes (e.g., 3D toric codes, fracton models).
- Homological product codes as a generalization of hypergraph products.
- A unified interface:
ChainComplexwith methodsboundary(i),coboundary(i),homology(i).
- Fiber bundles: Twisted products where the fiber varies over the base — models codes like the Hastings-Haah fiber bundle codes. Requires:
- A
FiberBundleclass that takes a base complex and a fiber complex with a twist (automorphism of the fiber over each edge of the base). - Circuit generation that respects the bundle structure.
- A
Currently the GUI (weave/gui/) and the simulation logic (weave/codes/, weave/util/) are completely decoupled. The canvas stores nodes and edges as plain dicts; the simulation expects NumPy parity-check matrices. To unify them:
-
Canvas → Code extraction: Implement
Canvas.to_css_code()that:- Reads the quantum nodes (qubits, Z-stabilizers, X-stabilizers) and edges.
- Constructs HX and HZ matrices from the Tanner graph adjacency.
- Extracts node positions as the embedding for crossing detection.
- Returns a
CSSCodeinstance ready for simulation.
-
Code → Canvas loading: Implement
Canvas.from_css_code(code)that:- Takes a
CSSCode(orHypergraphProductCode) and populates the canvas with its Tanner graph. - Uses the code's embedding positions (from
embed()) to place nodes.
- Takes a
-
In-GUI simulation: Add a "Simulate" action to the GUI menu that:
- Extracts the code from the canvas.
- Runs a Sinter/Stim simulation with user-specified noise parameters.
- Displays results (logical error rate, decoding success) in a panel or dialog.
-
Live feedback: As the user drags nodes, update the crossing count in real time (already partially implemented) and optionally show the estimated impact on logical error rate.
We tackle these in dependency order:
- Physical correctness audit (Phase I) — must come first; everything else builds on a correct foundation.
- Bug fixes and modernization (Phase II) — clean up the codebase so extensions are built on solid ground.
- GUI ↔ Simulation bridge (Phase III, item 4) — the most immediate user-facing improvement.
- Topological generalization (Phase III) — surface embeddings in the GUI, then 3D.
- Chain complexes / fiber bundles (Phase III) — the deep algebraic generalization.
- Beyond Pauli noise (Phase III) — requires external simulator integration, lowest priority.