Tyson Jones, Balint Koczor, Simon C. Benjamin
- Department of Materials, University of Oxford
- Quantum Motion Technologies Ltd
This repository contains C++
implementations of the multithreaded, distributed algorithms presented in this manuscript, and unit tests using Catch2. If the code is useful to you, feel free to cite
@misc{jones2023distributed,
title={Distributed Simulation of Statevectors and Density Matrices},
author={Tyson Jones and Bálint Koczor and Simon C. Benjamin},
year={2023},
eprint={2311.01512},
archivePrefix={arXiv},
primaryClass={quant-ph}
}
The below API makes use of the following custom types defined in types.hpp
, wherein you can vary their precision.
Type | Use | Default |
---|---|---|
Real |
A real scalar | double |
Nat |
A natural scalar | unsigned int |
Index |
A state index | long long unsigned int |
Amp |
A complex scalar | std::complex<Real> |
We also define arrays and matrices of these types, such as NatArray
, which are merely eye-candy for std::vector<Nat>
.
Before calling any of the below functions, you should initialise MPI with comm_init()
, and before exiting, finalise with comm_end()
.
Instantiate a quantum state via:
StateVector psi = StateVector(numQubits);
DensityMatrix rho = DensityMatrix(numQubits);
Statevectors can be passed to the below unitary functions, prefixed with distributed_statevector_
.
-
oneTargGate(StateVector psi, Nat target, AmpMatrix gate)
-
manyCtrlOneTargGate(StateVector psi, NatArray controls, Nat target, AmpMatrix gate)
-
swapGate(StateVector psi, Nat qb1, Nat qb2)
-
manyTargGate(StateVector psi, NatArray targets, AmpMatrix gate)
-
pauliTensor(StateVector psi, NatArray targets, NatArray paulis)
-
pauliGadget(StateVector psi, NatArray targets, NatArray paulis, Real theta)
-
phaseGadget(StateVector psi, NatArray targets, Real theta)
Density matrices can be passed to the below functions, prefixed with distributed_densitymatrix_
.
-
manyTargGate(DensityMatrix rho, NatArray targets, AmpMatrix gate)
-
swapGate(DensityMatrix rho, Nat qb1, Nat qb2)
-
pauliTensor(DensityMatrix rho, NatArray targets, NatArray paulis)
-
pauliGadget(DensityMatrix rho, NatArray targets, NatArray paulis, Real theta)
-
phaseGadget(DensityMatrix rho, NatArray targets, Real theta)
-
phaseGadget(DensityMatrix rho, NatArray targets, Real theta)
-
oneQubitDephasing(DensityMatrix rho, Nat qb, Real prob)
-
twoQubitDephasing(DensityMatrix rho, Nat qb1, Nat qb2, Real prob)
-
oneQubitDepolarising(DensityMatrix rho, Nat qb, Real prob)
-
twoQubitDepolarising(DensityMatrix rho, Nat qb1, Nat qb2, Real prob)
-
damping(DensityMatrix rho, Nat qb, Real prob)
-
expecPauliString(DensityMatrix rho, RealArray coeffs, NatArray allPaulis)
-
partialTrace(DensityMatrix inRho, NatArray targets)
View the definition of these functions in the src
folder.
See an example in main.cpp
.
To compile both main.cpp
and the unit tests, simply call
source ./compile
Additionally, set the number of threads (per node) via
export OMP_NUM_THREADS=24
and launch the executables between (e.g.) 16
nodes via
mpirun -np 16 ./main
mpirun -np 16 ./test
You must use a power-of-2 number of nodes.
This repository is licensed under the terms of the MIT license.