8 releases
| 0.4.1 | Jul 30, 2025 |
|---|---|
| 0.4.0 | Jul 30, 2025 |
| 0.3.7 | Jun 18, 2025 |
| 0.3.3 | May 30, 2025 |
#104 in Simulation
125KB
3.5K
SLoC
rqism
The manifestation of a dream where you do not have to install multiple scientific libraries and deal with python dependency hell to implement a quantum algorithm.
statuses of simulators
| statevector | stabilizer | MPS | |
|---|---|---|---|
| single qubit gates | ✅ | ✅ | ✅ |
| multi qubti gates | ✅ | ✅ | ❌ |
| measurement | ✅ | ✅ | ✅ |
| conditional instructions | ✅ | ✅ | ✅ |
| optimization | ✅* | ✅* | ❌ |
| T1 amplitude damping | ✅ | ❓ | ✅ |
| noisey measurement | ✅ | ✅ | ✅ |
| depolarizing noise | ✅ | ✅ | ✅ |
| testing | ✅ | ✅ | ❌* |
✅: implemented
❌: not implemented
❓: as far as i know, this type of simulator is not supposed to do that
-
MPS limitations are due to a lack of resources
-
the only single-threaded stabilizer operation is random measurement (which is O(n^2)), single-threaded due to usage of unsafe raw pointers to work around the borrow checker. multi-threading is possible, but will require finding a more proper solution to mutation limitations
-
the statevector is sparse, parallelized, and implements some common gates as direct statevector modification, but it is still more suited for the gpu. however, i am not in the mood for compute shaders :) also, note that lazily evalutated kronecker products are a horrible idea (9 qubit QFT in 67 seconds instead of half a second)
usage
bell state using both stabilizer and statevector:
use rqism::prelude::*;
fn main() {
let circuit = Circuit {
ins: vec![
Instruction::hadamard(0),
Instruction::cnot([0, 1]),
Instruction::MeasureState,
],
n: 2,
};
let machine = QuantumStateVector::new(2);
let counts = machine.get_counts(&circuit, 1000);
println!("State vecotr:");
counts.print_psi();
let machine = Stabilizer::new(2);
println!();
let counts = machine.get_counts(&circuit, 1000);
println!("Stabilizer:");
counts.print_psi();
}
output:

performance
tested on my i7-7700HQ
- 20 qubit linear-depth GHZ state on the statevector simulator takes an average of 44 nanoseconds to run.
- 1000 qubit linear-depth GHZ state on the stabilizer simulator takes an average of 30 ms to run.
Dependencies
~6MB
~117K SLoC