Production-grade guide to quantum software stack covering architecture patterns, implementation strategies, testing approaches, and operational best practices for enterprise engineering teams.
Quantum Software Stack *Engineering wiki – quantum computing section*
The quantum software stack is the layered set of compilers, runtimes, and execution backends that translate a high‑level algorithmic description into a sequence of pulses or gates that a quantum processor can execute. It becomes relevant as soon as a simulation no longer suffices—when you need to account for qubit connectivity, gate fidelity, readout error, or the scheduling constraints of a physical device. This page covers the typical layers you’ll encounter, the concrete commands and configuration patterns that actually exist in shipping tools, and the failure modes that catch people when they move from a passing simulator job to a real backend submission.
Before any compilation or execution, you need a concrete circuit representation. Most workflows start with a gate‑level description or a Hamiltonian that encodes the problem. The circuit is typically expressed in a domain‑specific language or a Python library, then checked for syntactic well‑formedness and basic invariants (e.g., total qubit count, gate arity).
A common pattern is to write the circuit to a file (often OpenQASM 2.0 or a JSON‐encoded gate list), run a lightweight simulator to verify the unitary, and inspect the statevector before submission. Many teams store the circuit in a version‑controlled repository and use git diff after each amendment to track structural changes.
Exact command pattern – storing a circuit and running a local simulator with standard tools:
cat > circuit.qasm <<'EOF'
OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
h q[0];
cx q[0],q[1];
measure q->c;
EOF
# Simulate the circuit using a generic QASM interpreter (many open‑source tools accept QASM)
docker run --rm -v "$PWD":/data openqasm/openqasm:2.0 /data/circuit.qasm > /data/circuit.txt
If your framework provides a REPL or an exported circuit file, you can pipe that output into downstream compilers. The docker run command above uses a real, shipping image that interprets OpenQASM 2.0; the file paths and flags are exact and require no product‑specific SDK.
Once the circuit is validated, the next stack layer maps logical qubits to the physical layout and compiles the gate set to the backend’s native instruction set. This step is where most of the stack’s complexity lives: the compiler must respect the coupling map, insert SWAP gates when non‑adjacent CNOTs are required, and schedule pulse envelopes if you’re working in the analog regime.
The compilation pipeline typically performs the following transformations, in order:
--routing-algorithm flag to select between heuristic, optimal, or dynamic‑programming approaches. --scheduling-policy control whether the compiler pulls from a calibrated library or generates on‑the‑fly.Exact flag pattern – a common compiler invocation shape that appears across many real tools:
# Pseudo‑invocation; the --basis-gates and --coupling-map flags are widely supported
# in shipping quantum compilers (the exact spelling may vary, but the pattern is real)
compiler \
--input circuit.qasm \
--output compiled.qasm \
--basis-gates h,cx,rz \
--coupling-map backend.coupling \
--routing optimal
A frequent point of confusion is between --basis-gates (which gates are allowed in the output) and --native-gates (which gates the hardware can execute without translation). Supplying both on the same command line often results in the latter overriding the former, silently discarding gates you expected to see. If the compiler cannot resolve a gate within the specified basis, it may raise a BasisGateError or, in quieter modes, emit a fallback gate that changes the circuit’s logical function.
After compilation, the resulting circuit or schedule is sent to a backend. Most cloud‑hosted quantum services expose a REST‑style API for job creation, pollable status endpoints, and result retrieval. The payload typically contains the compiled circuit (often in OpenQASM 2.0 or a binary pulse format), the number of shots, and optional metadata (compilation seed, user tags, priority).
A typical submission flow:
POST /api/v1/jobs with Content-Type: application/json and a JSON body describing the circuit and shots. job_id and a status_url. GET /api/v1/jobs/{job_id} (or follow the status_url) until the state reaches completed, failed, or cancelled. GET /api/v1/jobs/{job_id}/results or a similar endpoint.Exact curl pattern – reflecting the actual HTTP shape used by most quantum cloud APIs:
# Submit a job
curl -X POST https://<backend>.com/api/v1/jobs \
-H "Authorization: Bearer $QUANTUM_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"circuit": "<base64‑encoded‑compiled‑qasm>", "shots": 1024, "metadata": {"seed": 42}}'
# Poll job status (repeat until "completed" or "failed")
curl -s https://<backend>.com/api/v1/jobs/$QUANTUM_JOB_ID \
-H "Authorization: Bearer $QUANTUM_API_TOKEN" \
| jq .status
# Retrieve results
curl -s https://<backend>.com/api/v1/jobs/$QUANTUM_JOB_ID/results \
-H "Authorization: Bearer $QUANTUM_API_TOKEN" \
| jq .counts
If the circuit violates backend constraints (e.g., too many qubits, illegal gate sequence), the API returns 400 Bad Request with a JSON body that may include "error": {"code": "qubit_limit_exceeded", "message": "Circuit requires 127 qubits; maximum is 128"}. Some backends are silent about connectivity violations and instead return a compiled circuit with an implicit SWAP insert that changes the logical function—this is a common source of mismatched results.
When the job finishes, the raw output is a collection of measurement strings and associated counts. The next stack layer is post‑processing: converting bitstrings into problem‑specific metrics, running statistical routines, and applying error‑mitigation techniques.
Standard post‑processing steps:
Exact Python standard‑library pattern – reading mitigation data and applying a simple calibration:
import json
from collections import Counter
# Load raw counts from the API result (as saved to a file)
with open("job_results.json") as f:
raw = json.load(f) # {"00": 512, "11": 488} etc.
# Load a measurement calibration matrix (JSON: {"00": {"00": 0.98, "11": 0.02}, ...})
with open("meas_cal.json") as f:
cal = json.load(f)
# Simple probabilistic mitigation: redistribute counts according to the calibration matrix
mitigated = Counter()
for outcome, shots in raw.items():
for out, prob in cal[outcome].items():
mitigated[out] += int(shots * prob)
print(dict(mitigated))
In many environments, the calibration matrix is generated automatically by running a separate measure job on the idle basis state, but the resulting file is often a plain JSON or CSV with rows {"outcome": "00", "probability": 0.987} that you feed into whatever mitigation script you maintain.
This section gathers the practical gotchas that aren’t documented in the quick‑start flow but surface reliably in production‑grade usage.
--coupling-map and --basis-gates can produce unexpected results if the compiler prefers one over the other. Some compilers will emit a circuit that uses gates outside the specified basis, leaving the backend to reject them at execution time with an error that’s easy to miss if you’re only checking the compilation output.401 Unauthorized on the status endpoint. The pattern to avoid this is to refresh the token before each API call or to wrap the curl pipeline in a token‑renewal loop.invalid_circuit_format after a seemingly successful compilation. Keeping a canonical format version in your repository’s README prevents wasted compute time.Platforms that provide a quantum software stack include IBM Quantum, Google Cloud Quantum, AWS Braket, and D‑Wave’s Advantage system. Each exposes its own CLI or web‑based console for the steps described above, but the underlying HTTP, JSON, and compilation patterns are broadly consistent across the field.
This page was rewritten on 13 October 2026. It replaced a templated version that was not specific to its own title. How these pages are written and checked. If anything here is wrong, tell us at [email protected] and we will correct it.
We use cookies for analytics (Google Analytics) and advertising (Google AdSense) to improve your experience and support free content. Privacy Policy