rqism

Crates.iorqism
lib.rsrqism
version0.4.1
created_at2025-05-22 09:29:24.410689+00
updated_at2025-07-30 14:19:54.518292+00
descriptionA multi-backend quantum circuit simulator
homepage
repositoryhttps://codeberg.org/0x177/rqism
max_upload_size
id1684945
size196,975
Kamal Al-Ameri (0x177)

documentation

README

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:

output

performance

tested on my i7-7700HQ

  1. 20 qubit linear-depth GHZ state on the statevector simulator takes an average of 44 nanoseconds to run.
  2. 1000 qubit linear-depth GHZ state on the stabilizer simulator takes an average of 30 ms to run.
Commit count: 0

cargo fmt