QuantumKit
QuantumKit

Swift · Metal · Apple silicon

Quantum circuits that run in your app process.

Statevector and density-matrix engines on the GPU, CPU when there is no Metal. No Python. No cloud backend. Version 1.0.0.

31 qubits, Metal statevector
0 network calls at run time
1 product: QuantumKit

Install

macOS 13+, iOS 16+. Xcode: File → Add Package Dependencies… → the URL below.

dependencies: [
    .package(url: "https://github.com/acemoglu/QuantumKit.git", from: "1.0.0")
]
import QuantumKit

var circuit = try QuantumCircuit(qubitCount: 2)
try circuit.h(0)
try circuit.cx(0, 1)
try circuit.measure(0)
try circuit.measure(1)

let backend = try QuantumBackendFactory.makeRecommended(circuit: circuit)
let result = try backend.run(
    circuit: circuit,
    options: QuantumRunOptions(seed: 1, shots: 1024)
)
print(result.bitstringCounts ?? [:])

Until a 1.0.0 git tag exists, add the package from main.

How it picks a path

QuantumBackendFactory.makeRecommended uses Metal when a GPU is there, otherwise CPU. Noiseless circuits with trailing measurements evolve once, then sample — time follows width and gates, not shot count. OpenQASM 2 and a core OpenQASM 3 subset import into the same IR.

Width limits

PathMax qubits
Metal statevector31
CPU statevector16
Metal density matrix14
CPU density matrix8

n = 30 is about 8 GB of amplitude buffers. Metal engines use Float32 and renormalize every 50 gates by default. First Metal run at a width compiles shaders — time the next one.

The app

Visual circuit editor for Mac, iPhone, and iPad. Drag gates onto wires or write OpenQASM, then run locally on this library. No account, login, or network is required.

  1. Open Samples
  2. Select Bell State (or any other sample)
  3. Tap or click Run. A measurement histogram should appear (for Bell, roughly 00 and 11).

You can also write OpenQASM in the Code tab, or build a circuit on the Circuit canvas (tap a gate, then a qubit), then Run.

Download on the App Store