Skip to content

Latest commit

 

History

History
86 lines (60 loc) · 3.34 KB

README.md

File metadata and controls

86 lines (60 loc) · 3.34 KB

Q-Sylvan

License CI testing

Q-Sylvan extends the parallel decision diagram library Sylvan (v1.8.0) with QMDDs (i.e. multiplicative AADDs), as well as functionality to simulate quantum circuits. This is currently still a beta version.

Installation

Dependencies

Q-Sylvan requires the following libraries: popt, GMP, MPFR and MPC. On Ubuntu it should be possible to install these with

  • sudo apt-get install libpopt-dev
  • sudo apt-get install libgmp-dev
  • sudo apt-get install libmpfr-dev
  • sudo apt-get install libmpc-dev
  • sudo apt-get install cmake

Compiling the code

After downloading or cloning the repository, from the repository folder the code can be compiled with:

  1. mkdir build
  2. cd build
  3. cmake ..
  4. make

Test can be run with make test or ctest, or a specific test such as ./test/test_mtbdd.

Debugging can be activated with gdb ./test/test_mtbdd.

The GNU GDB Debugger accepts command as (gdb) run or (gdb) backtrace or (gdb) exit.

See also https://cs.brown.edu/courses/cs033/docs/guides/gdb.pdf.

For output on failure use ctest -output-on-failure.

Another build can be run after removal of the build folder with rm -rdf build.

Example usage

The following code snippets are a toy example for creating the Bell state |Phi^+> = 1/sqrt(2) (|01> + |10>), first in the C interface, and secondly in the QASM interface.

C interface

// Create |Phi^+>
int nqubits = 2;
QMDD state = qmdd_create_all_zero_state(nqubits);
state = qmdd_gate(state, GATEID_H, 0);     // H on q0
state = qmdd_cgate(state, GATEID_X, 0, 1); // CNOT on c=q0, t=q1
state = qmdd_gate(state, GATEID_X, 0);     // X on q0

// Measure state
bool outcome[] = {0, 0};
double prob;
qmdd_measure_all(state, nqubits, outcome, &prob);

This code can be found in examples/bell_state.c and after compiling the code as described above can be run with ./examples/bell_state from the build/ directory. A more complete set of available functions can be found here.

QASM interface

OPENQASM 2.0;
include "qelib1.inc";

// 2 qubit quantum register and 2 bit classical register
qreg q[2];
creg c[2];

// Create |Phi^+>
h q[0];
cx q[0], q[1];
x q[0];

// Measure state
measure q[0]->c[0];
measure q[1]->c[1];

This code can be found in qasm/circuits/bell_state.qasm and can be run with ./build/qasm/run_qasm_on_qmdd qasm/circuits/bell_state.qasm. All gates specified in qelib1.inc are supported, as well as measurements. Custom definitions of gates and classical conditioning are currently not supported.

Documentation

A more complete documentation of the C interface can be found here.

Acknowledgements

This work is supported by the NEASQC project, funded by the European Union's Horizon 2020 programme, Grant Agreement No. 951821.