Advanced Rust quantum computer simulator

Overview

quantum Build Status License

Advanced Rust quantum computer simulator.

Motivation

Quantum is a quantum computer simulator written with the following design goals in mind:

  1. Utility: we can simulate a 5-qubit register, enough to run interesting algorithms.

  2. Efficiency: we implement all important operations from scratch using primitives

  3. Educational Value: the documentation is a prose description of how to implement a quantum computer in Rust.

  4. Correctness: it's entirely written in safe Rust with well-defined states.

A good place to start reading the theory behind this is the Wikipedia article, and you can follow the documentation for our implementations of gates, kets, common operations, and quantum registers.

Usage

# Cargo.toml

[dependencies]
quantum = "0.1.3"
// main.rs

use computer::QuantumComputer;
use algorithms::deutsch;
use gates;

// Let's do something simple of a 3-qubit system.
let mut c1 = QuantumComputer::new(3);
c1.initialize(5);
c1.apply(gates::identity(3));
c1.collapse();
assert_eq!(5, c1.value());

// Now let's perform a coin flip using the Hadamard transform.
let mut c2 = QuantumComputer::new(1);
c2.initialize(0);
c2.apply(gates::hadamard(1));
c2.collapse();
let result = if 1 == c2.value() { "heads" } else { "tails" };
println!("coin flip: {}", result);

// Finally let's determine whether f: {0, 1} -> {0, 1} is constant
// or balanced using Deutsch's algorithm.
// (see http://physics.stackexchange.com/q/3400)
let mut c3 = QuantumComputer::new(2);
c3.initialize(1);
c3.apply(gates::hadamard(2));
c3.apply(deutsch::deutsch_gate(f));
c3.apply(gates::hadamard(2));
c3.collapse();
let result = if 1 == c3.value() { "constant" } else { "balanced" };
println!("f is: {}", result);

Gates

We provide the following quantum gates:

  • Identity
  • Hadamard
  • Pauli-X
  • Pauli-Y
  • Pauli-Z
  • Phase Shifts
  • Swap
  • Sqrt(Swap)
  • Controlled Not
  • General Controlled-U
  • Controlled-X
  • Controlled-Y
  • Controlled-Z
  • Toffoli
  • Fredkin
  • Quantum Fourier Transform

Contributing

  • Create or take ownership of an issue
  • Fork development branch
  • Write code and tests
  • rust test
  • Commit with a reasonable message and push
  • Submit a pull request
Comments
  • Should allow gate transformations

    Should allow gate transformations

    We need to allow, e.g. a reversed control-not gate.

    At the moment the gates::* implementations are set to use, e.g. the first qubit as a control.

    The solution is to allow gate transformations which will do things like permute underlying matrix rows/columns. Then we could change the interfaces to accepting parameters.

    enhancement 
    opened by beneills 2
  • Cannot be run as an executable

    Cannot be run as an executable

    End users should be able to run this.

    The solution is to package a thin binary, which:

    • accepts a script as input
    • which is in some common language, like IBM's
    • reads this line-by-line and dispatches equivalent library calls
    enhancement 
    opened by beneills 2
  • Could you publish the latest library please

    Could you publish the latest library please

    I am getting the following error:

    Updating registry `https://github.com/rust-lang/crates.io-index`
    error: no matching version `^0.1.3` found for package `quantum` (required by `quantum`)
    location searched: registry `https://github.com/rust-lang/crates.io-index`
    versions found: 0.1.2, 0.1.0
    

    Thank you & BR,

    Maciej

    opened by literadix 0
  • Unitary matrices: a possible implementation.

    Unitary matrices: a possible implementation.

    Hi!

    I saw that your project needs a check for the input matrix to be unitary, in some of its parts. I came across the nalgebra crate, which provides a framework for linear algebra. In particular, they provide a nice trick to avoid checks for unity, by exposing a Unit wrapper.

    Hopefully, may this help you in your project!

    Best,

    Filippo.

    opened by filippodebortoli 0
  • Should have benchmarks

    Should have benchmarks

    We should add some benchmarking using the best-practice Rust solution.

    This will allow us to:

    • measure current performance
    • stop us regressing performance
    • justify our README claim of efficiency
    enhancement 
    opened by beneills 0
Owner
Ben Eills
Software Engineer, Oxford Maths, founder of CoderAudit, worked at IBM
Ben Eills
RailCar: Rust implementation of the Open Containers Initiative oci-runtime

railcar - rust implementation of the oci-runtime spec What is railcar? railcar is a rust implementation of the opencontainers initiative's runtime spe

Oracle 1.1k Dec 21, 2022
Rust bindings for the unicorn CPU emulator

unicorn-rs THIS PACKAGE IS DEPRECATED AND NO LONGER MAINTAINED. Rust bindings are now included with unicorn and will be maintained there from now on.

null 129 Oct 10, 2022
Rust API to the OS X Hypervisor framework for hardware-accelerated virtualization

hypervisor-rs hypervisor is a Rust library that taps into functionality that enables hardware-accelerated execution of virtual machines on OS X. It bi

Saurav Sachidanand 57 Dec 8, 2022
StarWM is an extensible window manager written in Rust.

StarWM is an extensible, floating and tiling, X window manager for Linux-based operating systems written in Rust.

StarWM 30 Dec 9, 2022
An LC-3 virtual machine written in Rust for learning purposes.

LC-3 written in Rust An LC-3 virtual machine written in Rust for learning purposes.

Rodrigo Araújo 30 Dec 11, 2022
Revolutionary Machine (revm) is a fast Ethereum virtual machine written in rust.

revm - Revolutionary Machine Is Rust Ethereum Virtual Machine with great name that is focused on speed and simplicity.

null 513 Dec 31, 2022
Dragonball-sandbox is a collection of Rust crates to help build custom Virtual Machine Monitors and hypervisors

Dragonball-sandbox is a collection of Rust crates to help build custom Virtual Machine Monitors and hypervisors. The crates here are considered to be the downstream of rust-vmm.

OpenAnolis Community 62 Dec 30, 2022
A toy Cairo VM implementation in Rust

oriac A toy Cairo VM implementation in Rust This is a toy implementation of the Cairo VM I'm building for learning purposes. There's no guarantee on w

Jonathan LEI 57 Nov 23, 2022
A Rust implementation of the Lox programming language. Based on clox, the bytecode virtual machine.

A Rust implementation of the Lox programming language. Based on clox, the bytecode virtual machine.

Diego Freijo 23 Dec 26, 2022
BM - a basic virtual machine written in rust

A basic virtual machine implementation with it's own binary format and assembly, as a learning experience.

KaviiSuri 1 May 8, 2022
Aftermath - a high-performance JVM for the TapVM framework written in the Rust

Aftermath Welcome to the source, my friend! Note -> This README is targetted towards users, not contributors. Please read the docs present at docs/for

null 6 Aug 1, 2022
LC3 Virtual Machine written in Rust 🦀

LC3 - Emulator LC3-rust is a virtual machine for the Little Computer 3 architecture, written using the Rust programming language. The VM has been writ

Gabriele Pappalardo 2 Oct 25, 2022
Advanced Rust quantum computer simulator

quantum Advanced Rust quantum computer simulator. Motivation Quantum is a quantum computer simulator written with the following design goals in mind:

Ben Eills 215 Jan 1, 2023
Damavand is a quantum circuit simulator. It can run on laptops or High Performance Computing architectures, such CPU distributed architectures or multi GPU distributed architectures.

Damavand is a quantum circuit simulator. It can run on laptops or High Performance Computing architectures, such CPU distributed architectures or multi GPU distributed architectures.

MichelNowak 0 Mar 29, 2022
Damavand is a quantum circuit simulator. It can run on laptops or High Performance Computing architectures, such CPU distributed architectures or multi GPU distributed architectures.

Damavand is a code that simulates quantum circuits. In order to learn more about damavand, refer to the documentation. Development status Core feature

prevision.io 6 Mar 29, 2022
A simple tomasulo simulator written in Rust for the course Computer Architecture.

Tomasulo Simulator This is a Tomasulo simulator written in Rust for the course Computer Architecture. Two Demo programs are tested in the simulator, w

GZTime 5 Dec 28, 2022
Simulator for the pioneering TX-2 computer

TX-2 Simulator We are trying to create a simulator for Lincoln Lab's historic TX-2 computer. Notably, this is the computer on which Ivan Sutherland's

TX-2 Simulator Project 10 Dec 6, 2022
⚛ Quantum computing crate for Rust programming language.

?? Quantum crab Quantum crab is a quantum computing crate for Rust programming language. use quantum_crab::{ backend::Backend, quantum_circuit

Adi Salimgereyev 4 May 22, 2023
PyQIR is a set of APIs for generating, parsing, and evaluating Quantum Intermediate Representation (QIR).

PyQIR PyQIR is a set of APIs for generating, parsing, and evaluating Quantum Intermediate Representation (QIR). It consists of the following component

QIR Alliance 37 Dec 31, 2022
The Devils' Programming Language (Quantum Programming Language)

devilslang has roots in Scheme and ML-flavored languages: it's the culmination of everything I expect from a programming language, including the desire to keep everything as minimalistic and concise as possible. At its core, devilslang is lambda-calculus with pattern-matching, structural types, fiber-based concurrency, and syntactic extension.

Devils' Language 2 Aug 26, 2022