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.
git clone https://github.com/beehive-lab/TornadoQSim.git
- 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 .
$ 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
$ mvn clean install
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)
// 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));
}