Index
operations
bind
bind(
source: Union[Input[QVar], List[Input[QVar]]],
destination: Union[Output[QVar], List[Output[QVar]]],
) -> None
control
control(
ctrl: Union[SymbolicExpr, QBit, QArray[QBit]],
stmt_block: Union[QCallable, Callable[[], None]],
) -> None
if_
if_(
condition: Union[SymbolicExpr, bool],
then: Union[QCallable, Callable[[], None]],
else_: Union[
QCallable, Callable[[], None], int
] = _MISSING_VALUE,
) -> None
phase
phase(expr: SymbolicExpr, theta: float = 1.0) -> None
power
power(
exponent: Union[SymbolicExpr, int],
stmt_block: Union[QCallable, Callable[[], None]],
) -> None
repeat
repeat(
count: Union[SymbolicExpr, int],
iteration: Callable[[int], None],
) -> None
within_apply
within_apply(
within: Callable[[], None], apply: Callable[[], None]
) -> None
functions
BUILTIN_FUNCTION_DECLARATIONS
BUILTIN_FUNCTION_DECLARATIONS = {name: _62IYyhSafor func_decl in STD_QMOD_OPERATORS + OPEN_LIB_DECLS + CORE_LIB_DECLS}
CORE_LIB_DECLS
CORE_LIB_DECLS = [
func_decl
for func in (
molecule_ucc,
molecule_hva,
molecule_hartree_fock,
fock_hamiltonian_ucc,
fock_hamiltonian_hva,
fock_hamiltonian_hartree_fock,
log_normal_finance,
gaussian_finance,
pauli_feature_map,
bloch_sphere_feature_map,
H,
X,
Y,
Z,
I,
S,
T,
SDG,
TDG,
PHASE,
RX,
RY,
RZ,
R,
RXX,
RYY,
RZZ,
CH,
CX,
CY,
CZ,
CRX,
CRY,
CRZ,
CPHASE,
SWAP,
IDENTITY,
prepare_state,
prepare_amplitudes,
unitary,
add,
modular_add,
integer_xor,
U,
CCX,
allocate,
free,
randomized_benchmarking,
inplace_prepare_state,
inplace_prepare_amplitudes,
single_pauli_exponent,
suzuki_trotter,
qdrift,
exponentiation_with_depth_constraint,
)
]
Input
Input = _Q
OPEN_LIB_DECLS
OPEN_LIB_DECLS = [
func_decl
for func in (
qpe_flexible,
qpe,
_single_pauli,
linear_pauli_rotations,
amplitude_estimation,
phase_oracle,
reflect_about_zero,
grover_diffuser,
grover_operator,
grover_search,
hadamard_transform,
apply_to_all,
qft_no_swap,
qft_space_add_const,
cc_modular_add,
c_modular_multiply,
multiswap,
inplace_c_modular_multiply,
modular_exp,
qsvt_step,
qsvt,
projector_controlled_phase,
qsvt_inversion,
allocate_num,
qaoa_mixer_layer,
qaoa_cost_layer,
qaoa_layer,
qaoa_init,
qaoa_penalty,
full_hea,
swap_test,
prepare_uniform_trimmed_state,
prepare_uniform_interval_state,
prepare_ghz_state,
prepare_exponential_state,
prepare_bell_state,
inplace_prepare_int,
prepare_int,
switch,
qct_qst_type1,
qct_qst_type2,
qct_type2,
qst_type2,
modular_increment,
qft,
_ctrl_x,
_prepare_uniform_trimmed_state_step,
_qct_d_operator,
_qct_pi_operator,
_check_msb,
)
]
Output
Output = _Q
CArray
CArray(expr: str)
Bases: CParam
, ArrayBase[_P]
len
len: int
CBool
CBool(expr: str)
Bases: CParam
CInt
CInt(expr: str)
Bases: CParam
CReal
CReal(expr: str)
Bases: CParam
FinanceFunction
FockHamiltonianProblem
GaussianModel
LogNormalModel
MoleculeProblem
Pauli
Bases: IntEnum
Enumeration for the Pauli matrices used in quantum computing.
The Pauli matrices are fundamental operations in quantum computing, and this enum assigns integer values to represent each matrix.
I
I = 0
I (int): Identity matrix, represented by the integer 0.
\(I = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}\)
X
X = 1
X (int): Pauli-X matrix, represented by the integer 1.
\(X = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}\)
Y
Y = 2
Y (int): Pauli-Y matrix, represented by the integer 2.
\(Y = \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}\)
Z
Z = 3
Z (int): Pauli-Z matrix, represented by the integer 3.
\(Z = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}\)
PauliTerm
A term in a Hamiltonian, represented as a product of Pauli operators.
Attributes:
Name | Type | Description |
---|---|---|
pauli |
CArray[Pauli]
|
The list of the chosen Pauli operators in the term, corresponds to a product of them. |
coefficient |
CReal
|
The coefficient of the term (floating number). |
QArray
QArray(
name: Union[str, HandleBinding],
element_type: Union[_GenericAlias, QuantumType] = QBit,
length: Optional[
Union[int, SymbolicExpr, Expression]
] = None,
_expr_str: Optional[str] = None,
)
Bases: ArrayBase[_P]
, QVar
len
len: Union[CParamScalar, int]
get_qmod_type
get_qmod_type() -> QuantumBitvector
to_qmod_quantum_type
to_qmod_quantum_type(type_hint: Any) -> QuantumType
to_qvar
to_qvar(
origin: Union[str, HandleBinding],
type_hint: Any,
expr_str: Optional[str],
) -> QArray
QBit
QBit(
origin: Union[str, HandleBinding],
*,
_expr_str: Optional[str] = None,
depth: int = 2
)
Bases: QScalar
get_qmod_type
get_qmod_type() -> QuantumType
to_qmod_quantum_type
to_qmod_quantum_type(type_hint: Any) -> QuantumType
to_qvar
to_qvar(
origin: Union[str, HandleBinding],
type_hint: Any,
expr_str: Optional[str],
) -> QBit
QCallable
Bases: Generic[P]
, ABC
CURRENT_EXPANDABLE
CURRENT_EXPANDABLE: Optional[QExpandableInterface] = None
FRAME_DEPTH
FRAME_DEPTH = 1
func_decl
func_decl: AnonQuantumFunctionDeclaration
create_quantum_function_call
create_quantum_function_call(
source_ref_: SourceReference, *args: Any, **kwargs: Any
) -> QuantumFunctionCall
QCallableList
Bases: QCallable
, Generic[P]
, ABC
len
len: int
QNum
QNum(
name: Union[str, HandleBinding],
size: Union[int, CInt, Expression, None] = None,
is_signed: Union[
bool, Expression, SymbolicExpr, None
] = None,
fraction_digits: Union[
int, CInt, Expression, None
] = None,
_expr_str: Optional[str] = None,
)
Bases: Generic[_P]
, QScalar
fraction_digits
fraction_digits: Union[CParamScalar, int]
is_signed
is_signed: Union[CParamScalar, bool]
get_qmod_type
get_qmod_type() -> QuantumType
to_qmod_quantum_type
to_qmod_quantum_type(type_hint: Any) -> QuantumType
to_qvar
to_qvar(
origin: Union[str, HandleBinding],
type_hint: Any,
expr_str: Optional[str],
) -> QNum
QSVMFeatureMapPauli
CCX
[Qmod core-library function]
Applies the Pauli-X gate to the target qubit, conditioned on the two control qubits (Toffoli).
This operation is represented by the following matrix:
More information can be found on Wikipedia.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
control |
QArray[QBit, Literal[2]]
|
The control qubits. |
required |
target |
QBit
|
The qubit to apply the conditioned Pauli-X gate on. |
required |
Link: Reference Manual
CH
[Qmod core-library function]
Applies the Hadamard gate to the target qubit, conditioned on the control qubit.
This operation is represented by the following matrix:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
control |
QBit
|
The control qubit. |
required |
target |
QBit
|
The qubit to apply the Hadamard gate on. |
required |
Link: Reference Manual
CPHASE
[Qmod core-library function]
Applies the PHASE gate to the target qubit, conditioned on the control qubit.
This operation is represented by the following matrix:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
theta |
CReal
|
The rotation angle in radians. |
required |
control |
QBit
|
The control qubit. |
required |
target |
QBit
|
The qubit to apply the PHASE gate on. |
required |
Link: Reference Manual
CRX
[Qmod core-library function]
Applies the RX gate to the target qubit, conditioned on the control qubit.
This operation is represented by the following matrix:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
theta |
CReal
|
The rotation angle in radians. |
required |
control |
QBit
|
The control qubit. |
required |
target |
QBit
|
The qubit to apply the RX gate on. |
required |
Link: Reference Manual
CRY
[Qmod core-library function]
Applies the RY gate to the target qubit, conditioned on the control qubit.
This operation is represented by the following matrix:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
theta |
CReal
|
The rotation angle in radians. |
required |
control |
QBit
|
The control qubit. |
required |
target |
QBit
|
The qubit to apply the RY gate on. |
required |
Link: Reference Manual
CRZ
[Qmod core-library function]
Applies the RZ gate to the target qubit, conditioned on the control qubit.
This operation is represented by the following matrix:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
theta |
CReal
|
The rotation angle in radians. |
required |
control |
QBit
|
The control qubit. |
required |
target |
QBit
|
The qubit to apply the RZ gate on. |
required |
Link: Reference Manual
CX
[Qmod core-library function]
Applies the Pauli-X gate to the target qubit, conditioned on the control qubit.
This operation is represented by the following matrix:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
control |
QBit
|
The control qubit. |
required |
target |
QBit
|
The qubit to apply the Pauli-X gate on. |
required |
Link: Reference Manual
CY
[Qmod core-library function]
Applies the Pauli-Y gate to the target qubit, conditioned on the control qubit.
This operation is represented by the following matrix:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
control |
QBit
|
The control qubit. |
required |
target |
QBit
|
The qubit to apply the Pauli-Y gate on. |
required |
Link: Reference Manual
CZ
[Qmod core-library function]
Applies the Pauli-Z gate to the target qubit, conditioned on the control qubit.
This operation is represented by the following matrix:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
control |
QBit
|
The control qubit. |
required |
target |
QBit
|
The qubit to apply the Pauli-Z gate on. |
required |
Link: Reference Manual
H
H(target: QBit) -> None
[Qmod core-library function]
Performs the Hadamard gate on a qubit.
This operation is represented by the following matrix:
More information on quantum logic gates can be found on Wikipedia.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target |
QBit
|
The qubit to apply the Hadamard gate to. |
required |
Link: Reference Manual
I
I(target: QBit) -> None
[Qmod core-library function]
Performs the identity gate on a qubit.
This operation is represented by the following matrix:
More information on quantum logic gates can be found on Wikipedia.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target |
QBit
|
The qubit to apply the identity gate to. |
required |
Link: Reference Manual
IDENTITY
[Qmod core-library function]
Does nothing.
This operation is represented by the following matrix:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target |
QArray[QBit]
|
The qubits to apply the IDENTITY gate on. |
required |
Link: Reference Manual
PHASE
[Qmod core-library function]
Performs the phase gate on a qubit.
This operation is represented by the following matrix:
More information on quantum logic gates can be found on Wikipedia.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
theta |
CReal
|
The phase angle in radians. |
required |
target |
QBit
|
The qubit to apply the phase gate to. |
required |
Link: Reference Manual
R
[Qmod core-library function]
Performs a rotation of \(\theta\) around the \(cos(\phi)\hat{x} + sin(\phi)\hat{y}\) axis on a qubit.
This operation is represented by the following matrix:
More information on this gate can be found in the Qiskit documentation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
theta |
CReal
|
The rotation angle in radians. |
required |
phi |
CReal
|
The phase angle in radians. |
required |
target |
QBit
|
The qubit to apply the general single-qubit rotation gate to. |
required |
Link: Reference Manual
RX
[Qmod core-library function]
Performs the Pauli-X rotation gate on a qubit.
This operation is represented by the following matrix:
More information on quantum logic gates can be found on Wikipedia.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
theta |
CReal
|
The rotation angle in radians. |
required |
target |
QBit
|
The qubit to apply the Pauli-X rotation gate to. |
required |
Link: Reference Manual
RXX
[Qmod core-library function]
Performs the XX rotation gate on a pair of qubits.
This operation is represented by the following matrix:
For more information on quantum logic gates, see Wikipedia.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
theta |
CReal
|
The rotation angle in radians. |
required |
target |
QArray[QBit, Literal[2]]
|
The pair of qubits to apply the XX rotation gate to. |
required |
Link: Reference Manual
RY
[Qmod core-library function]
Performs the Pauli-Y rotation gate on a qubit.
This operation is represented by the following matrix:
More information on quantum logic gates can be found on Wikipedia.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
theta |
CReal
|
The rotation angle in radians. |
required |
target |
QBit
|
The qubit to apply the Pauli-Y rotation gate to. |
required |
Link: Reference Manual
RYY
[Qmod core-library function]
Performs the YY rotation gate on a pair of qubits.
This operation is represented by the following matrix:
For more information on quantum logic gates, see Wikipedia.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
theta |
CReal
|
The rotation angle in radians. |
required |
target |
QArray[QBit, Literal[2]]
|
The pair of qubits to apply the YY rotation gate to. |
required |
Link: Reference Manual
RZ
[Qmod core-library function]
Performs the Pauli-Z rotation gate on a qubit.
This operation is represented by the following matrix:
More information on quantum logic gates can be found on Wikipedia.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
theta |
CReal
|
The rotation angle in radians. |
required |
target |
QBit
|
The qubit to apply the Pauli-Z rotation gate to. |
required |
Link: Reference Manual
RZZ
[Qmod core-library function]
Performs the ZZ rotation gate on a pair of qubits.
This operation is represented by the following matrix:
For more information on quantum logic gates, see Wikipedia.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
theta |
CReal
|
The rotation angle in radians. |
required |
target |
QArray[QBit, Literal[2]]
|
The pair of qubits to apply the ZZ rotation gate to. |
required |
Link: Reference Manual
S
S(target: QBit) -> None
[Qmod core-library function]
Performs the S gate on a qubit.
This operation is represented by the following matrix:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target |
QBit
|
The qubit to apply the S gate to. |
required |
Link: Reference Manual
SDG
SDG(target: QBit) -> None
[Qmod core-library function]
Performs the S-dagger gate on a qubit.
This operation is represented by the following matrix:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target |
QBit
|
The qubit to apply the S-dagger gate to. |
required |
Link: Reference Manual
SWAP
[Qmod core-library function]
Swaps the states of two qubits.
This operation is represented by the following matrix:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qbit0 |
QBit
|
The first qubit. |
required |
qbit1 |
QBit
|
The second qubit. |
required |
Link: Reference Manual
T
T(target: QBit) -> None
[Qmod core-library function]
Performs the T gate on a qubit.
This operation is represented by the following matrix:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target |
QBit
|
The qubit to apply the T gate to. |
required |
Link: Reference Manual
TDG
TDG(target: QBit) -> None
[Qmod core-library function]
Performs the T-dagger gate on a qubit.
This operation is represented by the following matrix:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target |
QBit
|
The qubit to apply the T-dagger gate to. |
required |
Link: Reference Manual
U
[Qmod core-library function]
Performs a general single-qubit unitary gate that applies phase and rotation with three Euler angles on a qubit.
This operation is represented by the following matrix:
More information on this gate can be found on Wikipedia.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
theta |
CReal
|
The first Euler angle in radians. |
required |
phi |
CReal
|
The second Euler angle in radians. |
required |
lam |
CReal
|
The third Euler angle in radians. |
required |
gam |
CReal
|
The global phase angle in radians. |
required |
target |
QBit
|
The qubit to apply the general single-qubit unitary gate to. |
required |
Link: Reference Manual
X
X(target: QBit) -> None
[Qmod core-library function]
Performs the Pauli-X gate on a qubit.
This operation is represented by the following matrix:
More information on quantum logic gates can be found on Wikipedia.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target |
QBit
|
The qubit to apply the Pauli-X gate to. |
required |
Link: Reference Manual
Y
Y(target: QBit) -> None
[Qmod core-library function]
Performs the Pauli-Y gate on a qubit.
This operation is represented by the following matrix:
More information on quantum logic gates can be found on Wikipedia.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target |
QBit
|
The qubit to apply the Pauli-Y gate to. |
required |
Link: Reference Manual
Z
Z(target: QBit) -> None
[Qmod core-library function]
Performs the Pauli-Z gate on a qubit.
This operation is represented by the following matrix:
More information on quantum logic gates can be found on Wikipedia.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target |
QBit
|
The qubit to apply the Pauli-Z gate to. |
required |
Link: Reference Manual
add
add(
left: QArray[QBit],
right: QArray[QBit],
result: Output[
QArray[
QBit,
Literal[
"Max(get_field(left, 'len'), get_field(right, 'len')) + 1"
],
]
],
) -> None
allocate
[Qmod core-library function]
Allocates the specified number of qubits to a given quantum variable and initializes them in the zero state:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_qubits |
CInt
|
The number of qubits to allocate. Must be a positive integer. |
required |
out |
Output[QArray[QBit, Literal['num_qubits']]]
|
The quantum variable that will receive the allocated qubits. Must be uninitialized before allocation. For more information on quantum variable initialization, see here. |
required |
Notes
- If the output variable has been declared with a specific number of qubits, the number of qubits allocated must match the declared number.
- The synthesis engine automatically handles the allocation, either by drawing new qubits from the available pool or by reusing existing ones.
allocate_num
allocate_num(
num_qubits: CInt,
is_signed: CBool,
fraction_digits: CInt,
out: Output[
QNum[
Literal["num_qubits"],
Literal["is_signed"],
Literal["fraction_digits"],
]
],
) -> None
[Qmod Classiq-library function]
Initializes a quantum number with the given number of qubits, sign, and fractional digits.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_qubits |
CInt
|
The number of qubits to allocate. |
required |
is_signed |
CBool
|
Whether the number is signed or unsigned. |
required |
fraction_digits |
CInt
|
The number of fractional digits. |
required |
Further reading is available on the reference manual
amplitude_estimation
amplitude_estimation(
oracle: QCallable[QArray[QBit]],
space_transform: QCallable[QArray[QBit]],
phase: QNum,
packed_vars: QArray[QBit],
) -> None
[Qmod Classiq-library function]
Estimate the probability of a state being marked by the operand oracle
as a "good state."
The algorithm prepares the state in the packed_vars
register and estimates the probability of this state being marked by the oracle as a "good state."
This is done using the Quantum Phase Estimation (QPE) algorithm, where the unitary for QPE is the Grover operator, which is composed of the oracle
and space_transform
operators.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
oracle |
QCallable[QArray[QBit]]
|
The oracle operator that marks the "good" state. This operator should flip the sign of the amplitude of the "good" state. |
required |
space_transform |
QCallable[QArray[QBit]]
|
The space transform operator (which is known also the state preparation operator), which is first applied to prepare the state before the QPE, and then used inside the Grover operator. |
required |
phase |
QNum
|
Assuming this variable starts from the zero state -this variable output holds the \(phase=\theta\) result in the [0,1] domain, which relates to the estimated probability \(a\) through \(a=\sin^2(\pi \theta)\). |
required |
packed_vars |
QArray[QBit]
|
The variable that holds the state to be estimated. Assumed to be in the zero state at the beginning of the algorithm. |
required |
apply_to_all
[Qmod Classiq-library function]
Applies the single-qubit operand gate_operand
to each qubit in the qubit
array target
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gate_operand |
QCallable[QBit]
|
The single-qubit gate to apply to each qubit in the array. |
required |
target |
QArray[QBit]
|
The qubit array to apply the gate to. |
required |
bloch_sphere_feature_map
bloch_sphere_feature_map(
feature_dimension: CInt,
qbv: QArray[
QBit, Literal["ceiling(feature_dimension / 2)"]
],
) -> None
c_modular_multiply
[Qmod Classiq-library function]
Performs out-of-place multiplication of a quantum number x
by a classical number a
modulo classical number n
,
controlled by a quantum bit ctrl
and adds the result to a quantum array b
. Applies \(b += xa \mod n\) if ctrl=1
, and the identity otherwise.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
CInt
|
The modulo number. Should be non-negative. |
required |
a |
CInt
|
The classical factor. Should be non-negative. |
required |
b |
QArray[QBit]
|
The quantum number added to the multiplication result. Stores the result of the multiplication. |
required |
x |
QArray[QBit]
|
The quantum factor. |
required |
ctrl |
QBit
|
The control bit. |
required |
cc_modular_add
[Qmod Classiq-library function]
Adds a constant a
to a quantum number phi_b
modulo the constant n
, controlled by 2 qubits.
The quantum number phi_b
and the constant a
are assumed to be in the QFT space.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
CInt
|
The modulo number. |
required |
a |
CInt
|
The constant to add to the quantum number. |
required |
phi_b |
QArray[QBit]
|
The quantum number to which the constant is added. |
required |
c1 |
QBit
|
a control qubit. |
required |
c2 |
QBit
|
a control qubit. |
required |
exponentiation_with_depth_constraint
exponentiation_with_depth_constraint(
pauli_operator: CArray[PauliTerm],
evolution_coefficient: CReal,
max_depth: CInt,
qbv: QArray[
QBit,
Literal[
"get_field(get_field(pauli_operator[0], 'pauli'), 'len')"
],
],
) -> None
[Qmod core-library function]
Exponentiates a Pauli operator via the Suzuki-Trotter decomposition with a depth constraint. The Suzuki-Trotter decomposition is a method for approximating the exponential of a sum of operators by a product of exponentials of each operator. This function automatically determines the order and number of repetitions of the Suzuki-Trotter decomposition to minimize the error given a depth constraint.
See A. M. Childs et al., Toward the first quantum simulation with quantum speedup (2017).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pauli_operator |
CArray[PauliTerm]
|
The Pauli operator to be exponentiated. |
required |
evolution_coefficient |
CReal
|
A global coefficient multiplying the Pauli operator. |
required |
max_depth |
CInt
|
The maximum depth of the exponentiation. |
required |
qbv |
QArray[QBit, Literal["get_field(get_field(pauli_operator[0], 'pauli'), 'len')"]]
|
The target quantum variable of the exponentiation. |
required |
fock_hamiltonian_hartree_fock
fock_hamiltonian_hartree_fock(
fock_hamiltonian_problem: FockHamiltonianProblem,
qbv: QArray[
QBit,
Literal[
"get_field(get_field(fock_hamiltonian_problem_to_hamiltonian(fock_hamiltonian_problem)[0], 'pauli'), 'len')"
],
],
) -> None
fock_hamiltonian_hva
fock_hamiltonian_hva(
fock_hamiltonian_problem: FockHamiltonianProblem,
reps: CInt,
qbv: QArray[
QBit,
Literal[
"get_field(get_field(fock_hamiltonian_problem_to_hamiltonian(fock_hamiltonian_problem)[0], 'pauli'), 'len')"
],
],
) -> None
fock_hamiltonian_ucc
fock_hamiltonian_ucc(
fock_hamiltonian_problem: FockHamiltonianProblem,
excitations: CArray[CInt],
qbv: QArray[
QBit,
Literal[
"get_field(get_field(fock_hamiltonian_problem_to_hamiltonian(fock_hamiltonian_problem)[0], 'pauli'), 'len')"
],
],
) -> None
free
[Qmod core-library function]
Releases the qubits allocated to a quantum variable, allowing them to be reused.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
in_ |
Input[QArray[QBit]]
|
The quantum variable that will be freed. Must be initialized before. For more information on quantum variable initialization, see here. |
required |
Note
This operation does not uncompute the qubits. It is the responsibility of the user to ensure that the qubits are at the zero state before freeing them.
full_hea
full_hea(
num_qubits: CInt,
is_parametrized: CArray[CInt],
angle_params: CArray[CReal],
connectivity_map: CArray[CArray[CInt]],
reps: CInt,
operands_1qubit: QCallableList[CReal, QBit],
operands_2qubit: QCallableList[CReal, QBit, QBit],
x: QArray[QBit, Literal["num_qubits"]],
) -> None
[Qmod Classiq-library function]
Implements an ansatz on a qubit array x
with the given 1-qubit and 2-qubit operations.
The number of ansatz layers is given in argument reps
.
Each layer applies the 1-qubit operands in operands_1qubit
to all the qubits in x
.
Next, it applies the 2-qubit operands in operands_2qubit
to qubits (i, j) for each
pair of indices (i, j) in connectivity_map
.
The list is_parametrized
specifies whether the operands in operands_1qubit
and
operands_2qubit
are parametric (expect a classical argument).
is_parametrized
is a list of flags (0 and 1 integers) of length
len(operands_1qubit) + len(operands_2qubit)
.
The first len(operands_1qubit)
flags refer to the operands_1qubit
operands and
the next len(operands_2qubit)
flags refer to the operands_2qubit
operands.
The classical arguments to the parametric operands are given in argument
angle_params
.
angle_params
concatenates a set of arguments for each ansatz layer.
Each set contains an argument for each qubit in x
times the number
of parametric operands in operands_1qubit
.
These are followed by an argument for each mapping pair in connectivity_map
times
the number of parametric operands in operands_2qubit
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_qubits |
CInt
|
The length of qubit array x |
required |
is_parametrized |
CArray[CInt]
|
A list of 0 and 1 flags |
required |
connectivity_map |
CArray[CArray[CInt]]
|
A list of pairs of qubit indices |
required |
reps |
CInt
|
The number of ansatz layers |
required |
operands_1qubit |
QCallableList[CReal, QBit]
|
A list of operations on a single qubit |
required |
operands_2qubit |
QCallableList[CReal, QBit, QBit]
|
A list of operations on two qubits |
required |
x |
QArray[QBit, Literal['num_qubits']]
|
The quantum object to be transformed by the ansatz |
required |
gaussian_finance
gaussian_finance(
finance_model: GaussianModel,
finance_function: FinanceFunction,
func_port: QArray[
QBit,
Literal[
"get_field(finance_model, 'num_qubits') + get_field(get_field(finance_model, 'rhos'), 'len') + floor(log(sum(get_field(finance_model, 'loss')), 2)) + 1"
],
],
obj_port: QBit,
) -> None
grover_diffuser
[Qmod Classiq-library function]
Reflects the given state about the A|0> state, where A
is the space_transform
parameter. It is defined as:
where \(S_0\) is the reflection about the |0> state (see reflect_about_zero
).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
space_transform |
QCallable[QArray[QBit]]
|
The operator which encodes the axis of reflection. |
required |
packed_vars |
QArray[QBit]
|
The state to which to apply the diffuser. |
required |
grover_operator
grover_operator(
oracle: QCallable[QArray[QBit]],
space_transform: QCallable[QArray[QBit]],
packed_vars: QArray[QBit],
) -> None
[Qmod Classiq-library function]
Applies the grover operator, defined by:
where \(S_{\psi_1}\) is a reflection about marked states, and \(S_{\psi_0}\) is a reflection about a given state defined by \(|\psi_0 angle = A|0 angle\).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
oracle |
QCallable[QArray[QBit]]
|
A unitary operator which adds a phase of (-1) to marked states. |
required |
space_transform |
QCallable[QArray[QBit]]
|
The operator which creates \(|\psi_0 angle\), the initial state, used by the diffuser to reflect about it. |
required |
packed_vars |
QArray[QBit]
|
The state to which to apply the grover operator. |
required |
For further reading, see:
grover_search
[Qmod Classiq-library function]
Applies Grover search algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reps |
CInt
|
Number of repetitions of the grover operator. |
required |
oracle |
QCallable[QArray[QBit]]
|
An oracle that marks the solution. |
required |
packed_vars |
QArray[QBit]
|
Packed form of the variable to apply the grover operator on. |
required |
Returns: None
Links
hadamard_transform
[Qmod Classiq-library function]
Applies Hadamard transform to the target qubits.
Corresponds to the braket notation:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target |
QArray[QBit]
|
qubits to apply to Hadamard transform to. |
required |
inplace_c_modular_multiply
[Qmod Classiq-library function]
Performs multiplication of a quantum number x
by a classical number a
modulo classical number n
,
controlled by a quantum bit ctrl
. Applies \(x=xa \mod n\) if ctrl=1
, and the identity otherwise.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
CInt
|
The modulo number. Should be non-negative. |
required |
a |
CInt
|
The classical factor. Should be non-negative. |
required |
x |
QArray[QBit]
|
The quantum factor. |
required |
ctrl |
QBit
|
The control bit. |
required |
inplace_prepare_amplitudes
inplace_prepare_amplitudes(
amplitudes: CArray[CReal],
bound: CReal,
target: QArray[
QBit,
Literal["log(get_field(amplitudes, 'len'), 2)"],
],
) -> None
[Qmod core-library function]
Transforms a given quantum variable in the state |0> to the state per the specified amplitudes
(similar to prepare_amplitudes
but preformed on an initialized variable).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
amplitudes |
CArray[CReal]
|
The amplitudes to initialize the quantum variable. Must be a valid real quantum state vector, i.e., the sum of squares should be 1. Must have a valid length (a power of 2). |
required |
bound |
CReal
|
An error bound, expressed as the \(L^{2}\) norm between the expected and actual distributions. A larger bound can reduce the circuit size at the expense of accuracy. Must be a positive real number. |
required |
target |
QArray[QBit, Literal["log(get_field(amplitudes, 'len'), 2)"]]
|
The quantum variable to act upon. |
required |
This is useful as part of quantum building blocks like the Grover diffuser operator, \(\left|\psi\right\rangle\left\langle\psi\right| \left( 2\left|0\right\rangle\left\langle0\right| - \mathcal{I} \right)\), where the output state of the oracle is reflected about this state.
inplace_prepare_int
[Qmod Classiq-library function]
Transitions a quantum variable in the zero state \(|0\rangle\) into the computational basis state \(|\text{value}\rangle\). In the general case, the function performs a bitwise-XOR, i.e. transitions the state \(|\psi\rangle\) into \(|\psi \oplus \text{value}\rangle\).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
CInt
|
The value to assign to the quantum variable. |
required |
target |
QArray[QBit]
|
The quantum variable to act upon. |
required |
Note
If the value cannot fit into the quantum variable, it is truncated, i.e. treated as the value modulo \(2^\text{target.size}\).
inplace_prepare_state
inplace_prepare_state(
probabilities: CArray[CReal],
bound: CReal,
target: QArray[
QBit,
Literal["log(get_field(probabilities, 'len'), 2)"],
],
) -> None
[Qmod core-library function]
Transforms a given quantum variable in the state |0> to the state per the specified probability distribution
(similar to prepare_state
but preformed on an initialized variable).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
probabilities |
CArray[CReal]
|
The probability distribution corresponding to the quantum variable state. Must be a valid probability distribution, i.e., a list of non-negative real numbers that sum to 1. Must have a valid length (a power of 2). |
required |
bound |
CReal
|
An error bound, expressed as the \(L^{2}\) norm between the expected and actual distributions. A larger bound can reduce the circuit size at the expense of accuracy. Must be a positive real number. |
required |
target |
QArray[QBit, Literal["log(get_field(probabilities, 'len'), 2)"]]
|
The quantum variable to act upon. |
required |
This is useful as part of quantum building blocks like the Grover diffuser operator, \(\left|\psi\right\rangle\left\langle\psi\right| \left( 2\left|0\right\rangle\left\langle0\right| - \mathcal{I} \right)\), where the output state of the oracle is reflected about this state.
linear_pauli_rotations
linear_pauli_rotations(
bases: CArray[Pauli],
slopes: CArray[CReal],
offsets: CArray[CReal],
x: QArray[QBit],
q: QArray[QBit],
) -> None
[Qmod Classiq-library function]
Performs a rotation on a series of \(m\) target qubits, where the rotation angle is a linear function of an \(n\)-qubit control register.
Corresponds to the braket notation:
where \(\left|x ight angle\) is the control register, \(\left|q ight angle\) is the target register, each \(P_{k}\) is one of the three Pauli matrices \(X\), \(Y\), or \(Z\), and \(a_{k}\), \(b_{k}\) are the user given slopes and offsets, respectively.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bases |
CArray[Pauli]
|
List of Pauli Enums. |
required |
slopes |
CArray[CReal]
|
Rotation slopes for each of the given Pauli bases. |
required |
offsets |
CArray[CReal]
|
Rotation offsets for each of the given Pauli bases. |
required |
x |
QArray[QBit]
|
Quantum state to apply the rotation based on its value. |
required |
q |
QArray[QBit]
|
List of indicator qubits for each of the given Pauli bases. |
required |
Notice that bases, slopes, offset and q should be of the same size.
Links
log_normal_finance
log_normal_finance(
finance_model: LogNormalModel,
finance_function: FinanceFunction,
func_port: QArray[
QBit,
Literal["get_field(finance_model, 'num_qubits')"],
],
obj_port: QBit,
) -> None
modular_exp
[Qmod Classiq-library function]
Raises a classical integer a
to the power of a quantum number x
modulo classical integer n
times a quantum number power
. Performs \(power=(a^x \mod n)*power\) in-place.
(and specifically if at the input \(power=1\), at the output \(power=a^x \mod n\)).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
CInt
|
The modulus number. Should be non-negative. |
required |
a |
CInt
|
The base of the exponentiation. Should be non-negative. |
required |
x |
QArray[QBit]
|
The power of the exponentiation. |
required |
power |
QArray[QBit]
|
A quantum number which multiplies the modular exponentiation and holds the output. |
required |
modular_increment
[Qmod Classiq-library function]
Adds \(a\) to \(x\) modulo the range of \(x\), assumed that \(x\) is a non-negative integer and \(a\) is an integer. Mathematically it is described as:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a |
CInt
|
A classical integer to be added to x. |
required |
x |
QNum
|
A quantum number that is assumed to be non-negative integer. |
required |
molecule_hartree_fock
molecule_hartree_fock(
molecule_problem: MoleculeProblem,
qbv: QArray[
QBit,
Literal[
"get_field(get_field(molecule_problem_to_hamiltonian(molecule_problem)[0], 'pauli'), 'len')"
],
],
) -> None
molecule_hva
molecule_hva(
molecule_problem: MoleculeProblem,
reps: CInt,
qbv: QArray[
QBit,
Literal[
"get_field(get_field(molecule_problem_to_hamiltonian(molecule_problem)[0], 'pauli'), 'len')"
],
],
) -> None
molecule_ucc
molecule_ucc(
molecule_problem: MoleculeProblem,
excitations: CArray[CInt],
qbv: QArray[
QBit,
Literal[
"get_field(get_field(molecule_problem_to_hamiltonian(molecule_problem)[0], 'pauli'), 'len')"
],
],
) -> None
multiswap
[Qmod Classiq-library function]
Swaps the qubit states between two arrays. Qubits of respective indices are swapped, and additional qubits in the longer array are left unchanged.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
QArray[QBit]
|
The first array |
required |
y |
QArray[QBit]
|
The second array |
required |
pauli_feature_map
pauli_feature_map(
feature_map: QSVMFeatureMapPauli,
qbv: QArray[
QBit,
Literal[
"get_field(feature_map, 'feature_dimension')"
],
],
) -> None
phase_oracle
[Qmod Classiq-library function]
Creates a phase oracle operator based on a predicate function.
Applies a predicate function and marks "good" and "bad" states with a phase flip. If the predicate is marked as \(\chi\), and the oracle is marked as \(S_\chi\), then:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
predicate |
QCallable[QArray[QBit], QBit]
|
A predicate function that takes a QArray of QBits and sets a single QBit |1> if the predicate is true, and |0> otherwise. |
required |
target |
QArray[QBit]
|
The target QArray of QBits to apply the phase oracle to. |
required |
prepare_amplitudes
prepare_amplitudes(
amplitudes: CArray[CReal],
bound: CReal,
out: Output[
QArray[
QBit,
Literal["log(get_field(amplitudes, 'len'), 2)"],
]
],
) -> None
[Qmod core-library function]
Initializes a quantum variable in a state corresponding to the given amplitudes:
with \(i = 0, 1, 2, ..., \text{len(amplitudes)}-1\) corresponding to computational basis states.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
amplitudes |
CArray[CReal]
|
The amplitudes to initialize the quantum variable. Must be a valid real quantum state vector, i.e., the sum of squares should be 1. Must have a valid length (a power of 2). |
required |
bound |
CReal
|
An error bound, expressed as the \(L^{2}\) norm between the expected and actual distributions. A larger bound can reduce the circuit size at the expense of accuracy. Must be a positive real number. |
required |
out |
Output[QArray[QBit, Literal["log(get_field(amplitudes, 'len'), 2)"]]]
|
The quantum variable that will receive the initialized state. Must be uninitialized. For more information on quantum variable initialization, see here. |
required |
Notes
- If the output variable has been declared with a specific number of qubits, the number of qubits formed by the distribution must match the declared number.
- The synthesis engine automatically handles the allocation, either by drawing new qubits from the available pool or by reusing existing ones.
prepare_bell_state
[Qmod Classiq-library function]
Initializes a quantum array of size 2 in one of the four Bell states.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state_num |
CInt
|
The number of the Bell state to be prepared. Must be an integer between 0 and 3. |
required |
q |
Output[QArray[QBit, Literal[2]]]
|
The quantum variable that will receive the initialized state. Must be uninitialized. |
required |
Bell States
The four Bell states are defined as follows (each state correlates to an integer between 0 and 3 as defined by the state_num
argument):
If state_num
= 0 the function prepares the Bell state:
If state_num
= 1 the function prepares the Bell state:
If state_num
= 2 the function prepares the Bell state:
If state_num
= 3 the function prepares the Bell state:
Notes
The synthesis engine automatically handles the allocation, either by drawing new qubits from the available pool or by reusing existing ones.
prepare_exponential_state
[Qmod Classiq-library function]
Prepares a quantum state with exponentially decreasing amplitudes. The state is prepared in the computational basis, with the amplitudes of the states decreasing exponentially with the index of the state:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rate |
CInt
|
The rate of the exponential decay. |
required |
q |
QArray[QBit]
|
The quantum register to prepare. |
required |
Further reading is available on the reference manual
prepare_ghz_state
[Qmod Classiq-library function]
Initializes a quantum variable in a Greenberger-Horne-Zeilinger (GHZ) state. i.e., a balanced superposition of all ones and all zeros, on an arbitrary number of qubits..
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size |
CInt
|
The number of qubits in the GHZ state. Must be a positive integer. |
required |
q |
Output[QArray[QBit]]
|
The quantum variable that will receive the initialized state. Must be uninitialized. |
required |
Notes
The synthesis engine automatically handles the allocation, either by drawing new qubits from the available pool or by reusing existing ones.
prepare_int
prepare_int(
value: CInt,
out: Output[
QNum[
Literal["floor(log(value, 2)) + 1"],
Literal[False],
Literal[0],
]
],
) -> None
[Qmod Classiq-library function]
Initializes a quantum variable to the computational basis state \(|\text{value}\rangle\). The number of allocated qubits is automatically computed from the value, and is the minimal number required for representation in the computational basis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
CInt
|
The value to assign to the quantum variable. |
required |
out |
Output[QNum[Literal['floor(log(value, 2)) + 1'], Literal[False], Literal[0]]]
|
The allocated quantum variable. Must be uninitialized. For more information on quantum variable initialization, see here. |
required |
Note
If the output variable has been declared with a specific number of qubits, it must match the number of allocated qubits.
prepare_state
prepare_state(
probabilities: CArray[CReal],
bound: CReal,
out: Output[
QArray[
QBit,
Literal[
"log(get_field(probabilities, 'len'), 2)"
],
]
],
) -> None
[Qmod core-library function]
Initializes a quantum variable in a state corresponding to a given probability distribution:
with \(i = 0, 1, 2, ..., \text{len(amplitudes)}-1\) corresponding to computational basis states.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
probabilities |
CArray[CReal]
|
The probability distribution to initialize the quantum variable. Must be a valid probability distribution, i.e., a list of non-negative real numbers that sum to 1. Must have a valid length (a power of 2). |
required |
bound |
CReal
|
An error bound, expressed as the \(L^{2}\) norm between the expected and actual distributions. A larger bound can reduce the circuit size at the expense of accuracy. Must be a positive real number. |
required |
out |
Output[QArray[QBit, Literal["log(get_field(probabilities, 'len'), 2)"]]]
|
The quantum variable that will receive the initialized state. Must be uninitialized. For more information on quantum variable initialization, see here. |
required |
Notes
- If the output variable has been declared with a specific number of qubits, the number of qubits formed by the distribution must match the declared number.
- The synthesis engine automatically handles the allocation, either by drawing new qubits from the available pool or by reusing existing ones.
prepare_uniform_interval_state
[Qmod Classiq-library function]
Initializes a quantum variable in a uniform superposition of the specified interval in the computational basis states:
The number of allocated qubits would be \(\left\lceil\log_2{\left(\text{end}\right)}\right\rceil\).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start |
CInt
|
The lower bound of the interval to load (inclusive). |
required |
end |
CInt
|
The upper bound of the interval to load (exclusive). |
required |
q |
QArray[QBit]
|
The quantum variable that will receive the initialized state. Must be uninitialized. For more information on quantum variable initialization, see here. |
required |
Notes
- If the output variable has been declared with a specific number of qubits, it must match the number of allocated qubits.
- The synthesis engine automatically handles the allocation, either by drawing new qubits from the available pool or by reusing existing ones.
prepare_uniform_trimmed_state
[Qmod Classiq-library function]
Initializes a quantum variable in a uniform superposition of the first m
computational basis states:
The number of allocated qubits would be \(\left\lceil\log_2{m}\right\rceil\).
The function is especially useful when m
is not a power of 2.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
m |
CInt
|
The number of states to load in the superposition. |
required |
q |
QArray[QBit]
|
The quantum variable that will receive the initialized state. Must be uninitialized. For more information on quantum variable initialization, see here. |
required |
Notes
- If the output variable has been declared with a specific number of qubits, it must match the number of allocated qubits.
- The synthesis engine automatically handles the allocation, either by drawing new qubits from the available pool or by reusing existing ones.
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:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
phase_seq |
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 |
Further reading in Classiq Library
qaoa_cost_layer
[Qmod Classiq-library function]
Applies the cost layer to the QAOA model.
This function integrates the problem-specific cost function into the QAOA model's objective function. The cost layer represents the primary objective that the QAOA algorithm seeks to optimize, such as minimizing energy or maximizing profit, depending on the application.
For more details on defining cost functions in QAOA models using Pyomo, see: Problem Formulation Args: g: The rotation parameter for the cost layer (prefactor). hamiltonian: The Hamiltonian terms for the QAOA model. target: The target quantum array variable.
qaoa_init
[Qmod Classiq-library function]
Initializes the QAOA circuit by applying the Hadamard gate to all qubits.
In the Quantum Approximate Optimization Algorithm (QAOA), the initial state is a uniform superposition created by applying the Hadamard gate to each qubit. This function prepares the qubits for the subsequent application of the cost and mixer layers by preparing them in an equal superposition state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target |
QArray[QBit]
|
The target quantum array variable. |
required |
qaoa_layer
[Qmod Classiq-library function]
Applies the QAOA layer, which concatenates the cost layer and the mixer layer.
The qaoa_layer
function integrates both the cost and mixer layers, essential components of the
Quantum Approximate Optimization Algorithm (QAOA). The cost layer encodes the problem's objective,
while the mixer layer introduces quantum superposition and drives the search across the solution space.
For more details mon the QAOA problem formulation, please see the following tutorial Args: g: The rotation parameter for the cost layer. b: The rotation parameter for the mixer layer. hamiltonian: The Hamiltonian terms for the QAOA model. target: The target quantum array variable.
qaoa_mixer_layer
[Qmod Classiq-library function]
Applies the mixer layer for the QAOA algorithm.
The mixer layer is a sequence of X
gates applied to each qubit in the target quantum
array variable.
Please refer to the QAOA mixer tutorial for an example
Parameters:
Name | Type | Description | Default |
---|---|---|---|
b |
CReal
|
The rotation parameter for the mixer layer. |
required |
target |
QArray[QBit]
|
The target quantum array. |
required |
qaoa_penalty
qaoa_penalty(
num_qubits: CInt,
params_list: CArray[CReal],
hamiltonian: CArray[PauliTerm],
target: QArray[QBit, Literal["num_qubits"]],
) -> None
[Qmod Classiq-library function]
Applies the penalty layer to the QAOA model.
This function adds a penalty term to the objective function of the QAOA model to enforce certain constraints (e.g., binary or integer variables) during the optimization process.
Please refer to the Optimization Problem tutorial for details.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_qubits |
CInt
|
The number of qubits in the quantum circuit. |
required |
hamiltonian |
CArray[PauliTerm]
|
The Hamiltonian terms for the QAOA model. |
required |
target |
QArray[QBit, Literal['num_qubits']]
|
The target quantum array variable. |
required |
qct_qst_type1
[Qmod Classiq-library function]
Applies the quantum discrete cosine (DCT) and sine (DST)
transform of type 1 to the qubit array x
.
Corresponds to the matrix (with \(n\equiv\)x.len
):
$$ \left( egin{array}{ccc|c} {} &{} &{} \ {}&{ m DCT}^{(1)}(2^{n-1}+1) & {}& 0\ {} &{} &{} \ \hline {} & 0 & {} & i{ m DST}^{(1)}(2^{n-1}-1) \end{array}
ight) $$
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
QArray[QBit]
|
The qubit array to apply the transform to. |
required |
qct_qst_type2
[Qmod Classiq-library function]
Applies the quantum discrete cosine (DCT) and sine (DST)
transform of type 2 to the qubit array x
concatenated with q
, with q
being the MSB.
Corresponds to the matrix (with \(n\equiv\)x.len
+1):
$$ \left( egin{array}{c|c} { m DCT}^{(2)}(2^{n-1}) & 0\ \hline 0 & -{ m DST}^{(2)}(2^{n-1}) \end{array}
ight) $$
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
QArray[QBit]
|
The LSB part of the qubit array to apply the transform to. |
required |
q |
QBit
|
The MSB of the qubit array to apply the transform to. |
required |
qct_type2
qdrift
qdrift(
pauli_operator: CArray[PauliTerm],
evolution_coefficient: CReal,
num_qdrift: CInt,
qbv: QArray[
QBit,
Literal[
"get_field(get_field(pauli_operator[0], 'pauli'), 'len')"
],
],
) -> None
[Qmod core-library function]
Exponentiates a Pauli operator using the QDrift method. The QDrift method is a stochastic method based on the Trotter decomposition for approximating the exponential of a sum of operators by a product of exponentials of each operator. The QDrift method randomizes the order of the operators in the product of exponentials to stochastically reduce the error of the approximation. The error of the QDrift method decreases as the number of QDrift steps increases.
See E. Campbell, Random Compiler for Fast Hamiltonian Simulation (2019).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pauli_operator |
CArray[PauliTerm]
|
The Pauli operator to be exponentiated. |
required |
evolution_coefficient |
CReal
|
A global evolution coefficient multiplying the Pauli operator. |
required |
num_qdrift |
The number of QDrift steps. |
required | |
qbv |
QArray[QBit, Literal["get_field(get_field(pauli_operator[0], 'pauli'), 'len')"]]
|
The target quantum variable of the exponentiation. |
required |
qft
[Qmod Classiq-library function]
Performs the Quantum Fourier Transform (QFT) on target
in-place.
Implements the following transformation:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target |
QArray[QBit]
|
The quantum object to be transformed |
required |
Further reading in Classiq Library: Link: qft library reference
qft_no_swap
qft_space_add_const
[Qmod Classiq-library function]
Adds a constant to a quantum number (in the Fourier space) using the Quantum Fourier Transform (QFT) Adder algorithm.
Assuming that the input phi_b
has n
qubits, the result will be \(\phi_b+=value \mod 2^n\).
To perform the full algorithm, use: within_apply(lambda: QFT(phi_b), qft_space_add_const(value, phi_b))
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
CInt
|
The constant to add to the quantum number. |
required |
phi_b |
QArray[QBit]
|
The quantum number (at the aft space) to which the constant is added. |
required |
qfunc
qfunc(
func: Optional[Callable] = None,
*,
external: bool = False,
generative: bool = False
) -> Union[Callable[[Callable], QCallable], QCallable]
qpe
[Qmod Classiq-library function]
Implements the standard Quantum Phase Estimation (QPE) algorithm, which estimates the phase (eigenvalue) associated with an eigenstate of a given unitary operator \(U\).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
unitary |
QCallable
|
A callable representing the unitary operator \(U\), whose eigenvalue is to be estimated. |
required |
phase |
QNum
|
The quantum variable that represents the estimated phase (eigenvalue), assuming initialized to zero. |
required |
Further reading in Classiq Library: Link: qpe library reference
qpe_flexible
[Qmod Classiq-library function]
Implements the Quantum Phase Estimation (QPE) algorithm, which estimates the phase (eigenvalue) associated with an eigenstate of a given unitary operator \(U\). This is a flexible version that allows the user to provide a callable that generates the unitary operator \(U^k\) for a given integer \(k\), offering greater flexibility in handling different quantum circuits using some powering rule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
unitary_with_power |
QCallable[CInt]
|
A callable that returns the unitary operator \(U^k\) given an integer \(k\). This callable is used to control the application of powers of the unitary operator. |
required |
phase |
QNum
|
The quantum variable that represents the estimated phase (eigenvalue), assuming initialized to zero. |
required |
Further reading in Classiq Library: Link: qpe library reference
qst_type2
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_{ ilde{\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_{ ilde{\Pi}}NOT\), the QSVT sequence is as follows:
for odd \(d\), and:
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 |
Further reading in Classiq Library
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 |
For usage example, see: QSVT matrix inversion example
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:
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 |
Further reading in Classiq Library
randomized_benchmarking
reflect_about_zero
[Qmod Classiq-library function]
Reflects the state about the |0> state (i.e. applies a (-1) phase to all states
besides the |0> state). Implements the operator $S_0$:
$$
egin{equation}
S_0|{x}
angle = (-1)^{(x e0)}|{x} angle= (2|{0} angle\langle{0}|-I)|{x} angle \end{equation} $$
Args:
packed_vars: The quantum state to reflect.
single_pauli_exponent
single_pauli_exponent(
pauli_string: CArray[Pauli],
coefficient: CReal,
qbv: QArray[
QBit, Literal["get_field(pauli_string, 'len')"]
],
) -> None
[Qmod core-library function]
Exponentiates the specified single Pauli operator multiplied by some coefficient.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pauli_string |
CArray[Pauli]
|
The Pauli operator to be exponentiated. |
required |
coefficient |
CReal
|
A coefficient multiplying the Pauli operator. |
required |
qbv |
QArray[QBit, Literal["get_field(pauli_string, 'len')"]]
|
The target quantum variable of the exponentiation. |
required |
suzuki_trotter
suzuki_trotter(
pauli_operator: CArray[PauliTerm],
evolution_coefficient: CReal,
order: CInt,
repetitions: CInt,
qbv: QArray[
QBit,
Literal[
"get_field(get_field(pauli_operator[0], 'pauli'), 'len')"
],
],
) -> None
[Qmod core-library function]
Applies the Suzuki-Trotter decomposition to a Pauli operator. The Suzuki-Trotter decomposition is a method for approximating the exponential of a sum of operators by a product of exponentials of each operator. The Suzuki-Trotter decomposition of a given order nullifies the error of the Taylor series expansion of the product of exponentials up to that order. The error of a Suzuki-Trotter decomposition decreases as the order and number of repetitions increase.
See N. Hatano and M. Suzuki, Finding Exponential Product Formulas of Higher Orders (2005).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pauli_operator |
CArray[PauliTerm]
|
The Pauli operator to be exponentiated. |
required |
evolution_coefficient |
CReal
|
A global evolution coefficient multiplying the Pauli operator. |
required |
order |
CInt
|
The order of the Suzuki-Trotter decomposition. |
required |
repetitions |
CInt
|
The number of repetitions of the Suzuki-Trotter decomposition. |
required |
qbv |
QArray[QBit, Literal["get_field(get_field(pauli_operator[0], 'pauli'), 'len')"]]
|
The target quantum variable of the exponentiation. |
required |
swap_test
[Qmod Classiq-library function]
Tests the overlap (in terms of fidelity) of two quantum states.
The fidelity of state1
and state2
is calculated from the probability of measuring test
qubit in the state 0 as follows:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state1 |
QArray[QBit]
|
A quantum state to check its overlap with state2. |
required |
state2 |
QArray[QBit]
|
A quantum state to check its overlap with state1. |
required |
test |
Output[QBit]
|
A qubit for which the probability of measuring 0 is \(0.5*(|\langle state1 | state2 \rangle |^2+1)\) |
required |
Example
Further reading in the Classiq library is found here.
unitary
unitary(
elements: CArray[CArray[CReal]],
target: QArray[
QBit,
Literal["log(get_field(elements[0], 'len'), 2)"],
],
) -> None
[Qmod core-library function]
Applies a unitary matrix on a quantum state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
elements |
CArray[CArray[CReal]]
|
A 2d array of complex numbers representing the unitary matrix. This matrix must be unitary. |
required |
target |
QArray[QBit, Literal["log(get_field(elements[0], 'len'), 2)"]]
|
The quantum state to apply the unitary on. Should be of corresponding size. |
required |
Links: Reference Manual
enums
BUILTIN_ENUM_DECLARATIONS
BUILTIN_ENUM_DECLARATIONS = {__name__: EnumDeclaration(name=__name__, members={name: _PSEbfor enum_val in enum_def})for enum_def in values() if isinstance(enum_def, type) and issubclass(enum_def, IntEnum) and enum_def is not IntEnum}
Element
Bases: IntEnum
Ac
Ac = 88
Ag
Ag = 46
Al
Al = 12
Am
Am = 94
Ar
Ar = 17
As
As = 32
At
At = 84
Au
Au = 78
B
B = 4
Ba
Ba = 55
Be
Be = 3
Bh
Bh = 106
Bi
Bi = 82
Bk
Bk = 96
Br
Br = 34
C
C = 5
Ca
Ca = 19
Cd
Cd = 47
Ce
Ce = 57
Cf
Cf = 97
Cl
Cl = 16
Cm
Cm = 95
Cn
Cn = 111
Co
Co = 26
Cr
Cr = 23
Cs
Cs = 54
Cu
Cu = 28
Db
Db = 104
Ds
Ds = 109
Dy
Dy = 65
Er
Er = 67
Es
Es = 98
Eu
Eu = 62
F
F = 8
Fe
Fe = 25
Fl
Fl = 113
Fm
Fm = 99
Fr
Fr = 86
Ga
Ga = 30
Gd
Gd = 63
Ge
Ge = 31
H
H = 0
He
He = 1
Hf
Hf = 71
Hg
Hg = 79
Ho
Ho = 66
Hs
Hs = 107
I
I = 52
In
In = 48
Ir
Ir = 76
K
K = 18
Kr
Kr = 35
La
La = 56
Li
Li = 2
Lr
Lr = 102
Lu
Lu = 70
Lv
Lv = 115
Mc
Mc = 114
Md
Md = 100
Mg
Mg = 11
Mn
Mn = 24
Mo
Mo = 41
Mt
Mt = 108
N
N = 6
Na
Na = 10
Nb
Nb = 40
Nd
Nd = 59
Ne
Ne = 9
Nh
Nh = 112
Ni
Ni = 27
No
No = 101
Np
Np = 92
O
O = 7
Og
Og = 117
Os
Os = 75
P
P = 14
Pa
Pa = 90
Pb
Pb = 81
Pd
Pd = 45
Pm
Pm = 60
Po
Po = 83
Pr
Pr = 58
Pt
Pt = 77
Pu
Pu = 93
Ra
Ra = 87
Rb
Rb = 36
Re
Re = 74
Rf
Rf = 103
Rg
Rg = 110
Rh
Rh = 44
Rn
Rn = 85
Ru
Ru = 43
S
S = 15
Sb
Sb = 50
Sc
Sc = 20
Se
Se = 33
Sg
Sg = 105
Si
Si = 13
Sm
Sm = 61
Sn
Sn = 49
Sr
Sr = 37
Ta
Ta = 72
Tb
Tb = 64
Tc
Tc = 42
Te
Te = 51
Th
Th = 89
Ti
Ti = 21
Tl
Tl = 80
Tm
Tm = 68
Ts
Ts = 116
U
U = 91
V
V = 22
W
W = 73
Xe
Xe = 53
Y
Y = 38
Yb
Yb = 69
Zn
Zn = 29
Zr
Zr = 39
FermionMapping
Bases: IntEnum
BRAVYI_KITAEV
BRAVYI_KITAEV = 2
FAST_BRAVYI_KITAEV
FAST_BRAVYI_KITAEV = 3
JORDAN_WIGNER
JORDAN_WIGNER = 0
PARITY
PARITY = 1
FinanceFunctionType
Bases: IntEnum
EUROPEAN_CALL_OPTION
EUROPEAN_CALL_OPTION = 3
SHORTFALL
SHORTFALL = 1
VAR
VAR = 0
X_SQUARE
X_SQUARE = 2
LadderOperator
Bases: IntEnum
MINUS
MINUS = 1
PLUS
PLUS = 0
Optimizer
Bases: IntEnum
ADAM
ADAM = 5
COBYLA
COBYLA = 1
L_BFGS_B
L_BFGS_B = 3
NELDER_MEAD
NELDER_MEAD = 4
SPSA
SPSA = 2
Pauli
Bases: IntEnum
Enumeration for the Pauli matrices used in quantum computing.
The Pauli matrices are fundamental operations in quantum computing, and this enum assigns integer values to represent each matrix.
I
I = 0
I (int): Identity matrix, represented by the integer 0.
\(I = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}\)
X
X = 1
X (int): Pauli-X matrix, represented by the integer 1.
\(X = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}\)
Y
Y = 2
Y (int): Pauli-Y matrix, represented by the integer 2.
\(Y = \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}\)
Z
Z = 3
Z (int): Pauli-Z matrix, represented by the integer 3.
\(Z = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}\)
QSVMFeatureMapEntanglement
Bases: IntEnum
CIRCULAR
CIRCULAR = 2
FULL
FULL = 0
LINEAR
LINEAR = 1
PAIRWISE
PAIRWISE = 4
SCA
SCA = 3
structs
BUILTIN_STRUCT_DECLARATIONS
BUILTIN_STRUCT_DECLARATIONS = {
__name__: StructDeclaration(
name=__name__,
variables={
name: convert(type)
for field in fields(struct_decl)
},
)
for struct_decl in values()
if is_dataclass(struct_decl)
}
ChemistryAtom
CombinatorialOptimizationSolution
FinanceFunction
FockHamiltonianProblem
GaussianModel
LadderTerm
LogNormalModel
MoleculeProblem
PauliTerm
A term in a Hamiltonian, represented as a product of Pauli operators.
Attributes:
Name | Type | Description |
---|---|---|
pauli |
CArray[Pauli]
|
The list of the chosen Pauli operators in the term, corresponds to a product of them. |
coefficient |
CReal
|
The coefficient of the term (floating number). |
classical_execution_primitives
CARRAY_SEPARATOR
CARRAY_SEPARATOR: Final[str] = '_'
ExecutionParams
ExecutionParams = Dict[
str, Union[float, int, List[int], List[float]]
]
batch_estimate
batch_estimate(
hamiltonian: List[QmodPyStruct],
batch_execution_params: List[ExecutionParams],
) -> EstimationResults
batch_sample
batch_sample(
batch_execution_params: List[ExecutionParams],
) -> MultipleExecutionDetails
estimate
estimate(
hamiltonian: List[QmodPyStruct],
execution_params: Optional[ExecutionParams] = None,
) -> EstimationResult
iqae
iqae(
epsilon: float,
alpha: float,
execution_params: Optional[ExecutionParams] = None,
) -> IQAEResult
molecule_ground_state_solution_post_process
molecule_ground_state_solution_post_process(
problem: QmodPyStruct, vqe_result: VQESolverResult
) -> QmodPyStruct
qae_with_qpe_result_post_processing
qae_with_qpe_result_post_processing(
estimation_register_size: int,
estimation_method: QaeWithQpeEstimationMethod,
result: ExecutionDetails,
) -> float
qsvm_full_run
qsvm_full_run(
train_data: Data,
train_labels: Labels,
test_data: Data,
test_labels: Labels,
predict_data: Data,
) -> QmodPyStruct
save
save(values_to_save: dict) -> None
vqe
vqe(
hamiltonian: List[QmodPyStruct],
maximize: bool,
initial_point: List[float],
optimizer: Optimizer,
max_iteration: int,
tolerance: float,
step_size: float,
skip_compute_variance: bool,
alpha_cvar: float,
) -> VQESolverResult
classical_functions
ChemistryAtom
CombinatorialOptimizationSolution
FinanceFunction
FockHamiltonianProblem
GaussianModel
LadderTerm
LogNormalModel
MoleculeProblem
PauliTerm
A term in a Hamiltonian, represented as a product of Pauli operators.
Attributes:
Name | Type | Description |
---|---|---|
pauli |
CArray[Pauli]
|
The list of the chosen Pauli operators in the term, corresponds to a product of them. |
coefficient |
CReal
|
The coefficient of the term (floating number). |
QSVMFeatureMapPauli
QsvmResult
fock_hamiltonian_problem_to_hamiltonian
fock_hamiltonian_problem_to_hamiltonian(
problem: FockHamiltonianProblem,
) -> CArray[PauliTerm]
gaussian_finance_post_process
gaussian_finance_post_process(
finance_model: GaussianModel,
estimation_method: FinanceFunction,
probability: CReal,
) -> CReal
grid_entangler_graph
grid_entangler_graph(
num_qubits: CInt,
schmidt_rank: CInt,
grid_randomization: CBool,
) -> CArray[CArray[CInt]]
log_normal_finance_post_process
log_normal_finance_post_process(
finance_model: LogNormalModel,
estimation_method: FinanceFunction,
probability: CReal,
) -> CReal
molecule_problem_to_hamiltonian
molecule_problem_to_hamiltonian(
problem: MoleculeProblem,
) -> CArray[PauliTerm]
qfunc
DEC_QFUNCS
DEC_QFUNCS: List[QFunc] = []
GEN_QFUNCS
GEN_QFUNCS: List[GenerativeQFunc] = []
qfunc
qfunc(
func: Optional[Callable] = None,
*,
external: bool = False,
generative: bool = False
) -> Union[Callable[[Callable], QCallable], QCallable]
set_discovered_functions
set_discovered_functions(
dec_funcs: List[QFunc], gen_funcs: List[GenerativeQFunc]
) -> None
QBit
QBit(
origin: Union[str, HandleBinding],
*,
_expr_str: Optional[str] = None,
depth: int = 2
)
Bases: QScalar
get_qmod_type
get_qmod_type() -> QuantumType
to_qmod_quantum_type
to_qmod_quantum_type(type_hint: Any) -> QuantumType
to_qvar
to_qvar(
origin: Union[str, HandleBinding],
type_hint: Any,
expr_str: Optional[str],
) -> QBit
QNum
QNum(
name: Union[str, HandleBinding],
size: Union[int, CInt, Expression, None] = None,
is_signed: Union[
bool, Expression, SymbolicExpr, None
] = None,
fraction_digits: Union[
int, CInt, Expression, None
] = None,
_expr_str: Optional[str] = None,
)
Bases: Generic[_P]
, QScalar
fraction_digits
fraction_digits: Union[CParamScalar, int]
is_signed
is_signed: Union[CParamScalar, bool]
get_qmod_type
get_qmod_type() -> QuantumType
to_qmod_quantum_type
to_qmod_quantum_type(type_hint: Any) -> QuantumType
to_qvar
to_qvar(
origin: Union[str, HandleBinding],
type_hint: Any,
expr_str: Optional[str],
) -> QNum
QArray
QArray(
name: Union[str, HandleBinding],
element_type: Union[_GenericAlias, QuantumType] = QBit,
length: Optional[
Union[int, SymbolicExpr, Expression]
] = None,
_expr_str: Optional[str] = None,
)
Bases: ArrayBase[_P]
, QVar
len
len: Union[CParamScalar, int]
get_qmod_type
get_qmod_type() -> QuantumBitvector
to_qmod_quantum_type
to_qmod_quantum_type(type_hint: Any) -> QuantumType
to_qvar
to_qvar(
origin: Union[str, HandleBinding],
type_hint: Any,
expr_str: Optional[str],
) -> QArray
CInt
CInt(expr: str)
Bases: CParam
CReal
CReal(expr: str)
Bases: CParam
CBool
CBool(expr: str)
Bases: CParam
CArray
CArray(expr: str)
Bases: CParam
, ArrayBase[_P]
len
len: int
QCallable
Bases: Generic[P]
, ABC
CURRENT_EXPANDABLE
CURRENT_EXPANDABLE: Optional[QExpandableInterface] = None
FRAME_DEPTH
FRAME_DEPTH = 1
func_decl
func_decl: AnonQuantumFunctionDeclaration
create_quantum_function_call
create_quantum_function_call(
source_ref_: SourceReference, *args: Any, **kwargs: Any
) -> QuantumFunctionCall
QCallableList
Bases: QCallable
, Generic[P]
, ABC
len
len: int
QStruct
QStruct(
name: Union[str, HandleBinding],
_struct_name: Optional[str] = None,
_fields: Optional[Mapping[str, QVar]] = None,
_expr_str: Optional[str] = None,
)
Bases: QVar
get_qmod_type
get_qmod_type() -> QuantumType
to_qmod_quantum_type
to_qmod_quantum_type(type_hint: Any) -> QuantumType
to_qvar
to_qvar(
origin: Union[str, HandleBinding],
type_hint: Any,
expr_str: Optional[str],
) -> QStruct
QConstant
QConstant(name: str, py_type: type, value: Any)
Bases: SymbolicExpr
CURRENT_QMODULE
CURRENT_QMODULE: Optional[ModelStateContainer] = None
add_to_model
add_to_model() -> None
set_current_model
set_current_model(qmodule: ModelStateContainer) -> None
cfunc
cfunc
cfunc(
func: Optional[Callable] = None,
) -> Union[Callable[[Callable], CFunc], CFunc]
get_caller_locals
get_caller_locals() -> Dict[str, Any]
Print the local variables in the caller's frame.
create_model
create_model(
entry_point: Union[QFunc, GenerativeQFunc],
constraints: Optional[Constraints] = None,
execution_preferences: Optional[
ExecutionPreferences
] = None,
preferences: Optional[Preferences] = None,
classical_execution_function: Optional[CFunc] = None,
out_file: Optional[str] = None,
) -> SerializedModel
Create a serialized model from a given Qmod entry function and additional parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entry_point |
Union[QFunc, GenerativeQFunc]
|
The entry point function for the model, which must be a QFunc named 'main'. |
required |
constraints |
Optional[Constraints]
|
Constraints for the synthesis of the model. See Constraints (Optional). |
None
|
execution_preferences |
Optional[ExecutionPreferences]
|
Preferences for the execution of the model. See ExecutionPreferences (Optional). |
None
|
preferences |
Optional[Preferences]
|
Preferences for the synthesis of the model. See Preferences (Optional). |
None
|
classical_execution_function |
Optional[CFunc]
|
A function for the classical execution logic, which must be a CFunc (Optional). |
None
|
out_file |
Optional[str]
|
File path to write the Qmod model in native Qmod representation to (Optional). |
None
|
Returns:
Name | Type | Description |
---|---|---|
SerializedModel |
SerializedModel
|
A serialized model. |
Raises:
Type | Description |
---|---|
ClassiqError
|
If the entry point function is not named 'main'. |
symbolic
Catalan
Catalan = SymbolicExpr('Catalan', False)