Add triangular color code plugin with superdense memory circuit#658
Open
kvmto wants to merge 9 commits into
Open
Add triangular color code plugin with superdense memory circuit#658kvmto wants to merge 9 commits into
kvmto wants to merge 9 commits into
Conversation
Codes may declare record->detector feedback corrections as data via two new virtuals (get_inlined_feedback / get_observable_inlined_feedback, empty default = existing behavior); memory_circuit folds the declared records into its detector and observable definitions, so measurement schemes with readout byproducts get deterministic detectors through sample_memory_circuit without a physical correction gate. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: kvmto <kmato@nvidia.com>
…d_feedback The record->detector composition rule now lives in detector_error_model as a CSR layout builder; the memory_circuit kernel is a thin emitter walking the layout. Behavior is bit-identical; all suites pass unchanged. Signed-off-by: kvmto <kmato@nvidia.com>
…amed device helpers The kernel keeps its flat-matrix signature; all record-composition logic lives in reusable __qpu__ functions in device/inlined_feedback.h. The host CSR layout builder (build_inlined_feedback_layout) is retained for record-stream consumers and pinned to the kernel by an M2D conformance test Signed-off-by: kvmto <kmato@nvidia.com>
Signed-off-by: kvmto <kmato@nvidia.com>
Validate feedback matrices before conversion, clarify raw sampling semantics, reject unsupported qpp-cpu Python sampling, and expand detector/observable conformance coverage. Signed-off-by: kvmto <kmato@nvidia.com>
…ry circuit Registers the triangular color code as the Python plugin 'color_code' (geometry, CSS stabilizers/observables, patch kernels) and adds a superdense memory circuit for it: the paired-ancilla 8-CNOT-layer schedule with the measurement feedforward absorbed into explicit cudaq.detector / cudaq.logical_observable annotations. DEM extraction and detector-ordered sampling via cudaq.dem_from_kernel / cudaq.sample; validated against a reference stim construction (identical error mechanisms, both bases). Signed-off-by: kvmto <kmato@nvidia.com>
Signed-off-by: kvmto <kmato@nvidia.com>
with the structure of the existing code plugins; the plugin is used through the standard qec.sample_memory_circuit / dem_from_memory_circuit API. The geometry retains the pre-decoder mapping surface (CNN grid embedding, syndrome-to-grid indices, superdense plaquette labels) for upcoming work. Signed-off-by: kvmto <kmato@nvidia.com>
The registered stabilizer_round now implements the reference superdense CX schedule (captured host-built layers) with the readout byproduct handled via the code-declared inlined-feedback matrices instead of an in-circuit correction. The framework-path DEM matches the reference construction mechanism-for-mechanism (golden tests, both bases, exact probabilities). Signed-off-by: kvmto <kmato@nvidia.com>
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.
Description
Adds the triangular color code to CUDA-QX as a Python QEC code plugin. The registered
stabilizer_roundimplements a superdense (paired-ancilla) syndrome-extraction schedule that measures both stabilizer bases of every plaquette in a single depth-8 CNOT pass; the record-conditioned readout byproduct inherent to this scheme is handled through the code-declared inlined-feedback mechanism of #665 rather than by an in-circuit correction gate. The plugin runs end-to-end through the standard framework API (sample_memory_circuit,dem_from_memory_circuit), and the resulting detector error model is validated mechanism-for-mechanism against an independently constructed reference DEM.Depends on #665 (this branch contains its commits; review the top commit here). The feedback-declaration API (
get_inlined_feedback,get_observable_inlined_feedback_z/_x) is defined there.Design
ColorCodeGeometry— triangular color code with a rectangular-grid embedding (data-qubit grid, algorithmic plaquette generation, syndrome-to-grid mapping, superdense plaquette labeling), ported from an internal reference implementation. Retains the pre-decoder mapping surface (CNN grid embedding, syndrome-to-grid indices) for upcoming decoder work.z_side_data,superdense_schedule) — host-side construction of the per-round CNOT schedule from the geometry: 8 layers over a unified index space, with the ancilla-pair partition of each plaquette's support determined by plaquette weight and color.stabilizer_round, and the boundary-plaquette partition is color-dependent, i.e. not derivable from parity rows alone. The plugin therefore registers a@cudaq.kerneldefined in a factory that captures the host-built schedule; the fixed framework signature is unchanged and the captured lists survive the sub-kernel dispatch from the C++memory_circuit(multiple instances remain independent). Records are returned in[Z][X]order.F(S) = {a : |z_side(a) ∩ S| odd}: the detector matrix hasfb(j,k) = 1iffj,k < Pand plaquettek ∈ F(supp(plaquette j)); the Z-basis observable row is the indicator ofF(logical-operator support); the X basis declares none. Diagonal entries exploit the XOR multiset semantics ofcudaq::detector(a duplicated record cancels), which is what allows a detector to exclude its own previous-round record.__init__asserts the minimum data-qubit index is strictly increasing across grid-ordered plaquettes, which guarantees the framework's stabilizer re-sorting is the identity permutation (record k ↔ plaquette k).Validation
prep0/1/p/m) are noiseless-deterministic with correct logical readout for d=3 at 2 and 4 rounds; DEM extraction succeeds in both bases under two-qubit depolarizing noise; a decode smoke test shows strict logical-error reduction.Notes for reviewers
Follow-ups (out of scope here)
🤖 Generated with Claude Code