classiq 0.38.0__py3-none-any.whl → 0.39.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 +21 -22
- classiq/_internals/api_wrapper.py +13 -1
- classiq/_internals/client.py +12 -2
- classiq/analyzer/analyzer.py +3 -1
- classiq/applications/__init__.py +1 -8
- classiq/applications/chemistry/__init__.py +6 -0
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/arithmetic/arithmetic_expression.py +1 -1
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/combinatorial_problem_utils.py +26 -6
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/encoding_mapping.py +1 -1
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/encoding_utils.py +1 -1
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/memory.py +2 -4
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/optimization_model.py +6 -10
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/pauli_helpers/pauli_utils.py +10 -0
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/pyomo_utils.py +4 -2
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/transformations/encoding.py +3 -10
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/transformations/fixed_variables.py +4 -6
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/transformations/ising_converter.py +3 -5
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/transformations/penalty_support.py +3 -7
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/transformations/slack_variables.py +4 -6
- classiq/applications/combinatorial_optimization/__init__.py +9 -3
- classiq/{applications_model_constructors → applications/combinatorial_optimization}/combinatorial_optimization_model_constructor.py +7 -8
- classiq/applications/finance/__init__.py +3 -2
- classiq/{applications_model_constructors → applications/finance}/finance_model_constructor.py +24 -14
- classiq/applications/grover/__init__.py +11 -0
- classiq/applications/libraries/qmci_library.py +35 -0
- classiq/applications/qsvm/__init__.py +5 -1
- classiq/execution/all_hardware_devices.py +13 -0
- classiq/executor.py +2 -1
- classiq/interface/_version.py +1 -1
- classiq/interface/analyzer/result.py +1 -5
- classiq/interface/applications/qsvm.py +4 -2
- classiq/interface/ast_node.py +23 -0
- classiq/interface/combinatorial_optimization/examples/mht.py +8 -3
- classiq/interface/executor/execution_request.py +2 -37
- classiq/interface/executor/vqe_result.py +1 -1
- classiq/interface/generator/builtin_api_builder.py +0 -5
- classiq/interface/generator/constant.py +2 -3
- classiq/interface/generator/expressions/expression.py +2 -4
- classiq/interface/generator/expressions/qmod_qscalar_proxy.py +1 -1
- classiq/interface/generator/functions/__init__.py +2 -2
- classiq/interface/generator/functions/builtins/__init__.py +15 -0
- classiq/interface/generator/functions/builtins/core_library/__init__.py +14 -0
- classiq/interface/generator/functions/builtins/internal_operators.py +62 -0
- classiq/interface/generator/functions/{core_lib_declarations/quantum_functions/std_lib_functions.py → builtins/open_lib_functions.py} +109 -83
- classiq/interface/generator/functions/builtins/quantum_operators.py +37 -0
- classiq/interface/generator/functions/classical_type.py +2 -4
- classiq/interface/generator/functions/function_declaration.py +2 -2
- classiq/interface/generator/hartree_fock.py +10 -2
- classiq/interface/generator/model/classical_main_validator.py +1 -1
- classiq/interface/generator/model/model.py +1 -1
- classiq/interface/generator/quantum_function_call.py +1 -1
- classiq/interface/generator/types/struct_declaration.py +2 -4
- classiq/interface/model/call_synthesis_data.py +3 -3
- classiq/interface/model/classical_if.py +13 -0
- classiq/interface/model/classical_parameter_declaration.py +2 -3
- classiq/interface/model/control.py +16 -0
- classiq/interface/model/handle_binding.py +3 -2
- classiq/interface/model/invert.py +10 -0
- classiq/interface/model/model.py +2 -1
- classiq/interface/model/power.py +12 -0
- classiq/interface/model/quantum_function_call.py +9 -4
- classiq/interface/model/quantum_if_operation.py +3 -3
- classiq/interface/model/quantum_lambda_function.py +3 -9
- classiq/interface/model/quantum_statement.py +3 -2
- classiq/interface/model/quantum_type.py +2 -4
- classiq/interface/model/quantum_variable_declaration.py +2 -2
- classiq/interface/model/repeat.py +13 -0
- classiq/interface/model/resolvers/function_call_resolver.py +26 -0
- classiq/interface/model/statement_block.py +21 -4
- classiq/interface/model/validations/handles_validator.py +8 -12
- classiq/interface/model/within_apply_operation.py +4 -4
- classiq/interface/server/routes.py +0 -4
- classiq/qmod/builtins/classical_functions.py +9 -9
- classiq/qmod/builtins/functions.py +153 -226
- classiq/qmod/builtins/operations.py +160 -13
- classiq/qmod/native/pretty_printer.py +49 -20
- classiq/qmod/qmod_constant.py +26 -2
- classiq/qmod/qmod_parameter.py +2 -1
- classiq/qmod/qmod_variable.py +48 -15
- classiq/qmod/quantum_callable.py +1 -0
- classiq/qmod/quantum_expandable.py +6 -7
- classiq/qmod/quantum_function.py +4 -0
- classiq/qmod/symbolic.py +2 -2
- {classiq-0.38.0.dist-info → classiq-0.39.0.dist-info}/METADATA +1 -1
- {classiq-0.38.0.dist-info → classiq-0.39.0.dist-info}/RECORD +107 -124
- classiq/applications/benchmarking/__init__.py +0 -9
- classiq/applications/benchmarking/mirror_benchmarking.py +0 -70
- classiq/applications/numpy_utils.py +0 -37
- classiq/applications_model_constructors/__init__.py +0 -25
- classiq/applications_model_constructors/combinatorial_helpers/multiple_comp_basis_sp.py +0 -34
- classiq/applications_model_constructors/libraries/qmci_library.py +0 -107
- classiq/builtin_functions/__init__.py +0 -43
- classiq/builtin_functions/amplitude_loading.py +0 -3
- classiq/builtin_functions/binary_ops.py +0 -1
- classiq/builtin_functions/exponentiation.py +0 -5
- classiq/builtin_functions/qpe.py +0 -4
- classiq/builtin_functions/qsvm.py +0 -7
- classiq/builtin_functions/range_types.py +0 -5
- classiq/builtin_functions/standard_gates.py +0 -1
- classiq/builtin_functions/state_preparation.py +0 -6
- classiq/builtin_functions/suzuki_trotter.py +0 -3
- classiq/interface/generator/functions/core_lib_declarations/quantum_functions/__init__.py +0 -18
- classiq/interface/generator/functions/core_lib_declarations/quantum_operators.py +0 -95
- classiq/model/__init__.py +0 -14
- classiq/model/composite_function_generator.py +0 -33
- classiq/model/function_handler.py +0 -462
- classiq/model/logic_flow.py +0 -149
- classiq/model/logic_flow_change_handler.py +0 -71
- classiq/model/model.py +0 -229
- classiq/quantum_functions/__init__.py +0 -17
- classiq/quantum_functions/annotation_parser.py +0 -205
- classiq/quantum_functions/decorators.py +0 -22
- classiq/quantum_functions/function_library.py +0 -181
- classiq/quantum_functions/function_parser.py +0 -74
- classiq/quantum_functions/quantum_function.py +0 -236
- /classiq/{applications_model_constructors → applications/chemistry}/chemistry_model_constructor.py +0 -0
- /classiq/{applications_model_constructors → applications}/combinatorial_helpers/__init__.py +0 -0
- /classiq/{applications_model_constructors → applications}/combinatorial_helpers/allowed_constraints.py +0 -0
- /classiq/{applications_model_constructors → applications}/combinatorial_helpers/arithmetic/__init__.py +0 -0
- /classiq/{applications_model_constructors → applications}/combinatorial_helpers/arithmetic/isolation.py +0 -0
- /classiq/{applications_model_constructors → applications}/combinatorial_helpers/pauli_helpers/__init__.py +0 -0
- /classiq/{applications_model_constructors → applications}/combinatorial_helpers/pauli_helpers/pauli_sparsing.py +0 -0
- /classiq/{applications_model_constructors → applications}/combinatorial_helpers/py.typed +0 -0
- /classiq/{applications_model_constructors/combinatorial_helpers/transformations → applications/combinatorial_helpers/solvers}/__init__.py +0 -0
- /classiq/{applications_model_constructors → applications}/combinatorial_helpers/sympy_utils.py +0 -0
- /classiq/{applications_model_constructors/libraries → applications/combinatorial_helpers/transformations}/__init__.py +0 -0
- /classiq/{applications_model_constructors → applications}/combinatorial_helpers/transformations/penalty.py +0 -0
- /classiq/{applications_model_constructors → applications}/combinatorial_helpers/transformations/sign_seperation.py +0 -0
- /classiq/{applications_model_constructors → applications/grover}/grover_model_constructor.py +0 -0
- /classiq/{interface/generator/functions/core_lib_declarations → applications/libraries}/__init__.py +0 -0
- /classiq/{applications_model_constructors → applications}/libraries/ampltitude_estimation_library.py +0 -0
- /classiq/{applications_model_constructors → applications/qsvm}/qsvm_model_constructor.py +0 -0
- /classiq/interface/generator/functions/{core_lib_declarations/quantum_functions → builtins/core_library}/atomic_quantum_functions.py +0 -0
- /classiq/interface/generator/functions/{core_lib_declarations/quantum_functions → builtins/core_library}/chemistry_functions.py +0 -0
- /classiq/interface/generator/functions/{core_lib_declarations/quantum_functions → builtins/core_library}/exponentiation_functions.py +0 -0
- /classiq/{quantum_register.py → interface/model/quantum_register.py} +0 -0
- {classiq-0.38.0.dist-info → classiq-0.39.0.dist-info}/WHEEL +0 -0
@@ -6,6 +6,7 @@ from classiq.interface.model.quantum_function_declaration import (
|
|
6
6
|
|
7
7
|
QFT_STEP = QuantumFunctionDeclaration.parse_raw(
|
8
8
|
"""{
|
9
|
+
"source_ref": null,
|
9
10
|
"name": "qft_step",
|
10
11
|
"param_decls": {},
|
11
12
|
"port_declarations": {
|
@@ -21,6 +22,7 @@ QFT_STEP = QuantumFunctionDeclaration.parse_raw(
|
|
21
22
|
|
22
23
|
QFT = QuantumFunctionDeclaration.parse_raw(
|
23
24
|
"""{
|
25
|
+
"source_ref": null,
|
24
26
|
"name": "qft",
|
25
27
|
"param_decls": {},
|
26
28
|
"port_declarations": {
|
@@ -36,6 +38,7 @@ QFT = QuantumFunctionDeclaration.parse_raw(
|
|
36
38
|
|
37
39
|
QPE_FLEXIBLE = QuantumFunctionDeclaration.parse_raw(
|
38
40
|
"""{
|
41
|
+
"source_ref": null,
|
39
42
|
"name": "qpe_flexible",
|
40
43
|
"param_decls": {},
|
41
44
|
"port_declarations": {
|
@@ -87,6 +90,7 @@ QPE_FLEXIBLE = QuantumFunctionDeclaration.parse_raw(
|
|
87
90
|
|
88
91
|
QPE = QuantumFunctionDeclaration.parse_raw(
|
89
92
|
"""{
|
93
|
+
"source_ref": null,
|
90
94
|
"name": "qpe",
|
91
95
|
"param_decls": {},
|
92
96
|
"port_declarations": {
|
@@ -122,34 +126,9 @@ QPE = QuantumFunctionDeclaration.parse_raw(
|
|
122
126
|
}"""
|
123
127
|
)
|
124
128
|
|
125
|
-
STANDARD_QPE = QuantumFunctionDeclaration.parse_raw(
|
126
|
-
"""{
|
127
|
-
"name": "standard_qpe",
|
128
|
-
"param_decls": {
|
129
|
-
"precision": {
|
130
|
-
"kind": "int"
|
131
|
-
}
|
132
|
-
},
|
133
|
-
"port_declarations": {
|
134
|
-
"phase": {
|
135
|
-
"name": "phase",
|
136
|
-
"size": {
|
137
|
-
"expr": "precision"
|
138
|
-
},
|
139
|
-
"direction": "inout"
|
140
|
-
}
|
141
|
-
},
|
142
|
-
"operand_declarations": {
|
143
|
-
"unitary": {
|
144
|
-
"name": "unitary"
|
145
|
-
}
|
146
|
-
},
|
147
|
-
"positional_arg_declarations": []
|
148
|
-
}"""
|
149
|
-
)
|
150
|
-
|
151
129
|
SINGLE_PAULI = QuantumFunctionDeclaration.parse_raw(
|
152
130
|
"""{
|
131
|
+
"source_ref": null,
|
153
132
|
"name": "single_pauli",
|
154
133
|
"param_decls": {
|
155
134
|
"slope": {
|
@@ -197,6 +176,7 @@ SINGLE_PAULI = QuantumFunctionDeclaration.parse_raw(
|
|
197
176
|
|
198
177
|
LINEAR_PAULI_ROTATIONS = QuantumFunctionDeclaration.parse_raw(
|
199
178
|
"""{
|
179
|
+
"source_ref": null,
|
200
180
|
"name": "linear_pauli_rotations",
|
201
181
|
"param_decls": {
|
202
182
|
"bases": {
|
@@ -235,85 +215,107 @@ LINEAR_PAULI_ROTATIONS = QuantumFunctionDeclaration.parse_raw(
|
|
235
215
|
|
236
216
|
AMPLITUDE_ESTIMATION = QuantumFunctionDeclaration.parse_raw(
|
237
217
|
"""{
|
218
|
+
"source_ref": null,
|
238
219
|
"name": "amplitude_estimation",
|
239
|
-
"param_decls": {
|
240
|
-
"num_phase_qubits": {
|
241
|
-
"kind": "int"
|
242
|
-
},
|
243
|
-
"num_unitary_qubits": {
|
244
|
-
"kind": "int"
|
245
|
-
}
|
246
|
-
},
|
220
|
+
"param_decls": {},
|
247
221
|
"port_declarations": {
|
248
|
-
"
|
249
|
-
"name": "
|
222
|
+
"phase": {
|
223
|
+
"name": "phase",
|
250
224
|
"quantum_type": {
|
251
|
-
"kind": "qnum"
|
252
|
-
"size": {
|
253
|
-
"expr": "num_phase_qubits"
|
254
|
-
},
|
255
|
-
"is_signed": {
|
256
|
-
"expr": "False"
|
257
|
-
},
|
258
|
-
"fraction_digits": {
|
259
|
-
"expr": "num_phase_qubits"
|
260
|
-
}
|
261
|
-
},
|
262
|
-
"size": {
|
263
|
-
"expr": "num_phase_qubits"
|
225
|
+
"kind": "qnum"
|
264
226
|
},
|
265
|
-
"direction": "
|
227
|
+
"direction": "inout"
|
266
228
|
},
|
267
|
-
"
|
268
|
-
"name": "
|
269
|
-
"
|
270
|
-
"
|
229
|
+
"packed_vars": {
|
230
|
+
"name": "packed_vars",
|
231
|
+
"quantum_type": {
|
232
|
+
"length": null,
|
233
|
+
"kind": "qvec"
|
271
234
|
},
|
272
|
-
"direction": "
|
235
|
+
"direction": "inout"
|
273
236
|
}
|
274
237
|
},
|
275
238
|
"operand_declarations": {
|
276
|
-
"
|
277
|
-
"name": "
|
278
|
-
"
|
279
|
-
|
280
|
-
"
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
"spq": {
|
285
|
-
"name": "spq",
|
286
|
-
"size": {
|
287
|
-
"expr": "num_unitary_qubits"
|
239
|
+
"oracle": {
|
240
|
+
"name": "oracle",
|
241
|
+
"positional_arg_declarations": [
|
242
|
+
{
|
243
|
+
"name": "arg0",
|
244
|
+
"quantum_type": {
|
245
|
+
"length": null,
|
246
|
+
"kind": "qvec"
|
288
247
|
},
|
289
248
|
"direction": "inout"
|
290
249
|
}
|
291
|
-
|
250
|
+
],
|
251
|
+
"is_list": false
|
292
252
|
},
|
293
|
-
"
|
294
|
-
"name": "
|
295
|
-
"
|
296
|
-
|
297
|
-
"
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
"oq": {
|
302
|
-
"name": "oq",
|
303
|
-
"size": {
|
304
|
-
"expr": "num_unitary_qubits"
|
253
|
+
"space_transform": {
|
254
|
+
"name": "space_transform",
|
255
|
+
"positional_arg_declarations": [
|
256
|
+
{
|
257
|
+
"name": "arg0",
|
258
|
+
"quantum_type": {
|
259
|
+
"length": null,
|
260
|
+
"kind": "qvec"
|
305
261
|
},
|
306
262
|
"direction": "inout"
|
307
263
|
}
|
308
|
-
|
264
|
+
],
|
265
|
+
"is_list": false
|
309
266
|
}
|
310
267
|
},
|
311
|
-
"positional_arg_declarations": [
|
268
|
+
"positional_arg_declarations": [
|
269
|
+
{
|
270
|
+
"name": "oracle",
|
271
|
+
"positional_arg_declarations": [
|
272
|
+
{
|
273
|
+
"name": "arg0",
|
274
|
+
"quantum_type": {
|
275
|
+
"length": null,
|
276
|
+
"kind": "qvec"
|
277
|
+
},
|
278
|
+
"direction": "inout"
|
279
|
+
}
|
280
|
+
],
|
281
|
+
"is_list": false
|
282
|
+
},
|
283
|
+
{
|
284
|
+
"name": "space_transform",
|
285
|
+
"positional_arg_declarations": [
|
286
|
+
{
|
287
|
+
"name": "arg0",
|
288
|
+
"quantum_type": {
|
289
|
+
"length": null,
|
290
|
+
"kind": "qvec"
|
291
|
+
},
|
292
|
+
"direction": "inout"
|
293
|
+
}
|
294
|
+
],
|
295
|
+
"is_list": false
|
296
|
+
},
|
297
|
+
{
|
298
|
+
"name": "phase",
|
299
|
+
"quantum_type": {
|
300
|
+
"kind": "qnum"
|
301
|
+
},
|
302
|
+
"direction": "inout"
|
303
|
+
},
|
304
|
+
{
|
305
|
+
"name": "packed_vars",
|
306
|
+
"quantum_type": {
|
307
|
+
"length": null,
|
308
|
+
"kind": "qvec"
|
309
|
+
},
|
310
|
+
"direction": "inout"
|
311
|
+
}
|
312
|
+
]
|
312
313
|
}"""
|
313
314
|
)
|
314
315
|
|
315
316
|
PHASE_ORACLE = QuantumFunctionDeclaration.parse_raw(
|
316
317
|
"""{
|
318
|
+
"source_ref": null,
|
317
319
|
"name": "phase_oracle",
|
318
320
|
"param_decls": {},
|
319
321
|
"port_declarations": {
|
@@ -385,6 +387,7 @@ PHASE_ORACLE = QuantumFunctionDeclaration.parse_raw(
|
|
385
387
|
|
386
388
|
REFLECT_ABOUT_ZERO = QuantumFunctionDeclaration.parse_raw(
|
387
389
|
"""{
|
390
|
+
"source_ref": null,
|
388
391
|
"name": "reflect_about_zero",
|
389
392
|
"param_decls": {},
|
390
393
|
"port_declarations": {
|
@@ -413,6 +416,7 @@ REFLECT_ABOUT_ZERO = QuantumFunctionDeclaration.parse_raw(
|
|
413
416
|
|
414
417
|
GROVER_DIFFUSER = QuantumFunctionDeclaration.parse_raw(
|
415
418
|
"""{
|
419
|
+
"source_ref": null,
|
416
420
|
"name": "grover_diffuser",
|
417
421
|
"param_decls": {},
|
418
422
|
"port_declarations": {
|
@@ -470,6 +474,7 @@ GROVER_DIFFUSER = QuantumFunctionDeclaration.parse_raw(
|
|
470
474
|
|
471
475
|
GROVER_OPERATOR = QuantumFunctionDeclaration.parse_raw(
|
472
476
|
"""{
|
477
|
+
"source_ref": null,
|
473
478
|
"name": "grover_operator",
|
474
479
|
"param_decls": {},
|
475
480
|
"port_declarations": {
|
@@ -555,6 +560,7 @@ GROVER_OPERATOR = QuantumFunctionDeclaration.parse_raw(
|
|
555
560
|
|
556
561
|
GROVER_SEARCH = QuantumFunctionDeclaration.parse_raw(
|
557
562
|
"""{
|
563
|
+
"source_ref": null,
|
558
564
|
"name": "grover_search",
|
559
565
|
"param_decls": {
|
560
566
|
"reps": {
|
@@ -622,6 +628,7 @@ GROVER_SEARCH = QuantumFunctionDeclaration.parse_raw(
|
|
622
628
|
|
623
629
|
HADAMARD_TRANSFORM = QuantumFunctionDeclaration.parse_raw(
|
624
630
|
"""{
|
631
|
+
"source_ref": null,
|
625
632
|
"name": "hadamard_transform",
|
626
633
|
"param_decls": {},
|
627
634
|
"port_declarations": {
|
@@ -637,6 +644,7 @@ HADAMARD_TRANSFORM = QuantumFunctionDeclaration.parse_raw(
|
|
637
644
|
|
638
645
|
APPLY_TO_ALL = QuantumFunctionDeclaration.parse_raw(
|
639
646
|
"""{
|
647
|
+
"source_ref": null,
|
640
648
|
"name": "apply_to_all",
|
641
649
|
"param_decls": {},
|
642
650
|
"port_declarations": {
|
@@ -665,6 +673,7 @@ APPLY_TO_ALL = QuantumFunctionDeclaration.parse_raw(
|
|
665
673
|
|
666
674
|
ALLOCATE_NUM = QuantumFunctionDeclaration.parse_raw(
|
667
675
|
"""{
|
676
|
+
"source_ref": null,
|
668
677
|
"name": "allocate_num",
|
669
678
|
"param_decls": {
|
670
679
|
"num_qubits": {
|
@@ -702,6 +711,7 @@ ALLOCATE_NUM = QuantumFunctionDeclaration.parse_raw(
|
|
702
711
|
|
703
712
|
QAOA_MIXER_LAYER = QuantumFunctionDeclaration.parse_raw(
|
704
713
|
"""{
|
714
|
+
"source_ref": null,
|
705
715
|
"name": "qaoa_mixer_layer",
|
706
716
|
"param_decls": {
|
707
717
|
"b": {
|
@@ -721,6 +731,7 @@ QAOA_MIXER_LAYER = QuantumFunctionDeclaration.parse_raw(
|
|
721
731
|
|
722
732
|
QAOA_COST_LAYER = QuantumFunctionDeclaration.parse_raw(
|
723
733
|
"""{
|
734
|
+
"source_ref": null,
|
724
735
|
"name": "qaoa_cost_layer",
|
725
736
|
"param_decls": {
|
726
737
|
"g": {
|
@@ -747,6 +758,7 @@ QAOA_COST_LAYER = QuantumFunctionDeclaration.parse_raw(
|
|
747
758
|
|
748
759
|
QAOA_LAYER = QuantumFunctionDeclaration.parse_raw(
|
749
760
|
"""{
|
761
|
+
"source_ref": null,
|
750
762
|
"name": "qaoa_layer",
|
751
763
|
"param_decls": {
|
752
764
|
"g": {
|
@@ -776,6 +788,7 @@ QAOA_LAYER = QuantumFunctionDeclaration.parse_raw(
|
|
776
788
|
|
777
789
|
QAOA_INIT = QuantumFunctionDeclaration.parse_raw(
|
778
790
|
"""{
|
791
|
+
"source_ref": null,
|
779
792
|
"name": "qaoa_init",
|
780
793
|
"param_decls": {},
|
781
794
|
"port_declarations": {
|
@@ -791,6 +804,7 @@ QAOA_INIT = QuantumFunctionDeclaration.parse_raw(
|
|
791
804
|
|
792
805
|
QAOA_PENALTY = QuantumFunctionDeclaration.parse_raw(
|
793
806
|
"""{
|
807
|
+
"source_ref": null,
|
794
808
|
"name": "qaoa_penalty",
|
795
809
|
"param_decls": {
|
796
810
|
"num_qubits": {
|
@@ -826,6 +840,7 @@ QAOA_PENALTY = QuantumFunctionDeclaration.parse_raw(
|
|
826
840
|
|
827
841
|
FULL_HEA = QuantumFunctionDeclaration.parse_raw(
|
828
842
|
"""{
|
843
|
+
"source_ref": null,
|
829
844
|
"name": "full_hea",
|
830
845
|
"param_decls": {
|
831
846
|
"num_qubits": {
|
@@ -916,6 +931,7 @@ FULL_HEA = QuantumFunctionDeclaration.parse_raw(
|
|
916
931
|
|
917
932
|
SWAP_TEST = QuantumFunctionDeclaration.parse_raw(
|
918
933
|
"""{
|
934
|
+
"source_ref": null,
|
919
935
|
"name": "swap_test",
|
920
936
|
"param_decls": {},
|
921
937
|
"port_declarations": {
|
@@ -974,6 +990,7 @@ SWAP_TEST = QuantumFunctionDeclaration.parse_raw(
|
|
974
990
|
|
975
991
|
PREPARE_GHZ_STATE = QuantumFunctionDeclaration.parse_raw(
|
976
992
|
"""{
|
993
|
+
"source_ref": null,
|
977
994
|
"name": "prepare_ghz_state",
|
978
995
|
"param_decls": {
|
979
996
|
"size": {
|
@@ -1012,6 +1029,7 @@ PREPARE_GHZ_STATE = QuantumFunctionDeclaration.parse_raw(
|
|
1012
1029
|
|
1013
1030
|
PREPARE_EXPONENTIAL_STATE = QuantumFunctionDeclaration.parse_raw(
|
1014
1031
|
"""{
|
1032
|
+
"source_ref": null,
|
1015
1033
|
"name": "prepare_exponential_state",
|
1016
1034
|
"param_decls": {
|
1017
1035
|
"rate": {
|
@@ -1050,6 +1068,7 @@ PREPARE_EXPONENTIAL_STATE = QuantumFunctionDeclaration.parse_raw(
|
|
1050
1068
|
|
1051
1069
|
PREPARE_BELL_STATE = QuantumFunctionDeclaration.parse_raw(
|
1052
1070
|
"""{
|
1071
|
+
"source_ref": null,
|
1053
1072
|
"name": "prepare_bell_state",
|
1054
1073
|
"param_decls": {
|
1055
1074
|
"state_num": {
|
@@ -1092,6 +1111,7 @@ PREPARE_BELL_STATE = QuantumFunctionDeclaration.parse_raw(
|
|
1092
1111
|
|
1093
1112
|
INPLACE_PREPARE_INT = QuantumFunctionDeclaration.parse_raw(
|
1094
1113
|
"""{
|
1114
|
+
"source_ref": null,
|
1095
1115
|
"name": "inplace_prepare_int",
|
1096
1116
|
"param_decls": {
|
1097
1117
|
"value": {
|
@@ -1130,6 +1150,7 @@ INPLACE_PREPARE_INT = QuantumFunctionDeclaration.parse_raw(
|
|
1130
1150
|
|
1131
1151
|
PREPARE_INT = QuantumFunctionDeclaration.parse_raw(
|
1132
1152
|
"""{
|
1153
|
+
"source_ref": null,
|
1133
1154
|
"name": "prepare_int",
|
1134
1155
|
"param_decls": {
|
1135
1156
|
"value": {
|
@@ -1166,6 +1187,7 @@ PREPARE_INT = QuantumFunctionDeclaration.parse_raw(
|
|
1166
1187
|
|
1167
1188
|
SWITCH = QuantumFunctionDeclaration.parse_raw(
|
1168
1189
|
"""{
|
1190
|
+
"source_ref": null,
|
1169
1191
|
"name": "switch",
|
1170
1192
|
"param_decls": {
|
1171
1193
|
"selector": {
|
@@ -1196,12 +1218,15 @@ SWITCH = QuantumFunctionDeclaration.parse_raw(
|
|
1196
1218
|
}"""
|
1197
1219
|
)
|
1198
1220
|
|
1221
|
+
OPEN_LIB_DECLS = [
|
1222
|
+
func for func in vars().values() if isinstance(func, QuantumFunctionDeclaration)
|
1223
|
+
]
|
1224
|
+
|
1199
1225
|
__all__ = [
|
1200
1226
|
"QFT_STEP",
|
1201
1227
|
"QFT",
|
1202
1228
|
"QPE_FLEXIBLE",
|
1203
1229
|
"QPE",
|
1204
|
-
"STANDARD_QPE",
|
1205
1230
|
"SINGLE_PAULI",
|
1206
1231
|
"LINEAR_PAULI_ROTATIONS",
|
1207
1232
|
"AMPLITUDE_ESTIMATION",
|
@@ -1226,4 +1251,5 @@ __all__ = [
|
|
1226
1251
|
"INPLACE_PREPARE_INT",
|
1227
1252
|
"PREPARE_INT",
|
1228
1253
|
"SWITCH",
|
1254
|
+
"OPEN_LIB_DECLS",
|
1229
1255
|
]
|
@@ -0,0 +1,37 @@
|
|
1
|
+
from typing import Any
|
2
|
+
|
3
|
+
from classiq.interface.model.quantum_function_declaration import (
|
4
|
+
QuantumFunctionDeclaration,
|
5
|
+
QuantumOperandDeclaration,
|
6
|
+
)
|
7
|
+
|
8
|
+
|
9
|
+
def get_single_empty_operand_operator(
|
10
|
+
operator_name: str, **kwargs: Any
|
11
|
+
) -> QuantumFunctionDeclaration:
|
12
|
+
operand_field_name = "operand"
|
13
|
+
return QuantumFunctionDeclaration(
|
14
|
+
name=operator_name,
|
15
|
+
operand_declarations={
|
16
|
+
operand_field_name: QuantumOperandDeclaration(name=operand_field_name)
|
17
|
+
},
|
18
|
+
**kwargs,
|
19
|
+
)
|
20
|
+
|
21
|
+
|
22
|
+
PERMUTE_OPERATOR = QuantumFunctionDeclaration(
|
23
|
+
name="permute",
|
24
|
+
operand_declarations={
|
25
|
+
"functions": QuantumOperandDeclaration(
|
26
|
+
name="functions",
|
27
|
+
is_list=True,
|
28
|
+
)
|
29
|
+
},
|
30
|
+
)
|
31
|
+
|
32
|
+
APPLY_OPERATOR = get_single_empty_operand_operator(operator_name="apply")
|
33
|
+
|
34
|
+
STD_QMOD_OPERATORS = [
|
35
|
+
PERMUTE_OPERATOR,
|
36
|
+
APPLY_OPERATOR,
|
37
|
+
]
|
@@ -6,20 +6,18 @@ from pydantic import Extra, Field
|
|
6
6
|
from sympy import IndexedBase, Symbol
|
7
7
|
from typing_extensions import Annotated
|
8
8
|
|
9
|
+
from classiq.interface.ast_node import HashableASTNode
|
9
10
|
from classiq.interface.generator.expressions.enums.ladder_operator import (
|
10
11
|
LadderOperator as LadderOperatorEnum,
|
11
12
|
)
|
12
13
|
from classiq.interface.generator.expressions.enums.pauli import Pauli as PauliEnum
|
13
14
|
from classiq.interface.generator.expressions.expression_types import RuntimeExpression
|
14
|
-
from classiq.interface.helpers.hashable_pydantic_base_model import (
|
15
|
-
HashablePydanticBaseModel,
|
16
|
-
)
|
17
15
|
from classiq.interface.helpers.pydantic_model_helpers import values_with_discriminator
|
18
16
|
|
19
17
|
NamedSymbol = Union[IndexedBase, Symbol]
|
20
18
|
|
21
19
|
|
22
|
-
class ClassicalType(
|
20
|
+
class ClassicalType(HashableASTNode):
|
23
21
|
def as_symbolic(self, name: str) -> Union[NamedSymbol, List[NamedSymbol]]:
|
24
22
|
return Symbol(name)
|
25
23
|
|
@@ -2,12 +2,12 @@ import abc
|
|
2
2
|
from typing import Dict
|
3
3
|
|
4
4
|
import pydantic
|
5
|
-
from pydantic.main import BaseModel
|
6
5
|
|
6
|
+
from classiq.interface.ast_node import ASTNode
|
7
7
|
from classiq.interface.generator.functions.classical_type import ConcreteClassicalType
|
8
8
|
|
9
9
|
|
10
|
-
class FunctionDeclaration(
|
10
|
+
class FunctionDeclaration(ASTNode, abc.ABC):
|
11
11
|
"""
|
12
12
|
Facilitates the creation of a common function interface object.
|
13
13
|
"""
|
@@ -1,6 +1,12 @@
|
|
1
|
+
from typing import Any, Union
|
2
|
+
|
1
3
|
import pydantic
|
2
4
|
|
3
|
-
from classiq.interface.chemistry.ground_state_problem import
|
5
|
+
from classiq.interface.chemistry.ground_state_problem import (
|
6
|
+
CHEMISTRY_PROBLEMS,
|
7
|
+
HamiltonianProblem,
|
8
|
+
MoleculeProblem,
|
9
|
+
)
|
4
10
|
from classiq.interface.generator.chemistry_function_params import (
|
5
11
|
ChemistryFunctionParams,
|
6
12
|
)
|
@@ -10,7 +16,9 @@ from classiq.exceptions import ClassiqValueError
|
|
10
16
|
|
11
17
|
class HartreeFock(ChemistryFunctionParams):
|
12
18
|
@pydantic.validator("gs_problem")
|
13
|
-
def validate_gs_problem(
|
19
|
+
def validate_gs_problem(
|
20
|
+
cls, gs_problem: Any
|
21
|
+
) -> Union[MoleculeProblem, HamiltonianProblem]:
|
14
22
|
if not isinstance(gs_problem, CHEMISTRY_PROBLEMS):
|
15
23
|
raise ClassiqValueError(
|
16
24
|
f"ground state problem must be of type {CHEMISTRY_PROBLEMS}"
|
@@ -26,10 +26,10 @@ from classiq.interface.generator.types.struct_declaration import StructDeclarati
|
|
26
26
|
from classiq.interface.helpers.pydantic_model_helpers import nameables_to_dict
|
27
27
|
from classiq.interface.helpers.validation_helpers import is_list_unique
|
28
28
|
from classiq.interface.helpers.versioned_model import VersionedModel
|
29
|
+
from classiq.interface.model.quantum_register import QReg, QRegGenericAlias
|
29
30
|
|
30
31
|
from classiq import ForeignFunctionDefinition as SynthesisForeignFunctionDefinition
|
31
32
|
from classiq.exceptions import ClassiqValueError
|
32
|
-
from classiq.quantum_register import QReg, QRegGenericAlias
|
33
33
|
|
34
34
|
MAIN_FUNCTION_NAME = "main"
|
35
35
|
CLASSICAL_ENTRY_FUNCTION_NAME = "cmain"
|
@@ -2,15 +2,13 @@ from typing import Any, ClassVar, Dict, Mapping
|
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
|
5
|
+
from classiq.interface.ast_node import HashableASTNode
|
5
6
|
from classiq.interface.generator.functions.classical_type import ConcreteClassicalType
|
6
|
-
from classiq.interface.helpers.hashable_pydantic_base_model import (
|
7
|
-
HashablePydanticBaseModel,
|
8
|
-
)
|
9
7
|
|
10
8
|
from classiq.exceptions import ClassiqValueError
|
11
9
|
|
12
10
|
|
13
|
-
class StructDeclaration(
|
11
|
+
class StructDeclaration(HashableASTNode):
|
14
12
|
name: str
|
15
13
|
|
16
14
|
variables: Dict[str, ConcreteClassicalType] = pydantic.Field(
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import dataclasses
|
2
|
-
from typing import Any, List, Mapping
|
2
|
+
from typing import Any, Iterator, List, Mapping
|
3
3
|
|
4
4
|
from sympy import sympify
|
5
5
|
|
@@ -61,8 +61,8 @@ class CallSynthesisData(Mapping):
|
|
61
61
|
def __getitem__(self, key: str) -> Any:
|
62
62
|
return dataclasses.asdict(self)[key]
|
63
63
|
|
64
|
-
def __iter__(self):
|
64
|
+
def __iter__(self) -> Iterator[str]:
|
65
65
|
return iter(dataclasses.asdict(self))
|
66
66
|
|
67
|
-
def __len__(self):
|
67
|
+
def __len__(self) -> int:
|
68
68
|
return len(dataclasses.asdict(self))
|
@@ -0,0 +1,13 @@
|
|
1
|
+
from typing import TYPE_CHECKING
|
2
|
+
|
3
|
+
from classiq.interface.generator.expressions.expression import Expression
|
4
|
+
from classiq.interface.model.quantum_statement import QuantumOperation
|
5
|
+
|
6
|
+
if TYPE_CHECKING:
|
7
|
+
from classiq.interface.model.statement_block import StatementBlock
|
8
|
+
|
9
|
+
|
10
|
+
class ClassicalIf(QuantumOperation):
|
11
|
+
condition: Expression
|
12
|
+
then: "StatementBlock"
|
13
|
+
else_: "StatementBlock"
|
@@ -1,8 +1,7 @@
|
|
1
|
-
import
|
2
|
-
|
1
|
+
from classiq.interface.ast_node import ASTNode
|
3
2
|
from classiq.interface.generator.functions.classical_type import ConcreteClassicalType
|
4
3
|
|
5
4
|
|
6
|
-
class ClassicalParameterDeclaration(
|
5
|
+
class ClassicalParameterDeclaration(ASTNode):
|
7
6
|
name: str
|
8
7
|
classical_type: ConcreteClassicalType
|
@@ -0,0 +1,16 @@
|
|
1
|
+
from typing import TYPE_CHECKING, Union
|
2
|
+
|
3
|
+
from classiq.interface.model.handle_binding import (
|
4
|
+
HandleBinding,
|
5
|
+
SlicedHandleBinding,
|
6
|
+
SubscriptHandleBinding,
|
7
|
+
)
|
8
|
+
from classiq.interface.model.quantum_statement import QuantumOperation
|
9
|
+
|
10
|
+
if TYPE_CHECKING:
|
11
|
+
from classiq.interface.model.statement_block import StatementBlock
|
12
|
+
|
13
|
+
|
14
|
+
class Control(QuantumOperation):
|
15
|
+
control: Union[SlicedHandleBinding, SubscriptHandleBinding, HandleBinding]
|
16
|
+
body: "StatementBlock"
|
@@ -1,9 +1,10 @@
|
|
1
|
-
from pydantic import
|
1
|
+
from pydantic import Extra
|
2
2
|
|
3
|
+
from classiq.interface.ast_node import ASTNode
|
3
4
|
from classiq.interface.generator.expressions.expression import Expression
|
4
5
|
|
5
6
|
|
6
|
-
class HandleBinding(
|
7
|
+
class HandleBinding(ASTNode):
|
7
8
|
name: str
|
8
9
|
|
9
10
|
class Config:
|
@@ -0,0 +1,10 @@
|
|
1
|
+
from typing import TYPE_CHECKING
|
2
|
+
|
3
|
+
from classiq.interface.model.quantum_statement import QuantumOperation
|
4
|
+
|
5
|
+
if TYPE_CHECKING:
|
6
|
+
from classiq.interface.model.statement_block import StatementBlock
|
7
|
+
|
8
|
+
|
9
|
+
class Invert(QuantumOperation):
|
10
|
+
body: "StatementBlock"
|
classiq/interface/model/model.py
CHANGED
@@ -3,6 +3,7 @@ from typing import Any, Dict, List, Literal, NewType, Optional, Set
|
|
3
3
|
|
4
4
|
import pydantic
|
5
5
|
|
6
|
+
from classiq.interface.ast_node import ASTNode
|
6
7
|
from classiq.interface.executor.execution_preferences import ExecutionPreferences
|
7
8
|
from classiq.interface.generator.constant import Constant
|
8
9
|
from classiq.interface.generator.functions.port_declaration import (
|
@@ -51,7 +52,7 @@ class VersionedSerializedModel(VersionedModel):
|
|
51
52
|
model: SerializedModel
|
52
53
|
|
53
54
|
|
54
|
-
class Model(VersionedModel):
|
55
|
+
class Model(VersionedModel, ASTNode):
|
55
56
|
"""
|
56
57
|
All the relevant data for generating quantum circuit in one place.
|
57
58
|
"""
|
@@ -0,0 +1,12 @@
|
|
1
|
+
from typing import TYPE_CHECKING
|
2
|
+
|
3
|
+
from classiq.interface.generator.expressions.expression import Expression
|
4
|
+
from classiq.interface.model.quantum_statement import QuantumOperation
|
5
|
+
|
6
|
+
if TYPE_CHECKING:
|
7
|
+
from classiq.interface.model.statement_block import StatementBlock
|
8
|
+
|
9
|
+
|
10
|
+
class Power(QuantumOperation):
|
11
|
+
power: Expression
|
12
|
+
body: "StatementBlock"
|