classiq 0.37.1__py3-none-any.whl → 0.38.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 (228) hide show
  1. classiq/__init__.py +2 -2
  2. classiq/_analyzer_extras/_ipywidgets_async_extension.py +1 -1
  3. classiq/_analyzer_extras/interactive_hardware.py +3 -3
  4. classiq/_internals/api_wrapper.py +24 -16
  5. classiq/_internals/async_utils.py +1 -74
  6. classiq/_internals/authentication/device.py +9 -4
  7. classiq/_internals/authentication/password_manager.py +25 -10
  8. classiq/_internals/authentication/token_manager.py +2 -2
  9. classiq/_internals/client.py +13 -5
  10. classiq/_internals/jobs.py +10 -7
  11. classiq/analyzer/analyzer.py +26 -28
  12. classiq/analyzer/analyzer_utilities.py +5 -5
  13. classiq/analyzer/rb.py +4 -5
  14. classiq/analyzer/show_interactive_hack.py +6 -6
  15. classiq/applications/benchmarking/mirror_benchmarking.py +9 -6
  16. classiq/applications/combinatorial_optimization/__init__.py +5 -0
  17. classiq/applications/qnn/circuit_utils.py +2 -2
  18. classiq/applications/qnn/gradients/quantum_gradient.py +2 -2
  19. classiq/applications/qnn/types.py +2 -2
  20. classiq/applications/qsvm/qsvm.py +4 -7
  21. classiq/applications/qsvm/qsvm_data_generation.py +2 -5
  22. classiq/applications_model_constructors/__init__.py +9 -1
  23. classiq/applications_model_constructors/chemistry_model_constructor.py +9 -16
  24. classiq/applications_model_constructors/combinatorial_helpers/__init__.py +0 -0
  25. classiq/applications_model_constructors/combinatorial_helpers/allowed_constraints.py +20 -0
  26. classiq/applications_model_constructors/combinatorial_helpers/arithmetic/__init__.py +0 -0
  27. classiq/applications_model_constructors/combinatorial_helpers/arithmetic/arithmetic_expression.py +35 -0
  28. classiq/applications_model_constructors/combinatorial_helpers/arithmetic/isolation.py +42 -0
  29. classiq/applications_model_constructors/combinatorial_helpers/combinatorial_problem_utils.py +130 -0
  30. classiq/applications_model_constructors/combinatorial_helpers/encoding_mapping.py +107 -0
  31. classiq/applications_model_constructors/combinatorial_helpers/encoding_utils.py +122 -0
  32. classiq/applications_model_constructors/combinatorial_helpers/memory.py +79 -0
  33. classiq/applications_model_constructors/combinatorial_helpers/multiple_comp_basis_sp.py +34 -0
  34. classiq/applications_model_constructors/combinatorial_helpers/optimization_model.py +166 -0
  35. classiq/applications_model_constructors/combinatorial_helpers/pauli_helpers/__init__.py +0 -0
  36. classiq/applications_model_constructors/combinatorial_helpers/pauli_helpers/pauli_sparsing.py +31 -0
  37. classiq/applications_model_constructors/combinatorial_helpers/pauli_helpers/pauli_utils.py +65 -0
  38. classiq/applications_model_constructors/combinatorial_helpers/py.typed +0 -0
  39. classiq/applications_model_constructors/combinatorial_helpers/pyomo_utils.py +243 -0
  40. classiq/applications_model_constructors/combinatorial_helpers/sympy_utils.py +22 -0
  41. classiq/applications_model_constructors/combinatorial_helpers/transformations/__init__.py +0 -0
  42. classiq/applications_model_constructors/combinatorial_helpers/transformations/encoding.py +194 -0
  43. classiq/applications_model_constructors/combinatorial_helpers/transformations/fixed_variables.py +144 -0
  44. classiq/applications_model_constructors/combinatorial_helpers/transformations/ising_converter.py +124 -0
  45. classiq/applications_model_constructors/combinatorial_helpers/transformations/penalty.py +32 -0
  46. classiq/applications_model_constructors/combinatorial_helpers/transformations/penalty_support.py +41 -0
  47. classiq/applications_model_constructors/combinatorial_helpers/transformations/sign_seperation.py +75 -0
  48. classiq/applications_model_constructors/combinatorial_helpers/transformations/slack_variables.py +90 -0
  49. classiq/applications_model_constructors/combinatorial_optimization_model_constructor.py +48 -91
  50. classiq/applications_model_constructors/finance_model_constructor.py +4 -17
  51. classiq/applications_model_constructors/grover_model_constructor.py +20 -91
  52. classiq/applications_model_constructors/libraries/qmci_library.py +17 -19
  53. classiq/builtin_functions/standard_gates.py +1 -1
  54. classiq/exceptions.py +43 -1
  55. classiq/executor.py +10 -9
  56. classiq/interface/_version.py +1 -1
  57. classiq/interface/analyzer/analysis_params.py +6 -3
  58. classiq/interface/analyzer/result.py +12 -4
  59. classiq/interface/applications/qsvm.py +13 -1
  60. classiq/interface/backend/backend_preferences.py +4 -2
  61. classiq/interface/backend/pydantic_backend.py +3 -1
  62. classiq/interface/backend/quantum_backend_providers.py +1 -0
  63. classiq/interface/chemistry/fermionic_operator.py +15 -13
  64. classiq/interface/chemistry/ground_state_problem.py +18 -3
  65. classiq/interface/chemistry/molecule.py +8 -6
  66. classiq/interface/chemistry/operator.py +20 -14
  67. classiq/interface/combinatorial_optimization/examples/ascending_sequence.py +1 -1
  68. classiq/interface/combinatorial_optimization/examples/greater_than_ilp.py +1 -1
  69. classiq/interface/combinatorial_optimization/examples/ilp.py +2 -1
  70. classiq/interface/combinatorial_optimization/examples/integer_portfolio_optimization.py +2 -2
  71. classiq/interface/combinatorial_optimization/examples/mds.py +2 -1
  72. classiq/interface/combinatorial_optimization/examples/mht.py +3 -3
  73. classiq/interface/combinatorial_optimization/examples/mis.py +4 -1
  74. classiq/interface/combinatorial_optimization/examples/mvc.py +2 -1
  75. classiq/interface/combinatorial_optimization/examples/set_cover.py +2 -1
  76. classiq/interface/combinatorial_optimization/examples/tsp.py +4 -3
  77. classiq/interface/combinatorial_optimization/examples/tsp_digraph.py +6 -2
  78. classiq/interface/combinatorial_optimization/mht_qaoa_input.py +9 -3
  79. classiq/interface/executor/aws_execution_cost.py +4 -3
  80. classiq/interface/executor/estimation.py +2 -2
  81. classiq/interface/executor/execution_preferences.py +5 -34
  82. classiq/interface/executor/execution_request.py +19 -17
  83. classiq/interface/executor/optimizer_preferences.py +22 -13
  84. classiq/interface/executor/{quantum_program.py → quantum_code.py} +21 -15
  85. classiq/interface/executor/quantum_instruction_set.py +2 -1
  86. classiq/interface/executor/register_initialization.py +1 -3
  87. classiq/interface/executor/result.py +41 -10
  88. classiq/interface/executor/vqe_result.py +1 -1
  89. classiq/interface/finance/function_input.py +17 -4
  90. classiq/interface/finance/gaussian_model_input.py +3 -1
  91. classiq/interface/finance/log_normal_model_input.py +3 -1
  92. classiq/interface/finance/model_input.py +2 -0
  93. classiq/interface/generator/amplitude_loading.py +6 -3
  94. classiq/interface/generator/application_apis/__init__.py +1 -0
  95. classiq/interface/generator/application_apis/arithmetic_declarations.py +14 -0
  96. classiq/interface/generator/arith/argument_utils.py +14 -4
  97. classiq/interface/generator/arith/arithmetic.py +3 -1
  98. classiq/interface/generator/arith/arithmetic_arg_type_validator.py +12 -13
  99. classiq/interface/generator/arith/arithmetic_expression_abc.py +4 -1
  100. classiq/interface/generator/arith/arithmetic_expression_parser.py +8 -2
  101. classiq/interface/generator/arith/arithmetic_expression_validator.py +16 -2
  102. classiq/interface/generator/arith/arithmetic_operations.py +5 -10
  103. classiq/interface/generator/arith/ast_node_rewrite.py +1 -1
  104. classiq/interface/generator/arith/binary_ops.py +202 -54
  105. classiq/interface/generator/arith/extremum_operations.py +5 -3
  106. classiq/interface/generator/arith/logical_ops.py +4 -2
  107. classiq/interface/generator/arith/machine_precision.py +3 -0
  108. classiq/interface/generator/arith/number_utils.py +34 -44
  109. classiq/interface/generator/arith/register_user_input.py +21 -1
  110. classiq/interface/generator/arith/unary_ops.py +16 -25
  111. classiq/interface/generator/chemistry_function_params.py +4 -4
  112. classiq/interface/generator/commuting_pauli_exponentiation.py +3 -1
  113. classiq/interface/generator/compiler_keywords.py +4 -0
  114. classiq/interface/generator/complex_type.py +3 -10
  115. classiq/interface/generator/control_state.py +5 -3
  116. classiq/interface/generator/credit_risk_example/linear_gci.py +10 -3
  117. classiq/interface/generator/credit_risk_example/weighted_adder.py +14 -4
  118. classiq/interface/generator/expressions/atomic_expression_functions.py +5 -3
  119. classiq/interface/generator/expressions/evaluated_expression.py +18 -4
  120. classiq/interface/generator/expressions/expression.py +1 -1
  121. classiq/interface/generator/expressions/qmod_qscalar_proxy.py +33 -0
  122. classiq/interface/generator/expressions/sympy_supported_expressions.py +2 -1
  123. classiq/interface/generator/finance.py +1 -1
  124. classiq/interface/generator/function_params.py +7 -6
  125. classiq/interface/generator/functions/__init__.py +1 -1
  126. classiq/interface/generator/functions/core_lib_declarations/quantum_functions/std_lib_functions.py +505 -138
  127. classiq/interface/generator/functions/core_lib_declarations/quantum_operators.py +25 -99
  128. classiq/interface/generator/functions/foreign_function_definition.py +12 -4
  129. classiq/interface/generator/functions/function_implementation.py +8 -4
  130. classiq/interface/generator/functions/native_function_definition.py +4 -2
  131. classiq/interface/generator/functions/register.py +4 -2
  132. classiq/interface/generator/functions/register_mapping_data.py +14 -10
  133. classiq/interface/generator/generated_circuit_data.py +2 -2
  134. classiq/interface/generator/grover_operator.py +5 -3
  135. classiq/interface/generator/hamiltonian_evolution/suzuki_trotter.py +5 -1
  136. classiq/interface/generator/hardware/hardware_data.py +6 -4
  137. classiq/interface/generator/hardware_efficient_ansatz.py +25 -8
  138. classiq/interface/generator/hartree_fock.py +3 -1
  139. classiq/interface/generator/linear_pauli_rotations.py +3 -1
  140. classiq/interface/generator/mcu.py +5 -3
  141. classiq/interface/generator/mcx.py +7 -5
  142. classiq/interface/generator/model/constraints.py +2 -1
  143. classiq/interface/generator/model/model.py +11 -19
  144. classiq/interface/generator/model/preferences/preferences.py +4 -3
  145. classiq/interface/generator/oracles/custom_oracle.py +4 -2
  146. classiq/interface/generator/oracles/oracle_abc.py +2 -2
  147. classiq/interface/generator/qpe.py +6 -4
  148. classiq/interface/generator/qsvm.py +5 -8
  149. classiq/interface/generator/quantum_function_call.py +21 -16
  150. classiq/interface/generator/{generated_circuit.py → quantum_program.py} +10 -14
  151. classiq/interface/generator/range_types.py +3 -1
  152. classiq/interface/generator/slice_parsing_utils.py +8 -3
  153. classiq/interface/generator/standard_gates/controlled_standard_gates.py +4 -2
  154. classiq/interface/generator/state_preparation/metrics.py +2 -1
  155. classiq/interface/generator/state_preparation/state_preparation.py +7 -5
  156. classiq/interface/generator/state_propagator.py +16 -5
  157. classiq/interface/generator/types/builtin_struct_declarations/__init__.py +0 -1
  158. classiq/interface/generator/types/struct_declaration.py +8 -3
  159. classiq/interface/generator/ucc.py +6 -4
  160. classiq/interface/generator/unitary_gate.py +7 -3
  161. classiq/interface/generator/validations/flow_graph.py +6 -4
  162. classiq/interface/generator/validations/validator_functions.py +6 -4
  163. classiq/interface/hardware.py +2 -2
  164. classiq/interface/helpers/custom_encoders.py +3 -0
  165. classiq/interface/helpers/pydantic_model_helpers.py +0 -6
  166. classiq/interface/helpers/validation_helpers.py +1 -1
  167. classiq/interface/helpers/versioned_model.py +4 -1
  168. classiq/interface/ide/show.py +2 -2
  169. classiq/interface/jobs.py +72 -3
  170. classiq/interface/model/bind_operation.py +18 -11
  171. classiq/interface/model/call_synthesis_data.py +68 -0
  172. classiq/interface/model/inplace_binary_operation.py +2 -2
  173. classiq/interface/model/model.py +27 -21
  174. classiq/interface/model/native_function_definition.py +3 -5
  175. classiq/interface/model/quantum_expressions/amplitude_loading_operation.py +9 -4
  176. classiq/interface/model/quantum_expressions/control_state.py +2 -2
  177. classiq/interface/model/quantum_function_call.py +25 -139
  178. classiq/interface/model/quantum_function_declaration.py +8 -0
  179. classiq/interface/model/quantum_if_operation.py +2 -3
  180. classiq/interface/model/quantum_lambda_function.py +64 -0
  181. classiq/interface/model/quantum_type.py +57 -56
  182. classiq/interface/model/quantum_variable_declaration.py +1 -1
  183. classiq/interface/model/statement_block.py +32 -0
  184. classiq/interface/model/validations/handles_validator.py +14 -12
  185. classiq/interface/model/within_apply_operation.py +11 -0
  186. classiq/interface/pyomo_extension/pyomo_sympy_bimap.py +4 -1
  187. classiq/interface/server/routes.py +5 -0
  188. classiq/model/function_handler.py +5 -9
  189. classiq/model/model.py +2 -19
  190. classiq/qmod/__init__.py +13 -6
  191. classiq/qmod/builtins/classical_execution_primitives.py +27 -36
  192. classiq/qmod/builtins/classical_functions.py +24 -14
  193. classiq/qmod/builtins/functions.py +162 -145
  194. classiq/qmod/builtins/operations.py +24 -35
  195. classiq/qmod/builtins/structs.py +15 -15
  196. classiq/qmod/cfunc.py +42 -0
  197. classiq/qmod/classical_function.py +6 -14
  198. classiq/qmod/declaration_inferrer.py +12 -21
  199. classiq/qmod/expression_query.py +23 -0
  200. classiq/qmod/model_state_container.py +2 -0
  201. classiq/qmod/native/__init__.py +0 -0
  202. classiq/qmod/native/expression_to_qmod.py +189 -0
  203. classiq/qmod/native/pretty_printer.py +311 -0
  204. classiq/qmod/qfunc.py +27 -0
  205. classiq/qmod/qmod_constant.py +76 -0
  206. classiq/qmod/qmod_parameter.py +34 -12
  207. classiq/qmod/qmod_struct.py +3 -3
  208. classiq/qmod/qmod_variable.py +102 -18
  209. classiq/qmod/quantum_expandable.py +16 -16
  210. classiq/qmod/quantum_function.py +37 -8
  211. classiq/qmod/symbolic.py +47 -4
  212. classiq/qmod/symbolic_expr.py +9 -0
  213. classiq/qmod/utilities.py +13 -0
  214. classiq/qmod/write_qmod.py +39 -0
  215. classiq/quantum_functions/__init__.py +2 -2
  216. classiq/quantum_functions/annotation_parser.py +9 -11
  217. classiq/quantum_functions/function_parser.py +1 -1
  218. classiq/quantum_functions/quantum_function.py +3 -3
  219. classiq/quantum_register.py +17 -9
  220. {classiq-0.37.1.dist-info → classiq-0.38.0.dist-info}/METADATA +2 -1
  221. {classiq-0.37.1.dist-info → classiq-0.38.0.dist-info}/RECORD +222 -186
  222. {classiq-0.37.1.dist-info → classiq-0.38.0.dist-info}/WHEEL +1 -1
  223. classiq/interface/generator/expressions/qmod_qnum_proxy.py +0 -22
  224. classiq/interface/generator/types/builtin_struct_declarations/qaoa_declarations.py +0 -23
  225. classiq/interface/generator/types/combinatorial_problem.py +0 -26
  226. classiq/interface/model/numeric_reinterpretation.py +0 -25
  227. classiq/interface/model/operator_synthesis_data.py +0 -48
  228. classiq/model/function_handler.pyi +0 -152
@@ -42,7 +42,6 @@ QPE_FLEXIBLE = QuantumFunctionDeclaration.parse_raw(
42
42
  "phase": {
43
43
  "name": "phase",
44
44
  "quantum_type": {
45
- "size": null,
46
45
  "kind": "qnum"
47
46
  },
48
47
  "direction": "inout"
@@ -78,7 +77,6 @@ QPE_FLEXIBLE = QuantumFunctionDeclaration.parse_raw(
78
77
  {
79
78
  "name": "phase",
80
79
  "quantum_type": {
81
- "size": null,
82
80
  "kind": "qnum"
83
81
  },
84
82
  "direction": "inout"
@@ -95,7 +93,6 @@ QPE = QuantumFunctionDeclaration.parse_raw(
95
93
  "phase": {
96
94
  "name": "phase",
97
95
  "quantum_type": {
98
- "size": null,
99
96
  "kind": "qnum"
100
97
  },
101
98
  "direction": "inout"
@@ -117,7 +114,6 @@ QPE = QuantumFunctionDeclaration.parse_raw(
117
114
  {
118
115
  "name": "phase",
119
116
  "quantum_type": {
120
- "size": null,
121
117
  "kind": "qnum"
122
118
  },
123
119
  "direction": "inout"
@@ -251,6 +247,18 @@ AMPLITUDE_ESTIMATION = QuantumFunctionDeclaration.parse_raw(
251
247
  "port_declarations": {
252
248
  "phase_port": {
253
249
  "name": "phase_port",
250
+ "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
+ },
254
262
  "size": {
255
263
  "expr": "num_phase_qubits"
256
264
  },
@@ -304,117 +312,311 @@ AMPLITUDE_ESTIMATION = QuantumFunctionDeclaration.parse_raw(
304
312
  }"""
305
313
  )
306
314
 
307
- SIMPLE_ORACLE = QuantumFunctionDeclaration.parse_raw(
315
+ PHASE_ORACLE = QuantumFunctionDeclaration.parse_raw(
308
316
  """{
309
- "name": "simple_oracle",
317
+ "name": "phase_oracle",
310
318
  "param_decls": {},
311
319
  "port_declarations": {
312
320
  "target": {
313
321
  "name": "target",
322
+ "quantum_type": {
323
+ "length": null,
324
+ "kind": "qvec"
325
+ },
314
326
  "direction": "inout"
315
327
  }
316
328
  },
317
329
  "operand_declarations": {
318
330
  "predicate": {
319
331
  "name": "predicate",
320
- "port_declarations": {
321
- "vars": {
322
- "name": "vars",
323
- "size": {
324
- "expr": "len(target)"
332
+ "positional_arg_declarations": [
333
+ {
334
+ "name": "arg0",
335
+ "quantum_type": {
336
+ "length": null,
337
+ "kind": "qvec"
325
338
  },
326
339
  "direction": "inout"
327
340
  },
328
- "result": {
329
- "name": "result",
330
- "size": {
331
- "expr": "1"
341
+ {
342
+ "name": "arg1",
343
+ "quantum_type": {
344
+ "kind": "qbit"
332
345
  },
333
346
  "direction": "inout"
334
347
  }
335
- }
348
+ ],
349
+ "is_list": false
336
350
  }
337
351
  },
338
- "positional_arg_declarations": []
352
+ "positional_arg_declarations": [
353
+ {
354
+ "name": "predicate",
355
+ "positional_arg_declarations": [
356
+ {
357
+ "name": "arg0",
358
+ "quantum_type": {
359
+ "length": null,
360
+ "kind": "qvec"
361
+ },
362
+ "direction": "inout"
363
+ },
364
+ {
365
+ "name": "arg1",
366
+ "quantum_type": {
367
+ "kind": "qbit"
368
+ },
369
+ "direction": "inout"
370
+ }
371
+ ],
372
+ "is_list": false
373
+ },
374
+ {
375
+ "name": "target",
376
+ "quantum_type": {
377
+ "length": null,
378
+ "kind": "qvec"
379
+ },
380
+ "direction": "inout"
381
+ }
382
+ ]
339
383
  }"""
340
384
  )
341
385
 
342
- GROVER_DIFFUSER = QuantumFunctionDeclaration.parse_raw(
386
+ REFLECT_ABOUT_ZERO = QuantumFunctionDeclaration.parse_raw(
343
387
  """{
344
- "name": "grover_diffuser",
345
- "param_decls": {
346
- "num_qubits": {
347
- "kind": "int"
388
+ "name": "reflect_about_zero",
389
+ "param_decls": {},
390
+ "port_declarations": {
391
+ "packed_vars": {
392
+ "name": "packed_vars",
393
+ "quantum_type": {
394
+ "length": null,
395
+ "kind": "qvec"
396
+ },
397
+ "direction": "inout"
348
398
  }
349
399
  },
400
+ "operand_declarations": {},
401
+ "positional_arg_declarations": [
402
+ {
403
+ "name": "packed_vars",
404
+ "quantum_type": {
405
+ "length": null,
406
+ "kind": "qvec"
407
+ },
408
+ "direction": "inout"
409
+ }
410
+ ]
411
+ }"""
412
+ )
413
+
414
+ GROVER_DIFFUSER = QuantumFunctionDeclaration.parse_raw(
415
+ """{
416
+ "name": "grover_diffuser",
417
+ "param_decls": {},
350
418
  "port_declarations": {
351
- "p": {
352
- "name": "p",
353
- "size": {
354
- "expr": "num_qubits"
419
+ "packed_vars": {
420
+ "name": "packed_vars",
421
+ "quantum_type": {
422
+ "length": null,
423
+ "kind": "qvec"
355
424
  },
356
425
  "direction": "inout"
357
426
  }
358
427
  },
359
- "operand_declarations": {},
360
- "positional_arg_declarations": []
428
+ "operand_declarations": {
429
+ "space_transform": {
430
+ "name": "space_transform",
431
+ "positional_arg_declarations": [
432
+ {
433
+ "name": "arg0",
434
+ "quantum_type": {
435
+ "length": null,
436
+ "kind": "qvec"
437
+ },
438
+ "direction": "inout"
439
+ }
440
+ ],
441
+ "is_list": false
442
+ }
443
+ },
444
+ "positional_arg_declarations": [
445
+ {
446
+ "name": "space_transform",
447
+ "positional_arg_declarations": [
448
+ {
449
+ "name": "arg0",
450
+ "quantum_type": {
451
+ "length": null,
452
+ "kind": "qvec"
453
+ },
454
+ "direction": "inout"
455
+ }
456
+ ],
457
+ "is_list": false
458
+ },
459
+ {
460
+ "name": "packed_vars",
461
+ "quantum_type": {
462
+ "length": null,
463
+ "kind": "qvec"
464
+ },
465
+ "direction": "inout"
466
+ }
467
+ ]
361
468
  }"""
362
469
  )
363
470
 
364
471
  GROVER_OPERATOR = QuantumFunctionDeclaration.parse_raw(
365
472
  """{
366
473
  "name": "grover_operator",
474
+ "param_decls": {},
475
+ "port_declarations": {
476
+ "packed_vars": {
477
+ "name": "packed_vars",
478
+ "quantum_type": {
479
+ "length": null,
480
+ "kind": "qvec"
481
+ },
482
+ "direction": "inout"
483
+ }
484
+ },
485
+ "operand_declarations": {
486
+ "oracle": {
487
+ "name": "oracle",
488
+ "positional_arg_declarations": [
489
+ {
490
+ "name": "arg0",
491
+ "quantum_type": {
492
+ "length": null,
493
+ "kind": "qvec"
494
+ },
495
+ "direction": "inout"
496
+ }
497
+ ],
498
+ "is_list": false
499
+ },
500
+ "space_transform": {
501
+ "name": "space_transform",
502
+ "positional_arg_declarations": [
503
+ {
504
+ "name": "arg0",
505
+ "quantum_type": {
506
+ "length": null,
507
+ "kind": "qvec"
508
+ },
509
+ "direction": "inout"
510
+ }
511
+ ],
512
+ "is_list": false
513
+ }
514
+ },
515
+ "positional_arg_declarations": [
516
+ {
517
+ "name": "oracle",
518
+ "positional_arg_declarations": [
519
+ {
520
+ "name": "arg0",
521
+ "quantum_type": {
522
+ "length": null,
523
+ "kind": "qvec"
524
+ },
525
+ "direction": "inout"
526
+ }
527
+ ],
528
+ "is_list": false
529
+ },
530
+ {
531
+ "name": "space_transform",
532
+ "positional_arg_declarations": [
533
+ {
534
+ "name": "arg0",
535
+ "quantum_type": {
536
+ "length": null,
537
+ "kind": "qvec"
538
+ },
539
+ "direction": "inout"
540
+ }
541
+ ],
542
+ "is_list": false
543
+ },
544
+ {
545
+ "name": "packed_vars",
546
+ "quantum_type": {
547
+ "length": null,
548
+ "kind": "qvec"
549
+ },
550
+ "direction": "inout"
551
+ }
552
+ ]
553
+ }"""
554
+ )
555
+
556
+ GROVER_SEARCH = QuantumFunctionDeclaration.parse_raw(
557
+ """{
558
+ "name": "grover_search",
367
559
  "param_decls": {
368
- "num_qubits": {
560
+ "reps": {
369
561
  "kind": "int"
370
562
  }
371
563
  },
372
564
  "port_declarations": {
373
- "p": {
374
- "name": "p",
375
- "size": {
376
- "expr": "num_qubits"
565
+ "packed_vars": {
566
+ "name": "packed_vars",
567
+ "quantum_type": {
568
+ "length": null,
569
+ "kind": "qvec"
377
570
  },
378
571
  "direction": "inout"
379
572
  }
380
573
  },
381
574
  "operand_declarations": {
382
- "sp_op": {
383
- "name": "sp_op",
384
- "param_decls": {
385
- "num_qubits": {
386
- "kind": "int"
387
- }
388
- },
389
- "port_declarations": {
390
- "spq": {
391
- "name": "spq",
392
- "size": {
393
- "expr": "num_qubits"
575
+ "oracle": {
576
+ "name": "oracle",
577
+ "positional_arg_declarations": [
578
+ {
579
+ "name": "arg0",
580
+ "quantum_type": {
581
+ "length": null,
582
+ "kind": "qvec"
394
583
  },
395
584
  "direction": "inout"
396
585
  }
586
+ ],
587
+ "is_list": false
588
+ }
589
+ },
590
+ "positional_arg_declarations": [
591
+ {
592
+ "name": "reps",
593
+ "classical_type": {
594
+ "kind": "int"
397
595
  }
398
596
  },
399
- "oracle_op": {
400
- "name": "oracle_op",
401
- "param_decls": {
402
- "num_qubits": {
403
- "kind": "int"
404
- }
405
- },
406
- "port_declarations": {
407
- "oq": {
408
- "name": "oq",
409
- "size": {
410
- "expr": "num_qubits"
597
+ {
598
+ "name": "oracle",
599
+ "positional_arg_declarations": [
600
+ {
601
+ "name": "arg0",
602
+ "quantum_type": {
603
+ "length": null,
604
+ "kind": "qvec"
411
605
  },
412
606
  "direction": "inout"
413
607
  }
414
- }
608
+ ],
609
+ "is_list": false
610
+ },
611
+ {
612
+ "name": "packed_vars",
613
+ "quantum_type": {
614
+ "length": null,
615
+ "kind": "qvec"
616
+ },
617
+ "direction": "inout"
415
618
  }
416
- },
417
- "positional_arg_declarations": []
619
+ ]
418
620
  }"""
419
621
  )
420
622
 
@@ -461,71 +663,6 @@ APPLY_TO_ALL = QuantumFunctionDeclaration.parse_raw(
461
663
  }"""
462
664
  )
463
665
 
464
- GROVER_SEARCH = QuantumFunctionDeclaration.parse_raw(
465
- """{
466
- "name": "grover_search",
467
- "param_decls": {
468
- "num_qubits": {
469
- "kind": "int"
470
- },
471
- "reps": {
472
- "kind": "int"
473
- }
474
- },
475
- "port_declarations": {
476
- "gsq": {
477
- "name": "gsq",
478
- "size": {
479
- "expr": "num_qubits"
480
- },
481
- "direction": "inout"
482
- }
483
- },
484
- "operand_declarations": {
485
- "oracle_op": {
486
- "name": "oracle_op",
487
- "param_decls": {
488
- "num_qubits": {
489
- "kind": "int"
490
- }
491
- },
492
- "port_declarations": {
493
- "oq": {
494
- "name": "oq",
495
- "size": {
496
- "expr": "num_qubits"
497
- },
498
- "direction": "inout"
499
- }
500
- }
501
- }
502
- },
503
- "positional_arg_declarations": []
504
- }"""
505
- )
506
-
507
- PREPARE_INT = QuantumFunctionDeclaration.parse_raw(
508
- """{
509
- "name": "prepare_int",
510
- "param_decls": {
511
- "val": {
512
- "kind": "int"
513
- }
514
- },
515
- "port_declarations": {
516
- "out": {
517
- "name": "out",
518
- "quantum_type": {
519
- "kind": "qnum"
520
- },
521
- "direction": "output"
522
- }
523
- },
524
- "operand_declarations": {},
525
- "positional_arg_declarations": []
526
- }"""
527
- )
528
-
529
666
  ALLOCATE_NUM = QuantumFunctionDeclaration.parse_raw(
530
667
  """{
531
668
  "name": "allocate_num",
@@ -544,7 +681,16 @@ ALLOCATE_NUM = QuantumFunctionDeclaration.parse_raw(
544
681
  "out": {
545
682
  "name": "out",
546
683
  "quantum_type": {
547
- "kind": "qnum"
684
+ "kind": "qnum",
685
+ "size": {
686
+ "expr": "num_qubits"
687
+ },
688
+ "is_signed": {
689
+ "expr": "is_signed"
690
+ },
691
+ "fraction_digits": {
692
+ "expr": "fraction_digits"
693
+ }
548
694
  },
549
695
  "direction": "output"
550
696
  }
@@ -586,9 +732,6 @@ QAOA_COST_LAYER = QuantumFunctionDeclaration.parse_raw(
586
732
  "kind": "struct_instance",
587
733
  "name": "PauliTerm"
588
734
  }
589
- },
590
- "is_st": {
591
- "kind": "bool"
592
735
  }
593
736
  },
594
737
  "port_declarations": {
@@ -618,9 +761,6 @@ QAOA_LAYER = QuantumFunctionDeclaration.parse_raw(
618
761
  "kind": "struct_instance",
619
762
  "name": "PauliTerm"
620
763
  }
621
- },
622
- "is_st": {
623
- "kind": "bool"
624
764
  }
625
765
  },
626
766
  "port_declarations": {
@@ -668,9 +808,6 @@ QAOA_PENALTY = QuantumFunctionDeclaration.parse_raw(
668
808
  "kind": "struct_instance",
669
809
  "name": "PauliTerm"
670
810
  }
671
- },
672
- "is_st": {
673
- "kind": "bool"
674
811
  }
675
812
  },
676
813
  "port_declarations": {
@@ -835,6 +972,230 @@ SWAP_TEST = QuantumFunctionDeclaration.parse_raw(
835
972
  }"""
836
973
  )
837
974
 
975
+ PREPARE_GHZ_STATE = QuantumFunctionDeclaration.parse_raw(
976
+ """{
977
+ "name": "prepare_ghz_state",
978
+ "param_decls": {
979
+ "size": {
980
+ "kind": "int"
981
+ }
982
+ },
983
+ "port_declarations": {
984
+ "q": {
985
+ "name": "q",
986
+ "quantum_type": {
987
+ "length": null,
988
+ "kind": "qvec"
989
+ },
990
+ "direction": "output"
991
+ }
992
+ },
993
+ "operand_declarations": {},
994
+ "positional_arg_declarations": [
995
+ {
996
+ "name": "size",
997
+ "classical_type": {
998
+ "kind": "int"
999
+ }
1000
+ },
1001
+ {
1002
+ "name": "q",
1003
+ "quantum_type": {
1004
+ "length": null,
1005
+ "kind": "qvec"
1006
+ },
1007
+ "direction": "output"
1008
+ }
1009
+ ]
1010
+ }"""
1011
+ )
1012
+
1013
+ PREPARE_EXPONENTIAL_STATE = QuantumFunctionDeclaration.parse_raw(
1014
+ """{
1015
+ "name": "prepare_exponential_state",
1016
+ "param_decls": {
1017
+ "rate": {
1018
+ "kind": "int"
1019
+ }
1020
+ },
1021
+ "port_declarations": {
1022
+ "q": {
1023
+ "name": "q",
1024
+ "quantum_type": {
1025
+ "length": null,
1026
+ "kind": "qvec"
1027
+ },
1028
+ "direction": "inout"
1029
+ }
1030
+ },
1031
+ "operand_declarations": {},
1032
+ "positional_arg_declarations": [
1033
+ {
1034
+ "name": "rate",
1035
+ "classical_type": {
1036
+ "kind": "int"
1037
+ }
1038
+ },
1039
+ {
1040
+ "name": "q",
1041
+ "quantum_type": {
1042
+ "length": null,
1043
+ "kind": "qvec"
1044
+ },
1045
+ "direction": "inout"
1046
+ }
1047
+ ]
1048
+ }"""
1049
+ )
1050
+
1051
+ PREPARE_BELL_STATE = QuantumFunctionDeclaration.parse_raw(
1052
+ """{
1053
+ "name": "prepare_bell_state",
1054
+ "param_decls": {
1055
+ "state_num": {
1056
+ "kind": "int"
1057
+ }
1058
+ },
1059
+ "port_declarations": {
1060
+ "q": {
1061
+ "name": "q",
1062
+ "quantum_type": {
1063
+ "length": {
1064
+ "expr": "2"
1065
+ },
1066
+ "kind": "qvec"
1067
+ },
1068
+ "direction": "output"
1069
+ }
1070
+ },
1071
+ "operand_declarations": {},
1072
+ "positional_arg_declarations": [
1073
+ {
1074
+ "name": "state_num",
1075
+ "classical_type": {
1076
+ "kind": "int"
1077
+ }
1078
+ },
1079
+ {
1080
+ "name": "q",
1081
+ "quantum_type": {
1082
+ "length": {
1083
+ "expr": "2"
1084
+ },
1085
+ "kind": "qvec"
1086
+ },
1087
+ "direction": "output"
1088
+ }
1089
+ ]
1090
+ }"""
1091
+ )
1092
+
1093
+ INPLACE_PREPARE_INT = QuantumFunctionDeclaration.parse_raw(
1094
+ """{
1095
+ "name": "inplace_prepare_int",
1096
+ "param_decls": {
1097
+ "value": {
1098
+ "kind": "int"
1099
+ }
1100
+ },
1101
+ "port_declarations": {
1102
+ "target": {
1103
+ "name": "target",
1104
+ "quantum_type": {
1105
+ "length": null,
1106
+ "kind": "qvec"
1107
+ },
1108
+ "direction": "inout"
1109
+ }
1110
+ },
1111
+ "operand_declarations": {},
1112
+ "positional_arg_declarations": [
1113
+ {
1114
+ "name": "value",
1115
+ "classical_type": {
1116
+ "kind": "int"
1117
+ }
1118
+ },
1119
+ {
1120
+ "name": "target",
1121
+ "quantum_type": {
1122
+ "length": null,
1123
+ "kind": "qvec"
1124
+ },
1125
+ "direction": "inout"
1126
+ }
1127
+ ]
1128
+ }"""
1129
+ )
1130
+
1131
+ PREPARE_INT = QuantumFunctionDeclaration.parse_raw(
1132
+ """{
1133
+ "name": "prepare_int",
1134
+ "param_decls": {
1135
+ "value": {
1136
+ "kind": "int"
1137
+ }
1138
+ },
1139
+ "port_declarations": {
1140
+ "out": {
1141
+ "name": "out",
1142
+ "quantum_type": {
1143
+ "kind": "qnum"
1144
+ },
1145
+ "direction": "output"
1146
+ }
1147
+ },
1148
+ "operand_declarations": {},
1149
+ "positional_arg_declarations": [
1150
+ {
1151
+ "name": "value",
1152
+ "classical_type": {
1153
+ "kind": "int"
1154
+ }
1155
+ },
1156
+ {
1157
+ "name": "out",
1158
+ "quantum_type": {
1159
+ "kind": "qnum"
1160
+ },
1161
+ "direction": "output"
1162
+ }
1163
+ ]
1164
+ }"""
1165
+ )
1166
+
1167
+ SWITCH = QuantumFunctionDeclaration.parse_raw(
1168
+ """{
1169
+ "name": "switch",
1170
+ "param_decls": {
1171
+ "selector": {
1172
+ "kind": "int"
1173
+ }
1174
+ },
1175
+ "port_declarations": {},
1176
+ "operand_declarations": {
1177
+ "cases": {
1178
+ "name": "cases",
1179
+ "positional_arg_declarations": [],
1180
+ "is_list": true
1181
+ }
1182
+ },
1183
+ "positional_arg_declarations": [
1184
+ {
1185
+ "name": "selector",
1186
+ "classical_type": {
1187
+ "kind": "int"
1188
+ }
1189
+ },
1190
+ {
1191
+ "name": "cases",
1192
+ "positional_arg_declarations": [],
1193
+ "is_list": true
1194
+ }
1195
+ ]
1196
+ }"""
1197
+ )
1198
+
838
1199
  __all__ = [
839
1200
  "QFT_STEP",
840
1201
  "QFT",
@@ -844,13 +1205,13 @@ __all__ = [
844
1205
  "SINGLE_PAULI",
845
1206
  "LINEAR_PAULI_ROTATIONS",
846
1207
  "AMPLITUDE_ESTIMATION",
847
- "SIMPLE_ORACLE",
1208
+ "PHASE_ORACLE",
1209
+ "REFLECT_ABOUT_ZERO",
848
1210
  "GROVER_DIFFUSER",
849
1211
  "GROVER_OPERATOR",
1212
+ "GROVER_SEARCH",
850
1213
  "HADAMARD_TRANSFORM",
851
1214
  "APPLY_TO_ALL",
852
- "GROVER_SEARCH",
853
- "PREPARE_INT",
854
1215
  "ALLOCATE_NUM",
855
1216
  "QAOA_MIXER_LAYER",
856
1217
  "QAOA_COST_LAYER",
@@ -859,4 +1220,10 @@ __all__ = [
859
1220
  "QAOA_PENALTY",
860
1221
  "FULL_HEA",
861
1222
  "SWAP_TEST",
1223
+ "PREPARE_GHZ_STATE",
1224
+ "PREPARE_EXPONENTIAL_STATE",
1225
+ "PREPARE_BELL_STATE",
1226
+ "INPLACE_PREPARE_INT",
1227
+ "PREPARE_INT",
1228
+ "SWITCH",
862
1229
  ]