Skip to content

beehive-lab/TornadoQSim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TornadoQSim

TornadoQSim is a quantum computing framework, that allows to develop quantum algorithms and simulate them on a variety of quantum simulators. The aim is to achieve high-performance simulation of quantum circuits without the need to develop the simulator back-end in a platform specific programming language, such as CUDA.

This framework is developed entirely in Java, including the quantum simulator back-ends that are accelerated on heterogeneous hardware using TornadoVM.

TornadoQSim was developed by Ales Kubicek as part of the BSc Computer Science degree (final year project) at the University of Manchester.

Installation

1. Clone the project:

git clone https://github.com/beehive-lab/TornadoQSim.git

2. Install dependencies:

  • Install TornadoVM. The following example builds TornadoVM with GraalVM JDK 11 and OpenCL:
git clone https://github.com/beehive-lab/TornadoVM.git 
cd TornadoVM
./scripts/tornadoVMInstaller.sh --graal-jdk-11 --opencl
source source.sh
cd ..

If you cannot build TornadoVM with the installer, try the manual installation .

3. Set up the environment and store the variables in a file (e.g. sources.env):

$ cd TornadoQSim
$ vim sources.env
export TORNADO_QSIM_ROOT="${PWD}/TornadoQSim"
export PATH="${PATH}:${TORNADO_QSIM_ROOT=}/bin"
export TORNADO_ROOT=<path to TornadoVM>
export PATH="${PATH}:${TORNADO_ROOT}/bin/bin/"
export TORNADO_SDK=${TORNADO_ROOT}/bin/sdk
export JAVA_HOME=${TORNADO_ROOT}/TornadoVM-GraalJDK11/graalvm-ce-java11-22.3.2

Load the environment:

$ source sources.env
$ cd $TORNADO_QSIM_ROOT

4. Build TornadoQSim:

$ mvn clean install

5. Run TornadoQSim:

The tornado-qsim command displays the available options to simulate quantum circuits.

$ tornado-qsim

TornadoVM Quantum Simulator supports four execution modes:

tornado-qsim unitary-java  <circuit_class> <num_of_qubits>  for sequential execution of a quantum circuit with Unitary Matrix.
tornado-qsim unitary-accel <circuit_class> <num_of_qubits>  for parallel execution of a quantum circuit with Unitary Matrix.
tornado-qsim fsv-java      <circuit_class> <num_of_qubits>  for sequential execution of a quantum circuit with Full State Vector.
tornado-qsim fsv-accel     <circuit_class> <num_of_qubits>  for parallel execution of a quantum circuit with Full State Vector.

For example, to simulate the circuit described in the QuantumCode.java class using the unitary matrix backend that uses GPU acceleration, run:

$ tornado-qsim unitary-accel QuantumCode 3
(--------------------- TornadoVM Quantum Simulator ---------------------)
Running QuantumCode circuit with the Unitary Matrix backend (parallel execution)
State vector:
000  0.00  (0.000 + 0.000i)
001  0.25  (0.000 - 0.500i)
010  0.00  (0.000 + 0.000i)
011  0.25  (0.000 - 0.500i)
100  0.00  (0.000 + 0.000i)
101  0.25  (0.000 - 0.500i)
110  0.00  (0.000 + 0.000i)
111  0.25  (0.000 - 0.500i)

6. Example of the Bell state using TornadoQSim:

// Bell state example
public static void main(String[] args) {
    int noQubits = 2;

    // Example circuit - Bell state
    Circuit circuit = new Circuit(noQubits);

    circuit.H(0);
    circuit.CNOT(0, 1);

    // Quantum simulator back-ends 
    // => other back-ends - future work
    Simulator simulatorAccelerated = new UnitarySimulatorAccelerated(noQubits);
    Simulator simulatorStandard = new UnitarySimulatorStandard();

    // Print full state vector
    System.out.println("--------- Accelerated --------");
    System.out.println(simulatorAccelerated.simulateFullState(circuit));

    System.out.println("---------- Standard ----------");
    System.out.println(simulatorStandard.simulateFullState(circuit));
}

Licenses

License

About

High-performance and modular quantum simulator in Java

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published