classiq 0.45.0__py3-none-any.whl → 0.46.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. classiq/__init__.py +0 -1
  2. classiq/_internals/__init__.py +20 -0
  3. classiq/_internals/authentication/authentication.py +11 -0
  4. classiq/analyzer/analyzer.py +12 -10
  5. classiq/applications/combinatorial_helpers/combinatorial_problem_utils.py +1 -1
  6. classiq/applications/combinatorial_helpers/pauli_helpers/pauli_utils.py +1 -1
  7. classiq/applications/combinatorial_optimization/combinatorial_optimization_model_constructor.py +1 -1
  8. classiq/applications/libraries/qmci_library.py +4 -9
  9. classiq/execution/execution_session.py +68 -7
  10. classiq/executor.py +14 -2
  11. classiq/interface/_version.py +1 -1
  12. classiq/interface/backend/backend_preferences.py +189 -0
  13. classiq/interface/backend/quantum_backend_providers.py +38 -0
  14. classiq/interface/debug_info/debug_info.py +22 -2
  15. classiq/interface/exceptions.py +16 -1
  16. classiq/interface/executor/execution_preferences.py +18 -0
  17. classiq/interface/generator/application_apis/chemistry_declarations.py +1 -177
  18. classiq/interface/generator/application_apis/combinatorial_optimization_declarations.py +0 -12
  19. classiq/interface/generator/application_apis/finance_declarations.py +8 -43
  20. classiq/interface/generator/application_apis/qsvm_declarations.py +0 -78
  21. classiq/interface/generator/builtin_api_builder.py +0 -3
  22. classiq/interface/generator/functions/__init__.py +0 -2
  23. classiq/interface/generator/functions/builtins/__init__.py +0 -15
  24. classiq/interface/generator/generated_circuit_data.py +2 -0
  25. classiq/interface/generator/hardware/hardware_data.py +37 -0
  26. classiq/interface/generator/model/constraints.py +18 -1
  27. classiq/interface/generator/model/preferences/preferences.py +53 -1
  28. classiq/interface/generator/model/quantum_register.py +1 -1
  29. classiq/interface/generator/quantum_program.py +10 -2
  30. classiq/interface/generator/transpiler_basis_gates.py +4 -0
  31. classiq/interface/generator/types/builtin_enum_declarations.py +136 -21
  32. classiq/interface/generator/types/enum_declaration.py +1 -3
  33. classiq/interface/generator/types/struct_declaration.py +1 -3
  34. classiq/interface/hardware.py +5 -0
  35. classiq/interface/ide/visual_model.py +1 -1
  36. classiq/interface/model/classical_parameter_declaration.py +6 -0
  37. classiq/interface/model/inplace_binary_operation.py +0 -14
  38. classiq/interface/model/model.py +1 -18
  39. classiq/interface/model/port_declaration.py +4 -2
  40. classiq/interface/model/quantum_function_declaration.py +19 -6
  41. classiq/interface/model/quantum_lambda_function.py +11 -1
  42. classiq/interface/model/quantum_variable_declaration.py +1 -1
  43. classiq/model_expansions/__init__.py +0 -0
  44. classiq/model_expansions/atomic_expression_functions_defs.py +250 -0
  45. classiq/model_expansions/capturing/__init__.py +0 -0
  46. classiq/model_expansions/capturing/captured_var_manager.py +50 -0
  47. classiq/model_expansions/capturing/mangling_utils.py +17 -0
  48. classiq/model_expansions/capturing/propagated_var_stack.py +180 -0
  49. classiq/model_expansions/closure.py +160 -0
  50. classiq/model_expansions/debug_flag.py +3 -0
  51. classiq/model_expansions/evaluators/__init__.py +0 -0
  52. classiq/model_expansions/evaluators/arg_type_match.py +160 -0
  53. classiq/model_expansions/evaluators/argument_types.py +42 -0
  54. classiq/model_expansions/evaluators/classical_expression.py +36 -0
  55. classiq/model_expansions/evaluators/control.py +144 -0
  56. classiq/model_expansions/evaluators/parameter_types.py +227 -0
  57. classiq/model_expansions/evaluators/quantum_type_utils.py +235 -0
  58. classiq/model_expansions/evaluators/type_type_match.py +90 -0
  59. classiq/model_expansions/expression_evaluator.py +125 -0
  60. classiq/model_expansions/expression_renamer.py +76 -0
  61. classiq/model_expansions/function_builder.py +192 -0
  62. classiq/model_expansions/generative_functions.py +101 -0
  63. classiq/model_expansions/interpreter.py +365 -0
  64. classiq/model_expansions/model_tables.py +105 -0
  65. classiq/model_expansions/quantum_operations/__init__.py +19 -0
  66. classiq/model_expansions/quantum_operations/bind.py +64 -0
  67. classiq/model_expansions/quantum_operations/classicalif.py +39 -0
  68. classiq/model_expansions/quantum_operations/control.py +235 -0
  69. classiq/model_expansions/quantum_operations/emitter.py +215 -0
  70. classiq/model_expansions/quantum_operations/expression_operation.py +218 -0
  71. classiq/model_expansions/quantum_operations/inplace_binary_operation.py +250 -0
  72. classiq/model_expansions/quantum_operations/invert.py +38 -0
  73. classiq/model_expansions/quantum_operations/power.py +74 -0
  74. classiq/model_expansions/quantum_operations/quantum_assignment_operation.py +174 -0
  75. classiq/model_expansions/quantum_operations/quantum_function_call.py +15 -0
  76. classiq/model_expansions/quantum_operations/repeat.py +33 -0
  77. classiq/model_expansions/quantum_operations/variable_decleration.py +28 -0
  78. classiq/model_expansions/quantum_operations/within_apply.py +46 -0
  79. classiq/model_expansions/scope.py +226 -0
  80. classiq/model_expansions/scope_initialization.py +136 -0
  81. classiq/model_expansions/sympy_conversion/__init__.py +0 -0
  82. classiq/model_expansions/sympy_conversion/arithmetics.py +49 -0
  83. classiq/model_expansions/sympy_conversion/expression_to_sympy.py +150 -0
  84. classiq/model_expansions/sympy_conversion/sympy_to_python.py +113 -0
  85. classiq/model_expansions/utils/__init__.py +0 -0
  86. classiq/model_expansions/utils/counted_name_allocator.py +11 -0
  87. classiq/model_expansions/visitors/__init__.py +0 -0
  88. classiq/model_expansions/visitors/boolean_expression_transformers.py +214 -0
  89. classiq/model_expansions/visitors/variable_references.py +115 -0
  90. classiq/qmod/__init__.py +1 -3
  91. classiq/qmod/builtins/enums.py +33 -2
  92. classiq/qmod/builtins/functions/__init__.py +251 -0
  93. classiq/qmod/builtins/functions/amplitude_estimation.py +26 -0
  94. classiq/qmod/builtins/functions/arithmetic.py +68 -0
  95. classiq/qmod/builtins/functions/benchmarking.py +8 -0
  96. classiq/qmod/builtins/functions/chemistry.py +91 -0
  97. classiq/qmod/builtins/functions/discrete_sine_cosine_transform.py +105 -0
  98. classiq/qmod/builtins/functions/exponentiation.py +110 -0
  99. classiq/qmod/builtins/functions/finance.py +34 -0
  100. classiq/qmod/builtins/functions/grover.py +179 -0
  101. classiq/qmod/builtins/functions/hea.py +59 -0
  102. classiq/qmod/builtins/functions/linear_pauli_rotation.py +65 -0
  103. classiq/qmod/builtins/functions/modular_exponentiation.py +137 -0
  104. classiq/qmod/builtins/functions/operators.py +22 -0
  105. classiq/qmod/builtins/functions/qaoa_penalty.py +116 -0
  106. classiq/qmod/builtins/functions/qft.py +23 -0
  107. classiq/qmod/builtins/functions/qpe.py +39 -0
  108. classiq/qmod/builtins/functions/qsvm.py +24 -0
  109. classiq/qmod/builtins/functions/qsvt.py +136 -0
  110. classiq/qmod/builtins/functions/standard_gates.py +739 -0
  111. classiq/qmod/builtins/functions/state_preparation.py +356 -0
  112. classiq/qmod/builtins/functions/swap_test.py +25 -0
  113. classiq/qmod/builtins/structs.py +50 -28
  114. classiq/qmod/cparam.py +64 -0
  115. classiq/qmod/create_model_function.py +190 -0
  116. classiq/qmod/declaration_inferrer.py +52 -81
  117. classiq/qmod/expression_query.py +16 -0
  118. classiq/qmod/generative.py +48 -0
  119. classiq/qmod/model_state_container.py +1 -2
  120. classiq/qmod/native/pretty_printer.py +7 -11
  121. classiq/qmod/pretty_print/pretty_printer.py +7 -11
  122. classiq/qmod/python_classical_type.py +67 -0
  123. classiq/qmod/qfunc.py +19 -4
  124. classiq/qmod/qmod_parameter.py +15 -64
  125. classiq/qmod/qmod_variable.py +28 -46
  126. classiq/qmod/quantum_callable.py +1 -1
  127. classiq/qmod/quantum_expandable.py +10 -4
  128. classiq/qmod/quantum_function.py +22 -40
  129. classiq/qmod/semantics/error_manager.py +22 -10
  130. classiq/qmod/semantics/static_semantics_visitor.py +10 -12
  131. classiq/qmod/semantics/validation/types_validation.py +6 -7
  132. classiq/qmod/utilities.py +2 -2
  133. classiq/qmod/write_qmod.py +14 -0
  134. classiq/show.py +10 -0
  135. classiq/synthesis.py +46 -2
  136. {classiq-0.45.0.dist-info → classiq-0.46.0.dist-info}/METADATA +1 -1
  137. {classiq-0.45.0.dist-info → classiq-0.46.0.dist-info}/RECORD +138 -74
  138. classiq/interface/generator/functions/builtins/core_library/__init__.py +0 -16
  139. classiq/interface/generator/functions/builtins/core_library/atomic_quantum_functions.py +0 -710
  140. classiq/interface/generator/functions/builtins/core_library/exponentiation_functions.py +0 -105
  141. classiq/interface/generator/functions/builtins/open_lib_functions.py +0 -2489
  142. classiq/interface/generator/functions/builtins/quantum_operators.py +0 -24
  143. classiq/interface/generator/types/builtin_struct_declarations/__init__.py +0 -1
  144. classiq/interface/generator/types/builtin_struct_declarations/pauli_struct_declarations.py +0 -21
  145. classiq/qmod/builtins/functions.py +0 -1029
  146. {classiq-0.45.0.dist-info → classiq-0.46.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,110 @@
1
+ from typing import Literal
2
+
3
+ from classiq.qmod.builtins.enums import Pauli
4
+ from classiq.qmod.builtins.structs import (
5
+ PauliTerm,
6
+ )
7
+ from classiq.qmod.qfunc import qfunc
8
+ from classiq.qmod.qmod_parameter import CArray, CInt, CReal
9
+ from classiq.qmod.qmod_variable import QArray, QBit
10
+
11
+
12
+ @qfunc(external=True)
13
+ def single_pauli_exponent(
14
+ pauli_string: CArray[Pauli],
15
+ coefficient: CReal,
16
+ qbv: QArray[QBit, Literal["get_field(pauli_string, 'len')"]],
17
+ ) -> None:
18
+ """
19
+ [Qmod Classiq-library function]
20
+ This function exponentiates a single Pauli operator.
21
+ The operator may be multiplied by a coefficient.
22
+
23
+ Args:
24
+ pauli_string: The Pauli operator to be exponentiated.
25
+ coefficient: A coefficient multiplying the Pauli operator.
26
+ qbv: The target quantum variable of the exponentiation.
27
+ """
28
+ pass
29
+
30
+
31
+ @qfunc(external=True)
32
+ def suzuki_trotter(
33
+ pauli_operator: CArray[PauliTerm],
34
+ evolution_coefficient: CReal,
35
+ order: CInt,
36
+ repetitions: CInt,
37
+ qbv: QArray[
38
+ QBit, Literal["get_field(get_field(pauli_operator[0], 'pauli'), 'len')"]
39
+ ],
40
+ ) -> None:
41
+ """
42
+ [Qmod Classiq-library function]
43
+ The Suzuki-Trotter decomposition is a method for approximating the exponential of a sum of operators by a product of exponentials of each operator.
44
+ This function applies the Suzuki-Trotter decomposition to a Pauli operator.
45
+ 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.
46
+ The error of a Suzuki-Trotter decomposition decreases as the order and number of repetitions increase.
47
+
48
+ See [N. Hatano and M. Suzuki, Finding Exponential Product Formulas of Higher Orders (2005)](https://arxiv.org/abs/math-ph/0506007).
49
+
50
+ Args:
51
+ pauli_operator: The Pauli operator to be exponentiated.
52
+ evolution_coefficient: A global evolution coefficient multiplying the Pauli operator.
53
+ order: The order of the Suzuki-Trotter decomposition.
54
+ repetitions: The number of repetitions of the Suzuki-Trotter decomposition.
55
+ qbv: The target quantum variable of the exponentiation.
56
+ """
57
+ pass
58
+
59
+
60
+ @qfunc(external=True)
61
+ def qdrift(
62
+ pauli_operator: CArray[PauliTerm],
63
+ evolution_coefficient: CReal,
64
+ num_qdrift: CInt,
65
+ qbv: QArray[
66
+ QBit, Literal["get_field(get_field(pauli_operator[0], 'pauli'), 'len')"]
67
+ ],
68
+ ) -> None:
69
+ """
70
+ [Qmod Classiq-library function]
71
+ 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.
72
+ This function exponentiates a Pauli operator using the QDrift method.
73
+ The QDrift method randomizes the order of the operators in the product of exponentials to stochastically reduce the error of the approximation.
74
+ The error of the QDrift method decreases as the number of QDrift steps increases.
75
+
76
+ See [E. Campbell, Random Compiler for Fast Hamiltonian Simulation (2019)](https://arxiv.org/abs/1811.08017).
77
+
78
+ Args:
79
+ pauli_operator: The Pauli operator to be exponentiated.
80
+ evolution_coefficient: A global evolution coefficient multiplying the Pauli operator.
81
+ num_qdrift : The number of QDrift steps.
82
+ qbv: The target quantum variable of the exponentiation.
83
+ """
84
+ pass
85
+
86
+
87
+ @qfunc(external=True)
88
+ def exponentiation_with_depth_constraint(
89
+ pauli_operator: CArray[PauliTerm],
90
+ evolution_coefficient: CReal,
91
+ max_depth: CInt,
92
+ qbv: QArray[
93
+ QBit, Literal["get_field(get_field(pauli_operator[0], 'pauli'), 'len')"]
94
+ ],
95
+ ) -> None:
96
+ """
97
+ [Qmod Classiq-library function]
98
+ This function exponentiates a Pauli operator via the Suzuki-Trotter decomposition with a depth constraint.
99
+ The Suzuki-Trotter decomposition is a method for approximating the exponential of a sum of operators by a product of exponentials of each operator.
100
+ This function automatically determines the order and number of repetitions of the Suzuki-Trotter decomposition to minimize the error given a depth constraint.
101
+
102
+ See [A. M. Childs et al., Toward the first quantum simulation with quantum speedup (2017)](https://arxiv.org/abs/1711.10980).
103
+
104
+ Args:
105
+ pauli_operator: The Pauli operator to be exponentiated.
106
+ evolution_coefficient: A global coefficient multiplying the Pauli operator.
107
+ max_depth: The maximum depth of the exponentiation.
108
+ qbv: The target quantum variable of the exponentiation.
109
+ """
110
+ pass
@@ -0,0 +1,34 @@
1
+ from typing import Literal
2
+
3
+ from classiq.qmod.builtins.structs import (
4
+ FinanceFunction,
5
+ GaussianModel,
6
+ LogNormalModel,
7
+ )
8
+ from classiq.qmod.qfunc import qfunc
9
+ from classiq.qmod.qmod_variable import QArray, QBit
10
+
11
+
12
+ @qfunc(external=True)
13
+ def log_normal_finance(
14
+ finance_model: LogNormalModel,
15
+ finance_function: FinanceFunction,
16
+ func_port: QArray[QBit, Literal["get_field(finance_model, 'num_qubits')"]],
17
+ obj_port: QBit,
18
+ ) -> None:
19
+ pass
20
+
21
+
22
+ @qfunc(external=True)
23
+ def gaussian_finance(
24
+ finance_model: GaussianModel,
25
+ finance_function: FinanceFunction,
26
+ func_port: QArray[
27
+ QBit,
28
+ Literal[
29
+ "get_field(finance_model, 'num_qubits') + get_field(get_field(finance_model, 'rhos'), 'len') + floor(log(sum(get_field(finance_model, 'loss')), 2)) + 1"
30
+ ],
31
+ ],
32
+ obj_port: QBit,
33
+ ) -> None:
34
+ pass
@@ -0,0 +1,179 @@
1
+ from typing_extensions import Annotated
2
+
3
+ from classiq.qmod.qfunc import qfunc
4
+ from classiq.qmod.qmod_parameter import CInt
5
+ from classiq.qmod.qmod_variable import QArray, QBit
6
+ from classiq.qmod.quantum_callable import QCallable
7
+
8
+
9
+ @qfunc(external=True)
10
+ def phase_oracle(
11
+ predicate: QCallable[QArray[QBit], QBit], target: QArray[QBit]
12
+ ) -> None:
13
+ r"""
14
+ Qmod Classiq-library function.
15
+
16
+ Creates a phase oracle operator based on a predicate function.
17
+ The function can be used on its own, or by other functions, such as Grover's algorithm.
18
+
19
+ Applies a predicate function and marks "good" and "bad" states with a phase flip.
20
+ If the predicate is marked as $\chi$, and the oracle is marked as $S_\chi$, then:
21
+
22
+
23
+ $$
24
+ S_\chi\lvert x \rangle =
25
+ \begin{cases}
26
+ -\lvert x \rangle & \text{if } \chi(x) = 1 \\
27
+ \phantom{-} \lvert x \rangle & \text{if } \chi(x) = 0
28
+ \end{cases}
29
+ $$
30
+
31
+ Args:
32
+ predicate: A predicate function that takes a QArray of QBits and sets a single QBit |1> if the predicate is true, and |0> otherwise.
33
+ target: The target QArray of QBits to apply the phase oracle to.
34
+
35
+ Usage Examples:
36
+ [Grover Algorithm](https://docs.classiq.io/latest/explore/functions/qmod_library_reference/classiq_open_library/grover_operator/grover_operator/)
37
+
38
+ [Hidden shift](https://docs.classiq.io/latest/explore/algorithms/algebraic/hidden_shift/hidden_shift/)
39
+ """
40
+ pass
41
+
42
+
43
+ @qfunc(external=True)
44
+ def reflect_about_zero(packed_vars: QArray[QBit]) -> None:
45
+ r"""
46
+ Qmod core-library function
47
+
48
+ Reflects the state about the |0> state (i.e. applies a (-1) phase to all states
49
+ besides the |0> state). Implements the operator $S_0$:
50
+
51
+ $$
52
+ \begin{equation}
53
+ S_0|{x}\rangle = (-1)^{(x\ne0)}|{x}\rangle= (2|{0}\rangle\langle{0}|-I)|{x}\rangle
54
+ \end{equation}
55
+ $$
56
+
57
+ Args:
58
+ packed_vars: The quantum state to reflect.
59
+ """
60
+ pass
61
+
62
+
63
+ @qfunc(external=True)
64
+ def grover_diffuser(
65
+ space_transform: QCallable[QArray[QBit]], packed_vars: QArray[QBit]
66
+ ) -> None:
67
+ r"""
68
+ Qmod core-library function
69
+
70
+ The Grover diffuser operator reflects the given state about the A|0> state, where A
71
+ is the `space_transform` parameter. It is defined as:
72
+
73
+ $$
74
+ \begin{equation}
75
+ D = A S_0 A^{\dagger}
76
+ \end{equation}
77
+ $$
78
+
79
+ where $S_0$ is the reflection about the |0> state (see `reflect_about_zero`).
80
+
81
+ Args:
82
+ space_transform: The operator which encodes the axis of reflection.
83
+ packed_vars: The state to which to apply the diffuser.
84
+ """
85
+ pass
86
+
87
+
88
+ @qfunc(external=True)
89
+ def grover_operator(
90
+ oracle: QCallable[QArray[QBit]],
91
+ space_transform: QCallable[QArray[QBit]],
92
+ packed_vars: QArray[QBit],
93
+ ) -> None:
94
+ r"""
95
+ Qmod open-library function
96
+
97
+ Applies the grover operator, defined by:
98
+
99
+ $$
100
+ Q=S_{\psi_0}S_{\psi_1}
101
+ $$
102
+
103
+ where $S_{\psi_1}$ is a reflection about marked states, and $S_{\psi_0}$ is a reflection
104
+ about a given state defined by $|\psi_0\rangle = A|0\rangle$.
105
+
106
+
107
+ Args:
108
+ oracle: A unitary operator which adds a phase of (-1) to marked states.
109
+ space_transform: The operator which creates $|\psi_0\rangle$, the initial state, used by the diffuser to reflect about it.
110
+ packed_vars: The state to which to apply the grover operator.
111
+
112
+
113
+ For further reading, see:
114
+
115
+ - [The Grover Operator notebook](../explore/functions/qmod_library_reference/classiq_open_library/grover_operator/grover_operator/)
116
+ - [Wikipedia page](https://en.wikipedia.org/wiki/Grover%27s_algorithm).
117
+
118
+ """
119
+ pass
120
+
121
+
122
+ @qfunc(external=True)
123
+ def grover_search(
124
+ reps: CInt, oracle: QCallable[QArray[QBit]], packed_vars: QArray[QBit]
125
+ ) -> None:
126
+ r"""
127
+ Qmod Classiq-library function.
128
+
129
+ Applies Grover search algorithm.
130
+
131
+ Args:
132
+ reps: Number of repetitions of the grover operator.
133
+ oracle: An oracle that marks the solution.
134
+ packed_vars: Packed form of the variable to apply the grover operator on.
135
+
136
+ Returns: None
137
+
138
+ Links:
139
+ [Grover Algorithm](https://docs.classiq.io/latest/explore/functions/qmod_library_reference/classiq_open_library/grover_operator/grover_operator/)
140
+
141
+ """
142
+ pass
143
+
144
+
145
+ @qfunc(external=True)
146
+ def hadamard_transform(target: QArray[QBit]) -> None:
147
+ r"""
148
+ Qmod Classiq-library function.
149
+
150
+ Applies Hadamard transform to the target qubits.
151
+
152
+ Corresponds to the braket notation:
153
+
154
+ $$
155
+ H^{\otimes n} |x\rangle = \frac{1}{\sqrt{2^n}} \sum_{y=0}^{2^n - 1} (-1)^{x \cdot y} |y\rangle
156
+ $$
157
+
158
+ Args:
159
+ target: qubits to apply to Hadamard transform to.
160
+
161
+ """
162
+ pass
163
+
164
+
165
+ @qfunc(external=True)
166
+ def apply_to_all(
167
+ gate_operand: QCallable[Annotated[QBit, "target"]], target: QArray[QBit]
168
+ ) -> None:
169
+ """
170
+ Qmod Classiq-library function.
171
+
172
+ Applies the single-qubit operand `gate_operand` to each qubit in the qubit
173
+ array `target`.
174
+
175
+ Args:
176
+ gate_operand: The single-qubit gate to apply to each qubit in the array.
177
+ target: The qubit array to apply the gate to.
178
+ """
179
+ pass
@@ -0,0 +1,59 @@
1
+ from typing import Literal
2
+
3
+ from typing_extensions import Annotated
4
+
5
+ from classiq.qmod.qfunc import qfunc
6
+ from classiq.qmod.qmod_parameter import CArray, CInt, CReal
7
+ from classiq.qmod.qmod_variable import QArray, QBit
8
+ from classiq.qmod.quantum_callable import QCallableList
9
+
10
+
11
+ @qfunc(external=True)
12
+ def full_hea(
13
+ num_qubits: CInt,
14
+ is_parametrized: CArray[CInt],
15
+ angle_params: CArray[CReal],
16
+ connectivity_map: CArray[CArray[CInt]],
17
+ reps: CInt,
18
+ operands_1qubit: QCallableList[Annotated[CReal, "angle"], Annotated[QBit, "q"]],
19
+ operands_2qubit: QCallableList[
20
+ Annotated[CReal, "angle"], Annotated[QBit, "q1"], Annotated[QBit, "q2"]
21
+ ],
22
+ x: QArray[QBit, Literal["num_qubits"]],
23
+ ) -> None:
24
+ """
25
+ Qmod Classiq-library function.
26
+
27
+ Implements an ansatz on a qubit array `x` with the given 1-qubit and 2-qubit operations.
28
+
29
+ The number of ansatz layers is given in argument `reps`.
30
+ Each layer applies the 1-qubit operands in `operands_1qubit` to all the qubits in `x`.
31
+ Next, it applies the 2-qubit operands in `operands_2qubit` to qubits (i, j) for each
32
+ pair of indices (i, j) in `connectivity_map`.
33
+
34
+ The list `is_parametrized` specifies whether the operands in `operands_1qubit` and
35
+ `operands_2qubit` are parametric (expect a classical argument).
36
+ `is_parametrized` is a list of flags (0 and 1 integers) of length
37
+ `len(operands_1qubit) + len(operands_2qubit)`.
38
+ The first `len(operands_1qubit)` flags refer to the `operands_1qubit` operands and
39
+ the next `len(operands_2qubit)` flags refer to the `operands_2qubit` operands.
40
+
41
+ The classical arguments to the parametric operands are given in argument
42
+ `angle_params`.
43
+ `angle_params` concatenates a set of arguments for each ansatz layer.
44
+ Each set contains an argument for each qubit in `x` times the number
45
+ of parametric operands in `operands_1qubit`.
46
+ These are followed by an argument for each mapping pair in `connectivity_map` times
47
+ the number of parametric operands in `operands_2qubit`.
48
+
49
+ Args:
50
+ num_qubits: The length of qubit array x
51
+ is_parametrized: A list of 0 and 1 flags
52
+ angle_params A list of arguments to gate
53
+ connectivity_map: A list of pairs of qubit indices
54
+ reps: The number of ansatz layers
55
+ operands_1qubit: A list of operations on a single qubit
56
+ operands_2qubit: A list of operations on two qubits
57
+ x: The quantum object to be transformed by the ansatz
58
+ """
59
+ pass
@@ -0,0 +1,65 @@
1
+ from typing_extensions import Annotated
2
+
3
+ from classiq.qmod.builtins.enums import Pauli
4
+ from classiq.qmod.qfunc import qfunc
5
+ from classiq.qmod.qmod_parameter import CArray, CReal
6
+ from classiq.qmod.qmod_variable import QArray, QBit
7
+ from classiq.qmod.quantum_callable import QCallable
8
+
9
+
10
+ @qfunc(external=True)
11
+ def _single_pauli(
12
+ slope: CReal,
13
+ offset: CReal,
14
+ q1_qfunc: QCallable[Annotated[CReal, "theta"], Annotated[QBit, "target"]],
15
+ x: QArray[QBit],
16
+ q: QBit,
17
+ ) -> None:
18
+ pass
19
+
20
+
21
+ @qfunc(external=True)
22
+ def linear_pauli_rotations(
23
+ bases: CArray[Pauli],
24
+ slopes: CArray[CReal],
25
+ offsets: CArray[CReal],
26
+ x: QArray[QBit],
27
+ q: QArray[QBit],
28
+ ) -> None:
29
+ r"""
30
+ Qmod Classiq-library function.
31
+
32
+ Performs a rotation on a series of $m$ target qubits,
33
+ where the rotation angle is a linear function of an $n$-qubit
34
+ control register.
35
+
36
+ Corresponds to the braket notation:
37
+
38
+ $$
39
+ \left|x\right\rangle _{n}\left|q\right\rangle
40
+ _{m}\rightarrow\left|x\right\rangle
41
+ _{n}\prod_{k=1}^{m}\left(\cos\left(\frac{a_{k}}{2}x+\frac{b_{k}}{2}\right)-
42
+ i\sin\left(\frac{a_{k}}{2}x+\frac{b_{k}}{2}\right)P_{k}\right)\left|q_{k}\right\rangle
43
+ $$
44
+
45
+ where $\left|x\right\rangle$ is the control register,
46
+ $\left|q\right\rangle$ is the target register, each $P_{k}$ is one of
47
+ the three Pauli matrices $X$, $Y$, or $Z$, and $a_{k}$, $b_{k}$ are
48
+ the user given slopes and offsets, respectively.
49
+
50
+ Args:
51
+ bases: List of Pauli Enums.
52
+ slopes: Rotation slopes for each of the given Pauli bases.
53
+ offsets: Rotation offsets for each of the given Pauli bases.
54
+ x: Quantum state to apply the rotation based on its value.
55
+ q: List of indicator qubits for each of the given Pauli bases.
56
+
57
+ Notice that bases, slopes, offset and q should be of the same size.
58
+
59
+
60
+
61
+ Links:
62
+ [linear_pauli_rotations](https://docs.classiq.io/latest/explore/functions/qmod_library_reference/classiq_open_library/linear_pauli_rotations/linear_pauli_rotations)
63
+ """
64
+
65
+ pass
@@ -0,0 +1,137 @@
1
+ from classiq.qmod.qfunc import qfunc
2
+ from classiq.qmod.qmod_parameter import CInt
3
+ from classiq.qmod.qmod_variable import QArray, QBit, QNum
4
+
5
+
6
+ @qfunc(external=True)
7
+ def qft_no_swap(qbv: QArray[QBit]) -> None:
8
+ """
9
+ Qmod Classiq-library function.
10
+
11
+ Applies the Quantum Fourier Transform (QFT) without the swap gates.
12
+
13
+ Args:
14
+ qbv: The quantum number to which the QFT is applied.
15
+
16
+ """
17
+ pass
18
+
19
+
20
+ @qfunc(external=True)
21
+ def _check_msb(ref: CInt, x: QArray[QBit], aux: QBit) -> None:
22
+ pass
23
+
24
+
25
+ @qfunc(external=True)
26
+ def _ctrl_x(ref: CInt, ctrl: QNum, aux: QBit) -> None:
27
+ pass
28
+
29
+
30
+ @qfunc(external=True)
31
+ def qft_space_add_const(value: CInt, phi_b: QArray[QBit]) -> None:
32
+ """
33
+ Qmod Classiq-library function.
34
+
35
+ Adds a constant to a quantum number (in the Fourier space) using the Quantum Fourier Transform (QFT) Adder algorithm.
36
+ Assuming that the input `phi_b` has `n` qubits, the result will be $\\phi_b+=value \\mod 2^n$.
37
+
38
+ To perform the full algorithm, use:
39
+ within_apply(lambda: QFT(phi_b), qft_space_add_const(value, phi_b))
40
+
41
+ Args:
42
+ value: The constant to add to the quantum number.
43
+ phi_b: The quantum number (at the aft space) to which the constant is added.
44
+
45
+ """
46
+ pass
47
+
48
+
49
+ @qfunc(external=True)
50
+ def cc_modular_add(n: CInt, a: CInt, phi_b: QArray[QBit], c1: QBit, c2: QBit) -> None:
51
+ """
52
+ Qmod Classiq-library function.
53
+
54
+ Adds a constant `a` to a quantum number `phi_b` modulo the constant `n`, controlled by 2 qubits.
55
+ The quantum number `phi_b` and the constant `a` are assumed to be in the QFT space.
56
+
57
+ Args:
58
+ n: The modulo number.
59
+ a: The constant to add to the quantum number.
60
+ phi_b: The quantum number to which the constant is added.
61
+ c1: a control qubit.
62
+ c2: a control qubit.
63
+
64
+ """
65
+ pass
66
+
67
+
68
+ @qfunc(external=True)
69
+ def c_modular_multiply(
70
+ n: CInt, a: CInt, b: QArray[QBit], x: QArray[QBit], ctrl: QBit
71
+ ) -> None:
72
+ """
73
+ Qmod Classiq-library function.
74
+
75
+ Performs out-of-place multiplication of a quantum number `x` by a classical number `a` modulo classical number `n`,
76
+ 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.
77
+
78
+ Args:
79
+ n: The modulo number. Should be non-negative.
80
+ a: The classical factor. Should be non-negative.
81
+ b: The quantum number added to the multiplication result. Stores the result of the multiplication.
82
+ x: The quantum factor.
83
+ ctrl: The control bit.
84
+ """
85
+ pass
86
+
87
+
88
+ @qfunc(external=True)
89
+ def multiswap(x: QArray[QBit], y: QArray[QBit]) -> None:
90
+ """
91
+ Qmod Classiq-library function.
92
+
93
+ Swaps the qubit states between two arrays.
94
+ Swaps according to the indices of the shorter array.
95
+
96
+ Args:
97
+ x: The first array
98
+ y: The second array
99
+
100
+ """
101
+ pass
102
+
103
+
104
+ @qfunc(external=True)
105
+ def inplace_c_modular_multiply(n: CInt, a: CInt, x: QArray[QBit], ctrl: QBit) -> None:
106
+ """
107
+ Qmod Classiq-library function.
108
+
109
+ Performs Multiplication of a quantum number `x` by a classical number `a` modulo classical number `n`,
110
+ controlled by a quantum bit `ctrl`. Applies $x=xa \\mod n$ if `ctrl=1`, and the identity otherwise.
111
+
112
+ Args:
113
+ n: The modulo number. Should be non-negative.
114
+ a: The classical factor. Should be non-negative.
115
+ x: The quantum factor.
116
+ ctrl: The control bit.
117
+ """
118
+ pass
119
+
120
+
121
+ @qfunc(external=True)
122
+ def modular_exp(n: CInt, a: CInt, x: QArray[QBit], power: QArray[QBit]) -> None:
123
+ """
124
+ Qmod Classiq-library function.
125
+
126
+ Raises a classical integer `a` to the power of a quantum number `x` modulo classical integer `n`
127
+ times a quantum number `power`. Performs $power=(a^x \\mod n)*power$ in-place.
128
+ (and specifically if at the input $power=1$, at the output $power=a^x \\mod n$).
129
+
130
+ Args:
131
+ n: The modulus number. Should be non-negative.
132
+ a: The base of the exponentiation. Should be non-negative.
133
+ x: The power of the exponentiation.
134
+ power: A quantum number which multiplies the modular exponentiation and holds the output.
135
+
136
+ """
137
+ pass
@@ -0,0 +1,22 @@
1
+ from classiq.qmod.cparam import CInt
2
+ from classiq.qmod.qfunc import qfunc
3
+ from classiq.qmod.quantum_callable import QCallable, QCallableList
4
+
5
+
6
+ @qfunc(external=True)
7
+ def permute(
8
+ functions: QCallableList,
9
+ ) -> None:
10
+ pass
11
+
12
+
13
+ @qfunc(external=True)
14
+ def apply(
15
+ operand: QCallable,
16
+ ) -> None:
17
+ pass
18
+
19
+
20
+ @qfunc(external=True)
21
+ def switch(selector: CInt, cases: QCallableList) -> None:
22
+ pass