Modular quantum state-vector simulator and circuit execution toolkit focuses on matrix-free state-vector execution, circuit correctness, explicit qubit-ordering conventions and a small understandable API for building and running quantum circuits.
- Matrix-free in-place state-vector execution
- Generic local
k-qubit gate application - Single-qubit gates: X, Y, Z, H, S, T, I
- Two-qubit gates: CNOT and CZ
- Multi-controlled gates: MCX and MCZ
- High-level Circuit API
- Dirac notation output
- Shot-based measurement simulation
- Deutsch, Deutsch–Jozsa and Grover search demos
- Dense matrix baseline for correctness verification
- Criterion benchmarks
- Command-line interface for custom circuits, demos and verification
Install qlab binary from the repository root:
cargo install --path .Run a custom circuit:
qlab run --qubits 2 --gate h:0 --gate cnot:0,1Output:
🐈 Quantum Lab 🐈⬛
Qubits: 2, Gates: [H(0), Cnot { control: 0, target: 1 }]
State: (0.707 + 0.000i)|00> + (0.707 + 0.000i)|11>
Supported gate syntax:
h:0
x:0
y:0
z:0
s:0
t:0
cnot:0,1
cz:0,1
mcx:0,1:2
mcz:0,1:2
For multi-controlled gates, the syntax is:
mcx:controls:target
mcz:controls:target
Show available algorithm demos:
qlab demo --helpShow available verification commands:
qlab verify --helpDuring development, run the current source without reinstalling the binary:
cargo run --bin qlab -- run --qubits 2 --gate h:0 --gate cnot:0,1To update an already installed local binary:
cargo install --path . --forcelet mut circuit = Circuit::new(2);
circuit.h(0).cnot(0, 1);
let state = circuit.run();
The public convention for controlled gates is:
cnot(control, target)
cz(control, target)
mcx(controls, target)
mcz(controls, target)
Qubit q0 is the least significant bit and appears as the rightmost bit in printed basis states.
Run the test suite:
cargo testRun benchmarks:
cargo benchFormat the project:
cargo fmtQuantum Lab is licensed under the GNU General Public License v3.0 or later.