LinAlg: Linear-algebra based quantum simulator
The qat.qpus.LinAlg QPU can be considered as the most simple and versatile gate-based
ideal simulator, as its performance and accuracy do not change depending on the shape or content of
the circuit submitted to it; only the size of the circuit matters.
LinAlg is a linear-algebra-based quantum emulator. This simulator encodes the
quantum amplitudes in a vector with \(2^n\) complex numbers, where \(n\) is the number of qubits.
This vector is modified by the application of quantum gates.
In Qaptiva-HPC, the emulator can run either as a single-process instance (CLinalg) or as a distributed emulator (DLinAlg) in an HPC environment.
Using the right number of nodes
The number of HPC nodes requires to run this emulator will rely on the amount of RAM \(MEM_{node}\) available on each node, and the number of qubits \(n_{qubits}\) to emulate.
The number of qubits per nodes is -, the number of nodes is -
Mathematical formula
The number of qubits emulatable on each node is given by:
Then, the number of nodes is given by:
Example of a simulation on a cluster
Two scripts are needed to run a simulation on a cluster:
A python program describing the quantum program to be simulated, and ressembles a program used by other Qaptiva simulator.
from qat.core import Job from qat.qpus import LinAlg qaoa_job = Job.load(f"qaoa_35_qubits.job") res = LinAlg().submit(qaoa_job) print(res)
A SLURM batch script that reserves some nodes in a cluster and then submits the python program to them.
#!/bin/bash #SBATCH --partition XXX // partition of the cluster to be used #SBATCH --nodes 8 // number of nodes #SBATCH --time 24:00:00 // time limit of the simulation job #SBATCH --job-name linalg_qaoa_35 // name of the job #SBATCH --output slurm-%A_%x_%N_%t.out // SLURM output file format #SBATCH --error slurm-%A_%x_%N_%t.err // SLURM error file format #SBATCH --exclusive // reserve the nodes on exclusive mode module load qaptiva-hpc python3 -u linalg_qaoa.py
The job can then be submitted with the sbatch command:
sbatch submit_linalg.sh
Example of the simulation result:
Result(raw_data=[], _value=ComplexNumber(re=-19.28229108973577, im=0.0), error=None, value_data=None, error_data=None, meta_data={'simulation_time': '147.557000'}, in_memory=False, data=None, qregs=[DefaultRegister(length=35, start=0, msb=None, _subtype_metadata=None, key=None)], _parameter_map=None, _values=None, values_data=None, need_flip=False, nbqbits=None, lsb_first=False, has_statevector=False, statevector=None)