QuEST.jl

Quantum Exact Simulation Toolkit is a high performance simulator of quantum circuits, state-vectors and density matrices
Author ediparquantum
Popularity
6 Stars
Updated Last
5 Months Ago
Started In
December 2023

QuEST Stable Dev Build Status

Details

  1. Quantum Exact Simulation Toolkit is a high performance simulator of quantum circuits, state-vectors and density matrices.
  2. QuEST.jl is a wrapper for QuEST, which is written in C. QuEST.jl was compiled using BinaryBuilder.jl, which is a system for the compilation of binary dependencies --whose aim it to just work anywhere the official Julia distribution does.
  3. Function calls, enumerators, structs, etc were wrapped automatically using Clang.jl, which provided the needed C bindings for the Julia interface.
  4. Note: Julia is indexed starting at $1$ and goes until $N$ items in an $N-$ element list. C indexes an $N-$ element list from $0$ to $N-1$.
  5. To give the Julia user uniform interface, every QuEST call using an integer index, will first shift the index to be in the $0$ indexed form inside the Julia function. The user should be aware of this, but it is the aim of the QuEST.jl parckage wrapper writer(s) to handle this for the user.

Getting started

Whilst we are working on getting this package registered with the official Julia registry, to use QuEST.jl

using Pkg
Pkg.add(url = "https://github.com/ediparquantum/QuEST.jl")

or

] add https://github.com/ediparquantum/QuEST.jl
using QuEST
num_qubits = 2
env = createQuESTEnv()
  
# create a 2 qubit register in the zero state
qubits = createQureg(num_qubits, env)
initZeroState(qubits)

# apply circuit
hadamard(qubits, 1)
controlledNot(qubits, 1, 2)
measure(qubits, 2)

# unload QuEST
destroyQureg(qubits, env)
destroyQuESTEnv(env)

Information direct from the QuEST developers

For more in depth tutorials see (C based)

  1. QuEST's github
  2. QuEST C based tutorial - there are some code examples to get an idea of the flow
  3. QuEST website
  4. QuEST's webiste documentation
  5. Decoherence (noise) models
  6. QuEST's code documentation
  7. QuESTlink - mathematica
  8. QuEST whitepaper

Maintenance

To maintain QuEST.jl with future releases of QuEST:

  1. go to BinaryBuilder.jl doc's page
  2. Follow instructions to pre-compile the latest version of QuEST according hardware requirements
  3. The build_tarballs.jl file showcasing how to precompile QuEST is found on the Yggdrasil package page here
  4. Best to follow instructions from (1) and use the wizard
  5. Once this is done the updated pacakge QuEST_jll.jl will automatically update with the latest precompiled version. Found on the Julia binary wrapper organisation (JuliaBinaryWrapper), check the repositories for your package (QuEST_jll.jl).
  6. Now if there are any updated funcation names or new interfaces, this package QuEST.jl will need to be updated. See example:

Wrapping QuEST from C in Julia

Call C with a ccall type function. Consider the Hadamard function as example

function hadamard(qureg, targetQubit)
    test_qubit_present(qureg,targetQubit)
    targetQubit = c_shift_index(targetQubit)
    @ccall libquest.hadamard(qureg::Qureg, targetQubit::Cint)::Cvoid
end

The line starting with @ccall... is calling the function by accessing the precompiled binary. To presenve segmentation faults and hence prevent Julia crashing at function call I assert the targetQubit, which is an integer and is in the set of qubits contained in the qureg, if not, then an error is thrown. Calls to C need to ensure indices are shifted to the 0-index, which is done with c_shift_index.

Then follow standard Julia package management and release for new version.

Acknowledgements

Some tests and functions were inspired and directly used from the public repository Dighvijay: QuEST.jl made possible from the efforts of Dighvijay on GitHub. We thank them for their valuable contributions.