classiq 0.93.0__py3-none-any.whl → 0.94.1__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.
- classiq/__init__.py +6 -19
- classiq/_analyzer_extras/_ipywidgets_async_extension.py +7 -7
- classiq/_analyzer_extras/interactive_hardware.py +19 -12
- classiq/_internals/api_wrapper.py +38 -52
- classiq/_internals/async_utils.py +4 -7
- classiq/_internals/authentication/auth0.py +3 -3
- classiq/_internals/authentication/device.py +4 -4
- classiq/_internals/authentication/password_manager.py +13 -13
- classiq/_internals/authentication/token_manager.py +4 -5
- classiq/_internals/client.py +17 -44
- classiq/_internals/config.py +1 -2
- classiq/_internals/help.py +1 -2
- classiq/_internals/host_checker.py +3 -3
- classiq/_internals/jobs.py +14 -14
- classiq/_internals/type_validation.py +3 -3
- classiq/analyzer/analyzer.py +18 -18
- classiq/analyzer/rb.py +17 -8
- classiq/applications/chemistry/__init__.py +0 -30
- classiq/applications/chemistry/op_utils.py +4 -4
- classiq/applications/chemistry/problems.py +3 -3
- classiq/applications/chemistry/ucc.py +1 -2
- classiq/applications/chemistry/z2_symmetries.py +4 -4
- classiq/applications/combinatorial_helpers/allowed_constraints.py +1 -3
- classiq/applications/combinatorial_helpers/arithmetic/arithmetic_expression.py +2 -1
- classiq/applications/combinatorial_helpers/combinatorial_problem_utils.py +2 -2
- classiq/applications/combinatorial_helpers/encoding_mapping.py +2 -3
- classiq/applications/combinatorial_helpers/encoding_utils.py +2 -2
- classiq/applications/combinatorial_helpers/optimization_model.py +3 -4
- classiq/applications/combinatorial_helpers/pauli_helpers/pauli_sparsing.py +2 -2
- classiq/applications/combinatorial_helpers/pyomo_utils.py +8 -8
- classiq/applications/combinatorial_helpers/sympy_utils.py +1 -3
- classiq/applications/combinatorial_helpers/transformations/encoding.py +3 -3
- classiq/applications/combinatorial_helpers/transformations/fixed_variables.py +1 -2
- classiq/applications/combinatorial_optimization/combinatorial_optimization_config.py +2 -3
- classiq/applications/combinatorial_optimization/combinatorial_optimization_model_constructor.py +4 -6
- classiq/applications/combinatorial_optimization/combinatorial_problem.py +15 -10
- classiq/applications/hamiltonian/pauli_decomposition.py +6 -4
- classiq/applications/iqae/iqae.py +8 -8
- classiq/applications/qnn/datasets/dataset_base_classes.py +6 -6
- classiq/applications/qnn/datasets/dataset_parity.py +6 -6
- classiq/applications/qnn/qlayer.py +8 -7
- classiq/applications/qnn/torch_utils.py +3 -4
- classiq/applications/qnn/types.py +2 -1
- classiq/applications/qsp/qsp.py +5 -4
- classiq/applications/qsvm/qsvm_data_generation.py +1 -2
- classiq/evaluators/classical_expression.py +0 -4
- classiq/evaluators/parameter_types.py +7 -8
- classiq/evaluators/qmod_annotated_expression.py +24 -26
- classiq/evaluators/qmod_expression_visitors/qmod_expression_evaluator.py +14 -14
- classiq/evaluators/qmod_expression_visitors/qmod_expression_simplifier.py +2 -1
- classiq/evaluators/qmod_expression_visitors/sympy_wrappers.py +8 -8
- classiq/evaluators/qmod_node_evaluators/classical_function_evaluation.py +4 -4
- classiq/evaluators/qmod_node_evaluators/list_evaluation.py +2 -2
- classiq/evaluators/qmod_node_evaluators/numeric_attrs_utils.py +3 -3
- classiq/evaluators/qmod_node_evaluators/subscript_evaluation.py +9 -9
- classiq/evaluators/qmod_node_evaluators/utils.py +6 -6
- classiq/evaluators/qmod_type_inference/classical_type_inference.py +9 -10
- classiq/evaluators/qmod_type_inference/quantum_type_inference.py +5 -5
- classiq/execution/execution_session.py +18 -19
- classiq/execution/jobs.py +26 -26
- classiq/execution/qnn.py +1 -2
- classiq/execution/user_budgets.py +52 -7
- classiq/executor.py +1 -3
- classiq/interface/_version.py +1 -1
- classiq/interface/analyzer/analysis_params.py +4 -4
- classiq/interface/analyzer/cytoscape_graph.py +3 -3
- classiq/interface/analyzer/result.py +4 -4
- classiq/interface/applications/qsvm.py +5 -8
- classiq/interface/ast_node.py +3 -3
- classiq/interface/backend/backend_preferences.py +16 -16
- classiq/interface/backend/ionq/ionq_quantum_program.py +5 -5
- classiq/interface/chemistry/ansatz_library.py +3 -5
- classiq/interface/chemistry/operator.py +3 -3
- classiq/interface/combinatorial_optimization/examples/knapsack.py +2 -4
- classiq/interface/combinatorial_optimization/examples/tsp_digraph.py +1 -2
- classiq/interface/compression_utils.py +2 -3
- classiq/interface/debug_info/debug_info.py +7 -7
- classiq/interface/exceptions.py +2 -3
- classiq/interface/execution/iqcc.py +1 -3
- classiq/interface/execution/primitives.py +6 -6
- classiq/interface/executor/estimate_cost.py +1 -1
- classiq/interface/executor/execution_preferences.py +3 -5
- classiq/interface/executor/execution_request.py +10 -10
- classiq/interface/executor/execution_result.py +1 -2
- classiq/interface/executor/quantum_code.py +8 -8
- classiq/interface/executor/result.py +28 -18
- classiq/interface/executor/user_budget.py +2 -3
- classiq/interface/executor/vqe_result.py +5 -6
- classiq/interface/generator/ansatz_library.py +6 -8
- classiq/interface/generator/application_apis/__init__.py +0 -2
- classiq/interface/generator/arith/arithmetic.py +2 -2
- classiq/interface/generator/arith/arithmetic_arg_type_validator.py +2 -3
- classiq/interface/generator/arith/arithmetic_expression_abc.py +4 -5
- classiq/interface/generator/arith/arithmetic_expression_parser.py +11 -4
- classiq/interface/generator/arith/arithmetic_expression_validator.py +12 -15
- classiq/interface/generator/arith/arithmetic_operations.py +4 -6
- classiq/interface/generator/arith/arithmetic_param_getters.py +70 -107
- classiq/interface/generator/arith/arithmetic_result_builder.py +4 -4
- classiq/interface/generator/arith/ast_node_rewrite.py +8 -4
- classiq/interface/generator/arith/binary_ops.py +7 -36
- classiq/interface/generator/arith/logical_ops.py +2 -3
- classiq/interface/generator/arith/number_utils.py +2 -2
- classiq/interface/generator/arith/register_user_input.py +2 -2
- classiq/interface/generator/arith/unary_ops.py +2 -2
- classiq/interface/generator/circuit_code/circuit_code.py +8 -10
- classiq/interface/generator/circuit_code/types_and_constants.py +1 -1
- classiq/interface/generator/complex_type.py +2 -2
- classiq/interface/generator/copy.py +1 -3
- classiq/interface/generator/expressions/atomic_expression_functions.py +0 -5
- classiq/interface/generator/expressions/evaluated_expression.py +2 -3
- classiq/interface/generator/expressions/expression.py +2 -2
- classiq/interface/generator/expressions/proxies/classical/classical_array_proxy.py +4 -7
- classiq/interface/generator/function_param_list.py +0 -20
- classiq/interface/generator/function_params.py +5 -6
- classiq/interface/generator/functions/classical_function_declaration.py +2 -2
- classiq/interface/generator/functions/classical_type.py +3 -3
- classiq/interface/generator/functions/type_modifier.py +0 -14
- classiq/interface/generator/functions/type_name.py +2 -2
- classiq/interface/generator/generated_circuit_data.py +12 -13
- classiq/interface/generator/hamiltonian_evolution/exponentiation.py +2 -4
- classiq/interface/generator/hardware/hardware_data.py +8 -8
- classiq/interface/generator/hardware_efficient_ansatz.py +8 -8
- classiq/interface/generator/mcu.py +3 -3
- classiq/interface/generator/mcx.py +3 -3
- classiq/interface/generator/model/constraints.py +34 -5
- classiq/interface/generator/model/preferences/preferences.py +15 -21
- classiq/interface/generator/model/quantum_register.py +7 -10
- classiq/interface/generator/noise_properties.py +3 -7
- classiq/interface/generator/parameters.py +1 -1
- classiq/interface/generator/partitioned_register.py +1 -2
- classiq/interface/generator/preferences/qasm_to_qmod_params.py +11 -0
- classiq/interface/generator/qsvm.py +2 -2
- classiq/interface/generator/quantum_function_call.py +8 -11
- classiq/interface/generator/quantum_program.py +12 -15
- classiq/interface/generator/range_types.py +3 -3
- classiq/interface/generator/slice_parsing_utils.py +4 -5
- classiq/interface/generator/standard_gates/standard_gates.py +2 -4
- classiq/interface/generator/state_preparation/state_preparation.py +6 -8
- classiq/interface/generator/synthesis_execution_parameter.py +1 -3
- classiq/interface/generator/synthesis_metadata/synthesis_execution_data.py +2 -3
- classiq/interface/generator/transpiler_basis_gates.py +2 -4
- classiq/interface/generator/types/builtin_enum_declarations.py +0 -136
- classiq/interface/generator/types/compilation_metadata.py +12 -1
- classiq/interface/generator/types/enum_declaration.py +2 -1
- classiq/interface/generator/validations/flow_graph.py +3 -3
- classiq/interface/generator/visitor.py +10 -12
- classiq/interface/hardware.py +2 -2
- classiq/interface/helpers/classproperty.py +2 -2
- classiq/interface/helpers/custom_encoders.py +2 -1
- classiq/interface/helpers/custom_pydantic_types.py +1 -1
- classiq/interface/helpers/text_utils.py +1 -4
- classiq/interface/ide/visual_model.py +5 -5
- classiq/interface/jobs.py +3 -3
- classiq/interface/model/allocate.py +4 -4
- classiq/interface/model/block.py +2 -2
- classiq/interface/model/bounds.py +3 -3
- classiq/interface/model/control.py +1 -1
- classiq/interface/model/inplace_binary_operation.py +2 -2
- classiq/interface/model/model.py +4 -4
- classiq/interface/model/parameter.py +1 -3
- classiq/interface/model/port_declaration.py +1 -1
- classiq/interface/model/quantum_expressions/quantum_expression.py +1 -2
- classiq/interface/model/quantum_function_call.py +3 -6
- classiq/interface/model/quantum_function_declaration.py +1 -0
- classiq/interface/model/quantum_lambda_function.py +4 -4
- classiq/interface/model/quantum_statement.py +4 -4
- classiq/interface/model/quantum_type.py +14 -14
- classiq/interface/model/validation_handle.py +2 -3
- classiq/interface/model/variable_declaration_statement.py +2 -2
- classiq/interface/pretty_print/expression_to_qmod.py +3 -4
- classiq/interface/server/routes.py +0 -4
- classiq/interface/source_reference.py +3 -4
- classiq/model_expansions/arithmetic.py +6 -7
- classiq/model_expansions/arithmetic_compute_result_attrs.py +4 -5
- classiq/model_expansions/capturing/captured_vars.py +3 -3
- classiq/model_expansions/capturing/mangling_utils.py +1 -2
- classiq/model_expansions/closure.py +12 -11
- classiq/model_expansions/function_builder.py +14 -6
- classiq/model_expansions/generative_functions.py +1 -4
- classiq/model_expansions/interpreters/base_interpreter.py +2 -6
- classiq/model_expansions/interpreters/generative_interpreter.py +5 -3
- classiq/model_expansions/quantum_operations/allocate.py +4 -4
- classiq/model_expansions/quantum_operations/assignment_result_processor.py +2 -4
- classiq/model_expansions/quantum_operations/call_emitter.py +31 -37
- classiq/model_expansions/quantum_operations/declarative_call_emitter.py +2 -2
- classiq/model_expansions/quantum_operations/emitter.py +3 -5
- classiq/model_expansions/quantum_operations/expression_evaluator.py +3 -3
- classiq/model_expansions/quantum_operations/skip_control_verifier.py +1 -2
- classiq/model_expansions/quantum_operations/variable_decleration.py +2 -2
- classiq/model_expansions/scope.py +7 -7
- classiq/model_expansions/scope_initialization.py +4 -0
- classiq/model_expansions/visitors/symbolic_param_inference.py +3 -3
- classiq/model_expansions/visitors/uncomputation_signature_inference.py +317 -0
- classiq/model_expansions/visitors/variable_references.py +15 -14
- classiq/open_library/functions/__init__.py +6 -0
- classiq/open_library/functions/discrete_sine_cosine_transform.py +5 -5
- classiq/open_library/functions/grover.py +8 -10
- classiq/open_library/functions/modular_exponentiation.py +96 -8
- classiq/qmod/__init__.py +5 -2
- classiq/qmod/builtins/classical_execution_primitives.py +4 -11
- classiq/qmod/builtins/classical_functions.py +1 -42
- classiq/qmod/builtins/enums.py +0 -136
- classiq/qmod/builtins/functions/__init__.py +0 -13
- classiq/qmod/builtins/functions/allocation.py +4 -4
- classiq/qmod/builtins/functions/arithmetic.py +22 -27
- classiq/qmod/builtins/functions/standard_gates.py +27 -27
- classiq/qmod/builtins/operations.py +35 -58
- classiq/qmod/builtins/structs.py +2 -58
- classiq/qmod/cfunc.py +3 -2
- classiq/qmod/classical_function.py +2 -1
- classiq/qmod/cparam.py +2 -8
- classiq/qmod/create_model_function.py +7 -7
- classiq/qmod/declaration_inferrer.py +33 -30
- classiq/qmod/model_state_container.py +2 -2
- classiq/qmod/native/pretty_printer.py +25 -14
- classiq/qmod/pretty_print/expression_to_python.py +5 -3
- classiq/qmod/pretty_print/pretty_printer.py +39 -17
- classiq/qmod/python_classical_type.py +40 -13
- classiq/qmod/qfunc.py +139 -16
- classiq/qmod/qmod_constant.py +2 -2
- classiq/qmod/qmod_parameter.py +5 -2
- classiq/qmod/qmod_variable.py +47 -43
- classiq/qmod/quantum_callable.py +18 -13
- classiq/qmod/quantum_expandable.py +31 -26
- classiq/qmod/quantum_function.py +51 -32
- classiq/qmod/semantics/annotation/call_annotation.py +2 -2
- classiq/qmod/semantics/error_manager.py +5 -6
- classiq/qmod/semantics/lambdas.py +1 -2
- classiq/qmod/semantics/validation/types_validation.py +1 -2
- classiq/qmod/symbolic.py +2 -4
- classiq/qmod/utilities.py +13 -10
- classiq/qmod/write_qmod.py +3 -4
- classiq/quantum_program.py +1 -3
- classiq/synthesis.py +11 -7
- {classiq-0.93.0.dist-info → classiq-0.94.1.dist-info}/METADATA +2 -3
- {classiq-0.93.0.dist-info → classiq-0.94.1.dist-info}/RECORD +238 -260
- classiq/applications/chemistry/ansatz_parameters.py +0 -29
- classiq/applications/chemistry/chemistry_execution_parameters.py +0 -16
- classiq/applications/chemistry/chemistry_model_constructor.py +0 -532
- classiq/applications/chemistry/ground_state_problem.py +0 -42
- classiq/evaluators/qmod_expression_visitors/qmod_expression_bwc.py +0 -129
- classiq/interface/chemistry/elements.py +0 -120
- classiq/interface/chemistry/fermionic_operator.py +0 -208
- classiq/interface/chemistry/ground_state_problem.py +0 -132
- classiq/interface/chemistry/ground_state_result.py +0 -8
- classiq/interface/chemistry/molecule.py +0 -71
- classiq/interface/generator/application_apis/chemistry_declarations.py +0 -69
- classiq/interface/generator/application_apis/entangler_declarations.py +0 -29
- classiq/interface/generator/chemistry_function_params.py +0 -50
- classiq/interface/generator/entangler_params.py +0 -72
- classiq/interface/generator/entanglers.py +0 -14
- classiq/interface/generator/hartree_fock.py +0 -26
- classiq/interface/generator/hva.py +0 -22
- classiq/interface/generator/linear_pauli_rotations.py +0 -92
- classiq/interface/generator/qft.py +0 -37
- classiq/interface/generator/ucc.py +0 -74
- classiq/interface/helpers/backward_compatibility.py +0 -9
- classiq/model_expansions/transformers/type_modifier_inference.py +0 -392
- classiq/qmod/builtins/functions/chemistry.py +0 -123
- {classiq-0.93.0.dist-info → classiq-0.94.1.dist-info}/WHEEL +0 -0
- {classiq-0.93.0.dist-info → classiq-0.94.1.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from typing import Literal
|
|
2
2
|
|
|
3
|
-
from classiq.qmod.qfunc import qfunc
|
|
3
|
+
from classiq.qmod.qfunc import qfunc, qperm
|
|
4
4
|
from classiq.qmod.qmod_parameter import CReal
|
|
5
|
-
from classiq.qmod.qmod_variable import Const,
|
|
5
|
+
from classiq.qmod.qmod_variable import Const, QArray, QBit
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
@qfunc(external=True)
|
|
@@ -24,8 +24,8 @@ def H(target: QBit) -> None:
|
|
|
24
24
|
pass
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
@
|
|
28
|
-
def X(target:
|
|
27
|
+
@qperm(external=True)
|
|
28
|
+
def X(target: QBit) -> None:
|
|
29
29
|
"""
|
|
30
30
|
[Qmod core-library function]
|
|
31
31
|
|
|
@@ -43,8 +43,8 @@ def X(target: Permutable[QBit]) -> None:
|
|
|
43
43
|
pass
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
@
|
|
47
|
-
def Y(target:
|
|
46
|
+
@qperm(external=True)
|
|
47
|
+
def Y(target: QBit) -> None:
|
|
48
48
|
"""
|
|
49
49
|
[Qmod core-library function]
|
|
50
50
|
|
|
@@ -62,7 +62,7 @@ def Y(target: Permutable[QBit]) -> None:
|
|
|
62
62
|
pass
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
@
|
|
65
|
+
@qperm(external=True)
|
|
66
66
|
def Z(target: Const[QBit]) -> None:
|
|
67
67
|
"""
|
|
68
68
|
[Qmod core-library function]
|
|
@@ -81,7 +81,7 @@ def Z(target: Const[QBit]) -> None:
|
|
|
81
81
|
pass
|
|
82
82
|
|
|
83
83
|
|
|
84
|
-
@
|
|
84
|
+
@qperm(external=True)
|
|
85
85
|
def I(target: Const[QBit]) -> None:
|
|
86
86
|
"""
|
|
87
87
|
[Qmod core-library function]
|
|
@@ -100,7 +100,7 @@ def I(target: Const[QBit]) -> None:
|
|
|
100
100
|
pass
|
|
101
101
|
|
|
102
102
|
|
|
103
|
-
@
|
|
103
|
+
@qperm(external=True)
|
|
104
104
|
def S(target: Const[QBit]) -> None:
|
|
105
105
|
"""
|
|
106
106
|
[Qmod core-library function]
|
|
@@ -119,7 +119,7 @@ def S(target: Const[QBit]) -> None:
|
|
|
119
119
|
pass
|
|
120
120
|
|
|
121
121
|
|
|
122
|
-
@
|
|
122
|
+
@qperm(external=True)
|
|
123
123
|
def T(target: Const[QBit]) -> None:
|
|
124
124
|
"""
|
|
125
125
|
[Qmod core-library function]
|
|
@@ -138,7 +138,7 @@ def T(target: Const[QBit]) -> None:
|
|
|
138
138
|
pass
|
|
139
139
|
|
|
140
140
|
|
|
141
|
-
@
|
|
141
|
+
@qperm(external=True)
|
|
142
142
|
def SDG(target: Const[QBit]) -> None:
|
|
143
143
|
"""
|
|
144
144
|
[Qmod core-library function]
|
|
@@ -157,7 +157,7 @@ def SDG(target: Const[QBit]) -> None:
|
|
|
157
157
|
pass
|
|
158
158
|
|
|
159
159
|
|
|
160
|
-
@
|
|
160
|
+
@qperm(external=True)
|
|
161
161
|
def TDG(target: Const[QBit]) -> None:
|
|
162
162
|
"""
|
|
163
163
|
[Qmod core-library function]
|
|
@@ -176,7 +176,7 @@ def TDG(target: Const[QBit]) -> None:
|
|
|
176
176
|
pass
|
|
177
177
|
|
|
178
178
|
|
|
179
|
-
@
|
|
179
|
+
@qperm(external=True)
|
|
180
180
|
def PHASE(theta: CReal, target: Const[QBit]) -> None:
|
|
181
181
|
"""
|
|
182
182
|
[Qmod core-library function]
|
|
@@ -238,7 +238,7 @@ def RY(theta: CReal, target: QBit) -> None:
|
|
|
238
238
|
pass
|
|
239
239
|
|
|
240
240
|
|
|
241
|
-
@
|
|
241
|
+
@qperm(external=True)
|
|
242
242
|
def RZ(theta: CReal, target: Const[QBit]) -> None:
|
|
243
243
|
"""
|
|
244
244
|
[Qmod core-library function]
|
|
@@ -323,7 +323,7 @@ def RYY(theta: CReal, target: QArray[QBit, Literal[2]]) -> None:
|
|
|
323
323
|
pass
|
|
324
324
|
|
|
325
325
|
|
|
326
|
-
@
|
|
326
|
+
@qperm(external=True)
|
|
327
327
|
def RZZ(theta: CReal, target: Const[QArray[QBit, Literal[2]]]) -> None:
|
|
328
328
|
"""
|
|
329
329
|
[Qmod core-library function]
|
|
@@ -369,8 +369,8 @@ def CH(ctrl: Const[QBit], target: QBit) -> None:
|
|
|
369
369
|
pass
|
|
370
370
|
|
|
371
371
|
|
|
372
|
-
@
|
|
373
|
-
def CX(ctrl: Const[QBit], target:
|
|
372
|
+
@qperm(external=True)
|
|
373
|
+
def CX(ctrl: Const[QBit], target: QBit) -> None:
|
|
374
374
|
"""
|
|
375
375
|
[Qmod core-library function]
|
|
376
376
|
|
|
@@ -394,8 +394,8 @@ def CX(ctrl: Const[QBit], target: Permutable[QBit]) -> None:
|
|
|
394
394
|
pass
|
|
395
395
|
|
|
396
396
|
|
|
397
|
-
@
|
|
398
|
-
def CY(ctrl: Const[QBit], target:
|
|
397
|
+
@qperm(external=True)
|
|
398
|
+
def CY(ctrl: Const[QBit], target: QBit) -> None:
|
|
399
399
|
"""
|
|
400
400
|
[Qmod core-library function]
|
|
401
401
|
|
|
@@ -419,7 +419,7 @@ def CY(ctrl: Const[QBit], target: Permutable[QBit]) -> None:
|
|
|
419
419
|
pass
|
|
420
420
|
|
|
421
421
|
|
|
422
|
-
@
|
|
422
|
+
@qperm(external=True)
|
|
423
423
|
def CZ(ctrl: Const[QBit], target: Const[QBit]) -> None:
|
|
424
424
|
"""
|
|
425
425
|
[Qmod core-library function]
|
|
@@ -496,7 +496,7 @@ def CRY(theta: CReal, ctrl: Const[QBit], target: QBit) -> None:
|
|
|
496
496
|
pass
|
|
497
497
|
|
|
498
498
|
|
|
499
|
-
@
|
|
499
|
+
@qperm(external=True)
|
|
500
500
|
def CRZ(theta: CReal, ctrl: Const[QBit], target: Const[QBit]) -> None:
|
|
501
501
|
"""
|
|
502
502
|
[Qmod core-library function]
|
|
@@ -522,7 +522,7 @@ def CRZ(theta: CReal, ctrl: Const[QBit], target: Const[QBit]) -> None:
|
|
|
522
522
|
pass
|
|
523
523
|
|
|
524
524
|
|
|
525
|
-
@
|
|
525
|
+
@qperm(external=True)
|
|
526
526
|
def CPHASE(theta: CReal, ctrl: Const[QBit], target: Const[QBit]) -> None:
|
|
527
527
|
"""
|
|
528
528
|
[Qmod core-library function]
|
|
@@ -548,8 +548,8 @@ def CPHASE(theta: CReal, ctrl: Const[QBit], target: Const[QBit]) -> None:
|
|
|
548
548
|
pass
|
|
549
549
|
|
|
550
550
|
|
|
551
|
-
@
|
|
552
|
-
def SWAP(qbit0:
|
|
551
|
+
@qperm(external=True)
|
|
552
|
+
def SWAP(qbit0: QBit, qbit1: QBit) -> None:
|
|
553
553
|
"""
|
|
554
554
|
[Qmod core-library function]
|
|
555
555
|
|
|
@@ -573,7 +573,7 @@ def SWAP(qbit0: Permutable[QBit], qbit1: Permutable[QBit]) -> None:
|
|
|
573
573
|
pass
|
|
574
574
|
|
|
575
575
|
|
|
576
|
-
@
|
|
576
|
+
@qperm(external=True)
|
|
577
577
|
def IDENTITY(target: Const[QArray[QBit]]) -> None:
|
|
578
578
|
"""
|
|
579
579
|
[Qmod core-library function]
|
|
@@ -622,8 +622,8 @@ def U(theta: CReal, phi: CReal, lam: CReal, gam: CReal, target: QBit) -> None:
|
|
|
622
622
|
pass
|
|
623
623
|
|
|
624
624
|
|
|
625
|
-
@
|
|
626
|
-
def CCX(ctrl: Const[QArray[QBit, Literal[2]]], target:
|
|
625
|
+
@qperm(external=True)
|
|
626
|
+
def CCX(ctrl: Const[QArray[QBit, Literal[2]]], target: QBit) -> None:
|
|
627
627
|
"""
|
|
628
628
|
[Qmod core-library function]
|
|
629
629
|
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import inspect
|
|
2
2
|
import sys
|
|
3
|
-
import
|
|
4
|
-
from collections.abc import Mapping
|
|
3
|
+
from collections.abc import Callable, Mapping
|
|
5
4
|
from types import FrameType
|
|
6
5
|
from typing import (
|
|
7
6
|
Any,
|
|
8
|
-
Callable,
|
|
9
7
|
Final,
|
|
10
8
|
NoReturn,
|
|
11
|
-
Optional,
|
|
12
|
-
Union,
|
|
13
9
|
overload,
|
|
14
10
|
)
|
|
15
11
|
|
|
16
|
-
from classiq.interface.exceptions import
|
|
12
|
+
from classiq.interface.exceptions import ClassiqValueError
|
|
17
13
|
from classiq.interface.generator.expressions.expression import Expression
|
|
18
14
|
from classiq.interface.generator.functions.builtins.internal_operators import (
|
|
19
15
|
REPEAT_OPERATOR_NAME,
|
|
@@ -61,7 +57,7 @@ _MISSING_VALUE: Final[int] = -1
|
|
|
61
57
|
|
|
62
58
|
|
|
63
59
|
@overload
|
|
64
|
-
def allocate(num_qubits:
|
|
60
|
+
def allocate(num_qubits: int | SymbolicExpr, out: Output[QVar]) -> None:
|
|
65
61
|
pass
|
|
66
62
|
|
|
67
63
|
|
|
@@ -72,9 +68,9 @@ def allocate(out: Output[QVar]) -> None:
|
|
|
72
68
|
|
|
73
69
|
@overload
|
|
74
70
|
def allocate(
|
|
75
|
-
num_qubits:
|
|
76
|
-
is_signed:
|
|
77
|
-
fraction_digits:
|
|
71
|
+
num_qubits: int | SymbolicExpr,
|
|
72
|
+
is_signed: bool | SymbolicExpr,
|
|
73
|
+
fraction_digits: int | SymbolicExpr,
|
|
78
74
|
out: Output[QVar],
|
|
79
75
|
) -> None:
|
|
80
76
|
pass
|
|
@@ -146,8 +142,8 @@ def allocate(*args: Any, **kwargs: Any) -> None:
|
|
|
146
142
|
|
|
147
143
|
@suppress_return_value
|
|
148
144
|
def bind(
|
|
149
|
-
source:
|
|
150
|
-
destination:
|
|
145
|
+
source: Input[QVar] | list[Input[QVar]],
|
|
146
|
+
destination: Output[QVar] | list[Output[QVar]],
|
|
151
147
|
) -> None:
|
|
152
148
|
"""
|
|
153
149
|
Reassign qubit or arrays of qubits by redirecting their logical identifiers.
|
|
@@ -182,9 +178,9 @@ def bind(
|
|
|
182
178
|
|
|
183
179
|
@suppress_return_value
|
|
184
180
|
def if_(
|
|
185
|
-
condition:
|
|
186
|
-
then:
|
|
187
|
-
else_:
|
|
181
|
+
condition: SymbolicExpr | bool,
|
|
182
|
+
then: QCallable | Callable[[], Statements],
|
|
183
|
+
else_: QCallable | Callable[[], Statements] | int = _MISSING_VALUE,
|
|
188
184
|
) -> None:
|
|
189
185
|
"""
|
|
190
186
|
Conditionally executes quantum operations based on a symbolic or boolean expression.
|
|
@@ -219,9 +215,9 @@ def if_(
|
|
|
219
215
|
|
|
220
216
|
@suppress_return_value
|
|
221
217
|
def control(
|
|
222
|
-
ctrl:
|
|
223
|
-
stmt_block:
|
|
224
|
-
else_block:
|
|
218
|
+
ctrl: SymbolicExpr | QBit | QArray[QBit] | list[QVar],
|
|
219
|
+
stmt_block: QCallable | Callable[[], Statements],
|
|
220
|
+
else_block: QCallable | Callable[[], Statements] | None = None,
|
|
225
221
|
) -> None:
|
|
226
222
|
"""
|
|
227
223
|
Conditionally executes quantum operations based on the value of quantum variables or expressions.
|
|
@@ -256,7 +252,15 @@ def control(
|
|
|
256
252
|
|
|
257
253
|
|
|
258
254
|
@suppress_return_value
|
|
259
|
-
def skip_control(stmt_block:
|
|
255
|
+
def skip_control(stmt_block: QCallable | Callable[[], Statements]) -> None:
|
|
256
|
+
"""
|
|
257
|
+
Applies quantum statements unconditionally.
|
|
258
|
+
|
|
259
|
+
Args:
|
|
260
|
+
stmt_block: A callable that produces a quantum operation.
|
|
261
|
+
|
|
262
|
+
For more details, see [Qmod Reference](https://docs.classiq.io/latest/qmod-reference/language-reference/statements/skip-control).
|
|
263
|
+
"""
|
|
260
264
|
_validate_operand(stmt_block)
|
|
261
265
|
assert QCallable.CURRENT_EXPANDABLE is not None
|
|
262
266
|
source_ref = get_source_ref(sys._getframe(1))
|
|
@@ -396,9 +400,7 @@ def within_apply(
|
|
|
396
400
|
|
|
397
401
|
|
|
398
402
|
@suppress_return_value
|
|
399
|
-
def repeat(
|
|
400
|
-
count: Union[SymbolicExpr, int], iteration: Callable[[int], Statements]
|
|
401
|
-
) -> None:
|
|
403
|
+
def repeat(count: SymbolicExpr | int, iteration: Callable[[int], Statements]) -> None:
|
|
402
404
|
"""
|
|
403
405
|
Executes a quantum loop a specified number of times, applying a quantum operation on each iteration.
|
|
404
406
|
|
|
@@ -454,8 +456,8 @@ def repeat(
|
|
|
454
456
|
|
|
455
457
|
@suppress_return_value
|
|
456
458
|
def power(
|
|
457
|
-
exponent:
|
|
458
|
-
stmt_block:
|
|
459
|
+
exponent: SymbolicExpr | int,
|
|
460
|
+
stmt_block: QCallable | Callable[[], Statements],
|
|
459
461
|
) -> None:
|
|
460
462
|
"""
|
|
461
463
|
Apply a quantum operation raised to a symbolic or integer power.
|
|
@@ -499,7 +501,7 @@ def power(
|
|
|
499
501
|
|
|
500
502
|
|
|
501
503
|
@suppress_return_value
|
|
502
|
-
def invert(stmt_block:
|
|
504
|
+
def invert(stmt_block: QCallable | Callable[[], Statements]) -> None:
|
|
503
505
|
"""
|
|
504
506
|
Apply the inverse of a quantum gate.
|
|
505
507
|
|
|
@@ -532,25 +534,10 @@ def invert(stmt_block: Union[QCallable, Callable[[], Statements]]) -> None:
|
|
|
532
534
|
QCallable.CURRENT_EXPANDABLE.append_statement_to_body(invert_stmt)
|
|
533
535
|
|
|
534
536
|
|
|
535
|
-
@overload
|
|
536
|
-
def phase(
|
|
537
|
-
phase_expr: Union[SymbolicExpr, float], theta: Union[SymbolicExpr, float] = 1.0
|
|
538
|
-
) -> None:
|
|
539
|
-
pass
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
@overload
|
|
543
|
-
def phase(
|
|
544
|
-
*, expr: Union[SymbolicExpr, float], theta: Union[SymbolicExpr, float] = 1.0
|
|
545
|
-
) -> None:
|
|
546
|
-
pass
|
|
547
|
-
|
|
548
|
-
|
|
549
537
|
@suppress_return_value
|
|
550
538
|
def phase(
|
|
551
|
-
phase_expr:
|
|
552
|
-
theta:
|
|
553
|
-
expr: Any = None,
|
|
539
|
+
phase_expr: SymbolicExpr | float | None = None,
|
|
540
|
+
theta: SymbolicExpr | float = 1.0,
|
|
554
541
|
) -> None:
|
|
555
542
|
"""
|
|
556
543
|
Applies a state-dependent or fixed phase shift (Z rotation) to the quantum state.
|
|
@@ -570,16 +557,6 @@ def phase(
|
|
|
570
557
|
they are equivalent when the phase_expr is a single-qubit variable.
|
|
571
558
|
"""
|
|
572
559
|
assert QCallable.CURRENT_EXPANDABLE is not None
|
|
573
|
-
if expr is not None:
|
|
574
|
-
warnings.warn(
|
|
575
|
-
"Parameter 'expr' of function 'phase' has been renamed to "
|
|
576
|
-
"'phase_expr'. Parameter 'expr' will no longer be supported starting on "
|
|
577
|
-
"2025-09-19 at the earliest.\nHint: Change `phase(expr=..., theta=...)` to "
|
|
578
|
-
"`phase(phase_expr=..., theta=...)` or `phase(..., ...)`.",
|
|
579
|
-
category=ClassiqDeprecationWarning,
|
|
580
|
-
stacklevel=2,
|
|
581
|
-
)
|
|
582
|
-
phase_expr = expr
|
|
583
560
|
source_ref = get_source_ref(sys._getframe(1))
|
|
584
561
|
QCallable.CURRENT_EXPANDABLE.append_statement_to_body(
|
|
585
562
|
PhaseOperation(
|
|
@@ -592,7 +569,7 @@ def phase(
|
|
|
592
569
|
|
|
593
570
|
@suppress_return_value
|
|
594
571
|
def block(
|
|
595
|
-
statements:
|
|
572
|
+
statements: QCallable | Callable[[], Statements],
|
|
596
573
|
) -> None:
|
|
597
574
|
_validate_operand(statements)
|
|
598
575
|
assert QCallable.CURRENT_EXPANDABLE is not None
|
|
@@ -617,8 +594,8 @@ def reset_bounds(
|
|
|
617
594
|
@overload
|
|
618
595
|
def reset_bounds(
|
|
619
596
|
target_var: QNum,
|
|
620
|
-
lower_bound:
|
|
621
|
-
upper_bound:
|
|
597
|
+
lower_bound: float | SymbolicExpr,
|
|
598
|
+
upper_bound: float | SymbolicExpr,
|
|
622
599
|
) -> None:
|
|
623
600
|
pass
|
|
624
601
|
|
|
@@ -626,8 +603,8 @@ def reset_bounds(
|
|
|
626
603
|
@suppress_return_value
|
|
627
604
|
def reset_bounds(
|
|
628
605
|
target_var: QNum,
|
|
629
|
-
lower_bound:
|
|
630
|
-
upper_bound:
|
|
606
|
+
lower_bound: float | SymbolicExpr | None = None,
|
|
607
|
+
upper_bound: float | SymbolicExpr | None = None,
|
|
631
608
|
) -> None:
|
|
632
609
|
assert QCallable.CURRENT_EXPANDABLE is not None
|
|
633
610
|
source_ref = get_source_ref(sys._getframe(1))
|
|
@@ -734,7 +711,7 @@ def _get_operand_hint(
|
|
|
734
711
|
|
|
735
712
|
|
|
736
713
|
def _operand_to_body(
|
|
737
|
-
callable_:
|
|
714
|
+
callable_: QCallable | Callable[[], Statements], param_name: str
|
|
738
715
|
) -> StatementBlock:
|
|
739
716
|
op_name = sys._getframe(1).f_code.co_name
|
|
740
717
|
if (
|
classiq/qmod/builtins/structs.py
CHANGED
|
@@ -5,8 +5,8 @@ from classiq.interface.exceptions import ClassiqValueError
|
|
|
5
5
|
from classiq.interface.generator.types.struct_declaration import StructDeclaration
|
|
6
6
|
from classiq.interface.helpers.text_utils import are, readable_list, s
|
|
7
7
|
|
|
8
|
-
from classiq.qmod.builtins.enums import
|
|
9
|
-
from classiq.qmod.cparam import CArray,
|
|
8
|
+
from classiq.qmod.builtins.enums import Pauli
|
|
9
|
+
from classiq.qmod.cparam import CArray, CInt, CReal
|
|
10
10
|
from classiq.qmod.python_classical_type import PythonClassicalType
|
|
11
11
|
|
|
12
12
|
|
|
@@ -131,55 +131,6 @@ class SparsePauliOp:
|
|
|
131
131
|
)
|
|
132
132
|
|
|
133
133
|
|
|
134
|
-
@dataclass
|
|
135
|
-
class Position:
|
|
136
|
-
x: CReal
|
|
137
|
-
y: CReal
|
|
138
|
-
z: CReal
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
@dataclass
|
|
142
|
-
class ChemistryAtom:
|
|
143
|
-
element: CInt
|
|
144
|
-
position: Position
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
@dataclass
|
|
148
|
-
class Molecule:
|
|
149
|
-
atoms: CArray[ChemistryAtom]
|
|
150
|
-
spin: CInt
|
|
151
|
-
charge: CInt
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
@dataclass
|
|
155
|
-
class MoleculeProblem:
|
|
156
|
-
mapping: CInt
|
|
157
|
-
z2_symmetries: CBool
|
|
158
|
-
molecule: Molecule
|
|
159
|
-
freeze_core: CBool
|
|
160
|
-
remove_orbitals: CArray[CInt]
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
@dataclass
|
|
164
|
-
class LadderOp:
|
|
165
|
-
op: LadderOperator
|
|
166
|
-
index: CInt
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
@dataclass
|
|
170
|
-
class LadderTerm:
|
|
171
|
-
coefficient: CReal
|
|
172
|
-
ops: CArray[LadderOp]
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
@dataclass
|
|
176
|
-
class FockHamiltonianProblem:
|
|
177
|
-
mapping: CInt
|
|
178
|
-
z2_symmetries: CBool
|
|
179
|
-
terms: CArray[LadderTerm]
|
|
180
|
-
num_particles: CArray[CInt]
|
|
181
|
-
|
|
182
|
-
|
|
183
134
|
@dataclass
|
|
184
135
|
class CombinatorialOptimizationSolution:
|
|
185
136
|
probability: CReal
|
|
@@ -234,18 +185,11 @@ BUILTIN_STRUCT_DECLARATIONS = {
|
|
|
234
185
|
|
|
235
186
|
|
|
236
187
|
__all__ = [
|
|
237
|
-
"ChemistryAtom",
|
|
238
188
|
"CombinatorialOptimizationSolution",
|
|
239
|
-
"FockHamiltonianProblem",
|
|
240
189
|
"GaussianModel",
|
|
241
190
|
"IndexedPauli",
|
|
242
|
-
"LadderOp",
|
|
243
|
-
"LadderTerm",
|
|
244
191
|
"LogNormalModel",
|
|
245
|
-
"Molecule",
|
|
246
|
-
"MoleculeProblem",
|
|
247
192
|
"PauliTerm",
|
|
248
|
-
"Position",
|
|
249
193
|
"QSVMFeatureMapPauli",
|
|
250
194
|
"QsvmResult",
|
|
251
195
|
"SparsePauliOp",
|
classiq/qmod/cfunc.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
from
|
|
1
|
+
from collections.abc import Callable
|
|
2
|
+
from typing import Any, overload
|
|
2
3
|
|
|
3
4
|
from classiq.qmod.classical_function import CFunc
|
|
4
5
|
|
|
@@ -30,7 +31,7 @@ def cfunc(func: Callable) -> CFunc: ...
|
|
|
30
31
|
def cfunc(func: None = None) -> Callable[[Callable], CFunc]: ...
|
|
31
32
|
|
|
32
33
|
|
|
33
|
-
def cfunc(func:
|
|
34
|
+
def cfunc(func: Callable | None = None) -> Callable[[Callable], CFunc] | CFunc:
|
|
34
35
|
caller_locals = get_caller_locals()
|
|
35
36
|
|
|
36
37
|
def wrapper(func: Callable) -> CFunc:
|
classiq/qmod/cparam.py
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import sys
|
|
2
1
|
from abc import ABC, abstractmethod
|
|
3
|
-
from typing import (
|
|
2
|
+
from typing import (
|
|
4
3
|
TYPE_CHECKING,
|
|
5
4
|
Any,
|
|
6
5
|
Generic,
|
|
7
6
|
Union,
|
|
8
|
-
_GenericAlias,
|
|
9
7
|
)
|
|
10
8
|
|
|
11
9
|
from typing_extensions import ParamSpec
|
|
@@ -59,11 +57,7 @@ _P = ParamSpec("_P")
|
|
|
59
57
|
|
|
60
58
|
|
|
61
59
|
class ArrayBase(Generic[_P]):
|
|
62
|
-
|
|
63
|
-
if sys.version_info[0:2] < (3, 10):
|
|
64
|
-
|
|
65
|
-
def __class_getitem__(cls, args) -> _GenericAlias:
|
|
66
|
-
return _GenericAlias(cls, args)
|
|
60
|
+
pass
|
|
67
61
|
|
|
68
62
|
|
|
69
63
|
class CArray(CParamAbstract, ArrayBase[_P]):
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import
|
|
1
|
+
from typing import cast
|
|
2
2
|
|
|
3
3
|
from classiq.interface.exceptions import ClassiqError
|
|
4
4
|
from classiq.interface.executor.execution_preferences import ExecutionPreferences
|
|
@@ -28,12 +28,12 @@ def add_entry_point(
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
def create_model(
|
|
31
|
-
entry_point:
|
|
32
|
-
constraints:
|
|
33
|
-
execution_preferences:
|
|
34
|
-
preferences:
|
|
35
|
-
classical_execution_function:
|
|
36
|
-
out_file:
|
|
31
|
+
entry_point: QFunc | GenerativeQFunc,
|
|
32
|
+
constraints: Constraints | None = None,
|
|
33
|
+
execution_preferences: ExecutionPreferences | None = None,
|
|
34
|
+
preferences: Preferences | None = None,
|
|
35
|
+
classical_execution_function: CFunc | None = None,
|
|
36
|
+
out_file: str | None = None,
|
|
37
37
|
) -> SerializedModel:
|
|
38
38
|
"""
|
|
39
39
|
Create a serialized model from a given Qmod entry function and additional parameters.
|