45 releases

0.15.0 Jun 14, 2021
0.14.0 Feb 18, 2021
0.13.1 Oct 8, 2020
0.13.0 Jun 9, 2020
0.1.8 Jul 18, 2019

#5 in Emulators

Download history 44/week @ 2021-03-31 44/week @ 2021-04-07 61/week @ 2021-04-14 92/week @ 2021-04-21 18/week @ 2021-04-28 61/week @ 2021-05-12 3/week @ 2021-05-19 1/week @ 2021-06-02 57/week @ 2021-06-09 3/week @ 2021-06-16 5/week @ 2021-06-23 8/week @ 2021-06-30 180/week @ 2021-07-14

165 downloads per month

MIT license

350KB
9K SLoC

RustQIP

Quantum Computing library leveraging graph building to build efficient quantum circuit simulations.

qip on crates.io qip docs unsafe forbidden

See all the examples in the examples directory of the Github repository.

Example (CSWAP)

Here's an example of a small circuit where two groups of qubits are swapped conditioned on a third. This circuit is very small, only three operations plus a measurement, so the boilerplate can look quite large in comparison, but that setup provides the ability to construct circuits easily and safely when they do get larger. Furthermore there are tools in the library which can clean up this code significantly. See the docs.

use qip::*;

// Setup inputs
let mut b = OpBuilder::new();
let q = b.qubit();
let ra = b.register(3)?;
let rb = b.register(3)?;

// We will want to feed in some inputs later.
let ha = ra.handle();
let hb = rb.handle();

// Define circuit
let q = b.hadamard(q);

let (q, _, _) = b.cswap(q, ra, rb)?;
let q = b.hadamard(q);

let (q, m1) = b.measure(q);

// Print circuit diagram
qip::run_debug(&q)?;

// Initialize ra to |0> and rb to |1> using their handles.
// Make an initial state: |0,000,001>
let initial_state = [ha.make_init_from_index(0)?,
                     hb.make_init_from_index(1)?];

// Run circuit
let (_, measured) = run_local_with_init::<f64>(&q, &initial_state)?;

println!("{:?}", measured.get_measurement(&m1));

Dependencies

~0.6–1MB
~19K SLoC