classiq 0.37.1__py3-none-any.whl → 0.65.3__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 (516) hide show
  1. classiq/__init__.py +49 -34
  2. classiq/_analyzer_extras/_ipywidgets_async_extension.py +3 -2
  3. classiq/_analyzer_extras/interactive_hardware.py +3 -3
  4. classiq/_internals/api_wrapper.py +241 -95
  5. classiq/_internals/async_utils.py +2 -77
  6. classiq/_internals/authentication/auth0.py +26 -10
  7. classiq/_internals/authentication/authentication.py +11 -0
  8. classiq/_internals/authentication/device.py +18 -8
  9. classiq/_internals/authentication/password_manager.py +40 -13
  10. classiq/_internals/authentication/token_manager.py +11 -6
  11. classiq/_internals/client.py +106 -37
  12. classiq/_internals/config.py +3 -4
  13. classiq/_internals/host_checker.py +38 -15
  14. classiq/_internals/jobs.py +56 -50
  15. classiq/_internals/type_validation.py +9 -9
  16. classiq/analyzer/__init__.py +1 -3
  17. classiq/analyzer/analyzer.py +50 -47
  18. classiq/analyzer/analyzer_utilities.py +15 -15
  19. classiq/analyzer/rb.py +19 -20
  20. classiq/analyzer/show_interactive_hack.py +30 -7
  21. classiq/analyzer/url_utils.py +2 -3
  22. classiq/applications/__init__.py +3 -12
  23. classiq/applications/chemistry/__init__.py +14 -10
  24. classiq/applications/chemistry/ansatz_parameters.py +4 -4
  25. classiq/{applications_model_constructors → applications/chemistry}/chemistry_model_constructor.py +170 -170
  26. classiq/applications/chemistry/ground_state_problem.py +1 -1
  27. classiq/applications/combinatorial_helpers/allowed_constraints.py +23 -0
  28. classiq/applications/combinatorial_helpers/arithmetic/arithmetic_expression.py +35 -0
  29. classiq/applications/combinatorial_helpers/arithmetic/isolation.py +42 -0
  30. classiq/applications/combinatorial_helpers/combinatorial_problem_utils.py +166 -0
  31. classiq/applications/combinatorial_helpers/encoding_mapping.py +107 -0
  32. classiq/applications/combinatorial_helpers/encoding_utils.py +124 -0
  33. classiq/applications/combinatorial_helpers/memory.py +75 -0
  34. classiq/applications/combinatorial_helpers/optimization_model.py +193 -0
  35. classiq/applications/combinatorial_helpers/pauli_helpers/pauli_sparsing.py +31 -0
  36. classiq/applications/combinatorial_helpers/pauli_helpers/pauli_utils.py +46 -0
  37. classiq/applications/combinatorial_helpers/pyomo_utils.py +447 -0
  38. classiq/applications/combinatorial_helpers/sympy_utils.py +22 -0
  39. classiq/applications/combinatorial_helpers/transformations/encoding.py +189 -0
  40. classiq/applications/combinatorial_helpers/transformations/fixed_variables.py +143 -0
  41. classiq/applications/combinatorial_helpers/transformations/ising_converter.py +120 -0
  42. classiq/applications/combinatorial_helpers/transformations/penalty.py +31 -0
  43. classiq/applications/combinatorial_helpers/transformations/penalty_support.py +37 -0
  44. classiq/applications/combinatorial_helpers/transformations/sign_seperation.py +74 -0
  45. classiq/applications/combinatorial_helpers/transformations/slack_variables.py +87 -0
  46. classiq/applications/combinatorial_optimization/__init__.py +24 -5
  47. classiq/applications/combinatorial_optimization/combinatorial_optimization_config.py +2 -2
  48. classiq/applications/combinatorial_optimization/combinatorial_optimization_model_constructor.py +137 -0
  49. classiq/applications/combinatorial_optimization/combinatorial_problem.py +229 -0
  50. classiq/applications/combinatorial_optimization/examples/__init__.py +1 -3
  51. classiq/applications/finance/__init__.py +4 -5
  52. classiq/{applications_model_constructors → applications/finance}/finance_model_constructor.py +50 -57
  53. classiq/applications/grover/__init__.py +9 -0
  54. classiq/applications/grover/grover_model_constructor.py +157 -0
  55. classiq/applications/hamiltonian/__init__.py +0 -0
  56. classiq/applications/hamiltonian/pauli_decomposition.py +113 -0
  57. classiq/applications/libraries/__init__.py +0 -0
  58. classiq/applications/libraries/qmci_library.py +22 -0
  59. classiq/applications/qnn/__init__.py +2 -4
  60. classiq/applications/qnn/circuit_utils.py +8 -8
  61. classiq/applications/qnn/datasets/__init__.py +9 -11
  62. classiq/applications/qnn/datasets/dataset_base_classes.py +7 -5
  63. classiq/applications/qnn/datasets/dataset_not.py +2 -1
  64. classiq/applications/qnn/datasets/dataset_parity.py +2 -2
  65. classiq/applications/qnn/gradients/quantum_gradient.py +2 -2
  66. classiq/applications/qnn/gradients/simple_quantum_gradient.py +2 -1
  67. classiq/applications/qnn/qlayer.py +30 -10
  68. classiq/applications/qnn/torch_utils.py +4 -3
  69. classiq/applications/qnn/types.py +7 -7
  70. classiq/applications/qsvm/__init__.py +6 -4
  71. classiq/applications/qsvm/qsvm.py +4 -10
  72. classiq/applications/qsvm/qsvm_data_generation.py +5 -8
  73. classiq/{applications_model_constructors → applications/qsvm}/qsvm_model_constructor.py +30 -28
  74. classiq/execution/__init__.py +8 -3
  75. classiq/execution/all_hardware_devices.py +11 -0
  76. classiq/execution/execution_session.py +400 -0
  77. classiq/execution/iqcc.py +63 -0
  78. classiq/execution/jobs.py +197 -25
  79. classiq/execution/qnn.py +79 -0
  80. classiq/executor.py +23 -117
  81. classiq/interface/_version.py +1 -1
  82. classiq/interface/analyzer/analysis_params.py +49 -16
  83. classiq/interface/analyzer/cytoscape_graph.py +15 -9
  84. classiq/interface/analyzer/result.py +36 -32
  85. classiq/interface/applications/qsvm.py +28 -25
  86. classiq/interface/ast_node.py +16 -0
  87. classiq/interface/backend/backend_preferences.py +390 -119
  88. classiq/interface/backend/ionq/ionq_quantum_program.py +15 -23
  89. classiq/interface/backend/pydantic_backend.py +27 -22
  90. classiq/interface/backend/quantum_backend_providers.py +70 -16
  91. classiq/interface/chemistry/fermionic_operator.py +43 -32
  92. classiq/interface/chemistry/ground_state_problem.py +42 -24
  93. classiq/interface/chemistry/molecule.py +20 -14
  94. classiq/interface/chemistry/operator.py +75 -236
  95. classiq/interface/combinatorial_optimization/encoding_types.py +1 -1
  96. classiq/interface/combinatorial_optimization/examples/ascending_sequence.py +2 -4
  97. classiq/interface/combinatorial_optimization/examples/greater_than_ilp.py +1 -1
  98. classiq/interface/combinatorial_optimization/examples/ilp.py +2 -1
  99. classiq/interface/combinatorial_optimization/examples/integer_portfolio_optimization.py +2 -4
  100. classiq/interface/combinatorial_optimization/examples/knapsack.py +3 -3
  101. classiq/interface/combinatorial_optimization/examples/mds.py +2 -1
  102. classiq/interface/combinatorial_optimization/examples/mht.py +10 -6
  103. classiq/interface/combinatorial_optimization/examples/mis.py +4 -1
  104. classiq/interface/combinatorial_optimization/examples/mvc.py +2 -1
  105. classiq/interface/combinatorial_optimization/examples/portfolio_variations.py +2 -2
  106. classiq/interface/combinatorial_optimization/examples/set_cover.py +3 -3
  107. classiq/interface/combinatorial_optimization/examples/tsp.py +4 -3
  108. classiq/interface/combinatorial_optimization/examples/tsp_digraph.py +6 -2
  109. classiq/interface/combinatorial_optimization/mht_qaoa_input.py +14 -9
  110. classiq/interface/combinatorial_optimization/optimization_problem.py +2 -2
  111. classiq/interface/combinatorial_optimization/result.py +1 -3
  112. classiq/interface/combinatorial_optimization/solver_types.py +1 -1
  113. classiq/interface/debug_info/__init__.py +0 -0
  114. classiq/interface/debug_info/debug_info.py +86 -0
  115. classiq/interface/exceptions.py +201 -0
  116. classiq/interface/execution/iqcc.py +19 -0
  117. classiq/interface/execution/jobs.py +15 -12
  118. classiq/interface/execution/primitives.py +18 -0
  119. classiq/interface/executor/constants.py +1 -0
  120. classiq/interface/executor/estimation.py +2 -2
  121. classiq/interface/executor/execution_preferences.py +26 -143
  122. classiq/interface/executor/execution_request.py +36 -56
  123. classiq/interface/executor/execution_result.py +30 -8
  124. classiq/interface/executor/iqae_result.py +4 -6
  125. classiq/interface/executor/optimizer_preferences.py +34 -22
  126. classiq/interface/executor/{quantum_program.py → quantum_code.py} +44 -34
  127. classiq/interface/executor/quantum_instruction_set.py +3 -2
  128. classiq/interface/executor/register_initialization.py +12 -17
  129. classiq/interface/executor/result.py +122 -64
  130. classiq/interface/executor/vqe_result.py +11 -11
  131. classiq/interface/finance/function_input.py +42 -19
  132. classiq/interface/finance/gaussian_model_input.py +7 -5
  133. classiq/interface/finance/log_normal_model_input.py +6 -4
  134. classiq/interface/finance/model_input.py +6 -4
  135. classiq/interface/generator/adjacency.py +1 -3
  136. classiq/interface/generator/amplitude_loading.py +27 -14
  137. classiq/interface/generator/ansatz_library.py +5 -5
  138. classiq/interface/generator/application_apis/__init__.py +1 -0
  139. classiq/interface/generator/application_apis/arithmetic_declarations.py +17 -0
  140. classiq/interface/generator/application_apis/chemistry_declarations.py +27 -187
  141. classiq/interface/generator/application_apis/combinatorial_optimization_declarations.py +18 -21
  142. classiq/interface/generator/application_apis/entangler_declarations.py +11 -6
  143. classiq/interface/generator/application_apis/finance_declarations.py +48 -69
  144. classiq/interface/generator/application_apis/qsvm_declarations.py +0 -70
  145. classiq/interface/generator/arith/argument_utils.py +57 -6
  146. classiq/interface/generator/arith/arithmetic.py +37 -16
  147. classiq/interface/generator/arith/arithmetic_arg_type_validator.py +15 -17
  148. classiq/interface/generator/arith/arithmetic_expression_abc.py +70 -26
  149. classiq/interface/generator/arith/arithmetic_expression_parser.py +18 -12
  150. classiq/interface/generator/arith/arithmetic_expression_validator.py +61 -43
  151. classiq/interface/generator/arith/arithmetic_operations.py +19 -16
  152. classiq/interface/generator/arith/arithmetic_param_getters.py +7 -8
  153. classiq/interface/generator/arith/arithmetic_result_builder.py +21 -17
  154. classiq/interface/generator/arith/ast_node_rewrite.py +4 -3
  155. classiq/interface/generator/arith/binary_ops.py +375 -139
  156. classiq/interface/generator/arith/endianness.py +1 -1
  157. classiq/interface/generator/arith/extremum_operations.py +96 -23
  158. classiq/interface/generator/arith/logical_ops.py +16 -12
  159. classiq/interface/generator/arith/machine_precision.py +3 -0
  160. classiq/interface/generator/arith/number_utils.py +44 -48
  161. classiq/interface/generator/arith/register_user_input.py +70 -27
  162. classiq/interface/generator/arith/unary_ops.py +57 -46
  163. classiq/interface/generator/arith/uncomputation_methods.py +1 -1
  164. classiq/interface/generator/builtin_api_builder.py +2 -9
  165. classiq/interface/generator/chemistry_function_params.py +5 -5
  166. classiq/interface/generator/circuit_code/circuit_code.py +7 -7
  167. classiq/interface/generator/circuit_code/types_and_constants.py +4 -7
  168. classiq/interface/generator/commuting_pauli_exponentiation.py +8 -6
  169. classiq/interface/generator/compiler_keywords.py +8 -0
  170. classiq/interface/generator/complex_type.py +13 -25
  171. classiq/interface/generator/constant.py +3 -4
  172. classiq/interface/generator/control_state.py +35 -28
  173. classiq/interface/generator/copy.py +47 -0
  174. classiq/interface/generator/custom_ansatz.py +2 -5
  175. classiq/interface/generator/distance.py +3 -5
  176. classiq/interface/generator/excitations.py +3 -2
  177. classiq/interface/generator/expressions/atomic_expression_functions.py +26 -8
  178. classiq/interface/generator/expressions/enums/__init__.py +0 -10
  179. classiq/interface/generator/expressions/enums/finance_functions.py +12 -22
  180. classiq/interface/generator/expressions/evaluated_expression.py +21 -7
  181. classiq/interface/generator/expressions/expression.py +27 -15
  182. classiq/interface/generator/expressions/expression_constants.py +9 -3
  183. classiq/interface/generator/expressions/non_symbolic_expr.py +119 -0
  184. classiq/interface/generator/expressions/qmod_qarray_proxy.py +99 -0
  185. classiq/interface/generator/expressions/qmod_qscalar_proxy.py +59 -0
  186. classiq/interface/generator/expressions/qmod_qstruct_proxy.py +36 -0
  187. classiq/interface/generator/expressions/qmod_sized_proxy.py +30 -2
  188. classiq/interface/generator/expressions/qmod_struct_instance.py +14 -2
  189. classiq/interface/generator/expressions/sympy_supported_expressions.py +20 -11
  190. classiq/interface/generator/finance.py +3 -3
  191. classiq/interface/generator/function_param_library.py +6 -6
  192. classiq/interface/generator/function_param_list_without_self_reference.py +2 -10
  193. classiq/interface/generator/function_params.py +42 -69
  194. classiq/interface/generator/functions/__init__.py +0 -22
  195. classiq/interface/generator/functions/builtins/__init__.py +0 -0
  196. classiq/interface/generator/functions/builtins/internal_operators.py +16 -0
  197. classiq/interface/generator/functions/classical_function_declaration.py +18 -9
  198. classiq/interface/generator/functions/classical_type.py +47 -166
  199. classiq/interface/generator/functions/concrete_types.py +55 -0
  200. classiq/interface/generator/functions/function_declaration.py +13 -14
  201. classiq/interface/generator/functions/port_declaration.py +1 -13
  202. classiq/interface/generator/functions/qmod_python_interface.py +2 -1
  203. classiq/interface/generator/functions/type_name.py +90 -0
  204. classiq/interface/generator/generated_circuit_data.py +155 -22
  205. classiq/interface/generator/grover_diffuser.py +32 -25
  206. classiq/interface/generator/grover_operator.py +34 -23
  207. classiq/interface/generator/hamiltonian_evolution/exponentiation.py +4 -6
  208. classiq/interface/generator/hamiltonian_evolution/qdrift.py +4 -4
  209. classiq/interface/generator/hamiltonian_evolution/suzuki_trotter.py +12 -8
  210. classiq/interface/generator/hardware/hardware_data.py +76 -36
  211. classiq/interface/generator/hardware_efficient_ansatz.py +38 -17
  212. classiq/interface/generator/hartree_fock.py +14 -4
  213. classiq/interface/generator/identity.py +10 -6
  214. classiq/interface/generator/linear_pauli_rotations.py +33 -19
  215. classiq/interface/generator/mcmt_method.py +1 -1
  216. classiq/interface/generator/mcu.py +20 -16
  217. classiq/interface/generator/mcx.py +29 -20
  218. classiq/interface/generator/model/__init__.py +2 -5
  219. classiq/interface/generator/model/constraints.py +27 -8
  220. classiq/interface/generator/model/model.py +32 -203
  221. classiq/interface/generator/model/preferences/preferences.py +118 -43
  222. classiq/{quantum_register.py → interface/generator/model/quantum_register.py} +27 -22
  223. classiq/interface/generator/oracles/arithmetic_oracle.py +2 -4
  224. classiq/interface/generator/oracles/custom_oracle.py +17 -13
  225. classiq/interface/generator/oracles/oracle_abc.py +9 -9
  226. classiq/interface/generator/partitioned_register.py +7 -7
  227. classiq/interface/generator/piecewise_linear_amplitude_loading.py +45 -29
  228. classiq/interface/generator/preferences/optimization.py +1 -2
  229. classiq/interface/generator/qpe.py +47 -34
  230. classiq/interface/generator/qsvm.py +13 -17
  231. classiq/interface/generator/quantum_function_call.py +107 -87
  232. classiq/interface/generator/{generated_circuit.py → quantum_program.py} +50 -37
  233. classiq/interface/generator/range_types.py +13 -12
  234. classiq/interface/generator/register_role.py +18 -6
  235. classiq/interface/generator/slice_parsing_utils.py +11 -6
  236. classiq/interface/generator/standard_gates/controlled_standard_gates.py +32 -39
  237. classiq/interface/generator/standard_gates/standard_angle_metaclass.py +2 -6
  238. classiq/interface/generator/standard_gates/standard_gates.py +3 -3
  239. classiq/interface/generator/standard_gates/u_gate.py +7 -10
  240. classiq/interface/generator/state_preparation/bell_state_preparation.py +3 -3
  241. classiq/interface/generator/state_preparation/computational_basis_state_preparation.py +2 -1
  242. classiq/interface/generator/state_preparation/distributions.py +16 -15
  243. classiq/interface/generator/state_preparation/metrics.py +5 -7
  244. classiq/interface/generator/state_preparation/state_preparation.py +30 -23
  245. classiq/interface/generator/synthesis_metadata/synthesis_duration.py +0 -4
  246. classiq/interface/generator/synthesis_metadata/synthesis_execution_data.py +20 -6
  247. classiq/interface/generator/transpiler_basis_gates.py +7 -3
  248. classiq/interface/generator/types/builtin_enum_declarations.py +178 -0
  249. classiq/interface/generator/types/compilation_metadata.py +6 -0
  250. classiq/interface/generator/types/enum_declaration.py +54 -0
  251. classiq/interface/generator/types/qstruct_declaration.py +18 -0
  252. classiq/interface/generator/types/struct_declaration.py +15 -14
  253. classiq/interface/generator/ucc.py +9 -6
  254. classiq/interface/generator/unitary_gate.py +10 -6
  255. classiq/interface/generator/user_defined_function_params.py +4 -1
  256. classiq/interface/generator/validations/flow_graph.py +11 -9
  257. classiq/interface/generator/validations/validator_functions.py +8 -6
  258. classiq/interface/generator/visitor.py +23 -16
  259. classiq/interface/hardware.py +31 -10
  260. classiq/interface/helpers/classproperty.py +8 -0
  261. classiq/interface/helpers/custom_encoders.py +3 -0
  262. classiq/interface/helpers/custom_pydantic_types.py +40 -50
  263. classiq/interface/helpers/datastructures.py +26 -0
  264. classiq/interface/helpers/hashable_mixin.py +3 -2
  265. classiq/interface/helpers/hashable_pydantic_base_model.py +2 -1
  266. classiq/interface/helpers/pydantic_model_helpers.py +7 -11
  267. classiq/interface/helpers/validation_helpers.py +4 -21
  268. classiq/interface/helpers/versioned_model.py +1 -1
  269. classiq/interface/ide/ide_data.py +16 -20
  270. classiq/interface/ide/visual_model.py +130 -0
  271. classiq/interface/interface_version.py +1 -0
  272. classiq/interface/jobs.py +35 -6
  273. classiq/interface/model/allocate.py +16 -0
  274. classiq/interface/model/bind_operation.py +44 -14
  275. classiq/interface/model/classical_if.py +15 -0
  276. classiq/interface/model/classical_parameter_declaration.py +33 -3
  277. classiq/interface/model/control.py +45 -0
  278. classiq/interface/model/handle_binding.py +298 -20
  279. classiq/interface/model/inplace_binary_operation.py +31 -26
  280. classiq/interface/model/invert.py +12 -0
  281. classiq/interface/model/model.py +87 -73
  282. classiq/interface/model/native_function_definition.py +16 -21
  283. classiq/interface/model/parameter.py +13 -0
  284. classiq/interface/model/phase_operation.py +11 -0
  285. classiq/interface/model/port_declaration.py +27 -9
  286. classiq/interface/model/power.py +14 -0
  287. classiq/interface/model/quantum_expressions/amplitude_loading_operation.py +38 -21
  288. classiq/interface/model/quantum_expressions/arithmetic_operation.py +51 -14
  289. classiq/interface/model/quantum_expressions/quantum_expression.py +12 -35
  290. classiq/interface/model/quantum_function_call.py +146 -462
  291. classiq/interface/model/quantum_function_declaration.py +193 -152
  292. classiq/interface/model/quantum_lambda_function.py +65 -0
  293. classiq/interface/model/quantum_statement.py +71 -12
  294. classiq/interface/model/quantum_type.py +205 -67
  295. classiq/interface/model/quantum_variable_declaration.py +4 -26
  296. classiq/interface/model/repeat.py +15 -0
  297. classiq/interface/model/statement_block.py +58 -0
  298. classiq/interface/model/validation_handle.py +13 -6
  299. classiq/interface/model/variable_declaration_statement.py +3 -1
  300. classiq/interface/model/within_apply_operation.py +13 -0
  301. classiq/interface/pyomo_extension/pyomo_sympy_bimap.py +4 -1
  302. classiq/interface/server/global_versions.py +6 -7
  303. classiq/interface/server/routes.py +22 -21
  304. classiq/interface/source_reference.py +59 -0
  305. classiq/model_expansions/__init__.py +0 -0
  306. classiq/model_expansions/atomic_expression_functions_defs.py +253 -0
  307. classiq/model_expansions/capturing/__init__.py +0 -0
  308. classiq/model_expansions/capturing/captured_vars.py +435 -0
  309. classiq/model_expansions/capturing/mangling_utils.py +56 -0
  310. classiq/model_expansions/closure.py +171 -0
  311. classiq/model_expansions/debug_flag.py +3 -0
  312. classiq/model_expansions/evaluators/__init__.py +0 -0
  313. classiq/model_expansions/evaluators/arg_type_match.py +158 -0
  314. classiq/model_expansions/evaluators/argument_types.py +42 -0
  315. classiq/model_expansions/evaluators/classical_expression.py +36 -0
  316. classiq/model_expansions/evaluators/control.py +144 -0
  317. classiq/model_expansions/evaluators/parameter_types.py +226 -0
  318. classiq/model_expansions/evaluators/quantum_type_utils.py +239 -0
  319. classiq/model_expansions/evaluators/type_type_match.py +90 -0
  320. classiq/model_expansions/expression_evaluator.py +135 -0
  321. classiq/model_expansions/expression_renamer.py +76 -0
  322. classiq/model_expansions/function_builder.py +247 -0
  323. classiq/model_expansions/generative_functions.py +158 -0
  324. classiq/model_expansions/interpreters/__init__.py +0 -0
  325. classiq/model_expansions/interpreters/base_interpreter.py +263 -0
  326. classiq/model_expansions/interpreters/frontend_generative_interpreter.py +28 -0
  327. classiq/model_expansions/interpreters/generative_interpreter.py +249 -0
  328. classiq/model_expansions/model_tables.py +18 -0
  329. classiq/model_expansions/quantum_operations/__init__.py +9 -0
  330. classiq/model_expansions/quantum_operations/bind.py +60 -0
  331. classiq/model_expansions/quantum_operations/call_emitter.py +266 -0
  332. classiq/model_expansions/quantum_operations/classicalif.py +53 -0
  333. classiq/model_expansions/quantum_operations/declarative_call_emitter.py +87 -0
  334. classiq/model_expansions/quantum_operations/emitter.py +181 -0
  335. classiq/model_expansions/quantum_operations/quantum_function_call.py +33 -0
  336. classiq/model_expansions/quantum_operations/repeat.py +56 -0
  337. classiq/model_expansions/quantum_operations/shallow_emitter.py +180 -0
  338. classiq/model_expansions/quantum_operations/variable_decleration.py +28 -0
  339. classiq/model_expansions/scope.py +240 -0
  340. classiq/model_expansions/scope_initialization.py +150 -0
  341. classiq/model_expansions/sympy_conversion/__init__.py +0 -0
  342. classiq/model_expansions/sympy_conversion/arithmetics.py +49 -0
  343. classiq/model_expansions/sympy_conversion/expression_to_sympy.py +179 -0
  344. classiq/model_expansions/sympy_conversion/sympy_to_python.py +123 -0
  345. classiq/model_expansions/transformers/__init__.py +0 -0
  346. classiq/model_expansions/transformers/ast_renamer.py +26 -0
  347. classiq/model_expansions/transformers/var_splitter.py +299 -0
  348. classiq/model_expansions/utils/__init__.py +0 -0
  349. classiq/model_expansions/utils/counted_name_allocator.py +11 -0
  350. classiq/model_expansions/utils/handles_collector.py +33 -0
  351. classiq/model_expansions/visitors/__init__.py +0 -0
  352. classiq/model_expansions/visitors/boolean_expression_transformers.py +214 -0
  353. classiq/model_expansions/visitors/variable_references.py +144 -0
  354. classiq/open_library/__init__.py +4 -0
  355. classiq/open_library/functions/__init__.py +130 -0
  356. classiq/open_library/functions/amplitude_estimation.py +30 -0
  357. classiq/open_library/functions/discrete_sine_cosine_transform.py +181 -0
  358. classiq/open_library/functions/grover.py +157 -0
  359. classiq/open_library/functions/hea.py +115 -0
  360. classiq/open_library/functions/linear_pauli_rotation.py +82 -0
  361. classiq/open_library/functions/modular_exponentiation.py +201 -0
  362. classiq/open_library/functions/qaoa_penalty.py +117 -0
  363. classiq/open_library/functions/qft_functions.py +54 -0
  364. classiq/open_library/functions/qpe.py +46 -0
  365. classiq/open_library/functions/qsvt.py +331 -0
  366. classiq/open_library/functions/state_preparation.py +301 -0
  367. classiq/open_library/functions/swap_test.py +27 -0
  368. classiq/open_library/functions/utility_functions.py +81 -0
  369. classiq/open_library/functions/variational.py +52 -0
  370. classiq/qmod/__init__.py +17 -10
  371. classiq/qmod/builtins/__init__.py +19 -2
  372. classiq/qmod/builtins/classical_execution_primitives.py +60 -47
  373. classiq/qmod/builtins/classical_functions.py +44 -38
  374. classiq/qmod/builtins/constants.py +10 -0
  375. classiq/qmod/builtins/enums.py +208 -0
  376. classiq/qmod/builtins/functions/__init__.py +137 -0
  377. classiq/qmod/builtins/functions/allocation.py +150 -0
  378. classiq/qmod/builtins/functions/arithmetic.py +55 -0
  379. classiq/qmod/builtins/functions/benchmarking.py +8 -0
  380. classiq/qmod/builtins/functions/chemistry.py +91 -0
  381. classiq/qmod/builtins/functions/exponentiation.py +105 -0
  382. classiq/qmod/builtins/functions/finance.py +34 -0
  383. classiq/qmod/builtins/functions/operators.py +16 -0
  384. classiq/qmod/builtins/functions/qsvm.py +24 -0
  385. classiq/qmod/builtins/functions/standard_gates.py +651 -0
  386. classiq/qmod/builtins/operations.py +379 -57
  387. classiq/qmod/builtins/structs.py +103 -80
  388. classiq/qmod/cfunc.py +42 -0
  389. classiq/qmod/classical_function.py +8 -20
  390. classiq/qmod/cparam.py +64 -0
  391. classiq/qmod/create_model_function.py +56 -0
  392. classiq/qmod/declaration_inferrer.py +145 -112
  393. classiq/qmod/expression_query.py +39 -0
  394. classiq/qmod/generative.py +42 -0
  395. classiq/qmod/model_state_container.py +19 -5
  396. classiq/qmod/native/__init__.py +7 -0
  397. classiq/qmod/native/expression_to_qmod.py +194 -0
  398. classiq/qmod/native/pretty_printer.py +401 -0
  399. classiq/qmod/pretty_print/__init__.py +7 -0
  400. classiq/qmod/pretty_print/expression_to_python.py +222 -0
  401. classiq/qmod/pretty_print/pretty_printer.py +572 -0
  402. classiq/qmod/python_classical_type.py +67 -0
  403. classiq/qmod/qfunc.py +79 -0
  404. classiq/qmod/qmod_constant.py +143 -0
  405. classiq/qmod/qmod_parameter.py +84 -53
  406. classiq/qmod/qmod_variable.py +497 -100
  407. classiq/qmod/quantum_callable.py +17 -7
  408. classiq/qmod/quantum_expandable.py +278 -105
  409. classiq/qmod/quantum_function.py +232 -48
  410. classiq/qmod/semantics/__init__.py +0 -0
  411. classiq/qmod/semantics/annotation/__init__.py +0 -0
  412. classiq/qmod/semantics/annotation/call_annotation.py +92 -0
  413. classiq/qmod/semantics/annotation/qstruct_annotator.py +23 -0
  414. classiq/qmod/semantics/error_manager.py +88 -0
  415. classiq/qmod/semantics/lambdas.py +25 -0
  416. classiq/qmod/semantics/static_semantics_visitor.py +384 -0
  417. classiq/qmod/semantics/validation/__init__.py +0 -0
  418. classiq/qmod/semantics/validation/constants_validation.py +16 -0
  419. classiq/qmod/semantics/validation/func_call_validation.py +99 -0
  420. classiq/qmod/semantics/validation/function_name_collisions_validation.py +23 -0
  421. classiq/qmod/semantics/validation/handle_validation.py +85 -0
  422. classiq/qmod/semantics/validation/main_validation.py +33 -0
  423. classiq/qmod/semantics/validation/types_validation.py +128 -0
  424. classiq/qmod/symbolic.py +178 -111
  425. classiq/qmod/symbolic_expr.py +36 -12
  426. classiq/qmod/symbolic_type.py +2 -5
  427. classiq/qmod/type_attribute_remover.py +32 -0
  428. classiq/qmod/utilities.py +108 -1
  429. classiq/qmod/write_qmod.py +53 -0
  430. classiq/synthesis.py +210 -22
  431. {classiq-0.37.1.dist-info → classiq-0.65.3.dist-info}/METADATA +16 -8
  432. classiq-0.65.3.dist-info/RECORD +521 -0
  433. {classiq-0.37.1.dist-info → classiq-0.65.3.dist-info}/WHEEL +1 -1
  434. classiq/_internals/_qfunc_ext.py +0 -6
  435. classiq/applications/benchmarking/__init__.py +0 -9
  436. classiq/applications/benchmarking/mirror_benchmarking.py +0 -67
  437. classiq/applications/numpy_utils.py +0 -37
  438. classiq/applications_model_constructors/__init__.py +0 -17
  439. classiq/applications_model_constructors/combinatorial_optimization_model_constructor.py +0 -178
  440. classiq/applications_model_constructors/grover_model_constructor.py +0 -227
  441. classiq/applications_model_constructors/libraries/ampltitude_estimation_library.py +0 -11
  442. classiq/applications_model_constructors/libraries/qmci_library.py +0 -109
  443. classiq/builtin_functions/__init__.py +0 -43
  444. classiq/builtin_functions/amplitude_loading.py +0 -3
  445. classiq/builtin_functions/binary_ops.py +0 -1
  446. classiq/builtin_functions/exponentiation.py +0 -5
  447. classiq/builtin_functions/qpe.py +0 -4
  448. classiq/builtin_functions/qsvm.py +0 -7
  449. classiq/builtin_functions/range_types.py +0 -5
  450. classiq/builtin_functions/standard_gates.py +0 -1
  451. classiq/builtin_functions/state_preparation.py +0 -6
  452. classiq/builtin_functions/suzuki_trotter.py +0 -3
  453. classiq/exceptions.py +0 -131
  454. classiq/interface/executor/aws_execution_cost.py +0 -72
  455. classiq/interface/executor/error_mitigation.py +0 -6
  456. classiq/interface/generator/credit_risk_example/linear_gci.py +0 -115
  457. classiq/interface/generator/credit_risk_example/weighted_adder.py +0 -59
  458. classiq/interface/generator/expressions/enums/chemistry.py +0 -28
  459. classiq/interface/generator/expressions/enums/classical_enum.py +0 -5
  460. classiq/interface/generator/expressions/enums/ladder_operator.py +0 -16
  461. classiq/interface/generator/expressions/enums/optimizers.py +0 -9
  462. classiq/interface/generator/expressions/enums/pauli.py +0 -8
  463. classiq/interface/generator/expressions/enums/qsvm_feature_map_entanglement.py +0 -9
  464. classiq/interface/generator/expressions/qmod_qnum_proxy.py +0 -22
  465. classiq/interface/generator/functions/core_lib_declarations/quantum_functions/__init__.py +0 -18
  466. classiq/interface/generator/functions/core_lib_declarations/quantum_functions/atomic_quantum_functions.py +0 -641
  467. classiq/interface/generator/functions/core_lib_declarations/quantum_functions/exponentiation_functions.py +0 -89
  468. classiq/interface/generator/functions/core_lib_declarations/quantum_functions/std_lib_functions.py +0 -862
  469. classiq/interface/generator/functions/core_lib_declarations/quantum_operators.py +0 -169
  470. classiq/interface/generator/functions/foreign_function_definition.py +0 -106
  471. classiq/interface/generator/functions/function_implementation.py +0 -103
  472. classiq/interface/generator/functions/native_function_definition.py +0 -153
  473. classiq/interface/generator/functions/quantum_function_declaration.py +0 -69
  474. classiq/interface/generator/functions/register.py +0 -42
  475. classiq/interface/generator/functions/register_mapping_data.py +0 -102
  476. classiq/interface/generator/inequality_mixer.py +0 -51
  477. classiq/interface/generator/model/classical_main_validator.py +0 -106
  478. classiq/interface/generator/range_mixer.py +0 -56
  479. classiq/interface/generator/state_propagator.py +0 -63
  480. classiq/interface/generator/types/builtin_struct_declarations/__init__.py +0 -2
  481. classiq/interface/generator/types/builtin_struct_declarations/pauli_struct_declarations.py +0 -22
  482. classiq/interface/generator/types/builtin_struct_declarations/qaoa_declarations.py +0 -23
  483. classiq/interface/generator/types/combinatorial_problem.py +0 -26
  484. classiq/interface/ide/show.py +0 -34
  485. classiq/interface/model/common_model_types.py +0 -23
  486. classiq/interface/model/numeric_reinterpretation.py +0 -25
  487. classiq/interface/model/operator_synthesis_data.py +0 -48
  488. classiq/interface/model/quantum_expressions/control_state.py +0 -38
  489. classiq/interface/model/quantum_if_operation.py +0 -95
  490. classiq/interface/model/resolvers/function_call_resolver.py +0 -43
  491. classiq/interface/model/validations/handle_validation_base.py +0 -55
  492. classiq/interface/model/validations/handles_validator.py +0 -154
  493. classiq/interface/model/validations/port_to_wire_name_generator.py +0 -12
  494. classiq/model/__init__.py +0 -14
  495. classiq/model/composite_function_generator.py +0 -33
  496. classiq/model/function_handler.py +0 -466
  497. classiq/model/function_handler.pyi +0 -152
  498. classiq/model/logic_flow.py +0 -149
  499. classiq/model/logic_flow_change_handler.py +0 -71
  500. classiq/model/model.py +0 -246
  501. classiq/qmod/builtins/functions.py +0 -896
  502. classiq/qmod/qmod_struct.py +0 -37
  503. classiq/quantum_functions/__init__.py +0 -17
  504. classiq/quantum_functions/annotation_parser.py +0 -207
  505. classiq/quantum_functions/decorators.py +0 -22
  506. classiq/quantum_functions/function_library.py +0 -181
  507. classiq/quantum_functions/function_parser.py +0 -74
  508. classiq/quantum_functions/quantum_function.py +0 -236
  509. classiq-0.37.1.dist-info/RECORD +0 -418
  510. /classiq/{applications_model_constructors/libraries → applications/combinatorial_helpers}/__init__.py +0 -0
  511. /classiq/{interface/generator/credit_risk_example → applications/combinatorial_helpers/arithmetic}/__init__.py +0 -0
  512. /classiq/{interface/generator/functions/core_lib_declarations → applications/combinatorial_helpers/pauli_helpers}/__init__.py +0 -0
  513. /classiq/{interface/generator/functions/core_lib_declarations/quantum_functions/chemistry_functions.py → applications/combinatorial_helpers/py.typed} +0 -0
  514. /classiq/{interface/model/resolvers → applications/combinatorial_helpers/solvers}/__init__.py +0 -0
  515. /classiq/{interface/model/validations → applications/combinatorial_helpers/transformations}/__init__.py +0 -0
  516. /classiq/{_internals → interface}/enum_utils.py +0 -0
@@ -1,10 +1,12 @@
1
1
  from __future__ import annotations
2
2
 
3
- from datetime import timedelta
4
- from typing import Any, Dict, Iterable, List, Optional, Union
3
+ import warnings
4
+ from collections.abc import Iterable
5
+ from typing import Any, Optional, Union
5
6
 
6
7
  import pydantic
7
- from pydantic import BaseModel, validator
8
+ from pydantic import BaseModel
9
+ from pydantic_settings import BaseSettings, SettingsConfigDict
8
10
 
9
11
  from classiq.interface.backend import pydantic_backend
10
12
  from classiq.interface.backend.quantum_backend_providers import (
@@ -12,22 +14,31 @@ from classiq.interface.backend.quantum_backend_providers import (
12
14
  AliceBobBackendNames,
13
15
  AmazonBraketBackendNames,
14
16
  AzureQuantumBackendNames,
15
- ClassiqAerBackendNames,
16
17
  ClassiqNvidiaBackendNames,
18
+ ClassiqSimulatorBackendNames,
19
+ IntelBackendNames,
17
20
  IonqBackendNames,
18
21
  OQCBackendNames,
19
22
  ProviderTypeVendor,
20
23
  ProviderVendor,
21
24
  )
25
+ from classiq.interface.exceptions import ClassiqDeprecationWarning
22
26
  from classiq.interface.hardware import Provider
23
- from classiq.interface.helpers.pydantic_model_helpers import values_with_discriminator
24
27
 
25
28
 
26
29
  class BackendPreferences(BaseModel):
27
- # Due to the way the field is currently implemented, i.e. it redefined with different types
28
- # in the subclass, it shouldn't be dumped with exclude_unset. This causes this field not to appear.
29
- # For example: don't use obj.dict(exclude_unset=True).
30
- backend_service_provider: str = pydantic.Field(
30
+ """
31
+ Preferences for the execution of the quantum program.
32
+
33
+ For more details, refer to:
34
+ [BackendPreferences](https://docs.classiq.io/latest/reference-manual/python-sdk/?h=backend#classiq.Preferences.backend_preferences)
35
+
36
+ Attributes:
37
+ backend_service_provider (str): Provider company or cloud for the requested backend.
38
+ backend_name (str): Name of the requested backend or target.
39
+ """
40
+
41
+ backend_service_provider: ProviderVendor = pydantic.Field(
31
42
  ..., description="Provider company or cloud for the requested backend."
32
43
  )
33
44
  backend_name: str = pydantic.Field(
@@ -38,89 +49,220 @@ class BackendPreferences(BaseModel):
38
49
  def hw_provider(self) -> Provider:
39
50
  return Provider(self.backend_service_provider)
40
51
 
41
- @pydantic.validator("backend_service_provider", pre=True)
42
- def validate_backend_service_provider(
43
- cls, backend_service_provider: Any
44
- ) -> Provider:
45
- return validate_backend_service_provider(backend_service_provider)
46
-
47
52
  @classmethod
48
53
  def batch_preferences(
49
54
  cls, *, backend_names: Iterable[str], **kwargs: Any
50
- ) -> List[BackendPreferences]:
55
+ ) -> list[BackendPreferences]:
51
56
  return [cls(backend_name=name, **kwargs) for name in backend_names]
52
57
 
53
58
  def is_nvidia_backend(self) -> bool:
54
59
  return False
55
60
 
56
61
 
57
- AWS_DEFAULT_JOB_TIMEOUT_SECONDS = int(timedelta(minutes=5).total_seconds())
58
-
59
-
60
62
  class AliceBobBackendPreferences(BackendPreferences):
61
- backend_service_provider: ProviderTypeVendor.ALICE_BOB
62
- api_key: pydantic_backend.PydanticAliceBobApiKeyType = pydantic.Field(
63
- ..., description="AliceBob API key"
63
+ """
64
+ Backend preferences specific to Alice&Bob for quantum computing tasks.
65
+
66
+ This class includes configuration options for setting up a backend using Alice&Bob's quantum hardware.
67
+ It extends the base `BackendPreferences` class and provides additional parameters required for working
68
+ with Alice&Bob's cat qubits, including settings for photon dissipation rates, repetition code distance,
69
+ and the average number of photons.
70
+
71
+ Attributes:
72
+ backend_service_provider (ProviderTypeVendor.ALICE_BOB):
73
+ The service provider for the backend, which is Alice&Bob.
74
+
75
+ distance (Optional[int]):
76
+ The number of times information is duplicated in the repetition code.
77
+ - **Tooltip**: Phase-flip probability decreases exponentially with this parameter, bit-flip probability increases linearly.
78
+ - **Supported Values**: 3 to 300, though practical values are usually lower than 30.
79
+ - **Default**: None.
80
+
81
+ kappa_1 (Optional[float]):
82
+ The rate at which the cat qubit loses one photon, creating a bit-flip.
83
+ - **Tooltip**: Lower values mean lower error rates.
84
+ - **Supported Values**: 10 to 10^5. Current hardware is at ~10^3.
85
+ - **Default**: None.
86
+
87
+ kappa_2 (Optional[float]):
88
+ The rate at which the cat qubit is stabilized using two-photon dissipation.
89
+ - **Tooltip**: Higher values mean lower error rates.
90
+ - **Supported Values**: 100 to 10^9. Current hardware is at ~10^5.
91
+ - **Default**: None.
92
+
93
+ average_nb_photons (Optional[float]):
94
+ The average number of photons.
95
+ - **Tooltip**: Bit-flip probability decreases exponentially with this parameter, phase-flip probability increases linearly.
96
+ - **Supported Values**: 4 to 10^5, though practical values are usually lower than 30.
97
+ - **Default**: None.
98
+
99
+ api_key (str):
100
+ The API key required to access Alice&Bob's quantum hardware.
101
+ - **Required**: Yes.
102
+
103
+ For more details, refer to the [Alice&Bob Backend Documentation](https://docs.classiq.io/latest/reference-manual/executor/cloud-providers/alice-and-bob-backends/).
104
+ """
105
+
106
+ backend_service_provider: ProviderTypeVendor.ALICE_BOB = pydantic.Field(
107
+ default=ProviderVendor.ALICE_AND_BOB
108
+ )
109
+ distance: Optional[int] = pydantic.Field(
110
+ default=None, description="Repetition code distance"
111
+ )
112
+ kappa_1: Optional[float] = pydantic.Field(
113
+ default=None, description="One-photon dissipation rate (Hz)"
114
+ )
115
+ kappa_2: Optional[float] = pydantic.Field(
116
+ default=None, description="Two-photon dissipation rate (Hz)"
117
+ )
118
+ average_nb_photons: Optional[float] = pydantic.Field(
119
+ default=None, description="Average number of photons"
120
+ )
121
+ api_key: Optional[pydantic_backend.PydanticAliceBobApiKeyType] = pydantic.Field(
122
+ default=None, description="AliceBob API key"
64
123
  )
65
124
 
66
- @pydantic.root_validator(pre=True)
67
- def _set_backend_service_provider(cls, values: Dict[str, Any]) -> Dict[str, Any]:
68
- return values_with_discriminator(
69
- values, "backend_service_provider", ProviderVendor.ALICE_AND_BOB
70
- )
125
+ @property
126
+ def parameters(self) -> dict[str, Any]:
127
+ parameters = {
128
+ "distance": self.distance,
129
+ "kappa1": self.kappa_1,
130
+ "kappa2": self.kappa_2,
131
+ "averageNbPhotons": self.average_nb_photons,
132
+ }
133
+ return {k: v for k, v in parameters.items() if v is not None}
134
+
135
+ @pydantic.field_validator("api_key", mode="after")
136
+ @classmethod
137
+ def _validate_api_key(cls, api_key: Optional[str]) -> Optional[str]:
138
+ if api_key is not None:
139
+ warnings.warn(
140
+ "API key is no longer required for Alice&Bob backends.",
141
+ ClassiqDeprecationWarning,
142
+ stacklevel=2,
143
+ )
144
+ return api_key
71
145
 
72
146
 
73
147
  class ClassiqBackendPreferences(BackendPreferences):
74
- backend_service_provider: ProviderTypeVendor.CLASSIQ
148
+ """
149
+ Represents backend preferences specific to Classiq quantum computing targets.
150
+
151
+ This class is used to configure the backend options for executing quantum circuits on Classiq's platform.
152
+ The relevant backend names for Classiq targets are specified in `ClassiqSimulatorBackendNames` & `ClassiqNvidiaBackendNames`.
75
153
 
76
- @pydantic.root_validator(pre=True)
77
- def _set_backend_service_provider(cls, values: Dict[str, Any]) -> Dict[str, Any]:
78
- return values_with_discriminator(
79
- values, "backend_service_provider", ProviderVendor.CLASSIQ
80
- )
154
+ For more details, refer to the [Classiq Backend Documentation](https://docs.classiq.io/latest/reference-manual/executor/cloud-providers/classiq-backends/).
155
+ """
156
+
157
+ backend_service_provider: ProviderTypeVendor.CLASSIQ = pydantic.Field(
158
+ default=ProviderVendor.CLASSIQ
159
+ )
81
160
 
82
161
  def is_nvidia_backend(self) -> bool:
83
162
  return self.backend_name in list(ClassiqNvidiaBackendNames)
84
163
 
164
+ # CAD-25390
165
+ @pydantic.field_validator("backend_name")
166
+ @classmethod
167
+ def _validate_nvidia_name_backwards_compatibility(cls, backend_name: str) -> str:
168
+ if backend_name == "nvidia_state_vector_simulator":
169
+ warnings.warn(
170
+ "The name 'nvidia_state_vector_simulator' is deprecated and "
171
+ "will be removed soon, no earlier than January 12th 2025. "
172
+ "Please use ClassiqNvidiaBackendNames.SIMULATOR instead",
173
+ ClassiqDeprecationWarning,
174
+ stacklevel=2,
175
+ )
176
+ return backend_name
177
+
85
178
 
86
179
  class AwsBackendPreferences(BackendPreferences):
87
- backend_service_provider: ProviderTypeVendor.AMAZON_BRAKET
88
- aws_role_arn: pydantic_backend.PydanticAwsRoleArn = pydantic.Field(
89
- description="ARN of the role to be assumed for execution on your Braket account."
180
+ """
181
+ AWS-specific backend preferences for quantum computing tasks using Amazon Braket.
182
+
183
+ This class contains configuration options specific to Amazon Braket, including the AWS role
184
+ ARN, S3 bucket details, and the folder path within the S3 bucket. It extends the base
185
+ `BackendPreferences` class to provide additional properties required for interaction with
186
+ Amazon Braket.
187
+
188
+ Attributes:
189
+ backend_service_provider (ProviderTypeVendor.AMAZON_BRAKET):
190
+ The service provider for the backend, which is Amazon Braket.
191
+
192
+ aws_role_arn (pydantic_backend.PydanticAwsRoleArn):
193
+ The Amazon Resource Name (ARN) of the role that will be assumed for execution
194
+ on your Braket account. This is a required field and should be provided to allow
195
+ secure and authorized access to AWS resources.
196
+
197
+ s3_bucket_name (str):
198
+ The name of the S3 bucket where results and other related data will be stored.
199
+ This field should contain a valid S3 bucket name under your AWS account.
200
+
201
+ s3_folder (pydantic_backend.PydanticS3BucketKey):
202
+ The folder path within the specified S3 bucket. This allows for organizing
203
+ results and data under a specific directory within the S3 bucket.
204
+
205
+
206
+ For more details, refer to:
207
+ [AwsBackendPreferences examples](https://docs.classiq.io/latest/reference-manual/executor/cloud-providers/amazon-backends/?h=awsbackend#usage)
208
+ """
209
+
210
+ backend_service_provider: ProviderTypeVendor.AMAZON_BRAKET = pydantic.Field(
211
+ default=ProviderVendor.AMAZON_BRAKET
90
212
  )
91
- s3_bucket_name: str = pydantic.Field(description="S3 Bucket Name")
92
- s3_folder: pydantic_backend.PydanticS3BucketKey = pydantic.Field(
93
- description="S3 Folder Path Within The S3 Bucket"
213
+ aws_role_arn: Optional[str] = pydantic.Field(
214
+ default=None,
215
+ description="ARN of the role to be assumed for execution on your Braket account.",
94
216
  )
95
- job_timeout: pydantic_backend.PydanticExecutionTimeout = pydantic.Field(
96
- description="Timeout for Jobs sent for execution in seconds.",
97
- default=AWS_DEFAULT_JOB_TIMEOUT_SECONDS,
217
+ s3_bucket_name: Optional[str] = pydantic.Field(
218
+ default=None, description="S3 Bucket Name"
219
+ )
220
+ s3_folder: Optional[str] = pydantic.Field(
221
+ default=None, description="S3 Folder Path Within The S3 Bucket"
222
+ )
223
+ run_through_classiq: bool = pydantic.Field(
224
+ default=False,
225
+ description="Run through Classiq's credentials while using user's allocated budget.",
98
226
  )
99
227
 
100
- @validator("s3_bucket_name")
101
- def _validate_s3_bucket_name(
102
- cls, s3_bucket_name: str, values: Dict[str, Any]
103
- ) -> str:
104
- s3_bucket_name = s3_bucket_name.strip()
105
- if not s3_bucket_name.startswith("amazon-braket-"):
106
- raise ValueError('S3 bucket name should start with "amazon-braket-"')
107
- return s3_bucket_name
108
228
 
109
- @pydantic.root_validator(pre=True)
110
- def _set_backend_service_provider(cls, values: Dict[str, Any]) -> Dict[str, Any]:
111
- return values_with_discriminator(
112
- values, "backend_service_provider", ProviderVendor.AMAZON_BRAKET
113
- )
229
+ class IBMBackendProvider(BaseModel):
230
+ """
114
231
 
232
+ Represents the provider specs for identifying an IBM Quantum backend.
233
+
234
+ Attributes:
235
+ hub (str): hub parameter of IBM Quantum provider. Defaults to `"ibm-q"`.
236
+ group (str): group parameter of IBM Quantum provider. Defaults to `"open"`.
237
+ project (str): project parameter of IBM Quantum provider. Defaults to `"main"`.
238
+
239
+ """
115
240
 
116
- class IBMBackendProvider(BaseModel):
117
241
  hub: str = "ibm-q"
118
242
  group: str = "open"
119
243
  project: str = "main"
120
244
 
121
245
 
122
246
  class IBMBackendPreferences(BackendPreferences):
123
- backend_service_provider: ProviderTypeVendor.IBM_QUANTUM
247
+ """
248
+ Represents the backend preferences specific to IBM Quantum services.
249
+
250
+ Inherits from `BackendPreferences` and adds additional fields and validations
251
+ specific to IBM Quantum backends.
252
+
253
+ Attributes:
254
+ backend_service_provider (ProviderTypeVendor.IBM_QUANTUM): Indicates the backend service provider as IBM Quantum.
255
+ access_token (Optional[str]): The IBM Quantum access token to be used with IBM Quantum hosted backends. Defaults to `None`.
256
+ provider (IBMBackendProvider): Specifications for identifying a single IBM Quantum provider. Defaults to a new `IBMBackendProvider`.
257
+ qctrl_api_key (Optional[str]): QCTRL API key to access QCTRL optimization abilities.
258
+ run_through_classiq (bool): Run through Classiq's credentials. Defaults to `False`.
259
+
260
+ See examples in the [IBM Quantum Backend Documentation](https://docs.classiq.io/latest/reference-manual/executor/cloud-providers/ibm-backends/?h=).
261
+ """
262
+
263
+ backend_service_provider: ProviderTypeVendor.IBM_QUANTUM = pydantic.Field(
264
+ default=ProviderVendor.IBM_QUANTUM
265
+ )
124
266
  access_token: Optional[str] = pydantic.Field(
125
267
  default=None,
126
268
  description="IBM Quantum access token to be used"
@@ -130,15 +272,28 @@ class IBMBackendPreferences(BackendPreferences):
130
272
  default_factory=IBMBackendProvider,
131
273
  description="Provider specs. for identifying a single IBM Quantum provider.",
132
274
  )
275
+ qctrl_api_key: Optional[str] = pydantic.Field(
276
+ default=None,
277
+ description="QCTRL API key to access QCTRL optimization abilities",
278
+ )
279
+ run_through_classiq: bool = pydantic.Field(
280
+ default=False,
281
+ description="Run through Classiq's credentials",
282
+ )
283
+
133
284
 
134
- @pydantic.root_validator(pre=True)
135
- def _set_backend_service_provider(cls, values: Dict[str, Any]) -> Dict[str, Any]:
136
- return values_with_discriminator(
137
- values, "backend_service_provider", ProviderVendor.IBM_QUANTUM
138
- )
285
+ class AzureCredential(BaseSettings):
286
+ """
287
+ Represents the credentials and configuration required to authenticate with Azure services.
139
288
 
289
+ Attributes:
290
+ tenant_id (str): Azure Tenant ID used to identify the directory in which the application is registered.
291
+ client_id (str): Azure Client ID, also known as the application ID, which is used to authenticate the application.
292
+ client_secret (str): Azure Client Secret associated with the application, used for authentication.
293
+ resource_id (pydantic_backend.PydanticAzureResourceIDType): Azure Resource ID, including the subscription ID,
294
+ resource group, and workspace, typically used for personal resources.
295
+ """
140
296
 
141
- class AzureCredential(pydantic.BaseSettings):
142
297
  tenant_id: str = pydantic.Field(description="Azure Tenant ID")
143
298
  client_id: str = pydantic.Field(description="Azure Client ID")
144
299
  client_secret: str = pydantic.Field(description="Azure Client Secret")
@@ -146,15 +301,39 @@ class AzureCredential(pydantic.BaseSettings):
146
301
  description="Azure Resource ID (including Azure subscription ID, resource "
147
302
  "group and workspace), for personal resource",
148
303
  )
304
+ model_config = SettingsConfigDict(
305
+ title="Azure Service Principal Credential",
306
+ env_prefix="AZURE_",
307
+ case_sensitive=False,
308
+ extra="allow",
309
+ )
149
310
 
150
- class Config:
151
- title = "Azure Service Principal Credential"
152
- env_prefix = "AZURE_"
153
- case_sensitive = False
311
+ def __init__(self, **data: Any) -> None:
312
+ initial_data = {
313
+ field: data[field] for field in data if field in self.model_fields
314
+ }
315
+ super().__init__(**data)
316
+ for field, value in initial_data.items():
317
+ setattr(self, field, value)
154
318
 
155
319
 
156
320
  class AzureBackendPreferences(BackendPreferences):
157
- backend_service_provider: ProviderTypeVendor.AZURE_QUANTUM
321
+ """
322
+ This class inherits from BackendPreferences.
323
+ This is where you specify Azure Quantum preferences.
324
+ See usage in the [Azure Backend Documentation](https://docs.classiq.io/latest/reference-manual/executor/cloud-providers/azure-backends/).
325
+
326
+ Attributes:
327
+ location (str): Azure personal resource region. Defaults to `"East US"`.
328
+ credentials (Optional[AzureCredential]): The service principal credential to access personal quantum workspace. Defaults to `None`.
329
+ ionq_error_mitigation_flag (Optional[bool]): Error mitigation configuration upon running on IonQ through Azure. Defaults to `False`.
330
+
331
+
332
+ """
333
+
334
+ backend_service_provider: ProviderTypeVendor.AZURE_QUANTUM = pydantic.Field(
335
+ default=ProviderVendor.AZURE_QUANTUM
336
+ )
158
337
 
159
338
  location: str = pydantic.Field(
160
339
  default="East US", description="Azure personal resource region"
@@ -165,53 +344,151 @@ class AzureBackendPreferences(BackendPreferences):
165
344
  description="The service principal credential to access personal quantum workspace",
166
345
  )
167
346
 
347
+ ionq_error_mitigation_flag: Optional[bool] = pydantic.Field(
348
+ default=False,
349
+ description="Error mitigation configuration upon running on IonQ through Azure.",
350
+ )
351
+
168
352
  @property
169
353
  def run_through_classiq(self) -> bool:
170
- return self.credentials is None
354
+ """
355
+
356
+ Returns: `True` if there are no Azure Credentials.
357
+ Therefore you will be running through Classiq's credentials.
171
358
 
172
- @pydantic.root_validator(pre=True)
173
- def _set_backend_service_provider(cls, values: Dict[str, Any]) -> Dict[str, Any]:
174
- return values_with_discriminator(
175
- values, "backend_service_provider", ProviderVendor.AZURE_QUANTUM
176
- )
359
+ """
360
+ return self.credentials is None
177
361
 
178
362
 
179
363
  class IonqBackendPreferences(BackendPreferences):
180
- backend_service_provider: ProviderTypeVendor.IONQ
181
- api_key: pydantic_backend.PydanticIonQApiKeyType = pydantic.Field(
182
- ..., description="IonQ API key"
183
- )
364
+ """
365
+ Represents the backend preferences specific to IonQ services.
366
+
367
+ Inherits from `BackendPreferences` and adds additional fields and configurations
368
+ specific to IonQ backends
184
369
 
185
- @pydantic.root_validator(pre=True)
186
- def _set_backend_service_provider(cls, values: Dict[str, Any]) -> Dict[str, Any]:
187
- return values_with_discriminator(
188
- values, "backend_service_provider", ProviderVendor.IONQ
189
- )
370
+ Attributes:
371
+ backend_service_provider (ProviderTypeVendor.IONQ): Indicates the backend service provider as IonQ.
372
+ api_key (PydanticIonQApiKeyType): The IonQ API key required for accessing IonQ's quantum computing services.
373
+ error_mitigation (bool): A configuration option to enable or disable error mitigation during execution. Defaults to `False`.
374
+ run_through_classiq (bool): Running through Classiq's credentials while using user's allocated budget.
375
+
376
+ See examples in the [IonQ Backend Documentation](https://docs.classiq.io/latest/reference-manual/executor/cloud-providers/ionq-backends/?h=).
377
+ """
378
+
379
+ backend_service_provider: ProviderTypeVendor.IONQ = pydantic.Field(
380
+ default=ProviderVendor.IONQ
381
+ )
382
+ api_key: Optional[pydantic_backend.PydanticIonQApiKeyType] = pydantic.Field(
383
+ default=None, description="IonQ API key"
384
+ )
385
+ error_mitigation: bool = pydantic.Field(
386
+ default=False,
387
+ description="Error mitigation configuration.",
388
+ )
389
+ run_through_classiq: bool = pydantic.Field(
390
+ default=False,
391
+ description="Running through Classiq's credentials while using user's allocated budget.",
392
+ )
190
393
 
191
394
 
192
395
  class GCPBackendPreferences(BackendPreferences):
193
- backend_service_provider: ProviderTypeVendor.GOOGLE
396
+ """
397
+ Represents the backend preferences specific to Google Cloud Platform (GCP) services.
398
+
399
+ Inherits from `BackendPreferences` and sets the backend service provider to Google.
400
+
401
+ Attributes:
402
+ backend_service_provider (ProviderTypeVendor.GOOGLE): Indicates the backend service provider as Google,
403
+ specifically for quantum computing services on Google Cloud Platform (GCP).
194
404
 
195
- @pydantic.root_validator(pre=True)
196
- def _set_backend_service_provider(cls, values: Dict[str, Any]) -> Dict[str, Any]:
197
- return values_with_discriminator(
198
- values, "backend_service_provider", ProviderVendor.GOOGLE
199
- )
405
+ See examples in the [Google Cloud Backend Documentation](https://docs.classiq.io/latest/reference-manual/executor/cloud-providers/google-backends/?h=).
406
+ """
407
+
408
+ backend_service_provider: ProviderTypeVendor.GOOGLE = pydantic.Field(
409
+ default=ProviderVendor.GOOGLE
410
+ )
200
411
 
201
412
  def is_nvidia_backend(self) -> bool:
202
413
  return True
203
414
 
204
415
 
205
416
  class OQCBackendPreferences(BackendPreferences):
206
- backend_service_provider: ProviderTypeVendor.OQC
417
+ """
418
+
419
+ This class inherits from `BackendPreferences`.
420
+ This is where you specify OQC preferences.
421
+
422
+ Attributes:
423
+ username (str): OQC username
424
+ password (str): OQC password
425
+ """
426
+
427
+ backend_service_provider: ProviderTypeVendor.OQC = pydantic.Field(
428
+ default=ProviderVendor.OQC
429
+ )
207
430
  username: str = pydantic.Field(description="OQC username")
208
431
  password: str = pydantic.Field(description="OQC password")
209
432
 
210
- @pydantic.root_validator(pre=True)
211
- def _set_backend_service_provider(cls, values: Dict[str, Any]) -> Dict[str, Any]:
212
- return values_with_discriminator(
213
- values, "backend_service_provider", ProviderVendor.OQC
214
- )
433
+
434
+ class IntelBackendPreferences(BackendPreferences):
435
+ """
436
+ Represents backend preferences specific to Classiq quantum computing targets.
437
+
438
+ This class is used to configure the backend options for executing quantum circuits on Classiq's platform.
439
+ The relevant backend names for Classiq targets are specified in `ClassiqSimulatorBackendNames` & `ClassiqNvidiaBackendNames`.
440
+
441
+ For more details, refer to the [Classiq Backend Documentation](https://docs.classiq.io/latest/reference-manual/executor/cloud-providers/classiq-backends/).
442
+ """
443
+
444
+ backend_service_provider: ProviderTypeVendor.INTEL = pydantic.Field(
445
+ default=ProviderVendor.INTEL
446
+ )
447
+
448
+
449
+ class AQTBackendPreferences(BackendPreferences):
450
+ """
451
+ NOTE: This is a work in progress and is subject to change.
452
+
453
+ Represents the backend preferences specific to AQT (Alpine Quantum Technologies).
454
+
455
+ Attributes:
456
+ api_key: The API key required to access AQT's quantum computing services.
457
+ workspace: The AQT workspace where the simulator/hardware is located.
458
+ """
459
+
460
+ backend_service_provider: ProviderTypeVendor.AQT = pydantic.Field(
461
+ default=ProviderVendor.AQT
462
+ )
463
+ api_key: str = pydantic.Field(description="AQT API key")
464
+ workspace: str = pydantic.Field(description="AQT workspace")
465
+
466
+
467
+ class IQCCBackendPreferences(BackendPreferences):
468
+ """
469
+ NOTE: This is a work in progress and is subject to change.
470
+
471
+ Represents the backend preferences specific to IQCC (Israeli Quantum Computing
472
+ Center).
473
+
474
+ Attributes:
475
+ auth_token: The authorization token generated by calling `generate_iqcc_token`.
476
+ target_id: The target ID of the login node.
477
+ target_scope_id: The scope ID of the specified target.
478
+ ssh_user_name: The user name to use when connecting to the SSH server on the login node.
479
+ ssh_key: The private key to use when connecting to the SSH server on the login node.
480
+ slurm_account: The account to use when initiating SLURM jobs.
481
+ """
482
+
483
+ backend_service_provider: ProviderTypeVendor.IQCC = pydantic.Field(
484
+ default=ProviderVendor.IQCC
485
+ )
486
+ auth_token: str
487
+ target_id: str
488
+ target_scope_id: str
489
+ ssh_user_name: str
490
+ ssh_key: str
491
+ slurm_account: str
215
492
 
216
493
 
217
494
  def is_exact_simulator(backend_preferences: BackendPreferences) -> bool:
@@ -219,13 +496,13 @@ def is_exact_simulator(backend_preferences: BackendPreferences) -> bool:
219
496
 
220
497
 
221
498
  def default_backend_preferences(
222
- backend_name: str = ClassiqAerBackendNames.AER_SIMULATOR,
499
+ backend_name: str = ClassiqSimulatorBackendNames.SIMULATOR,
223
500
  ) -> BackendPreferences:
224
501
  return ClassiqBackendPreferences(backend_name=backend_name)
225
502
 
226
503
 
227
504
  def backend_preferences_field(
228
- backend_name: str = ClassiqAerBackendNames.AER_SIMULATOR,
505
+ backend_name: str = ClassiqSimulatorBackendNames.SIMULATOR,
229
506
  ) -> Any:
230
507
  return pydantic.Field(
231
508
  default_factory=lambda: default_backend_preferences(backend_name),
@@ -243,37 +520,31 @@ BackendPreferencesTypes = Union[
243
520
  GCPBackendPreferences,
244
521
  AliceBobBackendPreferences,
245
522
  OQCBackendPreferences,
523
+ IntelBackendPreferences,
524
+ AQTBackendPreferences,
525
+ IQCCBackendPreferences,
246
526
  ]
247
527
 
248
528
  __all__ = [
529
+ "AQTBackendPreferences",
530
+ "AliceBobBackendNames",
531
+ "AliceBobBackendPreferences",
532
+ "AmazonBraketBackendNames",
533
+ "AwsBackendPreferences",
249
534
  "AzureBackendPreferences",
250
535
  "AzureCredential",
251
536
  "AzureQuantumBackendNames",
252
537
  "ClassiqBackendPreferences",
253
- "ClassiqAerBackendNames",
538
+ "ClassiqNvidiaBackendNames",
539
+ "ClassiqSimulatorBackendNames",
540
+ "GCPBackendPreferences",
254
541
  "IBMBackendPreferences",
255
542
  "IBMBackendProvider",
256
- "AwsBackendPreferences",
257
- "AmazonBraketBackendNames",
258
- "IonqBackendPreferences",
543
+ "IQCCBackendPreferences",
544
+ "IntelBackendNames",
545
+ "IntelBackendPreferences",
259
546
  "IonqBackendNames",
260
- "ClassiqNvidiaBackendNames",
261
- "GCPBackendPreferences",
262
- "AliceBobBackendPreferences",
263
- "AliceBobBackendNames",
264
- "OQCBackendPreferences",
547
+ "IonqBackendPreferences",
265
548
  "OQCBackendNames",
549
+ "OQCBackendPreferences",
266
550
  ]
267
-
268
-
269
- def validate_backend_service_provider(backend_service_provider: Any) -> Provider:
270
- if isinstance(backend_service_provider, Provider):
271
- return backend_service_provider
272
- if isinstance(backend_service_provider, str):
273
- for member in Provider:
274
- if member.lower() == backend_service_provider.lower():
275
- return Provider(member)
276
- raise ValueError(
277
- f"""Vendor {backend_service_provider} is not supported.
278
- The supported providers are {', '.join(Provider)}."""
279
- )