Skip to content

Stabilizer ​

A 60-qubit random Clifford circuit, far beyond any dense statevector.

py
"""A 60-qubit Clifford circuit, which only the stabilizer engine can run."""

import random

from menos import Circuit, Opcode, RunOptions, run

n, depth = 60, 12
rng = random.Random(5)
circuit = Circuit(n, n)
for _ in range(depth):
    for q in range(n):
        circuit.append(rng.choice([Opcode.H, Opcode.S, Opcode.X, Opcode.Z]), [q])
    order = list(range(n))
    rng.shuffle(order)
    for i in range(0, n - 1, 2):
        circuit.append(Opcode.CX, [order[i], order[i + 1]])
for q in range(n):
    circuit.append_measure(q, q)

options = RunOptions()
options.shots = 16
options.seed = 1
result = run(circuit, options)

report = result.explain()
strategy = next(line for line in report.splitlines() if line.startswith("strategy"))
print(strategy)
print("distinct outcomes in 16 shots:", len(result.counts))

assert "direct_stabilizer" in strategy
assert sum(result.counts.values()) == 16
assert result.exact

Output ​

text
strategy   direct_stabilizer (exact)
distinct outcomes in 16 shots: 16

Sixty qubits would need 16 · 2⁶⁰ bytes as a dense state. The stabilizer engine needs kilobytes, and the dense and MPS engines are both infeasible here, so it is the only candidate. A random Clifford circuit this deep spreads its outcomes widely, so 16 shots give 16 different results.

See also ​

Stabilizer

Released under the Apache-2.0 license. GitHub · PyPI