Skip to content

0xhokugava/quantum_lab

Repository files navigation

Quantum Lab

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.

Features

  • 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

Command-line interface

Install qlab binary from the repository root:

cargo install --path .

Run a custom circuit:

qlab run --qubits 2 --gate h:0 --gate cnot:0,1

Output:

🐈 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 --help

Show available verification commands:

qlab verify --help

During development, run the current source without reinstalling the binary:

cargo run --bin qlab -- run --qubits 2 --gate h:0 --gate cnot:0,1

To update an already installed local binary:

cargo install --path . --force

Circuit API

let 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.

Development

Run the test suite:

cargo test

Run benchmarks:

cargo bench

Format the project:

cargo fmt

Documentation

License

Quantum Lab is licensed under the GNU General Public License v3.0 or later.

About

Modular quantum computing simulator built with Rust.

Topics

Resources

License

Contributing

Stars

14 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors