Building stim circuits

From AndyLiuin/QEC-Autoresearch-Skills · View interactive version

Building stim circuits is an AI agent skill from the GitHub repository AndyLiuin/QEC-Autoresearch-Skills. Provides guidance for constructing, validating, and exporting stabilizer QEC circuits with Stim when studying memory experiments, syndrome extraction, or detector-model workflows.

How to use this skill

Skill file

Building Stim Circuits

What This Skill Is For

Use this skill when a task needs a concrete stabilizer-circuit workflow:

When To Use It Versus Alternatives

Use this skill when the workload is naturally low-level and Stim is the right primary backend.

Prefer future surface-sim workflows when the task is centered on structured logical-gate sequences, layout-aware surface-code operations, or user-facing logical-circuit construction rather than low-level circuit inspection.

Do not treat Stim .dem files as the universal internal representation. Use them as one artifact family among several.

Required Artifacts And Assumptions

Expected inputs:

Expected outputs:

Assumptions to make explicit:

Standard Workflow Checklist

  1. Read CODE0 and confirm the current workload and backend assumptions.
  2. Check CODE0 for the intended tool surface.
  3. Identify whether the task is circuit construction, detector-model compilation, sampling, or inspection.
  4. Classify the requested noise model before choosing parameters: code-capacity-approx, phenomenological, or circuit-level.
  5. Keep the output in the shared artifact families instead of returning large inline payloads.
  6. Record any backend-specific assumption that would affect later decoding or benchmarking.

Validation Loop

Before closing work:

  1. confirm the circuit spec is explicit enough to reproduce,
  2. confirm the detector-model or trajectory export path is recorded,
  3. confirm the chosen noise profile is recorded and matches the actual Stim parameters used,
  4. confirm backend-specific assumptions are written into project state or log,
  5. confirm the result is described as a Stim artifact, not a repo-wide canonical IR.

Common Issues And Fixes

Implicit decoder assumptions

Problem: a circuit is generated as if any decoder can consume its derived detector model.

Fix: record whether graphlike structure, observable ordering, or trajectory-level data is required by the downstream decoder lane.

Wrong noise-model abstraction

Problem: a request for code-capacity, phenomenological, or circuit-level noise is translated into whichever Stim knobs happen to be convenient.

Fix: map the requested study type onto an explicit profile first. Use CODE0 and record when the current generated-circuit lane is only an approximation, especially for strict code-capacity studies or variable-latency idling.

Tool-specific leakage

Problem: the workflow starts describing the project in terms of Stim file formats only.

Fix: map the output back to shared artifact families like CircuitBundle and DetectorModelBundle.

Validation drift

Problem: a circuit exists on disk, but there is no record of what was checked.

Fix: update CODE0 or registry metadata with the validation status and remaining caveats.

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.