classiq 0.92.0__py3-none-any.whl → 0.94.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.

Potentially problematic release.


This version of classiq might be problematic. Click here for more details.

Files changed (264) hide show
  1. classiq/__init__.py +6 -19
  2. classiq/_analyzer_extras/_ipywidgets_async_extension.py +7 -7
  3. classiq/_analyzer_extras/interactive_hardware.py +19 -12
  4. classiq/_internals/api_wrapper.py +38 -52
  5. classiq/_internals/async_utils.py +4 -7
  6. classiq/_internals/authentication/auth0.py +3 -3
  7. classiq/_internals/authentication/device.py +4 -4
  8. classiq/_internals/authentication/password_manager.py +13 -13
  9. classiq/_internals/authentication/token_manager.py +4 -5
  10. classiq/_internals/client.py +17 -44
  11. classiq/_internals/config.py +1 -2
  12. classiq/_internals/help.py +1 -2
  13. classiq/_internals/host_checker.py +3 -3
  14. classiq/_internals/jobs.py +14 -14
  15. classiq/_internals/type_validation.py +3 -3
  16. classiq/analyzer/analyzer.py +18 -18
  17. classiq/analyzer/rb.py +17 -8
  18. classiq/applications/chemistry/__init__.py +0 -30
  19. classiq/applications/chemistry/op_utils.py +4 -4
  20. classiq/applications/chemistry/problems.py +3 -3
  21. classiq/applications/chemistry/ucc.py +1 -2
  22. classiq/applications/chemistry/z2_symmetries.py +4 -4
  23. classiq/applications/combinatorial_helpers/allowed_constraints.py +1 -3
  24. classiq/applications/combinatorial_helpers/arithmetic/arithmetic_expression.py +2 -1
  25. classiq/applications/combinatorial_helpers/combinatorial_problem_utils.py +2 -2
  26. classiq/applications/combinatorial_helpers/encoding_mapping.py +2 -3
  27. classiq/applications/combinatorial_helpers/encoding_utils.py +2 -2
  28. classiq/applications/combinatorial_helpers/optimization_model.py +3 -4
  29. classiq/applications/combinatorial_helpers/pauli_helpers/pauli_sparsing.py +2 -2
  30. classiq/applications/combinatorial_helpers/pyomo_utils.py +8 -8
  31. classiq/applications/combinatorial_helpers/sympy_utils.py +1 -3
  32. classiq/applications/combinatorial_helpers/transformations/encoding.py +3 -3
  33. classiq/applications/combinatorial_helpers/transformations/fixed_variables.py +1 -2
  34. classiq/applications/combinatorial_optimization/combinatorial_optimization_config.py +2 -3
  35. classiq/applications/combinatorial_optimization/combinatorial_optimization_model_constructor.py +4 -6
  36. classiq/applications/combinatorial_optimization/combinatorial_problem.py +15 -10
  37. classiq/applications/hamiltonian/pauli_decomposition.py +6 -4
  38. classiq/applications/iqae/iqae.py +8 -8
  39. classiq/applications/qnn/datasets/dataset_base_classes.py +6 -6
  40. classiq/applications/qnn/datasets/dataset_parity.py +6 -6
  41. classiq/applications/qnn/qlayer.py +8 -7
  42. classiq/applications/qnn/torch_utils.py +3 -4
  43. classiq/applications/qnn/types.py +2 -1
  44. classiq/applications/qsp/qsp.py +6 -5
  45. classiq/applications/qsvm/qsvm_data_generation.py +1 -2
  46. classiq/evaluators/classical_expression.py +0 -4
  47. classiq/evaluators/parameter_types.py +17 -12
  48. classiq/evaluators/qmod_annotated_expression.py +24 -26
  49. classiq/evaluators/qmod_expression_visitors/qmod_expression_evaluator.py +14 -14
  50. classiq/evaluators/qmod_expression_visitors/qmod_expression_simplifier.py +2 -1
  51. classiq/evaluators/qmod_expression_visitors/sympy_wrappers.py +8 -8
  52. classiq/evaluators/qmod_node_evaluators/classical_function_evaluation.py +4 -4
  53. classiq/evaluators/qmod_node_evaluators/list_evaluation.py +2 -2
  54. classiq/evaluators/qmod_node_evaluators/numeric_attrs_utils.py +3 -3
  55. classiq/evaluators/qmod_node_evaluators/subscript_evaluation.py +9 -9
  56. classiq/evaluators/qmod_node_evaluators/utils.py +6 -6
  57. classiq/evaluators/qmod_type_inference/classical_type_inference.py +9 -10
  58. classiq/evaluators/qmod_type_inference/quantum_type_inference.py +5 -5
  59. classiq/execution/execution_session.py +18 -19
  60. classiq/execution/jobs.py +26 -26
  61. classiq/execution/qnn.py +1 -2
  62. classiq/execution/user_budgets.py +52 -7
  63. classiq/executor.py +1 -3
  64. classiq/interface/_version.py +1 -1
  65. classiq/interface/analyzer/analysis_params.py +4 -4
  66. classiq/interface/analyzer/cytoscape_graph.py +3 -3
  67. classiq/interface/analyzer/result.py +4 -4
  68. classiq/interface/applications/qsvm.py +5 -8
  69. classiq/interface/ast_node.py +3 -3
  70. classiq/interface/backend/backend_preferences.py +16 -16
  71. classiq/interface/backend/ionq/ionq_quantum_program.py +5 -5
  72. classiq/interface/chemistry/ansatz_library.py +3 -5
  73. classiq/interface/chemistry/operator.py +3 -3
  74. classiq/interface/combinatorial_optimization/examples/knapsack.py +2 -4
  75. classiq/interface/combinatorial_optimization/examples/tsp_digraph.py +1 -2
  76. classiq/interface/compression_utils.py +2 -3
  77. classiq/interface/debug_info/debug_info.py +7 -7
  78. classiq/interface/exceptions.py +6 -3
  79. classiq/interface/execution/iqcc.py +1 -3
  80. classiq/interface/execution/primitives.py +6 -6
  81. classiq/interface/executor/estimate_cost.py +1 -1
  82. classiq/interface/executor/execution_preferences.py +3 -5
  83. classiq/interface/executor/execution_request.py +10 -10
  84. classiq/interface/executor/execution_result.py +1 -2
  85. classiq/interface/executor/quantum_code.py +8 -8
  86. classiq/interface/executor/result.py +28 -18
  87. classiq/interface/executor/user_budget.py +2 -3
  88. classiq/interface/executor/vqe_result.py +5 -6
  89. classiq/interface/generator/ansatz_library.py +6 -8
  90. classiq/interface/generator/application_apis/__init__.py +0 -2
  91. classiq/interface/generator/arith/arithmetic.py +2 -2
  92. classiq/interface/generator/arith/arithmetic_arg_type_validator.py +2 -3
  93. classiq/interface/generator/arith/arithmetic_expression_abc.py +4 -5
  94. classiq/interface/generator/arith/arithmetic_expression_parser.py +11 -4
  95. classiq/interface/generator/arith/arithmetic_expression_validator.py +12 -15
  96. classiq/interface/generator/arith/arithmetic_operations.py +4 -6
  97. classiq/interface/generator/arith/arithmetic_param_getters.py +70 -107
  98. classiq/interface/generator/arith/arithmetic_result_builder.py +4 -4
  99. classiq/interface/generator/arith/ast_node_rewrite.py +8 -4
  100. classiq/interface/generator/arith/binary_ops.py +7 -36
  101. classiq/interface/generator/arith/logical_ops.py +2 -3
  102. classiq/interface/generator/arith/number_utils.py +2 -2
  103. classiq/interface/generator/arith/register_user_input.py +2 -2
  104. classiq/interface/generator/arith/unary_ops.py +2 -2
  105. classiq/interface/generator/circuit_code/circuit_code.py +8 -10
  106. classiq/interface/generator/circuit_code/types_and_constants.py +1 -1
  107. classiq/interface/generator/complex_type.py +2 -2
  108. classiq/interface/generator/copy.py +1 -3
  109. classiq/interface/generator/expressions/atomic_expression_functions.py +0 -5
  110. classiq/interface/generator/expressions/evaluated_expression.py +2 -3
  111. classiq/interface/generator/expressions/expression.py +2 -2
  112. classiq/interface/generator/expressions/proxies/classical/classical_array_proxy.py +4 -7
  113. classiq/interface/generator/function_param_list.py +0 -20
  114. classiq/interface/generator/function_params.py +5 -6
  115. classiq/interface/generator/functions/classical_function_declaration.py +2 -2
  116. classiq/interface/generator/functions/classical_type.py +3 -3
  117. classiq/interface/generator/functions/type_modifier.py +0 -14
  118. classiq/interface/generator/functions/type_name.py +2 -2
  119. classiq/interface/generator/generated_circuit_data.py +12 -13
  120. classiq/interface/generator/hamiltonian_evolution/exponentiation.py +2 -4
  121. classiq/interface/generator/hardware/hardware_data.py +8 -8
  122. classiq/interface/generator/hardware_efficient_ansatz.py +8 -8
  123. classiq/interface/generator/mcu.py +3 -3
  124. classiq/interface/generator/mcx.py +3 -3
  125. classiq/interface/generator/model/constraints.py +34 -5
  126. classiq/interface/generator/model/preferences/preferences.py +15 -21
  127. classiq/interface/generator/model/quantum_register.py +7 -10
  128. classiq/interface/generator/noise_properties.py +3 -7
  129. classiq/interface/generator/parameters.py +1 -1
  130. classiq/interface/generator/partitioned_register.py +1 -2
  131. classiq/interface/generator/preferences/qasm_to_qmod_params.py +11 -0
  132. classiq/interface/generator/qsvm.py +2 -2
  133. classiq/interface/generator/quantum_function_call.py +8 -11
  134. classiq/interface/generator/quantum_program.py +12 -15
  135. classiq/interface/generator/range_types.py +3 -3
  136. classiq/interface/generator/slice_parsing_utils.py +4 -5
  137. classiq/interface/generator/standard_gates/standard_gates.py +2 -4
  138. classiq/interface/generator/state_preparation/state_preparation.py +6 -8
  139. classiq/interface/generator/synthesis_execution_parameter.py +1 -3
  140. classiq/interface/generator/synthesis_metadata/synthesis_execution_data.py +2 -3
  141. classiq/interface/generator/transpiler_basis_gates.py +2 -4
  142. classiq/interface/generator/types/builtin_enum_declarations.py +0 -136
  143. classiq/interface/generator/types/compilation_metadata.py +12 -1
  144. classiq/interface/generator/types/enum_declaration.py +2 -1
  145. classiq/interface/generator/validations/flow_graph.py +3 -3
  146. classiq/interface/generator/visitor.py +10 -12
  147. classiq/interface/hardware.py +2 -2
  148. classiq/interface/helpers/classproperty.py +2 -2
  149. classiq/interface/helpers/custom_encoders.py +2 -1
  150. classiq/interface/helpers/custom_pydantic_types.py +1 -1
  151. classiq/interface/helpers/text_utils.py +1 -4
  152. classiq/interface/ide/visual_model.py +5 -5
  153. classiq/interface/jobs.py +3 -3
  154. classiq/interface/model/allocate.py +4 -4
  155. classiq/interface/model/block.py +2 -2
  156. classiq/interface/model/bounds.py +3 -3
  157. classiq/interface/model/control.py +1 -1
  158. classiq/interface/model/inplace_binary_operation.py +2 -2
  159. classiq/interface/model/model.py +4 -4
  160. classiq/interface/model/parameter.py +1 -3
  161. classiq/interface/model/port_declaration.py +1 -1
  162. classiq/interface/model/quantum_expressions/quantum_expression.py +1 -2
  163. classiq/interface/model/quantum_function_call.py +3 -6
  164. classiq/interface/model/quantum_function_declaration.py +1 -0
  165. classiq/interface/model/quantum_lambda_function.py +4 -4
  166. classiq/interface/model/quantum_statement.py +4 -4
  167. classiq/interface/model/quantum_type.py +14 -14
  168. classiq/interface/model/validation_handle.py +2 -3
  169. classiq/interface/model/variable_declaration_statement.py +2 -2
  170. classiq/interface/pretty_print/expression_to_qmod.py +3 -4
  171. classiq/interface/server/routes.py +0 -4
  172. classiq/interface/source_reference.py +3 -4
  173. classiq/model_expansions/arithmetic.py +6 -7
  174. classiq/model_expansions/arithmetic_compute_result_attrs.py +4 -5
  175. classiq/model_expansions/capturing/captured_vars.py +3 -3
  176. classiq/model_expansions/capturing/mangling_utils.py +1 -2
  177. classiq/model_expansions/closure.py +12 -11
  178. classiq/model_expansions/function_builder.py +14 -6
  179. classiq/model_expansions/generative_functions.py +1 -4
  180. classiq/model_expansions/interpreters/base_interpreter.py +2 -6
  181. classiq/model_expansions/interpreters/generative_interpreter.py +8 -4
  182. classiq/model_expansions/quantum_operations/allocate.py +4 -4
  183. classiq/model_expansions/quantum_operations/assignment_result_processor.py +8 -4
  184. classiq/model_expansions/quantum_operations/call_emitter.py +31 -37
  185. classiq/model_expansions/quantum_operations/declarative_call_emitter.py +2 -2
  186. classiq/model_expansions/quantum_operations/emitter.py +3 -5
  187. classiq/model_expansions/quantum_operations/expression_evaluator.py +3 -3
  188. classiq/model_expansions/quantum_operations/skip_control_verifier.py +1 -2
  189. classiq/model_expansions/quantum_operations/variable_decleration.py +61 -29
  190. classiq/model_expansions/scope.py +7 -7
  191. classiq/model_expansions/scope_initialization.py +4 -0
  192. classiq/model_expansions/visitors/symbolic_param_inference.py +3 -3
  193. classiq/model_expansions/visitors/uncomputation_signature_inference.py +317 -0
  194. classiq/model_expansions/visitors/variable_references.py +15 -14
  195. classiq/open_library/functions/__init__.py +6 -0
  196. classiq/open_library/functions/discrete_sine_cosine_transform.py +19 -14
  197. classiq/open_library/functions/grover.py +8 -10
  198. classiq/open_library/functions/modular_exponentiation.py +96 -8
  199. classiq/qmod/__init__.py +5 -2
  200. classiq/qmod/builtins/classical_execution_primitives.py +4 -11
  201. classiq/qmod/builtins/classical_functions.py +1 -42
  202. classiq/qmod/builtins/enums.py +0 -136
  203. classiq/qmod/builtins/functions/__init__.py +0 -13
  204. classiq/qmod/builtins/functions/allocation.py +4 -4
  205. classiq/qmod/builtins/functions/arithmetic.py +22 -27
  206. classiq/qmod/builtins/functions/standard_gates.py +27 -27
  207. classiq/qmod/builtins/operations.py +43 -58
  208. classiq/qmod/builtins/structs.py +2 -58
  209. classiq/qmod/cfunc.py +3 -2
  210. classiq/qmod/classical_function.py +2 -1
  211. classiq/qmod/classical_variable.py +4 -2
  212. classiq/qmod/cparam.py +2 -8
  213. classiq/qmod/create_model_function.py +7 -7
  214. classiq/qmod/declaration_inferrer.py +33 -30
  215. classiq/qmod/model_state_container.py +2 -2
  216. classiq/qmod/native/pretty_printer.py +25 -14
  217. classiq/qmod/pretty_print/expression_to_python.py +5 -3
  218. classiq/qmod/pretty_print/pretty_printer.py +39 -17
  219. classiq/qmod/python_classical_type.py +40 -13
  220. classiq/qmod/qfunc.py +139 -16
  221. classiq/qmod/qmod_constant.py +2 -2
  222. classiq/qmod/qmod_parameter.py +5 -2
  223. classiq/qmod/qmod_variable.py +47 -43
  224. classiq/qmod/quantum_callable.py +18 -13
  225. classiq/qmod/quantum_expandable.py +33 -26
  226. classiq/qmod/quantum_function.py +51 -32
  227. classiq/qmod/semantics/annotation/call_annotation.py +2 -2
  228. classiq/qmod/semantics/error_manager.py +5 -6
  229. classiq/qmod/semantics/lambdas.py +1 -2
  230. classiq/qmod/semantics/validation/types_validation.py +1 -2
  231. classiq/qmod/symbolic.py +2 -4
  232. classiq/qmod/symbolic_expr.py +12 -4
  233. classiq/qmod/utilities.py +13 -10
  234. classiq/qmod/write_qmod.py +3 -4
  235. classiq/quantum_program.py +1 -3
  236. classiq/synthesis.py +11 -7
  237. {classiq-0.92.0.dist-info → classiq-0.94.0.dist-info}/METADATA +38 -37
  238. {classiq-0.92.0.dist-info → classiq-0.94.0.dist-info}/RECORD +240 -261
  239. classiq-0.94.0.dist-info/WHEEL +4 -0
  240. classiq-0.94.0.dist-info/licenses/LICENSE.txt +27 -0
  241. classiq/applications/chemistry/ansatz_parameters.py +0 -29
  242. classiq/applications/chemistry/chemistry_execution_parameters.py +0 -16
  243. classiq/applications/chemistry/chemistry_model_constructor.py +0 -532
  244. classiq/applications/chemistry/ground_state_problem.py +0 -42
  245. classiq/evaluators/qmod_expression_visitors/qmod_expression_bwc.py +0 -129
  246. classiq/interface/chemistry/elements.py +0 -120
  247. classiq/interface/chemistry/fermionic_operator.py +0 -208
  248. classiq/interface/chemistry/ground_state_problem.py +0 -132
  249. classiq/interface/chemistry/ground_state_result.py +0 -8
  250. classiq/interface/chemistry/molecule.py +0 -71
  251. classiq/interface/generator/application_apis/chemistry_declarations.py +0 -69
  252. classiq/interface/generator/application_apis/entangler_declarations.py +0 -29
  253. classiq/interface/generator/chemistry_function_params.py +0 -50
  254. classiq/interface/generator/entangler_params.py +0 -72
  255. classiq/interface/generator/entanglers.py +0 -14
  256. classiq/interface/generator/hartree_fock.py +0 -26
  257. classiq/interface/generator/hva.py +0 -22
  258. classiq/interface/generator/linear_pauli_rotations.py +0 -92
  259. classiq/interface/generator/qft.py +0 -37
  260. classiq/interface/generator/ucc.py +0 -74
  261. classiq/interface/helpers/backward_compatibility.py +0 -9
  262. classiq/model_expansions/transformers/type_modifier_inference.py +0 -392
  263. classiq/qmod/builtins/functions/chemistry.py +0 -123
  264. classiq-0.92.0.dist-info/WHEEL +0 -4
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.8.15
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,27 @@
1
+ LICENSE AGREEMENT
2
+
3
+ By clicking the "accept" or "ok" button and/or by using the Software (as defined below) you expressly acknowledge and agree that you, on behalf of yourself or your organization ("Licensee", "you"), are entering into a legal agreement with Classiq Technologies Ltd., a company incorporated under the laws of the State of Israel having its principal place of business at 3 Daniel Frisch Street, Tel Aviv-Yafo, Israel ("Classiq") (each, a "Party" and collectively, the "Parties"), and have understood and agree to comply with, and be legally bound by, the terms and conditions of this Evaluation Agreement ("Agreement"). You hereby waive any applicable rights to require an original (non-electronic) signature or delivery or retention of non-electronic records, to the extent not prohibited under applicable law. If you do not agree to be bound by this Agreement, please do not use the Software.
4
+
5
+ 1. License.
6
+
7
+ 1.1. Subject to the terms of this Agreement, Classiq grants Licensee a limited, nonexclusive, non-assignable and nontransferable, fully revocable license to install, access and use Classiq's quantum algorithm design platform ("Software"), during the Evaluation Period (as defined below), solely for internal evaluation purposes ("Evaluation License"). Notwithstanding anything to the contrary, Classiq may, at its sole discretion, deny access to the Software or part thereof at any time.
8
+
9
+ 1.2. During the Evaluation Period, Licensee may allow its employees who are explicitly authorized by Licensee to use the Software, solely for the Licensee's evaluation of the Software (each, a "Permitted User"). Each Permitted User shall be bound by the terms and conditions in writing at least as restrictive as those contained in this Agreement and Licensee shall be liable for any breach of the terms of this Agreement by a Permitted User. Licensee shall immediately report any unauthorized access or use of the Software to Classiq. During the Evaluation Period, Classiq may collect, record and save information about Permitted Users' use and interaction with the Software, for the purposes of improving Classiq's services to you in relation to your use of the Software ("Interaction Information"). Subject to the terms of this Section 1.2, Classiq shall destroy all Interaction Information at the expiry or termination of this Agreement. Notwithstanding anything to the contrary, Classiq may save, store and retain Interaction Information for internal purposes such as (but not limited to) improving or developing products, provision of services to all clients and collaborating with partners, provided that such Interaction Information is aggregated and anonymized ("Anonymized Aggregated Information"). Classiq shall not be required to destroy any Anonymized Aggregated Information at the expiry or termination of this Agreement. Licensee represents and warrants that it has obtained the necessary consents from each Permitted User to allow Classiq to collect record and save the Interaction Information and to retain the Anonymized Aggregated Information in accordance with this Section 1.2.
10
+
11
+ 2. Title and Ownership. Other than the Evaluation License granted under this Agreement to Licensee during the Evaluation Period, all intellectual property rights, ownership rights, and proprietary rights in and to: (a) the Software, including any and all derivatives, updates, upgrades, changes and improvements thereof; and (b) Feedback (as defined below), lie and remain exclusively with Classiq and/or its licensors. Nothing herein constitutes a waiver of Classiq's intellectual property rights under any law. All rights not expressly granted hereunder are reserved by Classiq.
12
+
13
+ 3. Feedback. As a condition of the Evaluation License, Licensee shall provide Classiq with detailed Feedback (defined below), which may be used by Classiq at its sole discretion. "Feedback" means ideas, suggestions, or similar feedback about performance of the Software and/or for improving the Software, as well as the results of the evaluation. All Feedback shall be provided 'as is' with no warranty on behalf of Licensee and shall be deemed the exclusive property of Classiq, and Licensee hereby irrevocably transfers and assigns to Classiq all intellectual property rights to the Feedback and waives any and all moral rights or economic rights that Licensee may have with respect thereto.
14
+
15
+ 4. Restricted Use. Unless otherwise explicitly specified and permitted under this Agreement, without the prior written consent of Classiq, Licensee may not, directly or indirectly (i) copy, modify, create derivative works of or distribute any part of the Software (including by incorporation into its products); (ii) sell, license (or sub-license), lease, assign, transfer, pledge, or share Licensee's rights under this Agreement with any third party; (iii) use any "open source" or "copyleft software" in a manner that would require Classiq to disclose the source code of the Software to any third party; (iv) disclose the results of any testing or benchmarking of the Software to any third party; (v) disassemble, decompile, reverse engineer or attempt to discover the Software's source code or underlying algorithms; (vi) use the Software in a manner that violates or infringes any rights of any third party, including but not limited to, privacy rights, publicity rights or intellectual property rights; (vii) remove or alter any trademarks or other proprietary notices related to the Software; (viii) circumvent, disable or otherwise interfere with security-related features of the Software or features that enforce use limitations; (ix) export, make available or use the Software in any manner prohibited by applicable laws (including without limitation export control laws); and/or (x) transmit any malicious code (i.e., software viruses, Trojan horses, worms, malware or other computer instructions, devices, or techniques that erase data or programming, infect, disrupt, damage, disable, or shut down a computer system or any component of such computer system) or other unlawful material in connection with the Software.
16
+
17
+ 5. Open Source Components. The Software may use or include third party open source software, files, libraries or components that may be distributed to Licensee and are subject to third party open source license terms. If there is a conflict between any open source license and the terms of this Agreement, then the open source license terms shall prevail but solely in connection with the related third party open source software. Classiq makes no warranty or indemnity hereunder with respect to any third party open source software.
18
+
19
+ 6. Disclaimer of Warranties. EXCEPT AS EXPLICITLY SET FORTH IN THIS AGREEMENT THE SOFTWARE AND ANY OUTPUT WHICH MAY BE PROVIDED TO LICENSEE HEREUNDER ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND FOR INTERNAL EVALUATION PURPOSES ONLY. CLASSIQ DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON INFRINGEMENT, WITH RESPECT TO THE SOFTWARE AND ANY OTHER OUTPUT WHICH MAY BE PROVIDED TO LICENSEE HEREUNDER.
20
+
21
+ 7. Limitation of Liability. GIVEN THE NATURE OF THIS PILOT AGREEMENT AND THE FACT THAT THIS AGREEMENT IS FOR EVALUATION PURPOSES, TO THE MAXIMUM EXTENT PERMITTED BY LAW: (I) CLASSIQ SHALL NOT BE LIABLE FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING WITHOUT LIMITATION, ANY LOST PROFITS OR GOODWILL, LOST OR DAMAGED DATA OR DOCUMENTATION, LOST SAVINGS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THIS AGREEMENT, THE SOFTWARE, OR LICENSEE'S USE OF THE SOFTWARE; AND (II) IN NO EVENT SHALL CLASSIQ'S AGGREGATE LIABILITY FOR ANY DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT, WHETHER IN CONTRACT OR TORT, OR OTHERWISE EXCEED $100.
22
+
23
+ 8. Confidentiality. Each Party may have access to certain non-public information of the other Party, in any form or media, including without limitation trade secrets and other information related to the products, software, technology, data, know-how, or business of the other Party, and any other information that a reasonable person should have reason to believe is proprietary, confidential, or competitively sensitive (the "Confidential Information"). Each Party shall take reasonable measures, at least as protective as those taken to protect its own confidential information, but in no event less than reasonable care, to protect the other Party's Confidential Information from disclosure to a third party. The receiving party's obligations under this Section, with respect to any Confidential Information of the disclosing party, shall not apply to and/or shall terminate if such information: (a) was already lawfully known to the receiving party at the time of disclosure by the disclosing party; (b) was disclosed to the receiving party by a third party who had the right to make such disclosure without any confidentiality restrictions; (c) is, or through no fault of the receiving party has become, generally available to the public; or (d) was independently developed by the receiving party without access to, or use of, the disclosing party's Confidential Information. Neither Party shall use or disclose the Confidential Information of the other Party except for performance of its obligations under this Agreement. The receiving party shall only permit access to the disclosing party's Confidential Information to its respective employees, consultants, affiliates, agents and subcontractors having a need to know such information in connection with the abovementioned purpose, who either (i) have signed a non-disclosure agreement with the receiving party containing terms at least as restrictive as those contained herein or (ii) are otherwise bound by a duty of confidentiality to the receiving party at least as restrictive as the terms set forth herein. The receiving party will be allowed to disclose Confidential Information to the extent that such disclosure is required by law or by the order or a court of similar judicial or administrative body, provided that it notifies the disclosing Party of such required disclosure to enable disclosing party to seek a protective order or otherwise prevent or restrict such disclosure. All right, title and interest in and to Confidential Information are and shall remain the sole and exclusive property of the disclosing Party.
24
+
25
+ 9. Term and Termination. This Agreement shall commence on the date you accept the terms of this Agreement and shall expire ninety (90) days later ("Evaluation Period"), unless earlier terminated by either Party in writing on three (3) days' prior written notice to the other Party. Licensee's unauthorized use of the Software or otherwise failure to comply with the terms of this Agreement shall result in automatic immediate termination of this Agreement, upon notice by Classiq. Upon expiration or termination, (a) each Party shall promptly return or destroy all Confidential Information received from the other Party, and all copes thereof, (b) Licensee shall: (i) immediately cease access to and use of the Software; (ii) return the Software and all copies thereof, as well as it related documentation in Licensee or any of its Permitted Users' possession or control to Classiq; (iii) erase or otherwise destroy all copies of the Software in its possession, which are fixed or resident in the memory or hard disks of its devices; and (iv) return to Classiq any and all of Classiq's Confidential Information then in its possession. The following provisions shall survive the expiration or termination of this Agreement: 2 (Title and Ownership), 6 (Disclaimer of Warranties), 7 (Limitation of Liability), 8 (Confidentiality), 9 (Term and Termination) and 10 (Miscellaneous).
26
+
27
+ 10. Miscellaneous. This Agreement shall be governed by and construed under the laws of the State of Israel. The competent courts of Tel Aviv-Yafo, Israel shall have the exclusive jurisdiction with respect to any dispute and action arising under or in relation to this Agreement. Licensee shall not assign this Agreement without the prior written consent of Classiq. Any prohibited assignment shall be null and void. No waiver of rights arising under this Agreement shall be effective unless in writing and signed by the Party against whom such waiver is sought to be enforced. No failure or delay by either Party in exercising any right, power or remedy under this Agreement shall operate as a waiver of any such right, power or remedy and/or prejudice any rights of such Party. This Agreement does not, and shall not be construed to create any relationship, partnership, joint venture, employer-employee, agency, or franchisor-franchisee relationship between the Parties. Nothing in this Agreement shall be construed to limit or delay either Classiq's or Licensee's ability to seek immediate relief at law or in equity for any breach by the other. This Agreement constitutes the complete and entire agreement of the Parties and supersedes all previous communications between them, oral or written, relating to the subject matter hereof. This Agreement may be executed in two or more counterparts, each of which shall be deemed an original and all of which shall together be deemed to constitute one and the same agreement.
@@ -1,29 +0,0 @@
1
- import dataclasses
2
- from typing import Union
3
-
4
- from classiq.interface.generator.excitations import EXCITATIONS_TYPE_EXACT
5
- from classiq.interface.generator.ucc import default_excitation_factory
6
-
7
-
8
- @dataclasses.dataclass
9
- class UCCParameters:
10
- excitations: EXCITATIONS_TYPE_EXACT = dataclasses.field(
11
- default_factory=default_excitation_factory
12
- )
13
-
14
-
15
- @dataclasses.dataclass
16
- class HVAParameters:
17
- reps: int
18
-
19
-
20
- @dataclasses.dataclass
21
- class HEAParameters:
22
- reps: int
23
- num_qubits: int
24
- connectivity_map: list[tuple[int, int]]
25
- one_qubit_gates: list[str]
26
- two_qubit_gates: list[str]
27
-
28
-
29
- AnsatzParameters = Union[UCCParameters, HVAParameters, HEAParameters]
@@ -1,16 +0,0 @@
1
- import dataclasses
2
- from typing import Optional
3
-
4
- import numpy as np
5
-
6
- from classiq.interface.executor.optimizer_preferences import OptimizerType
7
-
8
-
9
- @dataclasses.dataclass
10
- class ChemistryExecutionParameters:
11
- optimizer: OptimizerType
12
- max_iteration: int
13
- initial_point: Optional[np.ndarray] = dataclasses.field(default=None)
14
- tolerance: float = dataclasses.field(default=0.0)
15
- step_size: float = dataclasses.field(default=0.0)
16
- skip_compute_variance: bool = dataclasses.field(default=False)
@@ -1,532 +0,0 @@
1
- import warnings
2
- from collections.abc import Mapping
3
- from typing import Optional, cast
4
-
5
- from classiq.interface.chemistry.fermionic_operator import (
6
- FermionicOperator,
7
- SummedFermionicOperator,
8
- )
9
- from classiq.interface.chemistry.ground_state_problem import (
10
- CHEMISTRY_PROBLEMS_TYPE,
11
- HamiltonianProblem,
12
- MoleculeProblem,
13
- )
14
- from classiq.interface.chemistry.molecule import Atom
15
- from classiq.interface.exceptions import ClassiqDeprecationWarning, ClassiqError
16
- from classiq.interface.generator.expressions.expression import Expression
17
- from classiq.interface.generator.function_params import IOName
18
- from classiq.interface.generator.functions.classical_type import (
19
- ClassicalArray,
20
- Real,
21
- )
22
- from classiq.interface.generator.functions.port_declaration import (
23
- PortDeclarationDirection,
24
- )
25
- from classiq.interface.generator.functions.type_modifier import TypeModifier
26
- from classiq.interface.model.allocate import Allocate
27
- from classiq.interface.model.classical_parameter_declaration import (
28
- ClassicalParameterDeclaration,
29
- )
30
- from classiq.interface.model.handle_binding import HandleBinding
31
- from classiq.interface.model.model import Model, SerializedModel
32
- from classiq.interface.model.native_function_definition import NativeFunctionDefinition
33
- from classiq.interface.model.port_declaration import PortDeclaration
34
- from classiq.interface.model.quantum_function_call import QuantumFunctionCall
35
- from classiq.interface.model.quantum_lambda_function import QuantumLambdaFunction
36
- from classiq.interface.model.quantum_statement import QuantumStatement
37
-
38
- from classiq.applications.chemistry.ansatz_parameters import (
39
- AnsatzParameters,
40
- HEAParameters,
41
- HVAParameters,
42
- UCCParameters,
43
- )
44
- from classiq.applications.chemistry.chemistry_execution_parameters import (
45
- ChemistryExecutionParameters,
46
- )
47
- from classiq.qmod.builtins.enums import (
48
- Element,
49
- FermionMapping,
50
- )
51
- from classiq.qmod.builtins.structs import (
52
- ChemistryAtom as QmodChemistryAtom,
53
- Molecule as QmodMolecule,
54
- MoleculeProblem as QmodMoleculeProblem,
55
- Position as QmodPosition,
56
- )
57
- from classiq.qmod.global_declarative_switch import set_global_declarative_switch
58
- from classiq.qmod.utilities import qmod_val_to_expr_str
59
-
60
- # isort: split
61
-
62
- # This import causes a circular import if done earlier. We use isort: split to avoid it
63
- from classiq.open_library.functions.hea import full_hea
64
-
65
- with set_global_declarative_switch():
66
- _FULL_HEA = cast(
67
- NativeFunctionDefinition, full_hea.create_model().function_dict["full_hea"]
68
- )
69
-
70
- _LADDER_OPERATOR_TYPE_INDICATOR_TO_QMOD_MAPPING: dict[str, str] = {
71
- "+": "PLUS",
72
- "-": "MINUS",
73
- }
74
-
75
- _CHEMISTRY_PROBLEM_PREFIX_MAPPING: dict[type[CHEMISTRY_PROBLEMS_TYPE], str] = {
76
- MoleculeProblem: "molecule",
77
- HamiltonianProblem: "fock_hamiltonian",
78
- }
79
-
80
- _ANSATZ_PARAMETERS_FUNCTION_NAME_MAPPING: dict[type[AnsatzParameters], str] = {
81
- UCCParameters: "ucc",
82
- HVAParameters: "hva",
83
- }
84
-
85
- _EXECUTION_RESULT = "vqe_result"
86
- _MOLECULE_PROBLEM_RESULT = "molecule_result"
87
-
88
- _HAE_GATE_MAPPING: dict[str, QuantumFunctionCall] = {
89
- "h": QuantumFunctionCall(
90
- function="H",
91
- positional_args=[HandleBinding(name="q")],
92
- ),
93
- "x": QuantumFunctionCall(
94
- function="X",
95
- positional_args=[HandleBinding(name="q")],
96
- ),
97
- "y": QuantumFunctionCall(
98
- function="Y",
99
- positional_args=[HandleBinding(name="q")],
100
- ),
101
- "z": QuantumFunctionCall(
102
- function="Z",
103
- positional_args=[HandleBinding(name="q")],
104
- ),
105
- "i": QuantumFunctionCall(
106
- function="I",
107
- positional_args=[HandleBinding(name="q")],
108
- ),
109
- "s": QuantumFunctionCall(
110
- function="S",
111
- positional_args=[HandleBinding(name="q")],
112
- ),
113
- "t": QuantumFunctionCall(
114
- function="T",
115
- positional_args=[HandleBinding(name="q")],
116
- ),
117
- "sdg": QuantumFunctionCall(
118
- function="SDG",
119
- positional_args=[HandleBinding(name="q")],
120
- ),
121
- "tdg": QuantumFunctionCall(
122
- function="TDG",
123
- positional_args=[HandleBinding(name="q")],
124
- ),
125
- "p": QuantumFunctionCall(
126
- function="PHASE",
127
- positional_args=[HandleBinding(name="q")],
128
- ),
129
- "rx": QuantumFunctionCall(
130
- function="RX",
131
- positional_args=[Expression(expr="angle"), HandleBinding(name="q")],
132
- ),
133
- "ry": QuantumFunctionCall(
134
- function="RY",
135
- positional_args=[Expression(expr="angle"), HandleBinding(name="q")],
136
- ),
137
- "rz": QuantumFunctionCall(
138
- function="RZ",
139
- positional_args=[Expression(expr="angle"), HandleBinding(name="q")],
140
- ),
141
- "rxx": QuantumFunctionCall(
142
- function="RXX",
143
- positional_args=[Expression(expr="angle"), HandleBinding(name="q")],
144
- ),
145
- "ryy": QuantumFunctionCall(
146
- function="RYY",
147
- positional_args=[Expression(expr="angle"), HandleBinding(name="q")],
148
- ),
149
- "rzz": QuantumFunctionCall(
150
- function="RZZ",
151
- positional_args=[Expression(expr="angle"), HandleBinding(name="q")],
152
- ),
153
- "ch": QuantumFunctionCall(
154
- function="CH",
155
- positional_args=[HandleBinding(name="q1"), HandleBinding(name="q2")],
156
- ),
157
- "cx": QuantumFunctionCall(
158
- function="CX",
159
- positional_args=[HandleBinding(name="q1"), HandleBinding(name="q2")],
160
- ),
161
- "cy": QuantumFunctionCall(
162
- function="CY",
163
- positional_args=[HandleBinding(name="q1"), HandleBinding(name="q2")],
164
- ),
165
- "cz": QuantumFunctionCall(
166
- function="CZ",
167
- positional_args=[HandleBinding(name="q1"), HandleBinding(name="q2")],
168
- ),
169
- "crx": QuantumFunctionCall(
170
- function="CRX",
171
- positional_args=[
172
- Expression(expr="angle"),
173
- HandleBinding(name="q1"),
174
- HandleBinding(name="q2"),
175
- ],
176
- ),
177
- "cry": QuantumFunctionCall(
178
- function="CRY",
179
- positional_args=[
180
- Expression(expr="angle"),
181
- HandleBinding(name="q1"),
182
- HandleBinding(name="q2"),
183
- ],
184
- ),
185
- "crz": QuantumFunctionCall(
186
- function="CRZ",
187
- positional_args=[
188
- Expression(expr="angle"),
189
- HandleBinding(name="q1"),
190
- HandleBinding(name="q2"),
191
- ],
192
- ),
193
- "cp": QuantumFunctionCall(
194
- function="CPHASE",
195
- positional_args=[
196
- Expression(expr="angle"),
197
- HandleBinding(name="q1"),
198
- HandleBinding(name="q2"),
199
- ],
200
- ),
201
- "swap": QuantumFunctionCall(
202
- function="SWAP",
203
- positional_args=[HandleBinding(name="q1"), HandleBinding(name="q2")],
204
- ),
205
- }
206
-
207
-
208
- def _atoms_to_qmod_atoms(atoms: list[Atom]) -> list[QmodChemistryAtom]:
209
- return [
210
- QmodChemistryAtom(
211
- element=Element[atom.symbol], # type:ignore[arg-type]
212
- position=QmodPosition(
213
- x=atom.x, # type:ignore[arg-type]
214
- y=atom.y, # type:ignore[arg-type]
215
- z=atom.z, # type:ignore[arg-type]
216
- ),
217
- )
218
- for atom in atoms
219
- ]
220
-
221
-
222
- def molecule_problem_to_qmod(
223
- molecule_problem: MoleculeProblem,
224
- ) -> QmodMoleculeProblem:
225
- return QmodMoleculeProblem(
226
- mapping=FermionMapping[ # type:ignore[arg-type]
227
- molecule_problem.mapping.value.upper()
228
- ],
229
- z2_symmetries=molecule_problem.z2_symmetries, # type:ignore[arg-type]
230
- molecule=QmodMolecule(
231
- atoms=_atoms_to_qmod_atoms(
232
- molecule_problem.molecule.atoms
233
- ), # type:ignore[arg-type]
234
- spin=molecule_problem.molecule.spin, # type:ignore[arg-type]
235
- charge=molecule_problem.molecule.charge, # type:ignore[arg-type]
236
- ),
237
- freeze_core=molecule_problem.freeze_core, # type:ignore[arg-type]
238
- remove_orbitals=molecule_problem.remove_orbitals, # type:ignore[arg-type]
239
- )
240
-
241
-
242
- def _fermionic_operator_to_qmod_ladder_ops(
243
- fermionic_operator: FermionicOperator,
244
- ) -> str:
245
- return "\n\t\t\t\t\t".join(
246
- [
247
- f"struct_literal(LadderOp, op=LadderOperator.{_LADDER_OPERATOR_TYPE_INDICATOR_TO_QMOD_MAPPING[ladder_op[0]]}, index={ladder_op[1]}),"
248
- for ladder_op in fermionic_operator.op_list
249
- ]
250
- )[:-1]
251
-
252
-
253
- def _summed_fermionic_operator_to_qmod_lader_terms(
254
- hamiltonian: SummedFermionicOperator,
255
- ) -> str:
256
- return "\t\t".join(
257
- [
258
- f"""
259
- struct_literal(LadderTerm,
260
- coefficient={fermionic_operator[1]},
261
- ops=[
262
- {_fermionic_operator_to_qmod_ladder_ops(fermionic_operator[0])}
263
- ]
264
- ),"""
265
- for fermionic_operator in hamiltonian.op_list
266
- ]
267
- )[:-1]
268
-
269
-
270
- def _hamiltonian_problem_to_qmod_fock_hamiltonian_problem(
271
- hamiltonian_problem: HamiltonianProblem,
272
- ) -> str:
273
- mapping = FermionMapping[hamiltonian_problem.mapping.value.upper()]
274
- return (
275
- # fmt: off
276
- "struct_literal("
277
- "FockHamiltonianProblem,"
278
- f"mapping={qmod_val_to_expr_str(mapping)},"
279
- f"z2_symmetries={hamiltonian_problem.z2_symmetries},"
280
- f"terms=[{_summed_fermionic_operator_to_qmod_lader_terms(hamiltonian_problem.hamiltonian)}],"
281
- f"num_particles={hamiltonian_problem.num_particles}"
282
- ")"
283
- # fmt: on
284
- )
285
-
286
-
287
- def _convert_library_problem_to_qmod_problem(problem: CHEMISTRY_PROBLEMS_TYPE) -> str:
288
- if isinstance(problem, MoleculeProblem):
289
- return qmod_val_to_expr_str(molecule_problem_to_qmod(problem))
290
- elif isinstance(problem, HamiltonianProblem):
291
- return _hamiltonian_problem_to_qmod_fock_hamiltonian_problem(problem)
292
- else:
293
- raise ClassiqError(f"Invalid problem type: {problem}")
294
-
295
-
296
- def _get_chemistry_function(
297
- chemistry_problem: CHEMISTRY_PROBLEMS_TYPE,
298
- chemistry_function_name: str,
299
- inouts: Mapping[IOName, HandleBinding],
300
- ansatz_parameters_expressions: Optional[list[Expression]] = None,
301
- ) -> QuantumFunctionCall:
302
- problem_prefix = _CHEMISTRY_PROBLEM_PREFIX_MAPPING[type(chemistry_problem)]
303
- return QuantumFunctionCall(
304
- function=f"{problem_prefix}_{chemistry_function_name}",
305
- positional_args=[
306
- Expression(
307
- expr=_convert_library_problem_to_qmod_problem(chemistry_problem)
308
- ),
309
- *(ansatz_parameters_expressions or []),
310
- *inouts.values(),
311
- ],
312
- )
313
-
314
-
315
- def _get_hartree_fock(
316
- chemistry_problem: CHEMISTRY_PROBLEMS_TYPE,
317
- ) -> QuantumFunctionCall:
318
- return _get_chemistry_function(
319
- chemistry_problem,
320
- "hartree_fock",
321
- {"qbv": HandleBinding(name="qbv")},
322
- )
323
-
324
-
325
- def _get_hea_function(hea_parameters: HEAParameters) -> QuantumFunctionCall:
326
- return QuantumFunctionCall(
327
- function="full_hea",
328
- positional_args=[
329
- Expression(expr=f"{hea_parameters.num_qubits}"),
330
- Expression(
331
- expr=f"{[int(_is_parametric_gate(_HAE_GATE_MAPPING[gate])) for gate in hea_parameters.one_qubit_gates+hea_parameters.two_qubit_gates]}"
332
- ),
333
- Expression(expr="t"),
334
- Expression(
335
- expr=f"{[list(connectivity_pair) for connectivity_pair in hea_parameters.connectivity_map]}"
336
- ),
337
- Expression(expr=f"{hea_parameters.reps}"),
338
- [
339
- QuantumLambdaFunction(
340
- pos_rename_params=["angle", "q"],
341
- body=[_HAE_GATE_MAPPING[gate]],
342
- )
343
- for gate in hea_parameters.one_qubit_gates
344
- ],
345
- [
346
- QuantumLambdaFunction(
347
- pos_rename_params=["angle", "q1", "q2"],
348
- body=[_HAE_GATE_MAPPING[gate]],
349
- )
350
- for gate in hea_parameters.two_qubit_gates
351
- ],
352
- HandleBinding(name="qbv"),
353
- ],
354
- )
355
-
356
-
357
- def _get_ansatz(
358
- chemistry_problem: CHEMISTRY_PROBLEMS_TYPE,
359
- ansatz_parameters: AnsatzParameters,
360
- ) -> QuantumFunctionCall:
361
- if isinstance(ansatz_parameters, HEAParameters):
362
- return _get_hea_function(ansatz_parameters)
363
- return _get_chemistry_function(
364
- chemistry_problem,
365
- _ANSATZ_PARAMETERS_FUNCTION_NAME_MAPPING[type(ansatz_parameters)],
366
- {"qbv": HandleBinding(name="qbv")},
367
- [
368
- Expression(expr=str(param_value))
369
- for param_name, param_value in ansatz_parameters.__dict__.items()
370
- ],
371
- )
372
-
373
-
374
- def _get_chemistry_vqe_additional_params(
375
- execution_parameters: ChemistryExecutionParameters,
376
- ) -> str:
377
- return f"""maximize=False,
378
- initial_point={execution_parameters.initial_point or list()},
379
- optimizer=Optimizer.{execution_parameters.optimizer.value},
380
- max_iteration={execution_parameters.max_iteration},
381
- tolerance={execution_parameters.tolerance or 0},
382
- step_size={execution_parameters.step_size or 0},
383
- skip_compute_variance={execution_parameters.skip_compute_variance},
384
- alpha_cvar=1.0,
385
- """
386
-
387
-
388
- def _get_molecule_problem_execution_post_processing(
389
- molecule_problem: MoleculeProblem,
390
- ) -> str:
391
- return f"""
392
- {_MOLECULE_PROBLEM_RESULT} = molecule_ground_state_solution_post_process({qmod_val_to_expr_str(molecule_problem_to_qmod(molecule_problem))},{_EXECUTION_RESULT})
393
- save({{{_MOLECULE_PROBLEM_RESULT!r}: {_MOLECULE_PROBLEM_RESULT}}})
394
- """
395
-
396
-
397
- def _is_parametric_gate(call: QuantumFunctionCall) -> bool:
398
- # FIXME: call call.params instead (CAD-21568)
399
- return any(
400
- arg for arg in call.positional_args if isinstance(arg, Expression)
401
- ) or any(isinstance(arg, Expression) for arg in call.positional_args)
402
-
403
-
404
- def _get_execution_result_post_processing_statements(
405
- problem: CHEMISTRY_PROBLEMS_TYPE,
406
- ) -> str:
407
- if isinstance(problem, MoleculeProblem):
408
- return _get_molecule_problem_execution_post_processing(problem)
409
- elif isinstance(problem, HamiltonianProblem):
410
- return ""
411
- else:
412
- raise ClassiqError(f"Invalid problem type: {problem}")
413
-
414
-
415
- def _count_parametric_gates(gates: list[str]) -> int:
416
- return sum(_is_parametric_gate(_HAE_GATE_MAPPING[gate]) for gate in gates)
417
-
418
-
419
- def _get_hea_port_size(hea_parameters: HEAParameters) -> int:
420
- return hea_parameters.reps * (
421
- hea_parameters.num_qubits
422
- * _count_parametric_gates(hea_parameters.one_qubit_gates)
423
- + len(hea_parameters.connectivity_map)
424
- * _count_parametric_gates(hea_parameters.two_qubit_gates)
425
- )
426
-
427
-
428
- def _get_chemistry_quantum_main_params(
429
- ansatz_parameters: AnsatzParameters,
430
- ) -> list[ClassicalParameterDeclaration]:
431
- if not isinstance(ansatz_parameters, HEAParameters):
432
- return []
433
- return [
434
- ClassicalParameterDeclaration(
435
- name="t",
436
- classical_type=ClassicalArray(
437
- element_type=Real(),
438
- length=Expression(expr=str(_get_hea_port_size(ansatz_parameters))),
439
- ),
440
- ),
441
- ]
442
-
443
-
444
- def _get_problem_to_hamiltonian_name(chemistry_problem: CHEMISTRY_PROBLEMS_TYPE) -> str:
445
- problem_prefix = _CHEMISTRY_PROBLEM_PREFIX_MAPPING[type(chemistry_problem)]
446
- return f"{problem_prefix}_problem_to_hamiltonian"
447
-
448
-
449
- def _get_chemistry_quantum_main(
450
- chemistry_problem: CHEMISTRY_PROBLEMS_TYPE,
451
- use_hartree_fock: bool,
452
- ansatz_parameters: AnsatzParameters,
453
- ) -> NativeFunctionDefinition:
454
- body: list[QuantumStatement] = []
455
- body.append(
456
- Allocate(
457
- size=Expression(
458
- expr=f"{_get_problem_to_hamiltonian_name(chemistry_problem)}({_convert_library_problem_to_qmod_problem(chemistry_problem)})[0].pauli.len"
459
- ),
460
- target=HandleBinding(name="qbv"),
461
- ),
462
- )
463
- if use_hartree_fock:
464
- body.append(_get_hartree_fock(chemistry_problem))
465
-
466
- body.append(_get_ansatz(chemistry_problem, ansatz_parameters))
467
-
468
- return NativeFunctionDefinition(
469
- name="main",
470
- positional_arg_declarations=_get_chemistry_quantum_main_params(
471
- ansatz_parameters
472
- )
473
- + [
474
- PortDeclaration(
475
- name="qbv",
476
- direction=PortDeclarationDirection.Output,
477
- type_modifier=TypeModifier.Mutable,
478
- )
479
- ],
480
- body=body,
481
- )
482
-
483
-
484
- def _get_chemistry_classical_code(
485
- chemistry_problem: CHEMISTRY_PROBLEMS_TYPE,
486
- execution_parameters: ChemistryExecutionParameters,
487
- ) -> str:
488
- qmod_problem = _convert_library_problem_to_qmod_problem(chemistry_problem)
489
- return (
490
- f"""
491
- {_EXECUTION_RESULT} = vqe(
492
- hamiltonian={_get_problem_to_hamiltonian_name(chemistry_problem)}({qmod_problem}), {_get_chemistry_vqe_additional_params(execution_parameters)}
493
- )
494
- save({{{_EXECUTION_RESULT!r}: {_EXECUTION_RESULT}}})
495
- """
496
- + _get_execution_result_post_processing_statements(chemistry_problem)
497
- ).strip()
498
-
499
-
500
- def construct_chemistry_model(
501
- chemistry_problem: CHEMISTRY_PROBLEMS_TYPE,
502
- use_hartree_fock: bool,
503
- ansatz_parameters: AnsatzParameters,
504
- execution_parameters: ChemistryExecutionParameters,
505
- ) -> SerializedModel:
506
- warnings.warn(
507
- (
508
- "The function `construct_chemistry_model` is deprecated and will no "
509
- "longer be supported starting on 2025-09-18 at the earliest. "
510
- "For more information on Classiq's chemistry application, see "
511
- "https://docs.classiq.io/latest/explore/applications/chemistry/classiq_chemistry_application/classiq_chemistry_application/."
512
- ),
513
- category=ClassiqDeprecationWarning,
514
- stacklevel=2,
515
- )
516
-
517
- chemistry_functions = [
518
- _get_chemistry_quantum_main(
519
- chemistry_problem,
520
- use_hartree_fock,
521
- ansatz_parameters,
522
- )
523
- ]
524
- if isinstance(ansatz_parameters, HEAParameters):
525
- chemistry_functions.append(_FULL_HEA)
526
- model = Model(
527
- functions=chemistry_functions,
528
- classical_execution_code=_get_chemistry_classical_code(
529
- chemistry_problem, execution_parameters
530
- ),
531
- )
532
- return model.get_model()
@@ -1,42 +0,0 @@
1
- from typing import Optional
2
-
3
- from classiq.interface.chemistry import ground_state_problem
4
- from classiq.interface.chemistry.ground_state_problem import (
5
- CHEMISTRY_PROBLEMS_TYPE,
6
- HamiltonianProblem,
7
- )
8
- from classiq.interface.chemistry.operator import PauliOperator
9
-
10
- from classiq._internals import async_utils
11
- from classiq._internals.api_wrapper import ApiWrapper
12
-
13
-
14
- async def generate_hamiltonian_async(
15
- problem: CHEMISTRY_PROBLEMS_TYPE,
16
- ) -> PauliOperator:
17
- return await ApiWrapper.call_generate_hamiltonian_task(problem)
18
-
19
-
20
- ground_state_problem.GroundStateProblem.generate_hamiltonian = async_utils.syncify_function(generate_hamiltonian_async) # type: ignore[attr-defined]
21
- ground_state_problem.GroundStateProblem.generate_hamiltonian_async = generate_hamiltonian_async # type: ignore[attr-defined]
22
-
23
-
24
- async def _get_num_qubits(problem: CHEMISTRY_PROBLEMS_TYPE) -> int:
25
- if isinstance(problem, HamiltonianProblem) and not problem.z2_symmetries:
26
- return problem.hamiltonian.num_qubits
27
- hamiltonian = await generate_hamiltonian_async(problem)
28
- return hamiltonian.num_qubits
29
-
30
-
31
- async def update_problem_async(
32
- problem: CHEMISTRY_PROBLEMS_TYPE, num_qubits: Optional[int] = None
33
- ) -> CHEMISTRY_PROBLEMS_TYPE:
34
- if num_qubits is None:
35
- num_qubits = await _get_num_qubits(problem)
36
- return problem.model_copy(update={"num_qubits": num_qubits})
37
-
38
-
39
- ground_state_problem.GroundStateProblem.update_problem = async_utils.syncify_function( # type: ignore[attr-defined]
40
- update_problem_async
41
- )
42
- ground_state_problem.GroundStateProblem.update_problem_async = update_problem_async # type: ignore[attr-defined]