The Quantum Exact Simulation Toolkit v4.3.0
Loading...
Searching...
No Matches
PauliStrSum gadgets

Functions for using Trotterisation to approximate the action of exponentials of weighted sums of Pauli tensors upon Quregs. More...

Functions

void applyTrotterizedControlledPauliStrSumGadget (Qureg qureg, int control, PauliStrSum sum, qreal angle, int order, int reps, bool permuteTerms)
 
void applyTrotterizedMultiControlledPauliStrSumGadget (Qureg qureg, int *controls, int numControls, PauliStrSum sum, qreal angle, int order, int reps, bool permuteTerms)
 
void applyTrotterizedMultiStateControlledPauliStrSumGadget (Qureg qureg, int *controls, int *states, int numControls, PauliStrSum sum, qreal angle, int order, int reps, bool permuteTerms)
 
void applyTrotterizedNonUnitaryPauliStrSumGadget (Qureg qureg, PauliStrSum sum, qcomp angle, int order, int reps, bool permuteTerms)
 
void applyTrotterizedPauliStrSumGadget (Qureg qureg, PauliStrSum sum, qreal angle, int order, int reps, bool permuteTerms)
 

Detailed Description

Functions for using Trotterisation to approximate the action of exponentials of weighted sums of Pauli tensors upon Quregs.

Function Documentation

◆ applyTrotterizedControlledPauliStrSumGadget()

void applyTrotterizedControlledPauliStrSumGadget ( Qureg qureg,
int control,
PauliStrSum sum,
qreal angle,
int order,
int reps,
bool permuteTerms )
Note
Documentation for this function or struct is under construction!
Warning
This function has not yet been unit tested and may contain bugs. Please use with caution!
Author
Tyson Jones
Vasco Ferreira (randomisation)
See also

Definition at line 190 of file trotterisation.cpp.

193 {
194 validate_quregFields(qureg, __func__);
195 validate_pauliStrSumFields(sum, __func__);
196 validate_pauliStrSumIsHermitian(sum, __func__);
197 validate_controlAndPauliStrSumTargets(qureg, control, sum, __func__);
198 validate_trotterParams(order, reps, __func__);
199
200 bool onlyLeftApply = false;
201 internal_applyAllTrotterRepetitions(qureg, &control, nullptr, 1, sum, angle, order, reps, onlyLeftApply, permuteTerms, __func__);
202}

◆ applyTrotterizedMultiControlledPauliStrSumGadget()

void applyTrotterizedMultiControlledPauliStrSumGadget ( Qureg qureg,
int * controls,
int numControls,
PauliStrSum sum,
qreal angle,
int order,
int reps,
bool permuteTerms )
Note
Documentation for this function or struct is under construction!
Warning
This function has not yet been unit tested and may contain bugs. Please use with caution!
Author
Tyson Jones
Vasco Ferreira (randomisation)
See also

Definition at line 204 of file trotterisation.cpp.

207 {
208 validate_quregFields(qureg, __func__);
209 validate_pauliStrSumFields(sum, __func__);
210 validate_pauliStrSumIsHermitian(sum, __func__);
211 validate_controlsAndPauliStrSumTargets(qureg, controls, numControls, sum, __func__);
212 validate_trotterParams(order, reps, __func__);
213
214 bool onlyLeftApply = false;
215 internal_applyAllTrotterRepetitions(qureg, controls, nullptr, numControls, sum, angle, order, reps, onlyLeftApply, permuteTerms, __func__);
216}

◆ applyTrotterizedMultiStateControlledPauliStrSumGadget()

void applyTrotterizedMultiStateControlledPauliStrSumGadget ( Qureg qureg,
int * controls,
int * states,
int numControls,
PauliStrSum sum,
qreal angle,
int order,
int reps,
bool permuteTerms )
Note
Documentation for this function or struct is under construction!
Warning
This function has not yet been unit tested and may contain bugs. Please use with caution!
Author
Tyson Jones
Vasco Ferreira (randomisation)
See also

Definition at line 218 of file trotterisation.cpp.

221 {
222 validate_quregFields(qureg, __func__);
223 validate_pauliStrSumFields(sum, __func__);
224 validate_pauliStrSumIsHermitian(sum, __func__);
225 validate_controlsAndPauliStrSumTargets(qureg, controls, numControls, sum, __func__);
226 validate_controlStates(states, numControls, __func__); // permits states==nullptr
227 validate_trotterParams(order, reps, __func__);
228
229 bool onlyLeftApply = false;
230 internal_applyAllTrotterRepetitions(qureg, controls, states, numControls, sum, angle, order, reps, onlyLeftApply, permuteTerms, __func__);
231}

◆ applyTrotterizedNonUnitaryPauliStrSumGadget()

void applyTrotterizedNonUnitaryPauliStrSumGadget ( Qureg qureg,
PauliStrSum sum,
qcomp angle,
int order,
int reps,
bool permuteTerms )
Warning
This function has not yet been unit tested and may contain bugs. Please use with caution!

A generalisation of applyTrotterizedPauliStrSumGadget() which accepts a complex angle and permits sum to be non-Hermitian, thereby effecting a potentially non-unitary and non-CPTP operation.

Formulae

Let \( \hat{H} = \) sum and \( \theta = \) angle \( \in \mathbb{C} \). This function approximates the action of

\[ \exp \left(\iu \, \theta \, \hat{H} \right) \]

via a Trotter-Suzuki decomposition of the specified order and number of repetitions (reps).

‍See applyTrotterizedPauliStrSumGadget() for more information about the decomposition, and other parameters.

Equivalences
  • When angle is set to \( \theta = \iu \, \Delta \tau \) and sum = \( \hat{H} \) is Hermitian, this function (approximately) evolves qureg in imaginary-time for duration \( \Delta \tau \), effecting non-unitary propagator

    \[ \exp(- \Delta \tau \hat{H}) \]

    as utilised by applyTrotterizedImaginaryTimeEvolution().
  • When angle is real and sum is Hermitian (i.e. has approximately real coefficients), the effected operation is unitary and this function becomes equivalent to applyTrotterizedPauliStrSumGadget().
Constraints
  • This function only ever effects \( \exp \left(\iu \, \theta \, \hat{H} \right) \) exactly when all PauliStr in sum = \( \hat{H} \) commute.
Parameters
[in,out]quregthe state to modify.
[in]suma weighted sum of Pauli strings to approximately exponentiate.
[in]anglean effective prefactor of sum in the exponent.
[in]orderthe order of the Trotter-Suzuki decomposition (e.g. 1, 2, 4, ...).
[in]repsthe number of Trotter repetitions.
[in]permuteTermswhether to randomly reorder Pauli terms at each repetition.
Exceptions
error
  • if qureg or sum are uninitialised.
  • if sum contains non-identities on qubits beyond the size of qureg.
  • if order is not 1 nor a positive, even integer.
  • if reps is not a positive integer.
  • if internal allocation needed for term permutation fails.
Author
Tyson Jones
Vasco Ferreira (randomisation)

Definition at line 167 of file trotterisation.cpp.

167 {
168 validate_quregFields(qureg, __func__);
169 validate_pauliStrSumFields(sum, __func__);
170 validate_pauliStrSumTargets(sum, qureg, __func__);
171 validate_trotterParams(order, reps, __func__);
172 // sum is permitted to be non-Hermitian
173
174 // |psi> -> U |psi>, rho -> U rho U^dagger
175 bool onlyLeftApply = false;
176 internal_applyAllTrotterRepetitions(qureg, nullptr, nullptr, 0, sum, angle, order, reps, onlyLeftApply, permuteTerms, __func__);
177}

◆ applyTrotterizedPauliStrSumGadget()

void applyTrotterizedPauliStrSumGadget ( Qureg qureg,
PauliStrSum sum,
qreal angle,
int order,
int reps,
bool permuteTerms )
Warning
This function has not yet been unit tested and may contain bugs. Please use with caution!

Effects an approximation to the exponential of sum, weighted by angle times \( i \), upon qureg, via the symmetrized Trotter-Suzuki decomposition (arXiv).

Increasing reps (the number of Trotter repetitions) or order (an even, positive integer or one) improves the accuracy of the approximation by reducing the "Trotter error" due to non-commuting terms of sum, though increases the runtime linearly and exponentially respectively. Using permuteTerms the ordering of terms in the sum can also be randomised, which generally improves the accuracy of the approximation for low order decompositions (arXiv).

Formulae

Let \( \hat{H} = \) sum and \( \theta = \) angle \( \in \mathbb{R} \). This function approximates the action of

\[ \exp \left(\iu \, \theta \, \hat{H} \right) \]

via a Trotter-Suzuki decomposition of the specified order and number of repetitions (reps). Simulation is exact, regardless of order or reps, only when all terms in sum commute.

Important
Observe that \( \theta \) lacks the \( -\frac{1}{2} \) prefactor present in other functions like applyPauliGadget().

To be precise, let \( r = \) reps and assume sum is composed of \( T \)-many terms of the form

\[ \hat{H} = \sum\limits_j^T c_j \, \hat{\sigma}_j \]

where \( c_j \) is the coefficient of the \( j \)-th PauliStr \( \hat{\sigma}_j \).

  • When order=1, this function performs first-order Trotterisation, where the terms of sum are effected in a repeated, arbitrary but fixed order.

    \[ \exp(\iu \, \theta \, \hat{H} ) \approx \prod\limits^{r} \prod\limits_{j=1}^{T} \exp \left( \iu \, \frac{\theta \, c_j}{r} \, \hat\sigma_j \right). \]

  • When order=2, this function performs the lowest order "symmetrized" Suzuki decomposition, whereby each repetition effects the terms of sum forward then in reverse.

    \[ \exp(\iu \, \theta \, \hat{H} ) \approx \prod\limits^{r} \left[ \prod\limits_{j=1}^{T} \exp \left( \iu \frac{\theta \, c_j}{2 \, r} \hat\sigma_j \right) \prod\limits_{j=T}^{1} \exp \left( \iu \frac{\theta \, c_j}{2 \, r} \hat\sigma_j \right) \right]. \]

  • Greater, even values of order (denoted by symbol \( n \)) invoke higher-order symmetrized decompositions \( S[\theta,n,r] \). These see the lower order Trotter circuits repeated twice forward, then reversed, then twice forward again, recursively. To be precise, letting \( p = \left( 4 - 4^{1/(n-1)} \right)^{-1} \), these satisfy

    \begin{align*} S[\theta, n, 1] &= \left( \prod\limits^2 S[p \, \theta, n-2, 1] \right) S[ (1-4p)\,\theta, n-2, 1] \left( \prod\limits^2 S[p \, \theta, n-2, 1] \right), \\ S[\theta, n, r] &= \prod\limits^{r} S\left[\frac{\theta}{r}, n, 1\right]. \end{align*}

‍These formulations are taken from 'Finding Exponential Product Formulas of Higher Orders', Naomichi Hatano and Masuo Suzuki (2005) (arXiv).

When permuteTerms=true, the terms of sum are effected in a random order at each repetition. That is, each repetition of the Trotter-Suzuki decomposition is evaluated with the sum

\[ \hat{H} = \sum\limits_j^T c_{\pi(j)} \, \hat{\sigma}_{\pi(j)} \]

where \( \pi \) is a randomly selected permutation.

Equivalences
  • By passing \( \theta = - \Delta t / \hbar \), this function approximates unitary time evolution of a closed system under the time-independent Hamiltonian sum = \( \hat{H} \) over a duration of \( \Delta t \), as described by propagator

    \[ \hat{U}(\Delta t) = \exp(- \iu \, \Delta t \,\hat{H} \, / \, \hbar), \]

    as utilised by the function applyTrotterizedUnitaryTimeEvolution().
  • This function is equivalent to applyTrotterizedNonUnitaryPauliStrSumGadget() when passing a qcomp instance with a zero imaginary component as the angle parameter. This latter function is useful for generalising dynamical simulation to imaginary-time evolution.
Constraints
  • Unitarity of the prescribed exponential(s) requires that sum is Hermitian, ergo containing only real coefficients. Validation will check that sum is approximately Hermitian, permitting coefficients with imaginary components smaller (in magnitude) than epsilon.

    \[ \max\limits_{i} |c_i| \le \valeps \]

    where the validation epsilon \( \valeps \) can be adjusted with setQuESTValidationEpsilon(). Otherwise, use applyTrotterizedNonUnitaryPauliStrSumGadget() to permit non-Hermitian sum and ergo effect a non-unitary exponential(s).
  • The angle parameter is necessarily real to retain unitarity, but can be relaxed to an arbitrary complex scalar (i.e. a qcomp) using applyTrotterizedNonUnitaryPauliStrSumGadget(). This permits cancelling the complex unit \( i \) to effect non-unitary \( \exp(\theta \, \hat{H}) \) as is useful for imaginary-time evolution.
  • This function only ever effects \( \exp \left(\iu \, \theta \, \hat{H} \right) \) exactly when all PauliStr in sum = \( \hat{H} \) commute, or reps \( \rightarrow \infty \).
Parameters
[in,out]quregthe state to modify.
[in]suma weighted sum of Pauli strings to approximately exponentiate.
[in]anglethe prefactor of sum times \( i \) in the exponent.
[in]orderthe order of the Trotter-Suzuki decomposition (e.g. 1, 2, 4, ...).
[in]repsthe number of Trotter repetitions.
[in]permuteTermswhether to randomly reorder Pauli terms at each repetition.
Exceptions
error
  • if qureg or sum are uninitialised.
  • if sum is not approximately Hermitian.
  • if sum contains non-identities on qubits beyond the size of qureg.
  • if order is not 1 nor a positive, even integer.
  • if reps is not a positive integer.
  • if internal allocation needed for term permutation fails.
See also
Author
Tyson Jones
Vasco Ferreira (randomisation)

Definition at line 179 of file trotterisation.cpp.

179 {
180 validate_quregFields(qureg, __func__);
181 validate_pauliStrSumFields(sum, __func__);
182 validate_pauliStrSumTargets(sum, qureg, __func__);
183 validate_pauliStrSumIsHermitian(sum, __func__);
184 validate_trotterParams(order, reps, __func__);
185
186 bool onlyLeftApply = false;
187 internal_applyAllTrotterRepetitions(qureg, nullptr, nullptr, 0, sum, angle, order, reps, onlyLeftApply, permuteTerms, __func__);
188}