classiq 0.60.1__py3-none-any.whl → 0.61.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.
- classiq/__init__.py +2 -0
- classiq/_internals/client.py +6 -1
- classiq/applications/__init__.py +1 -1
- classiq/applications/chemistry/__init__.py +7 -7
- classiq/applications/chemistry/chemistry_model_constructor.py +17 -6
- classiq/applications/combinatorial_optimization/__init__.py +7 -1
- classiq/applications/combinatorial_optimization/combinatorial_optimization_model_constructor.py +2 -0
- classiq/applications/combinatorial_optimization/combinatorial_problem.py +197 -0
- classiq/applications/finance/finance_model_constructor.py +6 -6
- classiq/applications/grover/grover_model_constructor.py +3 -0
- classiq/applications/libraries/qmci_library.py +1 -10
- classiq/applications/qnn/__init__.py +1 -1
- classiq/applications/qnn/datasets/__init__.py +8 -8
- classiq/applications/qsvm/qsvm.py +1 -1
- classiq/execution/__init__.py +0 -2
- classiq/execution/execution_session.py +6 -0
- classiq/executor.py +1 -1
- classiq/interface/_version.py +1 -1
- classiq/interface/backend/backend_preferences.py +12 -12
- classiq/interface/executor/execution_preferences.py +1 -1
- classiq/interface/generator/application_apis/chemistry_declarations.py +1 -1
- classiq/interface/generator/application_apis/finance_declarations.py +2 -2
- classiq/interface/generator/arith/arithmetic.py +16 -1
- classiq/interface/generator/arith/arithmetic_expression_validator.py +4 -3
- classiq/interface/generator/expressions/expression_constants.py +3 -0
- classiq/interface/generator/generated_circuit_data.py +58 -20
- classiq/interface/generator/model/__init__.py +1 -1
- classiq/interface/generator/model/quantum_register.py +3 -3
- classiq/interface/generator/standard_gates/controlled_standard_gates.py +20 -32
- classiq/interface/ide/visual_model.py +1 -0
- classiq/interface/interface_version.py +1 -1
- classiq/interface/model/model.py +2 -3
- classiq/interface/model/quantum_function_call.py +4 -7
- classiq/interface/model/quantum_function_declaration.py +7 -0
- classiq/interface/model/quantum_lambda_function.py +10 -1
- classiq/interface/model/quantum_type.py +3 -1
- classiq/model_expansions/atomic_expression_functions_defs.py +3 -1
- classiq/model_expansions/capturing/captured_vars.py +24 -8
- classiq/model_expansions/capturing/mangling_utils.py +23 -15
- classiq/model_expansions/evaluators/arg_type_match.py +7 -7
- classiq/model_expansions/expression_evaluator.py +5 -2
- classiq/model_expansions/function_builder.py +21 -4
- classiq/model_expansions/generative_functions.py +12 -90
- classiq/model_expansions/interpreter.py +58 -11
- classiq/model_expansions/quantum_operations/call_emitter.py +19 -10
- classiq/model_expansions/quantum_operations/classicalif.py +1 -1
- classiq/model_expansions/quantum_operations/control.py +5 -31
- classiq/model_expansions/quantum_operations/emitter.py +27 -14
- classiq/model_expansions/quantum_operations/expression_operation.py +3 -5
- classiq/model_expansions/quantum_operations/inplace_binary_operation.py +57 -15
- classiq/model_expansions/quantum_operations/invert.py +1 -6
- classiq/model_expansions/quantum_operations/phase.py +2 -5
- classiq/model_expansions/quantum_operations/power.py +0 -4
- classiq/model_expansions/quantum_operations/quantum_assignment_operation.py +19 -30
- classiq/model_expansions/quantum_operations/quantum_function_call.py +3 -1
- classiq/model_expansions/quantum_operations/shallow_emitter.py +155 -0
- classiq/model_expansions/quantum_operations/within_apply.py +0 -14
- classiq/model_expansions/scope.py +10 -4
- classiq/model_expansions/scope_initialization.py +0 -11
- classiq/model_expansions/sympy_conversion/expression_to_sympy.py +7 -0
- classiq/model_expansions/sympy_conversion/sympy_to_python.py +12 -2
- classiq/model_expansions/transformers/ast_renamer.py +26 -0
- classiq/model_expansions/transformers/var_splitter.py +11 -12
- classiq/model_expansions/visitors/variable_references.py +20 -12
- classiq/qmod/builtins/classical_execution_primitives.py +6 -6
- classiq/qmod/builtins/classical_functions.py +10 -10
- classiq/qmod/builtins/functions/__init__.py +89 -103
- classiq/qmod/builtins/functions/amplitude_estimation.py +1 -1
- classiq/qmod/builtins/functions/arithmetic.py +1 -1
- classiq/qmod/builtins/functions/discrete_sine_cosine_transform.py +6 -6
- classiq/qmod/builtins/functions/grover.py +5 -5
- classiq/qmod/builtins/functions/hea.py +1 -1
- classiq/qmod/builtins/functions/linear_pauli_rotation.py +2 -2
- classiq/qmod/builtins/functions/modular_exponentiation.py +8 -8
- classiq/qmod/builtins/functions/operators.py +1 -1
- classiq/qmod/builtins/functions/qaoa_penalty.py +5 -5
- classiq/qmod/builtins/functions/qft_functions.py +2 -2
- classiq/qmod/builtins/functions/qpe.py +9 -12
- classiq/qmod/builtins/functions/qsvt.py +177 -15
- classiq/qmod/builtins/functions/state_preparation.py +9 -9
- classiq/qmod/builtins/functions/swap_test.py +1 -1
- classiq/qmod/builtins/functions/utility_functions.py +2 -2
- classiq/qmod/builtins/functions/variational.py +2 -2
- classiq/qmod/builtins/operations.py +3 -3
- classiq/qmod/builtins/structs.py +9 -9
- classiq/qmod/native/pretty_printer.py +17 -19
- classiq/qmod/pretty_print/pretty_printer.py +9 -6
- classiq/qmod/qmod_variable.py +2 -5
- classiq/qmod/quantum_expandable.py +18 -4
- classiq/qmod/quantum_function.py +19 -6
- classiq/qmod/semantics/static_semantics_visitor.py +34 -16
- classiq/qmod/semantics/validation/func_call_validation.py +9 -5
- classiq/qmod/semantics/validation/function_name_collisions_validation.py +23 -0
- classiq/qmod/symbolic.py +47 -47
- {classiq-0.60.1.dist-info → classiq-0.61.0.dist-info}/METADATA +1 -1
- {classiq-0.60.1.dist-info → classiq-0.61.0.dist-info}/RECORD +97 -94
- classiq/execution/qaoa.py +0 -86
- {classiq-0.60.1.dist-info → classiq-0.61.0.dist-info}/WHEEL +0 -0
@@ -44,7 +44,7 @@ class SymbolPart:
|
|
44
44
|
return HandleBinding(name=self.target_var_name)
|
45
45
|
|
46
46
|
|
47
|
-
SymbolParts = dict[
|
47
|
+
SymbolParts = dict[HandleBinding, list[SymbolPart]]
|
48
48
|
PartNamer = Callable[[str], str]
|
49
49
|
|
50
50
|
|
@@ -78,7 +78,7 @@ class VarSplitter:
|
|
78
78
|
}
|
79
79
|
|
80
80
|
return {
|
81
|
-
symbol: [
|
81
|
+
symbol.handle: [
|
82
82
|
SymbolPart(
|
83
83
|
source_handle=part.handle,
|
84
84
|
target_var_name=namer(part.handle.identifier),
|
@@ -165,10 +165,10 @@ class VarSplitter:
|
|
165
165
|
def get_bind_ops(symbol_parts: SymbolParts) -> list[BindOperation]:
|
166
166
|
return [
|
167
167
|
BindOperation(
|
168
|
-
in_handles=[
|
168
|
+
in_handles=[handle],
|
169
169
|
out_handles=[part.target_var_handle for part in parts],
|
170
170
|
)
|
171
|
-
for
|
171
|
+
for handle, parts in symbol_parts.items()
|
172
172
|
]
|
173
173
|
|
174
174
|
@staticmethod
|
@@ -229,21 +229,20 @@ class VarSplitter:
|
|
229
229
|
vrc.visit(ast.parse(expression.expr))
|
230
230
|
|
231
231
|
handle_names = {
|
232
|
-
part.source_handle: part.
|
232
|
+
part.source_handle: part.target_var_handle
|
233
233
|
for parts in symbol_mapping.values()
|
234
234
|
for part in parts
|
235
235
|
}
|
236
236
|
new_expr_str = expression.expr
|
237
237
|
for handle in vrc.var_handles:
|
238
|
-
|
239
|
-
|
238
|
+
new_handle = handle.collapse()
|
239
|
+
for handle_to_replace, replacement in handle_names.items():
|
240
|
+
new_handle = new_handle.replace_prefix(handle_to_replace, replacement)
|
241
|
+
new_expr_str = new_expr_str.replace(str(handle), str(new_handle))
|
242
|
+
if handle.qmod_expr != str(handle):
|
240
243
|
new_expr_str = new_expr_str.replace(
|
241
|
-
|
244
|
+
handle.qmod_expr, new_handle.qmod_expr
|
242
245
|
)
|
243
|
-
if handle.qmod_expr != str(handle):
|
244
|
-
new_expr_str = new_expr_str.replace(
|
245
|
-
handle.qmod_expr, handle_names[collapsed_handle]
|
246
|
-
)
|
247
246
|
|
248
247
|
new_expr = Expression(expr=new_expr_str)
|
249
248
|
new_expr._evaluated_expr = expression._evaluated_expr
|
@@ -23,9 +23,12 @@ from classiq.interface.model.handle_binding import (
|
|
23
23
|
|
24
24
|
|
25
25
|
class VarRefCollector(ast.NodeVisitor):
|
26
|
-
def __init__(
|
26
|
+
def __init__(
|
27
|
+
self, ignore_duplicated_handles: bool = False, unevaluated: bool = False
|
28
|
+
) -> None:
|
27
29
|
self._var_handles: dict[HandleBinding, bool] = {}
|
28
30
|
self._ignore_duplicated_handles = ignore_duplicated_handles
|
31
|
+
self._unevaluated = unevaluated
|
29
32
|
self._is_nested = False
|
30
33
|
|
31
34
|
@property
|
@@ -57,23 +60,28 @@ class VarRefCollector(ast.NodeVisitor):
|
|
57
60
|
return None
|
58
61
|
|
59
62
|
handle: Union[SubscriptHandleBinding, SlicedHandleBinding]
|
60
|
-
if isinstance(node.slice, ast.
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
)
|
65
|
-
elif isinstance(node.slice, ast.Slice):
|
66
|
-
if not isinstance(node.slice.lower, ast.Num) or not isinstance(
|
67
|
-
node.slice.upper, ast.Num
|
63
|
+
if isinstance(node.slice, ast.Slice):
|
64
|
+
if not self._unevaluated and (
|
65
|
+
not isinstance(node.slice.lower, ast.Num)
|
66
|
+
or not isinstance(node.slice.upper, ast.Num)
|
68
67
|
):
|
69
68
|
raise ClassiqInternalExpansionError("Unevaluated slice bounds.")
|
69
|
+
if node.slice.lower is None or node.slice.upper is None:
|
70
|
+
raise ClassiqExpansionError(
|
71
|
+
f"{str(base_handle)!r} slice must specify both lower and upper bounds"
|
72
|
+
)
|
70
73
|
handle = SlicedHandleBinding(
|
71
74
|
base_handle=base_handle,
|
72
|
-
start=Expression(expr=
|
73
|
-
end=Expression(expr=
|
75
|
+
start=Expression(expr=ast.unparse(node.slice.lower)),
|
76
|
+
end=Expression(expr=ast.unparse(node.slice.upper)),
|
74
77
|
)
|
75
|
-
|
78
|
+
elif not self._unevaluated and not isinstance(node.slice, ast.Num):
|
76
79
|
raise ClassiqInternalExpansionError("Unevaluated slice.")
|
80
|
+
else:
|
81
|
+
handle = SubscriptHandleBinding(
|
82
|
+
base_handle=base_handle,
|
83
|
+
index=Expression(expr=ast.unparse(node.slice)),
|
84
|
+
)
|
77
85
|
|
78
86
|
if not self._is_nested:
|
79
87
|
self._var_handles[handle] = True
|
@@ -105,16 +105,16 @@ def molecule_ground_state_solution_post_process( # type: ignore[return]
|
|
105
105
|
|
106
106
|
__all__ = [
|
107
107
|
"ExecutionParams",
|
108
|
-
"
|
109
|
-
"sample",
|
108
|
+
"batch_estimate",
|
110
109
|
"batch_sample",
|
111
110
|
"estimate",
|
112
|
-
"batch_estimate",
|
113
|
-
"vqe",
|
114
|
-
"qae_with_qpe_result_post_processing",
|
115
|
-
"qsvm_full_run",
|
116
111
|
"iqae",
|
117
112
|
"molecule_ground_state_solution_post_process",
|
113
|
+
"qae_with_qpe_result_post_processing",
|
114
|
+
"qsvm_full_run",
|
115
|
+
"sample",
|
116
|
+
"save",
|
117
|
+
"vqe",
|
118
118
|
]
|
119
119
|
|
120
120
|
|
@@ -15,14 +15,14 @@ def qft_const_adder_phase(
|
|
15
15
|
return symbolic_function(bit_index, value, reg_len, return_type=CReal)
|
16
16
|
|
17
17
|
|
18
|
-
def
|
19
|
-
problem:
|
18
|
+
def fock_hamiltonian_problem_to_hamiltonian(
|
19
|
+
problem: FockHamiltonianProblem,
|
20
20
|
) -> CArray[PauliTerm]:
|
21
21
|
return symbolic_function(problem, return_type=CArray[PauliTerm])
|
22
22
|
|
23
23
|
|
24
|
-
def
|
25
|
-
problem:
|
24
|
+
def molecule_problem_to_hamiltonian(
|
25
|
+
problem: MoleculeProblem,
|
26
26
|
) -> CArray[PauliTerm]:
|
27
27
|
return symbolic_function(problem, return_type=CArray[PauliTerm])
|
28
28
|
|
@@ -43,8 +43,8 @@ def hypercube_entangler_graph(
|
|
43
43
|
return symbolic_function(num_qubits, return_type=CArray[CArray[CInt]])
|
44
44
|
|
45
45
|
|
46
|
-
def
|
47
|
-
finance_model:
|
46
|
+
def gaussian_finance_post_process(
|
47
|
+
finance_model: GaussianModel,
|
48
48
|
estimation_method: FinanceFunction,
|
49
49
|
probability: CReal,
|
50
50
|
) -> CReal:
|
@@ -53,8 +53,8 @@ def log_normal_finance_post_process(
|
|
53
53
|
)
|
54
54
|
|
55
55
|
|
56
|
-
def
|
57
|
-
finance_model:
|
56
|
+
def log_normal_finance_post_process(
|
57
|
+
finance_model: LogNormalModel,
|
58
58
|
estimation_method: FinanceFunction,
|
59
59
|
probability: CReal,
|
60
60
|
) -> CReal:
|
@@ -65,10 +65,10 @@ def gaussian_finance_post_process(
|
|
65
65
|
|
66
66
|
__all__ = [
|
67
67
|
"qft_const_adder_phase",
|
68
|
-
"molecule_problem_to_hamiltonian",
|
69
68
|
"fock_hamiltonian_problem_to_hamiltonian",
|
69
|
+
"molecule_problem_to_hamiltonian",
|
70
70
|
"grid_entangler_graph",
|
71
71
|
"hypercube_entangler_graph",
|
72
|
-
"log_normal_finance_post_process",
|
73
72
|
"gaussian_finance_post_process",
|
73
|
+
"log_normal_finance_post_process",
|
74
74
|
]
|
@@ -1,6 +1,3 @@
|
|
1
|
-
from classiq.interface.model.native_function_definition import NativeFunctionDefinition
|
2
|
-
|
3
|
-
from ...quantum_function import GenerativeQFunc
|
4
1
|
from .amplitude_estimation import *
|
5
2
|
from .arithmetic import *
|
6
3
|
from .benchmarking import *
|
@@ -90,7 +87,7 @@ CORE_LIB_DECLS = [
|
|
90
87
|
)
|
91
88
|
]
|
92
89
|
|
93
|
-
|
90
|
+
OPEN_LIBRARY_FUNCTIONS = [
|
94
91
|
qpe_flexible,
|
95
92
|
qpe,
|
96
93
|
_single_pauli,
|
@@ -112,8 +109,11 @@ OPEN_LIBRARY_UNPROCESSED_FUNCTIONS = [
|
|
112
109
|
modular_exp,
|
113
110
|
qsvt_step,
|
114
111
|
qsvt,
|
112
|
+
projector_controlled_double_phase,
|
115
113
|
projector_controlled_phase,
|
116
114
|
qsvt_inversion,
|
115
|
+
qsvt_lcu,
|
116
|
+
qsvt_lcu_step,
|
117
117
|
allocate_num,
|
118
118
|
qaoa_mixer_layer,
|
119
119
|
qaoa_cost_layer,
|
@@ -145,133 +145,119 @@ OPEN_LIBRARY_UNPROCESSED_FUNCTIONS = [
|
|
145
145
|
encode_on_bloch,
|
146
146
|
]
|
147
147
|
|
148
|
-
OPEN_LIBRARY_FUNCTIONS: list[NativeFunctionDefinition] = []
|
149
|
-
|
150
|
-
|
151
|
-
def load_open_library_implementations() -> None:
|
152
|
-
OPEN_LIBRARY_FUNCTIONS.extend(
|
153
|
-
[func.get_implementation() for func in OPEN_LIBRARY_UNPROCESSED_FUNCTIONS]
|
154
|
-
)
|
155
|
-
|
156
|
-
|
157
|
-
OPEN_LIBRARY_GENERATIVE_FUNCTIONS: list[GenerativeQFunc] = []
|
158
|
-
|
159
|
-
OPEN_LIB_DECLS = [
|
160
|
-
func.func_decl
|
161
|
-
for func in OPEN_LIBRARY_GENERATIVE_FUNCTIONS + OPEN_LIBRARY_UNPROCESSED_FUNCTIONS
|
162
|
-
]
|
163
|
-
|
164
148
|
STD_QMOD_OPERATORS = [func.func_decl for func in (apply, permute)]
|
165
149
|
|
166
150
|
BUILTIN_FUNCTION_DECLARATIONS = {
|
167
|
-
func_decl.name: func_decl
|
168
|
-
for func_decl in STD_QMOD_OPERATORS + OPEN_LIB_DECLS + CORE_LIB_DECLS
|
151
|
+
func_decl.name: func_decl for func_decl in STD_QMOD_OPERATORS + CORE_LIB_DECLS
|
169
152
|
}
|
170
153
|
|
171
|
-
__all__ = [
|
172
|
-
"
|
173
|
-
"
|
174
|
-
"
|
175
|
-
"
|
176
|
-
"
|
177
|
-
"
|
178
|
-
"
|
179
|
-
"
|
180
|
-
"
|
181
|
-
"gaussian_finance",
|
182
|
-
"pauli_feature_map",
|
183
|
-
"bloch_sphere_feature_map",
|
154
|
+
__all__ = [ # noqa: RUF022
|
155
|
+
"CCX",
|
156
|
+
"CH",
|
157
|
+
"CPHASE",
|
158
|
+
"CRX",
|
159
|
+
"CRY",
|
160
|
+
"CRZ",
|
161
|
+
"CX",
|
162
|
+
"CY",
|
163
|
+
"CZ",
|
184
164
|
"H",
|
185
|
-
"X",
|
186
|
-
"Y",
|
187
|
-
"Z",
|
188
165
|
"I",
|
189
|
-
"
|
190
|
-
"T",
|
191
|
-
"SDG",
|
192
|
-
"TDG",
|
166
|
+
"IDENTITY",
|
193
167
|
"PHASE",
|
194
|
-
"RX",
|
195
|
-
"RY",
|
196
|
-
"RZ",
|
197
168
|
"R",
|
169
|
+
"RX",
|
198
170
|
"RXX",
|
171
|
+
"RY",
|
199
172
|
"RYY",
|
173
|
+
"RZ",
|
200
174
|
"RZZ",
|
201
|
-
"
|
202
|
-
"
|
203
|
-
"CY",
|
204
|
-
"CZ",
|
205
|
-
"CRX",
|
206
|
-
"CRY",
|
207
|
-
"CRZ",
|
208
|
-
"CPHASE",
|
175
|
+
"SDG",
|
176
|
+
"S",
|
209
177
|
"SWAP",
|
210
|
-
"
|
211
|
-
"
|
212
|
-
"prepare_amplitudes",
|
213
|
-
"unitary",
|
214
|
-
"add",
|
215
|
-
"modular_add",
|
216
|
-
"integer_xor",
|
217
|
-
"modular_add_constant",
|
218
|
-
"real_xor_constant",
|
178
|
+
"T",
|
179
|
+
"TDG",
|
219
180
|
"U",
|
220
|
-
"
|
221
|
-
"
|
222
|
-
"
|
223
|
-
"randomized_benchmarking",
|
224
|
-
"inplace_prepare_state",
|
225
|
-
"inplace_prepare_amplitudes",
|
226
|
-
"single_pauli_exponent",
|
227
|
-
"suzuki_trotter",
|
228
|
-
"qdrift",
|
229
|
-
"exponentiation_with_depth_constraint",
|
230
|
-
"qpe_flexible",
|
231
|
-
"qpe",
|
181
|
+
"X",
|
182
|
+
"Y",
|
183
|
+
"Z",
|
232
184
|
"_single_pauli",
|
233
|
-
"
|
185
|
+
"add",
|
186
|
+
"allocate",
|
187
|
+
"allocate_num",
|
234
188
|
"amplitude_estimation",
|
235
|
-
"
|
236
|
-
"
|
189
|
+
"apply",
|
190
|
+
"apply_to_all",
|
191
|
+
"bloch_sphere_feature_map",
|
192
|
+
"c_modular_multiply",
|
193
|
+
"cc_modular_add",
|
194
|
+
"encode_in_angle",
|
195
|
+
"encode_on_bloch",
|
196
|
+
"exponentiation_with_depth_constraint",
|
197
|
+
"fock_hamiltonian_hartree_fock",
|
198
|
+
"fock_hamiltonian_hva",
|
199
|
+
"fock_hamiltonian_ucc",
|
200
|
+
"free",
|
201
|
+
"full_hea",
|
202
|
+
"gaussian_finance",
|
237
203
|
"grover_diffuser",
|
238
204
|
"grover_operator",
|
239
205
|
"grover_search",
|
240
206
|
"hadamard_transform",
|
241
|
-
"apply_to_all",
|
242
|
-
"qft_no_swap",
|
243
|
-
"qft_space_add_const",
|
244
|
-
"cc_modular_add",
|
245
|
-
"c_modular_multiply",
|
246
|
-
"multiswap",
|
247
207
|
"inplace_c_modular_multiply",
|
208
|
+
"inplace_prepare_amplitudes",
|
209
|
+
"inplace_prepare_int",
|
210
|
+
"inplace_prepare_state",
|
211
|
+
"integer_xor",
|
212
|
+
"linear_pauli_rotations",
|
213
|
+
"log_normal_finance",
|
214
|
+
"modular_add",
|
215
|
+
"modular_add_constant",
|
248
216
|
"modular_exp",
|
249
|
-
"
|
250
|
-
"
|
217
|
+
"modular_increment",
|
218
|
+
"molecule_hartree_fock",
|
219
|
+
"molecule_hva",
|
220
|
+
"molecule_ucc",
|
221
|
+
"multiswap",
|
222
|
+
"pauli_feature_map",
|
223
|
+
"permute",
|
224
|
+
"phase_oracle",
|
225
|
+
"prepare_amplitudes",
|
226
|
+
"prepare_bell_state",
|
227
|
+
"prepare_exponential_state",
|
228
|
+
"prepare_ghz_state",
|
229
|
+
"prepare_int",
|
230
|
+
"prepare_state",
|
231
|
+
"prepare_uniform_interval_state",
|
232
|
+
"prepare_uniform_trimmed_state",
|
233
|
+
"projector_controlled_double_phase",
|
251
234
|
"projector_controlled_phase",
|
252
|
-
"qsvt_inversion",
|
253
|
-
"allocate_num",
|
254
|
-
"qaoa_mixer_layer",
|
255
235
|
"qaoa_cost_layer",
|
256
|
-
"qaoa_layer",
|
257
236
|
"qaoa_init",
|
237
|
+
"qaoa_layer",
|
238
|
+
"qaoa_mixer_layer",
|
258
239
|
"qaoa_penalty",
|
259
|
-
"full_hea",
|
260
|
-
"swap_test",
|
261
|
-
"prepare_uniform_trimmed_state",
|
262
|
-
"prepare_uniform_interval_state",
|
263
|
-
"prepare_ghz_state",
|
264
|
-
"prepare_exponential_state",
|
265
|
-
"prepare_bell_state",
|
266
|
-
"inplace_prepare_int",
|
267
|
-
"prepare_int",
|
268
|
-
"switch",
|
269
240
|
"qct_qst_type1",
|
270
241
|
"qct_qst_type2",
|
271
242
|
"qct_type2",
|
272
|
-
"
|
273
|
-
"modular_increment",
|
243
|
+
"qdrift",
|
274
244
|
"qft",
|
275
|
-
"
|
276
|
-
"
|
245
|
+
"qft_no_swap",
|
246
|
+
"qft_space_add_const",
|
247
|
+
"qpe",
|
248
|
+
"qpe_flexible",
|
249
|
+
"qst_type2",
|
250
|
+
"qsvt",
|
251
|
+
"qsvt_inversion",
|
252
|
+
"qsvt_lcu",
|
253
|
+
"qsvt_lcu_step",
|
254
|
+
"qsvt_step",
|
255
|
+
"randomized_benchmarking",
|
256
|
+
"real_xor_constant",
|
257
|
+
"reflect_about_zero",
|
258
|
+
"single_pauli_exponent",
|
259
|
+
"suzuki_trotter",
|
260
|
+
"swap_test",
|
261
|
+
"switch",
|
262
|
+
"unitary",
|
277
263
|
]
|
@@ -14,13 +14,13 @@ def _b_operator(q: QBit) -> None:
|
|
14
14
|
H(q)
|
15
15
|
|
16
16
|
|
17
|
-
@qfunc
|
17
|
+
@qfunc
|
18
18
|
def _qct_d_operator(x: QNum, q: QBit) -> None:
|
19
19
|
_b_operator(q)
|
20
20
|
control(x == 0, lambda: invert(lambda: _b_operator(q)))
|
21
21
|
|
22
22
|
|
23
|
-
@qfunc
|
23
|
+
@qfunc
|
24
24
|
def _qct_pi_operator(x: QArray[QBit], q: QBit) -> None:
|
25
25
|
control(q == 1, lambda: apply_to_all(X, x))
|
26
26
|
control(q == 1, lambda: modular_increment(1, x))
|
@@ -82,7 +82,7 @@ def _un_dag_operator(x: QArray[QBit], q: QBit) -> None:
|
|
82
82
|
invert(lambda: _pi2_operator(x, q))
|
83
83
|
|
84
84
|
|
85
|
-
@qfunc
|
85
|
+
@qfunc
|
86
86
|
def qct_qst_type1(x: QArray[QBit]) -> None:
|
87
87
|
"""
|
88
88
|
[Qmod Classiq-library function]
|
@@ -109,7 +109,7 @@ def qct_qst_type1(x: QArray[QBit]) -> None:
|
|
109
109
|
within_apply(lambda: _t_operator(x), lambda: qft(x))
|
110
110
|
|
111
111
|
|
112
|
-
@qfunc
|
112
|
+
@qfunc
|
113
113
|
def qct_qst_type2(x: QArray[QBit], q: QBit) -> None:
|
114
114
|
"""
|
115
115
|
[Qmod Classiq-library function]
|
@@ -140,7 +140,7 @@ def qct_qst_type2(x: QArray[QBit], q: QBit) -> None:
|
|
140
140
|
_un_dag_operator(x, q)
|
141
141
|
|
142
142
|
|
143
|
-
@qfunc
|
143
|
+
@qfunc
|
144
144
|
def qct_type2(x: QArray[QBit]) -> None:
|
145
145
|
"""
|
146
146
|
[Qmod Classiq-library function]
|
@@ -155,7 +155,7 @@ def qct_type2(x: QArray[QBit]) -> None:
|
|
155
155
|
within_apply(lambda: allocate(1, q), lambda: qct_qst_type2(x, q))
|
156
156
|
|
157
157
|
|
158
|
-
@qfunc
|
158
|
+
@qfunc
|
159
159
|
def qst_type2(x: QArray[QBit]) -> None:
|
160
160
|
"""
|
161
161
|
[Qmod Classiq-library function]
|
@@ -15,7 +15,7 @@ from classiq.qmod.quantum_callable import QCallable
|
|
15
15
|
from classiq.qmod.symbolic import pi
|
16
16
|
|
17
17
|
|
18
|
-
@qfunc
|
18
|
+
@qfunc
|
19
19
|
def phase_oracle(
|
20
20
|
predicate: QCallable[QArray[QBit], QBit], target: QArray[QBit]
|
21
21
|
) -> None:
|
@@ -47,7 +47,7 @@ def phase_oracle(
|
|
47
47
|
)
|
48
48
|
|
49
49
|
|
50
|
-
@qfunc
|
50
|
+
@qfunc
|
51
51
|
def reflect_about_zero(packed_vars: QArray[QBit]) -> None:
|
52
52
|
"""
|
53
53
|
[Qmod Classiq-library function]
|
@@ -74,7 +74,7 @@ def reflect_about_zero(packed_vars: QArray[QBit]) -> None:
|
|
74
74
|
bind([msbs, lsb], packed_vars)
|
75
75
|
|
76
76
|
|
77
|
-
@qfunc
|
77
|
+
@qfunc
|
78
78
|
def grover_diffuser(
|
79
79
|
space_transform: QCallable[QArray[QBit]], packed_vars: QArray[QBit]
|
80
80
|
) -> None:
|
@@ -102,7 +102,7 @@ def grover_diffuser(
|
|
102
102
|
)
|
103
103
|
|
104
104
|
|
105
|
-
@qfunc
|
105
|
+
@qfunc
|
106
106
|
def grover_operator(
|
107
107
|
oracle: QCallable[QArray[QBit]],
|
108
108
|
space_transform: QCallable[QArray[QBit]],
|
@@ -130,7 +130,7 @@ def grover_operator(
|
|
130
130
|
U(0, 0, 0, pi, packed_vars[0])
|
131
131
|
|
132
132
|
|
133
|
-
@qfunc
|
133
|
+
@qfunc
|
134
134
|
def grover_search(
|
135
135
|
reps: CInt, oracle: QCallable[QArray[QBit]], packed_vars: QArray[QBit]
|
136
136
|
) -> None:
|
@@ -10,7 +10,7 @@ from classiq.qmod.qmod_variable import QArray, QBit
|
|
10
10
|
from classiq.qmod.quantum_callable import QCallable
|
11
11
|
|
12
12
|
|
13
|
-
@qfunc
|
13
|
+
@qfunc
|
14
14
|
def _single_pauli(
|
15
15
|
slope: CReal,
|
16
16
|
offset: CReal,
|
@@ -24,7 +24,7 @@ def _single_pauli(
|
|
24
24
|
q1_qfunc(offset, q)
|
25
25
|
|
26
26
|
|
27
|
-
@qfunc
|
27
|
+
@qfunc
|
28
28
|
def linear_pauli_rotations(
|
29
29
|
bases: CArray[Pauli],
|
30
30
|
slopes: CArray[CReal],
|
@@ -9,21 +9,21 @@ from classiq.qmod.qmod_variable import QArray, QBit, QNum
|
|
9
9
|
from classiq.qmod.symbolic import min, mod_inverse
|
10
10
|
|
11
11
|
|
12
|
-
@qfunc
|
12
|
+
@qfunc
|
13
13
|
def _check_msb(ref: CInt, x: QArray[QBit], aux: QBit) -> None:
|
14
14
|
within_apply(
|
15
15
|
lambda: invert(lambda: qft_no_swap(x)), lambda: _ctrl_x(ref, x[0], aux)
|
16
16
|
)
|
17
17
|
|
18
18
|
|
19
|
-
@qfunc
|
19
|
+
@qfunc
|
20
20
|
def _ctrl_x(
|
21
21
|
ref: CInt, ctrl: QNum, aux: QBit
|
22
22
|
) -> None: # TODO: remove qfunc when expressions of QBit is supported
|
23
23
|
control(ctrl == ref, lambda: X(aux))
|
24
24
|
|
25
25
|
|
26
|
-
@qfunc
|
26
|
+
@qfunc
|
27
27
|
def qft_space_add_const(value: CInt, phi_b: QArray[QBit]) -> None:
|
28
28
|
"""
|
29
29
|
[Qmod Classiq-library function]
|
@@ -50,7 +50,7 @@ def qft_space_add_const(value: CInt, phi_b: QArray[QBit]) -> None:
|
|
50
50
|
)
|
51
51
|
|
52
52
|
|
53
|
-
@qfunc
|
53
|
+
@qfunc
|
54
54
|
def cc_modular_add(n: CInt, a: CInt, phi_b: QArray[QBit], c1: QBit, c2: QBit) -> None:
|
55
55
|
"""
|
56
56
|
[Qmod Classiq-library function]
|
@@ -95,7 +95,7 @@ def cc_modular_add(n: CInt, a: CInt, phi_b: QArray[QBit], c1: QBit, c2: QBit) ->
|
|
95
95
|
)
|
96
96
|
|
97
97
|
|
98
|
-
@qfunc
|
98
|
+
@qfunc
|
99
99
|
def c_modular_multiply(
|
100
100
|
n: CInt, a: CInt, b: QArray[QBit], x: QArray[QBit], ctrl: QBit
|
101
101
|
) -> None:
|
@@ -123,7 +123,7 @@ def c_modular_multiply(
|
|
123
123
|
)
|
124
124
|
|
125
125
|
|
126
|
-
@qfunc
|
126
|
+
@qfunc
|
127
127
|
def multiswap(x: QArray[QBit], y: QArray[QBit]) -> None:
|
128
128
|
"""
|
129
129
|
[Qmod Classiq-library function]
|
@@ -142,7 +142,7 @@ def multiswap(x: QArray[QBit], y: QArray[QBit]) -> None:
|
|
142
142
|
)
|
143
143
|
|
144
144
|
|
145
|
-
@qfunc
|
145
|
+
@qfunc
|
146
146
|
def inplace_c_modular_multiply(n: CInt, a: CInt, x: QArray[QBit], ctrl: QBit) -> None:
|
147
147
|
"""
|
148
148
|
[Qmod Classiq-library function]
|
@@ -172,7 +172,7 @@ def inplace_c_modular_multiply(n: CInt, a: CInt, x: QArray[QBit], ctrl: QBit) ->
|
|
172
172
|
)
|
173
173
|
|
174
174
|
|
175
|
-
@qfunc
|
175
|
+
@qfunc
|
176
176
|
def modular_exp(n: CInt, a: CInt, x: QArray[QBit], power: QArray[QBit]) -> None:
|
177
177
|
"""
|
178
178
|
[Qmod Classiq-library function]
|