Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/itsubaki/qasm-playground/llms.txt

Use this file to discover all available pages before exploring further.

The playground runs your OpenQASM programs on a statevector simulator. The simulator tracks the full quantum state, which grows exponentially with qubit count. To keep simulation fast and deterministic in the browser, the playground caps the total number of qubits at 12.

Maximum qubit count

You can declare up to 12 qubits across all registers in a single program. Registers are counted by their declared size, so qubit[4] r and qubit[4] s and qubit a together use 9 qubits.
qubit[4] r;   // 4 qubits
qubit[4] s;   // 4 qubits
qubit a;      // 1 qubit — total: 9 qubits, within the limit
If your program declares more than 12 qubits, the simulator returns an error and no results are shown in the output panel.
Programs that exceed 12 qubits will fail at simulation time. The error appears in the results panel; the editor does not highlight the violation before you run the code.

Bit string ordering

Measurement results are displayed as bit strings in declaration order, which is MSB-first. The first qubit you declare corresponds to the leftmost (most significant) bit in the output. For example, in the Bell state program:
qubit[2] q;
reset q;

h q[0];
cx q[0], q[1];
The output bit strings are 00 and 11, where the left digit represents q[0] and the right digit represents q[1]. When registers are declared separately, the declaration order determines the concatenation order in the output. In Shor’s algorithm:
qubit[3] q;
qubit[4] a;
A measured bit string might read as 7 digits: 3 bits from q followed by 4 bits from a.

How qubit count affects simulation cost

The statevector for n qubits requires 2^n complex amplitudes. Each additional qubit doubles memory usage and computation time:
QubitsState vector size
12 amplitudes
416 amplitudes
8256 amplitudes
101,024 amplitudes
124,096 amplitudes
Programs near the 12-qubit limit will noticeably slower to simulate than programs using 4–6 qubits.

Additional limitations

Beyond the qubit count, the underlying itsubaki/qasm simulator has known constraints and open issues that may affect certain programs. For an up-to-date list of limitations, edge cases, and known bugs, check the GitHub issues for the simulator.
If your program runs within the 12-qubit limit but still produces unexpected results or an error, the cause may be a known simulator issue. Check the GitHub issues before reporting a new bug.

Tips for working within the limit

Split large algorithms into smaller sub-circuits. If you are exploring a 16-qubit algorithm, isolate one sub-routine (for example, just the QFT block) and verify it separately with fewer qubits. Reuse qubits with reset. Ancilla qubits can be reset after use and repurposed for a subsequent part of the circuit. The reset instruction reinitializes a qubit to |0⟩ without adding a new qubit to the count.
qubit a;       // ancilla

// first use
x a;
cx a, q[0];
reset a;       // clean up ancilla

// second use — same qubit, no extra cost
h a;
cx a, q[1];
Use the built-in examples as size references. The examples bundled with the playground are all verified to run within the 12-qubit limit. Quantum Phase Estimation (Rz(pi/3)) uses 8 qubits; Grover’s Algorithm uses 9; Quantum Counting uses 12, which is the maximum. Prefer parameterized gates over unrolled circuits. Defining gates and subroutines keeps programs readable but does not reduce qubit usage — the qubit count is determined by declarations, not by how many gates you apply.

Build docs developers (and LLMs) love