Skip to content

workbench_algorithms.utils.dyson_utils

Utility functions for Dyson Series Qubrick and Dyson Series unit tests.

DysonSeriesUnaryIndex dataclass

DysonSeriesUnaryIndex(
    trunc_reg: Qubits,
    discret_reg: list[Qubits],
    be_anc: Qubits,
    system_reg: Qubits,
    t_disc_param: int,
    name: str,
)

Bases: CompositeRegister

Dataclass for the unary Dyson Series Composite Register.

initialize classmethod

initialize(
    qc,
    name,
    trunc_param: int,
    t_disc_param: int,
    syst: Union[int, Qubits],
    n_be_anc: Union[int, list],
)

The unary Dyson Series Expansion composite index register.

Parameters:

Name Type Description Default
qc QPU

a QPU instance.

required
name str

name of composite register.

required
trunc_param int

truncation parameter.

required
t_disc_param int

time-discretization parameter.

required
syst Union[int, Qubits]

the system register an operator is applied to.

required
n_be_anc Union[int, list]

a register for the operator block encoding.

required

DysonSeriesBinaryIndex dataclass

DysonSeriesBinaryIndex(
    trunc_reg: Qubits,
    discret_reg: list[Qubits],
    be_anc: Qubits,
    system_reg: Qubits,
    name: str,
)

Bases: CompositeRegister

Dataclass for the binary Dyson Series Composite Register.

initialize classmethod

initialize(
    qc,
    name,
    trunc_param: int,
    t_disc_param: int,
    syst: Union[int, Qubits],
    n_be_anc: Union[int, list],
)

The binary Dyson Series Expansion composite index register.

Parameters:

Name Type Description Default
qc QPU

a QPU instance.

required
name str

name of composite register.

required
trunc_param int

truncation parameter.

required
t_disc_param int

time-discretization parameter.

required
syst Union[int, Qubits]

the system register an operator is applied to.

required
n_be_anc Union[int, list]

a register for the operator block encoding.

required

DysonSeriesData dataclass

DysonSeriesData(
    discretization: int,
    truncation: int,
    collision: bool,
    hamiltonian: PauliSum,
    t0: float,
)

Dataclass for the DysonSeriesLCU Qubrick.

Parameters:

Name Type Description Default
discretization int

the time discretization value.

required
truncation int

the truncation bound value.

required
collision bool

whether to flag a (time) collision in the time register.

required
hamiltonian PauliSum

a time independent part of the Hamiltinian to simulate.

required
t0 float

a time interval to simulate a Hamiltinian.

required

probabilities

probabilities()

Return the normalized probabilities for the state preparation routine.

DysonSelectStrategyNaive

DysonSelectStrategyNaive(
    truncation: int,
    fast_forward_exp: Qubrick,
    hamiltonian: PauliSum,
    block_encoding: Qubrick,
)

A helper class to apply an operator of the form \exp(-iH_0 t)V \exp(iH_0 t).

Parameters:

Name Type Description Default
truncation int

a value of the truncation parameter.

required
fast_forward_exp Qubrick

a fast-forwardable part \exp(-iH_0 t) of a Hamiltonian to simulate.

required
hamiltonian PauliSum

a block-encoded part BE(V) of a Hamiltonian to simulate.

required
block_encoding Qubrick

a block-encoding/LCU subroutine.

required

truncation property

truncation

Getter for the truncation parameter.

hamiltonian property

hamiltonian

Getter for the block-encoded part of a Hamiltonian to simulate.

fast_forward_exp property

fast_forward_exp

Getter for the fast-forwardable part of the Hamiltonian.

block_encoding property

block_encoding

Getter for the block encoding subroutine.

apply_compression_gadget_block_encoding

apply_compression_gadget_block_encoding(
    register: DysonSeriesBinaryIndex,
    idx: int,
    ctrl: Union[Qubits, int] = 0,
)

Apply the Hamiltonian operator to the system register.

Parameters:

Name Type Description Default
register CompositeRegister

a composite register for Dyson Series.

required
idx int

an index of the time iteration for the time discretization register.

required
ctrl (Qubits, int)

a register to control this operation on. Default to 0.

0

num_qubits_DysonSeriesExpansionIndex

num_qubits_DysonSeriesExpansionIndex(
    trunc_param,
    t_disc_param,
    syst,
    n_be_anc,
    reg_type="unary",
) -> int

Calculate the total size of the Dyson register.

Parameters:

Name Type Description Default
trunc_param int

truncation parameter.

required
t_disc_param int

time-discretization parameter

required
n_be_anc int

size of the register for block-encoding ancilla qubits.

required
syst Union[int, Qubits]

the system register an operator is applied to.

required
reg_type str

type of the truncation register of the Dyson Series (unary or binary).

'unary'
Return

size (int): the total number of qubits required for the Dyson Series expansion.

norm_beta

norm_beta(t0, cutoff)

Compute normalization beta (Dyson series).

Parameters:

Name Type Description Default
t0 float

time step

required
cutoff int

Cutoff of the Dyson series

required

dyson_target_prob

dyson_target_prob(t0, cutoff)

Compute the normalized probabilities for the state preparation routine (Dyson Series).

Parameters:

Name Type Description Default
t0 float

time step.

required
cutoff int

Cutoff of the Dyson series.

required

dyson_series_numpy

dyson_series_numpy(
    trunc_param, t_disc_param, t, H0, V, flag_collision
)

Compute the matrix representation of the (K, M)-Dyson series.

Computes the matrix representation of the K-truncated & M-discretized dyson series. \(\sum_{k = 0}^{K} (\frac{- i t}{k! M})^k (k! B_k + C_k)\)

where

\(B_k = \sum_{0 <= m_1 < m_2 < ... < m_k < M} \prod_{j=1}^{k} \exp{(i H_0 t m_i/ M)} V \exp{(- iH_0 t m_i/ M)}\)

and \(C_k = 0\) if one desire to exclude the collisions, to keep the collisions, meaning that it captures terms simuilar to B_k but where at least one pair of indices \(m_j = m_d\) collide for \(j != d\). See eq.16 in https://arxiv.org/pdf/1805.00675.

Parameters:

Name Type Description Default
trunc_param int

Truncation.

required
t_disc_param int

Discretization.

required
t float

Time.

required
H0 ndarray

Hermitian operator (diaginal operator, time dependent).

required
V ndarray

Hermitian operator (offdiaginal operator, time independent).

required
flag_collision bool

If flag_collision == True, the collisions will be flagged and the flag being in the 0 states excludes the collisions (a.k.a. \(C_k = 0\)). If flag_collision == False, the collisions will not be flagged and thus, will be included (\(C_k \neq 0\)).

required
Return

dyson (ndarray): the matrix representation of the (trunc_param, t_disc_param)-Dyson series.

evaluate_ham

evaluate_ham(t, H0, V)

Evaluate the operator of the form \(V(t)=\exp(iH_0t)V\exp(-iH_0t)\).

Parameters:

Name Type Description Default
t float

Evolution time.

required
H0 array

a matrix representation of the fast-forwardable part of the Hamiltonian.

required
V array

a matrix representation of the perturbation part of the Hamiltonian.

required
Return

result: the result of evaluating the operator \(V(t)\).