![]() |
The Quantum Exact Simulation Toolkit v4.0.0
|
Functions for creating statevectors and density matrices. More...
Functions | |
Qureg | createCloneQureg (Qureg qureg) |
Qureg | createCustomQureg (int numQubits, int isDensMatr, int useDistrib, int useGpuAccel, int useMultithread) |
Qureg | createDensityQureg (int numQubits) |
Qureg | createForcedDensityQureg (int numQubits) |
Qureg | createForcedQureg (int numQubits) |
Qureg | createQureg (int numQubits) |
Functions for creating statevectors and density matrices.
Definition at line 315 of file qureg.cpp.
Referenced by TEST_CASE(), and TEST_CASE().
Qureg createCustomQureg | ( | int | numQubits, |
int | isDensMatr, | ||
int | useDistrib, | ||
int | useGpuAccel, | ||
int | useMultithread ) |
Creates a statevector or density matrix with the specified deployments, initialised in the zero state. This function is an alternative to createQureg() and createDensityQureg() which permits explicitly forcing, disabling, or automating particular deployments.
numQubits
and isDensMatr
respectively inform the dimension of the Qureg, and whether the Qureg is a density matrix or statevector.Let \( N = \) numQubits
.
isDensMatr=0
, the returned statevector contains \( 2^N \) amplitudes, initialised to state \[ \ket{0}^{\otimes N} \;\; = \;\; \{ 1, \, 0, \, 0, \, \dots, \, 0 \}. \]
isDensMatr=1
, the returned density matrix contains \( 2^{N}\times 2^{N} \) amplitudes, initialised to state \[ \ket{0}\bra{0}^{\otimes N} \;\; = \;\; \begin{pmatrix} 1 & 0 & \dots \\ 0 & 0 & \\ \vdots & & \ddots \end{pmatrix}. \]
useDistrib
indicates whether (=1
) or not (=0
) to distribute the Qureg's amplitudes across all available MPI nodes. This is suitable for Qureg which are too large to fit into a single node, and requires allocating an additional communication buffer per-node. When useDistrib=0
but the QuEST executable is launched in distributed settings, the Qureg amplitudes will be duplicated upon every node.useGpuAccel
indicates whether (=1
) or not (=0
) to GPU-accelerate the Qureg, and requires allocating additional persistent memory in the GPU VRAM. When combined with useDistrib=1
, every node will allocate both communication buffers and persistent GPU memory, and an additional persistent GPU-memory communication buffer.useMultithread
indicates whether (=1
) or not (=0
) to use multithreading when subsequently modifying the Qureg with a CPU routine. This requires no additional allocations, and typically has no effect when GPU acceleration is also enabled.The deployment parameters can also be -1
to let QuEST choose that parameter, taking into account the other forced deployments. While it is always safe to disable a deployment, forcing a deployment which is invalid (e.g. because the device has insufficient free memory) will throw a validation error.
useMultithread
), and the size of the variable-precision qcomp
used to represent each amplitude. This is determined by preprocessor FLOAT_PRECISION
viaFLOAT_PRECISION | qcomp size (bytes) |
---|---|
1 | 8 |
2 | 16 |
4 | 16, 20, 32 |
where the quad-precision size is platform specific, and is often the size of two long double
primitives.
Let:
numQubits
sizeof(qcomp)
(the size in bytes)The allocated CPU memory (RAM) and GPU memory (VRAM) is
useDistrib | useGpuAccel | RAM per node | RAM total | VRAM per node | VRAM total | memory total |
---|---|---|---|---|---|---|
0 | 0 | \( B \, D \) | \( W B \, D \) | 0 | 0 | \( W B \, D \) |
0 | 1 | \( B \, D \) | \( W B \, D \) | \( B \, D \) | \( W B \, D \) | \( 2 \, W B \, D \) |
1 | 0 | \( 2 \, B \, D \, / \, W \) | \( 2 \, B \, D \) | 0 | 0 | \( 2 \, B \, D \) |
1 | 1 | \( 2 \, B \, D \, / \, W \) | \( 2 \, B \, D \) | \( 2 \, B \, D \, / \, W \) | \( 2 \, B \, D \) | \( 4 \, B \, D \) |
For illustration, using the default FLOAT_PRECISION=2
whereby \( B = 16 \) bytes, the RAM per node over varying distributions is:
isDensMatr | numQubits | \( W=1 \) | \( W=2 \) | \( W=4 \) | \( W=8 \) | \( W=16 \) | \( W=1024 \) |
---|---|---|---|---|---|---|---|
0 | 20 | 16 MiB | 16 MiB | 8 MiB | 4 MiB | 2 MiB | 32 KiB |
0 | 30 | 16 GiB | 16 GiB | 8 GiB | 4 GiB | 2 GiB | 32 MiB |
0 | 35 | 512 GiB | 512 GiB | 256 GiB | 128 GiB | 64 GiB | 1 GiB |
0 | 40 | 16 TiB | 16 TiB | 8 TiB | 4 TiB | 2 TiB | 32 GiB |
0 | 45 | 512 TiB | 512 TiB | 256 TiB | 128 TiB | 64 TiB | 1 TiB |
0 | 50 | 16 PiB | 16 PiB | 8 PiB | 4 PiB | 2 PiB | 32 TiB |
1 | 10 | 16 MiB | 16 MiB | 8 MiB | 4 MiB | 2 MiB | 32 KiB |
1 | 15 | 16 GiB | 16 GiB | 8 GiB | 4 GiB | 2 GiB | 32 MiB |
1 | 20 | 16 TiB | 16 TiB | 8 TiB | 4 TiB | 2 TiB | 32 GiB |
1 | 25 | 16 PiB | 16 PiB | 8 PiB | 4 PiB | 2 PiB | 32 TiB |
isDensMatr
).mpirun
).[in] | numQubits | the number of qubits in the output Qureg. |
[in] | isDensMatr | whether the Qureg is a density matrix (=1 ) or statevector (=0 ). |
[in] | useDistrib | whether to force (=1 ), disable (=0 ) or automate (=-1 ) distribution. |
[in] | useGpuAccel | whether to force (=1 ), disable (=0 ) or automate (=-1 ) GPU acceleration. |
[in] | useMultithread | whether to force (=1 ), disable (=0 ) or automate (=-1 ) multithreading. |
error |
|
-1
).Definition at line 273 of file qureg.cpp.
Referenced by TEST_CASE().
Qureg createDensityQureg | ( | int | numQubits | ) |
Creates a density matrix containing numQubits
qubits, with automatically chosen deployments, initialised in the zero state.
The chosen deployments (multithreading, GPU-acceleration and distribution) are informed by which facilities are compiled, available at runtime, beneficial for the specified Qureg size, and whether the necessary additional memory structures can fit in accelerators and buffers.
numQubits
. The returned Qureg contains \( 2^N \times 2^N \) amplitudes, each represented by a qcomp
, initialised to state \[ \ket{0}\bra{0}^{\otimes N} \;\; = \;\; \begin{pmatrix} 1 & 0 & \dots \\ 0 & 0 & \\ \vdots & & \ddots \end{pmatrix}. \]
isDensMatr=1
and -1
for all deployments to automate them. [in] | numQubits | the number of qubits in the output Qureg. |
error |
Definition at line 287 of file qureg.cpp.
Referenced by TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
Qureg createForcedDensityQureg | ( | int | numQubits | ) |
isDensMatr=1
and all deployments enabled by the QuEST environment. Definition at line 305 of file qureg.cpp.
Referenced by TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
Qureg createForcedQureg | ( | int | numQubits | ) |
isDensMatr=0
and all deployments enabled by the QuEST environment. Definition at line 295 of file qureg.cpp.
Referenced by TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().
Qureg createQureg | ( | int | numQubits | ) |
Creates a statevector containing numQubits
qubits, with automatically chosen deployments, initialised in the zero state.
The chosen deployments (multithreading, GPU-acceleration and distribution) are informed by which facilities are compiled, available at runtime, beneficial for the specified Qureg size, and whether the necessary additional memory structures can fit in accelerators and buffers.
numQubits
. The returned Qureg contains \( 2^N \) amplitudes, each represented by a qcomp
, initialised to state \[ \ket{0}^{\otimes N} \;\; = \;\; \{ 1, \, 0, \, 0, \, \dots, \, 0 \}. \]
isDensMatr=0
and -1
for all deployments to automate them. [in] | numQubits | the number of qubits in the output Qureg. |
error |
Definition at line 279 of file qureg.cpp.
Referenced by TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().