Skip to content

Qsvt

qsvt

Functions:

Name Description
qsvt_step

[Qmod Classiq-library function]

qsvt

[Qmod Classiq-library function]

projector_controlled_phase

[Qmod Classiq-library function]

qsvt_inversion

[Qmod Classiq-library function]

projector_controlled_double_phase

[Qmod Classiq-library function]

qsvt_lcu_step

[Qmod Classiq-library function]

qsvt_lcu

[Qmod Classiq-library function]

qsvt_step

qsvt_step(
    phase1: CReal,
    phase2: CReal,
    proj_cnot_1: QCallable[QArray[QBit], QBit],
    proj_cnot_2: QCallable[QArray[QBit], QBit],
    u: QCallable[QArray[QBit]],
    qvar: QArray[QBit],
    aux: QBit,
) -> None

[Qmod Classiq-library function]

Applies a single QSVT step, composed of 2 projector-controlled-phase rotations, and applications of the block encoding unitary u and its inverse:

\[ \Pi_{\phi_2}U^{\dagger}\tilde{\Pi}_{\phi_{1}}U \]

Parameters:

Name Type Description Default
phase1 CReal

1st rotation phase.

required
phase2 CReal

2nd rotation phase.

required
proj_cnot_1 QCallable[QArray[QBit], QBit]

Projector-controlled-not unitary that locates the encoded matrix columns within U. Accepts a quantum variable of the same size as qvar, and a qubit that is set to |1> when the state is in the block.

required
proj_cnot_2 QCallable[QArray[QBit], QBit]

Projector-controlled-not unitary that locates the encoded matrix rows within U. Accepts a quantum variable of the same size as qvar, and a qubit that is set to |1> when the state is in the block.

required
u QCallable[QArray[QBit]]

A block encoded unitary matrix.

required
qvar QArray[QBit]

The quantum variable to which U is applied, which resides in the entire block encoding space.

required
aux QBit

A zero auxilliary qubit, used for the projector-controlled-phase rotations. Given as an inout so that qsvt can be used as a building-block in a larger algorithm.

required

qsvt

qsvt(
    phase_seq: CArray[CReal],
    proj_cnot_1: QCallable[QArray[QBit], QBit],
    proj_cnot_2: QCallable[QArray[QBit], QBit],
    u: QCallable[QArray[QBit]],
    qvar: QArray[QBit],
    aux: QBit,
) -> None

[Qmod Classiq-library function]

Implements the Quantum Singular Value Transformation (QSVT) - an algorithmic framework, used to apply polynomial transformations of degree d on the singular values of a block encoded matrix, given as the unitary u. Given a unitary \(U\), a list of phase angles \(\phi_1, \phi_2, ..., \phi_{d+1}\) and 2 projector-controlled-not operands \(C_{\Pi}NOT,C_{\tilde{\Pi}}NOT\), the QSVT sequence is as follows: Given a unitary \(U\), a list of phase angles \(\phi_1, \phi_2, ..., \phi_{d+1}\) and 2 projector-controlled-not operands \(C_{\Pi}NOT,C_{\tilde{\Pi}}NOT\), the QSVT sequence is as follows:

\[ \tilde{\Pi}_{\phi_{d+1}}U \prod_{k=1}^{(d-1)/2} (\Pi_{\phi_{d-2k}} U^{\dagger}\tilde{\Pi}_{\phi_{d - (2k+1)}}U)\Pi_{\phi_{1}} \]

for odd \(d\), and:

\[ \prod_{k=1}^{d/2} (\Pi_{\phi_{d-(2k-1)}} U^{\dagger}\tilde{\Pi}_{\phi_{d-2k}}U)\Pi_{\phi_{1}} \]

for even \(d\).

Each of the \(\Pi\)s is a projector-controlled-phase unitary, according to the given projectors.

Parameters:

Name Type Description Default
phase_seq CArray[CReal]

A sequence of phase angles of length d+1.

required
proj_cnot_1 QCallable[QArray[QBit], QBit]

Projector-controlled-not unitary that locates the encoded matrix columns within U. Accepts a quantum variable of the same size as qvar, and a qubit that is set to |1> when the state is in the block.

required
proj_cnot_2 QCallable[QArray[QBit], QBit]

Projector-controlled-not unitary that locates the encoded matrix rows within U. Accepts a quantum variable of the same size as qvar, and a qubit that is set to |1> when the state is in the block.

required
u QCallable[QArray[QBit]]

A block encoded unitary matrix.

required
qvar QArray[QBit]

The quantum variable to which U is applied, which resides in the entire block encoding space.

required
aux QBit

A zero auxilliary qubit, used for the projector-controlled-phase rotations. Given as an inout so that qsvt can be used as a building-block in a larger algorithm.

required

projector_controlled_phase

projector_controlled_phase(
    phase: CReal,
    proj_cnot: QCallable[QArray[QBit], QBit],
    qvar: QArray[QBit],
    aux: QBit,
) -> None

[Qmod Classiq-library function]

Assigns a phase to the entire subspace determined by the given projector. Corresponds to the operation:

\[ \Pi_{\phi} = (C_{\Pi}NOT) e^{-i rac{\phi}{2}Z}(C_{\Pi}NOT) \]

Parameters:

Name Type Description Default
phase CReal

A rotation phase.

required
proj_cnot QCallable[QArray[QBit], QBit]

Projector-controlled-not unitary that sets an auxilliary qubit to |1> when the state is in the projection.

required
qvar QArray[QBit]

The quantum variable to which the rotation applies, which resides in the entire block encoding space.

required
aux QBit

A zero auxilliary qubit, used for the projector-controlled-phase rotation. Given as an inout so that qsvt can be used as a building-block in a larger algorithm.

required

qsvt_inversion

qsvt_inversion(
    phase_seq: CArray[CReal],
    block_encoding_cnot: QCallable[QArray[QBit], QBit],
    u: QCallable[QArray[QBit]],
    qvar: QArray[QBit],
    aux: QBit,
) -> None

[Qmod Classiq-library function]

Implements matrix inversion on a given block-encoding of a square matrix, using the QSVT framework. Applies a polynomial approximation of the inverse of the singular values of the matrix encoded in u. The phases for the polynomial should be pre-calculated and passed into the function.

Parameters:

Name Type Description Default
phase_seq CArray[CReal]

A sequence of phase angles of length d+1, corresponding to an odd polynomial approximation of the scaled inverse function.

required
block_encoding_cnot QCallable[QArray[QBit], QBit]

Projector-controlled-not unitary that locates the encoded matrix columns within U. Accepts a quantum variable of the same size as qvar, and a qubit that is set to |1> when the state is in the block.

required
u QCallable[QArray[QBit]]

A block encoded unitary matrix.

required
qvar QArray[QBit]

The quantum variable to which U is applied, which resides in the entire block encoding space.

required
aux QBit

A zero auxilliary qubit, used for the projector-controlled-phase rotations. Given as an inout so that qsvt can be used as a building-block in a larger algorithm.

required

projector_controlled_double_phase

projector_controlled_double_phase(
    phase_even: CReal,
    phase_odd: CReal,
    proj_cnot: QCallable[QArray[QBit], QBit],
    qvar: QArray[QBit],
    aux: QBit,
    lcu: QBit,
) -> None

[Qmod Classiq-library function]

Assigns 2 phases to the entire subspace determined by the given projector, each one is controlled differentely on a given lcu qvar. Used in the context of the qsvt_lcu function. Corresponds to the operation:

\[ \Pi_{\phi_{odd}, \phi_{even}} = (C_{\Pi}NOT) (C_{lcu=1}e^{-i\frac{\phi_{even}}{2}Z}) (C_{lcu=0}e^{-i\frac{\phi_{odd}}{2}Z}) (C_{\Pi}NOT) \]

Parameters:

Name Type Description Default
phase_even CReal

Rotation phase, corresponds to 'lcu'=1.

required
phase_odd CReal

Rotation phase, corresponds to 'lcu'=0.

required
proj_cnot QCallable[QArray[QBit], QBit]

Projector-controlled-not unitary that sets an auxilliary qubit to |1> when the state is in the projection.

required
qvar QArray[QBit]

The quantum variable to which the rotation applies, which resides in the entire block encoding space.

required
aux QBit

A zero auxilliary qubit, used for the projector-controlled-phase rotation. Given as an inout so that qsvt can be used as a building-block in a larger algorithm.

required

qsvt_lcu_step

qsvt_lcu_step(
    phases_even: CArray[CReal],
    phases_odd: CArray[CReal],
    proj_cnot_1: QCallable[QArray[QBit], QBit],
    proj_cnot_2: QCallable[QArray[QBit], QBit],
    u: QCallable[QArray[QBit]],
    qvar: QArray[QBit],
    aux: QBit,
    lcu: QBit,
) -> None

[Qmod Classiq-library function]

Applies a single QSVT-lcu step, composed of 2 double phase projector-controlled-phase rotations, and applications of the block encoding unitary u and its inverse:

\[ (C_{lcu=1}\Pi^{even}_{\phi_2})(C_{lcu=0}\Pi^{odd}_{\phi_2})U^{\dagger}(C_{lcu=1}\tilde{\Pi}^{even}_{\phi_1})(C_{lcu=0}\tilde{\Pi}^{odd}_{\phi_1})U \]

Parameters:

Name Type Description Default
phases_even CArray[CReal]

2 rotation phases for the even polynomial

required
phases_odd CArray[CReal]

2 rotation phases for the odd polynomial

required
proj_cnot_1 QCallable[QArray[QBit], QBit]

Projector-controlled-not unitary that locates the encoded matrix columns within U. Accepts a quantum variable of the same size as qvar, and a qubit that is set to |1> when the state is in the block.

required
proj_cnot_2 QCallable[QArray[QBit], QBit]

Projector-controlled-not unitary that locates the encoded matrix rows within U. Accepts a quantum variable of the same size as qvar, and a qubit that is set to |1> when the state is in the block.

required
u QCallable[QArray[QBit]]

A block encoded unitary matrix.

required
qvar QArray[QBit]

The quantum variable to which U is applied, which resides in the entire block encoding space.

required
aux QBit

A zero auxilliary qubit, used for the projector-controlled-phase rotations. Given as an inout so that qsvt can be used as a building-block in a larger algorithm.

required
lcu QBit

A qubit used for the combination of 2 polynomials within a single qsvt application

required

qsvt_lcu

qsvt_lcu(
    phase_seq_even: CArray[CReal],
    phase_seq_odd: CArray[CReal],
    proj_cnot_1: QCallable[QArray[QBit], QBit],
    proj_cnot_2: QCallable[QArray[QBit], QBit],
    u: QCallable[QArray[QBit]],
    qvar: QArray[QBit],
    aux: QBit,
    lcu: QBit,
) -> None

[Qmod Classiq-library function]

Implements the Quantum Singular Value Transformation (QSVT) for a linear combination of odd and even polynomials, so that it is possible to encode a polynomial of indefinite parity, such as approximation to exp(i*A) or exp(A). Should work for Hermitian block encodings.

The function is equivalent to applying the qsvt function for odd and even polynomials with a LCU function, but is more efficient as the two polynomials share the same applications of the given unitary.

The function is intended to be called within a context of LCU, where it is called as the SELECT operator, and wrapped with initialization of the lcu qubit to get the desired combination coefficients. The even polynomial corresponds to the case where the \(lcu=|0\rangle\), while the odd to #lcu=|1\rangle$.

Note: the two polynomials should have the same degree up to a difference of 1.

Parameters:

Name Type Description Default
phase_seq_odd CArray[CReal]

A sequence of phase angles of length d+1 for the odd polynomial.

required
phase_seq_even CArray[CReal]

A sequence of phase angles of length d+1 for the even polynomial.

required
proj_cnot_1 QCallable[QArray[QBit], QBit]

Projector-controlled-not unitary that locates the encoded matrix columns within U. Accepts a quantum variable of the same size as qvar, and a qubit that is set to |1> when the state is in the block.

required
proj_cnot_2 QCallable[QArray[QBit], QBit]

Projector-controlled-not unitary that locates the encoded matrix rows within U. Accepts a quantum variable of the same size as qvar, and a qubit that is set to |1> when the state is in the block.

required
u QCallable[QArray[QBit]]

A block encoded unitary matrix.

required
qvar QArray[QBit]

The quantum variable to which U is applied, which resides in the entire block encoding space.

required
aux QBit

A zero auxilliary qubit, used for the projector-controlled-phase rotations. Given as an inout so that qsvt can be used as a building-block in a larger algorithm.

required
lcu QBit

A qubit used for the combination of 2 polynomials within a single qsvt application

required