classiq 0.89.0__py3-none-any.whl → 0.90.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.
- classiq/__init__.py +1 -0
- classiq/_internals/api_wrapper.py +16 -32
- classiq/analyzer/show_interactive_hack.py +26 -1
- classiq/applications/chemistry/chemistry_model_constructor.py +14 -2
- classiq/applications/combinatorial_helpers/pyomo_utils.py +9 -6
- classiq/applications/combinatorial_optimization/combinatorial_optimization_model_constructor.py +2 -2
- classiq/applications/combinatorial_optimization/combinatorial_problem.py +16 -8
- classiq/evaluators/classical_expression.py +63 -41
- classiq/evaluators/control.py +31 -52
- classiq/evaluators/expression_evaluator.py +8 -4
- classiq/evaluators/parameter_types.py +200 -104
- classiq/evaluators/qmod_annotated_expression.py +3 -1
- classiq/evaluators/qmod_node_evaluators/classical_function_evaluation.py +12 -37
- classiq/evaluators/qmod_node_evaluators/constant_evaluation.py +8 -17
- classiq/evaluators/qmod_node_evaluators/measurement_evaluation.py +1 -1
- classiq/evaluators/qmod_node_evaluators/min_max_evaluation.py +7 -1
- classiq/evaluators/qmod_node_evaluators/name_evaluation.py +0 -1
- classiq/evaluators/qmod_node_evaluators/numeric_attrs_utils.py +9 -1
- classiq/evaluators/qmod_node_evaluators/utils.py +33 -0
- classiq/evaluators/qmod_type_inference/classical_type_inference.py +4 -7
- classiq/interface/_version.py +1 -1
- classiq/interface/analyzer/analysis_params.py +1 -25
- classiq/interface/analyzer/result.py +4 -0
- classiq/interface/chemistry/ground_state_problem.py +16 -2
- classiq/interface/executor/optimizer_preferences.py +0 -112
- classiq/interface/generator/application_apis/chemistry_declarations.py +3 -1
- classiq/interface/generator/arith/arithmetic_expression_validator.py +2 -7
- classiq/interface/generator/expressions/evaluated_expression.py +3 -13
- classiq/interface/generator/expressions/expression_types.py +8 -22
- classiq/interface/generator/expressions/proxies/classical/classical_proxy.py +2 -2
- classiq/interface/generator/expressions/proxies/classical/classical_struct_proxy.py +1 -2
- classiq/interface/generator/functions/concrete_types.py +1 -1
- classiq/interface/generator/generated_circuit_data.py +4 -0
- classiq/interface/generator/preferences/qasm_to_qmod_params.py +14 -0
- classiq/interface/helpers/model_normalizer.py +0 -6
- classiq/interface/ide/visual_model.py +1 -0
- classiq/interface/model/handle_binding.py +1 -1
- classiq/interface/model/port_declaration.py +2 -1
- classiq/interface/model/quantum_expressions/arithmetic_operation.py +16 -12
- classiq/interface/model/quantum_type.py +1 -1
- classiq/interface/server/routes.py +2 -3
- classiq/model_expansions/atomic_expression_functions_defs.py +4 -22
- classiq/model_expansions/capturing/captured_vars.py +7 -3
- classiq/model_expansions/closure.py +8 -0
- classiq/model_expansions/interpreters/base_interpreter.py +84 -22
- classiq/model_expansions/interpreters/frontend_generative_interpreter.py +1 -1
- classiq/model_expansions/interpreters/generative_interpreter.py +7 -5
- classiq/model_expansions/quantum_operations/allocate.py +92 -21
- classiq/model_expansions/quantum_operations/assignment_result_processor.py +28 -27
- classiq/model_expansions/quantum_operations/call_emitter.py +32 -26
- classiq/model_expansions/quantum_operations/classical_var_emitter.py +6 -2
- classiq/model_expansions/quantum_operations/emitter.py +39 -69
- classiq/model_expansions/quantum_operations/expression_evaluator.py +13 -2
- classiq/model_expansions/quantum_operations/quantum_function_call.py +4 -5
- classiq/model_expansions/quantum_operations/variable_decleration.py +16 -11
- classiq/model_expansions/scope.py +36 -29
- classiq/model_expansions/scope_initialization.py +3 -6
- classiq/model_expansions/sympy_conversion/sympy_to_python.py +6 -2
- classiq/model_expansions/transformers/model_renamer.py +35 -64
- classiq/model_expansions/transformers/type_modifier_inference.py +6 -6
- classiq/model_expansions/visitors/boolean_expression_transformers.py +7 -31
- classiq/model_expansions/visitors/symbolic_param_inference.py +9 -3
- classiq/open_library/functions/state_preparation.py +3 -3
- classiq/qmod/builtins/functions/allocation.py +8 -8
- classiq/qmod/builtins/functions/arithmetic.py +1 -1
- classiq/qmod/builtins/functions/chemistry.py +64 -0
- classiq/qmod/builtins/functions/exponentiation.py +7 -13
- classiq/qmod/builtins/functions/qsvm.py +1 -1
- classiq/qmod/builtins/operations.py +38 -10
- classiq/qmod/generative.py +2 -4
- classiq/qmod/native/pretty_printer.py +1 -1
- classiq/qmod/pretty_print/pretty_printer.py +1 -1
- classiq/qmod/qmod_constant.py +1 -1
- classiq/qmod/qmod_parameter.py +2 -2
- classiq/qmod/qmod_variable.py +15 -15
- classiq/qmod/quantum_expandable.py +1 -1
- classiq/synthesis.py +37 -1
- classiq/visualization.py +1 -1
- {classiq-0.89.0.dist-info → classiq-0.90.0.dist-info}/METADATA +1 -1
- {classiq-0.89.0.dist-info → classiq-0.90.0.dist-info}/RECORD +81 -85
- classiq/evaluators/arg_type_match.py +0 -168
- classiq/evaluators/classical_type_inference.py +0 -121
- classiq/interface/combinatorial_optimization/optimization_problem.py +0 -17
- classiq/interface/combinatorial_optimization/result.py +0 -9
- classiq/model_expansions/transformers/ast_renamer.py +0 -26
- {classiq-0.89.0.dist-info → classiq-0.90.0.dist-info}/WHEEL +0 -0
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import ast
|
|
2
1
|
import re
|
|
3
2
|
from collections.abc import Mapping, Sequence
|
|
4
3
|
from dataclasses import dataclass
|
|
5
|
-
from functools import cmp_to_key
|
|
6
4
|
from typing import TypeVar, cast
|
|
7
5
|
|
|
8
|
-
from classiq.interface.
|
|
6
|
+
from classiq.interface.generator.expressions.atomic_expression_functions import (
|
|
7
|
+
CLASSICAL_ATTRIBUTES,
|
|
8
|
+
)
|
|
9
9
|
from classiq.interface.generator.expressions.evaluated_expression import (
|
|
10
10
|
EvaluatedExpression,
|
|
11
11
|
)
|
|
12
12
|
from classiq.interface.generator.expressions.expression import Expression
|
|
13
|
-
from classiq.interface.generator.expressions.proxies.classical.any_classical_value import (
|
|
14
|
-
AnyClassicalValue,
|
|
15
|
-
)
|
|
16
13
|
from classiq.interface.generator.visitor import NodeType
|
|
17
|
-
from classiq.interface.model.handle_binding import HandleBinding
|
|
14
|
+
from classiq.interface.model.handle_binding import FieldHandleBinding, HandleBinding
|
|
18
15
|
from classiq.interface.model.model_visitor import ModelTransformer
|
|
19
16
|
from classiq.interface.model.quantum_expressions.quantum_expression import (
|
|
20
17
|
QuantumExpressionOperation,
|
|
21
18
|
)
|
|
22
19
|
|
|
23
|
-
from classiq.
|
|
20
|
+
from classiq.evaluators.qmod_annotated_expression import QmodAnnotatedExpression
|
|
21
|
+
from classiq.evaluators.qmod_expression_visitors.qmod_expression_renamer import (
|
|
22
|
+
replace_expression_type_attrs,
|
|
23
|
+
replace_expression_vars,
|
|
24
|
+
)
|
|
24
25
|
|
|
25
26
|
AST_NODE = TypeVar("AST_NODE", bound=NodeType)
|
|
26
27
|
|
|
@@ -39,31 +40,6 @@ def _handle_contains_handle(handle: HandleBinding, other_handle: HandleBinding)
|
|
|
39
40
|
return 0
|
|
40
41
|
|
|
41
42
|
|
|
42
|
-
class ExprNormalizer(ast.NodeTransformer):
|
|
43
|
-
def visit_Call(self, node: ast.Call) -> ast.AST:
|
|
44
|
-
if not isinstance(node.func, ast.Name):
|
|
45
|
-
return self.generic_visit(node)
|
|
46
|
-
if node.func.id == "get_field":
|
|
47
|
-
if (
|
|
48
|
-
len(node.args) != 2
|
|
49
|
-
or not isinstance(node.args[1], ast.Constant)
|
|
50
|
-
or not isinstance(node.args[1].value, str)
|
|
51
|
-
):
|
|
52
|
-
raise ClassiqInternalExpansionError("Unexpected 'get_field' arguments")
|
|
53
|
-
return ast.Attribute(
|
|
54
|
-
value=self.visit(node.args[0]), attr=node.args[1].value
|
|
55
|
-
)
|
|
56
|
-
if node.func.id == "do_subscript":
|
|
57
|
-
if len(node.args) != 2:
|
|
58
|
-
raise ClassiqInternalExpansionError(
|
|
59
|
-
"Unexpected 'do_subscript' arguments"
|
|
60
|
-
)
|
|
61
|
-
return ast.Subscript(
|
|
62
|
-
value=self.visit(node.args[0]), slice=self.visit(node.args[1])
|
|
63
|
-
)
|
|
64
|
-
return self.generic_visit(node)
|
|
65
|
-
|
|
66
|
-
|
|
67
43
|
@dataclass(frozen=True)
|
|
68
44
|
class HandleRenaming:
|
|
69
45
|
source_handle: HandleBinding
|
|
@@ -80,38 +56,33 @@ SymbolRenaming = Mapping[HandleBinding, Sequence[HandleRenaming]]
|
|
|
80
56
|
def rewrite_expression(
|
|
81
57
|
symbol_mapping: SymbolRenaming, expression: Expression
|
|
82
58
|
) -> Expression:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
for
|
|
92
|
-
|
|
93
|
-
|
|
59
|
+
if len(symbol_mapping) == 0:
|
|
60
|
+
return expression
|
|
61
|
+
expr_val = expression.value.value
|
|
62
|
+
if not isinstance(expr_val, QmodAnnotatedExpression):
|
|
63
|
+
return expression
|
|
64
|
+
|
|
65
|
+
type_attr_mapping = {
|
|
66
|
+
(source_handle.base_handle, source_attr): renaming.target_var_handle
|
|
67
|
+
for renamings in symbol_mapping.values()
|
|
68
|
+
for renaming in renamings
|
|
69
|
+
if isinstance(source_handle := renaming.source_handle, FieldHandleBinding)
|
|
70
|
+
and (source_attr := source_handle.field) in CLASSICAL_ATTRIBUTES
|
|
94
71
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
new_expr = Expression(expr=new_expr_str)
|
|
110
|
-
if not new_expr.is_evaluated():
|
|
111
|
-
new_expr._evaluated_expr = EvaluatedExpression(
|
|
112
|
-
value=AnyClassicalValue(new_expr_str)
|
|
113
|
-
)
|
|
114
|
-
return new_expr
|
|
72
|
+
expr_val = replace_expression_type_attrs(expr_val, type_attr_mapping)
|
|
73
|
+
|
|
74
|
+
var_mapping = {
|
|
75
|
+
source_handle: renaming.target_var_handle
|
|
76
|
+
for renamings in symbol_mapping.values()
|
|
77
|
+
for renaming in renamings
|
|
78
|
+
if not isinstance(source_handle := renaming.source_handle, FieldHandleBinding)
|
|
79
|
+
or source_handle.field not in CLASSICAL_ATTRIBUTES
|
|
80
|
+
}
|
|
81
|
+
expr_val = replace_expression_vars(expr_val, var_mapping)
|
|
82
|
+
|
|
83
|
+
renamed_expr = Expression(expr=str(expr_val))
|
|
84
|
+
renamed_expr._evaluated_expr = EvaluatedExpression(value=expr_val)
|
|
85
|
+
return renamed_expr
|
|
115
86
|
|
|
116
87
|
|
|
117
88
|
class _ReplaceSplitVarsHandles(ModelTransformer):
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import ast
|
|
2
1
|
import functools
|
|
3
2
|
import itertools
|
|
4
3
|
import warnings
|
|
@@ -37,7 +36,7 @@ from classiq.interface.model.quantum_function_call import QuantumFunctionCall
|
|
|
37
36
|
from classiq.interface.model.within_apply_operation import WithinApply
|
|
38
37
|
from classiq.interface.source_reference import SourceReference
|
|
39
38
|
|
|
40
|
-
from classiq.
|
|
39
|
+
from classiq.evaluators.qmod_annotated_expression import QmodAnnotatedExpression
|
|
41
40
|
|
|
42
41
|
|
|
43
42
|
def _inconsistent_type_modifier_error(
|
|
@@ -302,11 +301,12 @@ class TypeModifierValidation(ModelVisitor):
|
|
|
302
301
|
|
|
303
302
|
@staticmethod
|
|
304
303
|
def _extract_expr_vars(expr_op: QuantumExpressionOperation) -> list[str]:
|
|
305
|
-
|
|
306
|
-
|
|
304
|
+
expr_val = expr_op.expression.value.value
|
|
305
|
+
if not isinstance(expr_val, QmodAnnotatedExpression):
|
|
306
|
+
return []
|
|
307
|
+
return list(
|
|
308
|
+
dict.fromkeys(var.name for var in expr_val.get_quantum_vars().values())
|
|
307
309
|
)
|
|
308
|
-
vrc.visit(ast.parse(expr_op.expression.expr))
|
|
309
|
-
return [handle.name for handle in vrc.var_handles]
|
|
310
310
|
|
|
311
311
|
def visit_ArithmeticOperation(self, arith: ArithmeticOperation) -> None:
|
|
312
312
|
with self.source_reference_context(arith.source_ref):
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import ast
|
|
2
2
|
import copy
|
|
3
|
-
from typing import TYPE_CHECKING
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
4
|
|
|
5
5
|
from classiq.interface.exceptions import ClassiqInternalExpansionError
|
|
6
6
|
|
|
7
|
-
from classiq.evaluators.qmod_expression_visitors.sympy_wrappers import LogicalXor
|
|
8
|
-
|
|
9
7
|
|
|
10
8
|
class BooleanExpressionOptimizer(ast.NodeTransformer):
|
|
11
9
|
"""
|
|
@@ -36,13 +34,13 @@ class BooleanExpressionOptimizer(ast.NodeTransformer):
|
|
|
36
34
|
self._is_convertible = False
|
|
37
35
|
return node
|
|
38
36
|
|
|
39
|
-
def visit_BinOp(self, node: ast.BinOp) ->
|
|
37
|
+
def visit_BinOp(self, node: ast.BinOp) -> ast.AST:
|
|
40
38
|
self.generic_visit(node)
|
|
41
39
|
self._is_convertible = self._is_bool(node)
|
|
42
40
|
if not self._is_convertible:
|
|
43
41
|
return node
|
|
44
42
|
|
|
45
|
-
return self.
|
|
43
|
+
return self._convert_bin_op_to_bool_op(node)
|
|
46
44
|
|
|
47
45
|
def visit_UnaryOp(self, node: ast.UnaryOp) -> ast.AST:
|
|
48
46
|
self.generic_visit(node)
|
|
@@ -70,9 +68,7 @@ class BooleanExpressionOptimizer(ast.NodeTransformer):
|
|
|
70
68
|
return self._simplify_trivial_equality(node)
|
|
71
69
|
|
|
72
70
|
def visit_Call(self, node: ast.Call) -> ast.Call:
|
|
73
|
-
self._is_convertible =
|
|
74
|
-
isinstance(node.func, ast.Name) and node.func.id == LogicalXor.__name__
|
|
75
|
-
)
|
|
71
|
+
self._is_convertible = False
|
|
76
72
|
return node
|
|
77
73
|
|
|
78
74
|
def _is_bool(self, node: ast.AST) -> bool:
|
|
@@ -97,9 +93,7 @@ class BooleanExpressionOptimizer(ast.NodeTransformer):
|
|
|
97
93
|
and isinstance(node.ops[0], (ast.Eq, ast.NotEq))
|
|
98
94
|
)
|
|
99
95
|
if isinstance(node, ast.Call):
|
|
100
|
-
return
|
|
101
|
-
isinstance(node.func, ast.Name) and node.func.id == LogicalXor.__name__
|
|
102
|
-
)
|
|
96
|
+
return False
|
|
103
97
|
return False
|
|
104
98
|
|
|
105
99
|
def _convert_bin_op_to_bool_op(self, node: ast.BinOp) -> ast.AST:
|
|
@@ -116,11 +110,7 @@ class BooleanExpressionOptimizer(ast.NodeTransformer):
|
|
|
116
110
|
if not (
|
|
117
111
|
isinstance(node.left, ast.Constant) or isinstance(node.right, ast.Constant)
|
|
118
112
|
):
|
|
119
|
-
return ast.
|
|
120
|
-
func=ast.Name(LogicalXor.__name__),
|
|
121
|
-
args=[node.left, node.right],
|
|
122
|
-
keywords=[],
|
|
123
|
-
)
|
|
113
|
+
return ast.BinOp(left=node.left, op=ast.BitXor(), right=node.right)
|
|
124
114
|
|
|
125
115
|
if isinstance(node.left, ast.Constant):
|
|
126
116
|
constant = node.left.value
|
|
@@ -128,10 +118,7 @@ class BooleanExpressionOptimizer(ast.NodeTransformer):
|
|
|
128
118
|
else:
|
|
129
119
|
if TYPE_CHECKING:
|
|
130
120
|
assert isinstance(node.right, ast.Constant)
|
|
131
|
-
|
|
132
|
-
constant = node.right.value
|
|
133
|
-
except AttributeError as e:
|
|
134
|
-
raise e
|
|
121
|
+
constant = node.right.value
|
|
135
122
|
other = node.left
|
|
136
123
|
|
|
137
124
|
return other if constant == 0 else ast.UnaryOp(op=ast.Not(), operand=other)
|
|
@@ -201,14 +188,3 @@ class BooleanExpressionFuncLibAdapter(ast.NodeTransformer):
|
|
|
201
188
|
return node
|
|
202
189
|
self.generic_visit(node)
|
|
203
190
|
return ast.UnaryOp(op=ast.Not(), operand=node.operand)
|
|
204
|
-
|
|
205
|
-
def visit_BinOp(self, node: ast.BinOp) -> Union[ast.BinOp, ast.Call]:
|
|
206
|
-
"""Due to Sympy crap, we need to translate the Xor nodes to our LogicalXor"""
|
|
207
|
-
if not (self._is_boolean_optimized and isinstance(node.op, ast.BitXor)):
|
|
208
|
-
return node
|
|
209
|
-
self.generic_visit(node)
|
|
210
|
-
return ast.Call(
|
|
211
|
-
func=ast.Name(LogicalXor.__name__),
|
|
212
|
-
args=[node.left, node.right],
|
|
213
|
-
keywords=[],
|
|
214
|
-
)
|
|
@@ -100,6 +100,7 @@ class SymbolicParamInference(ModelVisitor):
|
|
|
100
100
|
)
|
|
101
101
|
self._inferred_funcs: set[str] = set()
|
|
102
102
|
self._scope: Mapping[str, ClassicalType] = {}
|
|
103
|
+
self._quantum_scope: set[str] = set()
|
|
103
104
|
self._scope_operands: dict[str, QuantumOperandDeclaration] = {}
|
|
104
105
|
|
|
105
106
|
def infer(self) -> None:
|
|
@@ -109,16 +110,19 @@ class SymbolicParamInference(ModelVisitor):
|
|
|
109
110
|
@contextmanager
|
|
110
111
|
def function_context(
|
|
111
112
|
self,
|
|
112
|
-
func_name: Optional[str],
|
|
113
113
|
scope: Mapping[str, ClassicalType],
|
|
114
|
+
quantum_scope: set[str],
|
|
114
115
|
scope_operands: dict[str, QuantumOperandDeclaration],
|
|
115
116
|
) -> Iterator[None]:
|
|
116
117
|
prev_scope = self._scope
|
|
117
118
|
self._scope = scope
|
|
119
|
+
prev_quantum_scope = self._quantum_scope
|
|
120
|
+
self._quantum_scope = quantum_scope
|
|
118
121
|
prev_scope_ops = self._scope_operands
|
|
119
122
|
self._scope_operands = scope_operands
|
|
120
123
|
yield
|
|
121
124
|
self._scope = prev_scope
|
|
125
|
+
self._quantum_scope = prev_quantum_scope
|
|
122
126
|
self._scope_operands = prev_scope_ops
|
|
123
127
|
|
|
124
128
|
def _infer_func_params(self, func: NativeFunctionDefinition) -> None:
|
|
@@ -126,8 +130,9 @@ class SymbolicParamInference(ModelVisitor):
|
|
|
126
130
|
return
|
|
127
131
|
self._inferred_funcs.add(func.name)
|
|
128
132
|
scope = {param.name: param.classical_type for param in func.param_decls}
|
|
133
|
+
quantum_scope = set(func.port_names)
|
|
129
134
|
scope_operands = func.operand_declarations_dict
|
|
130
|
-
with self.function_context(
|
|
135
|
+
with self.function_context(scope, quantum_scope, scope_operands):
|
|
131
136
|
for param in func.positional_arg_declarations:
|
|
132
137
|
for expr in _get_param_expressions(param):
|
|
133
138
|
self._process_compile_time_expression(expr.expr)
|
|
@@ -139,13 +144,14 @@ class SymbolicParamInference(ModelVisitor):
|
|
|
139
144
|
cast(str, param.name): param.classical_type
|
|
140
145
|
for param in func.named_func_decl.param_decls
|
|
141
146
|
}
|
|
147
|
+
quantum_scope = set(self._quantum_scope) | set(func.named_func_decl.port_names)
|
|
142
148
|
scope_operands = self._scope_operands | nameables_to_dict(
|
|
143
149
|
cast(
|
|
144
150
|
Sequence[QuantumOperandDeclaration],
|
|
145
151
|
func.named_func_decl.operand_declarations,
|
|
146
152
|
)
|
|
147
153
|
)
|
|
148
|
-
with self.function_context(
|
|
154
|
+
with self.function_context(scope, quantum_scope, scope_operands):
|
|
149
155
|
self.visit(func.body)
|
|
150
156
|
|
|
151
157
|
def visit_QuantumFunctionCall(self, call: QuantumFunctionCall) -> None:
|
|
@@ -327,7 +327,7 @@ def _classical_hadamard_transform(arr: list[float]) -> np.ndarray:
|
|
|
327
327
|
@qfunc
|
|
328
328
|
def apply_phase_table(
|
|
329
329
|
phases: list[float],
|
|
330
|
-
target: QArray[QBit, Literal["log(
|
|
330
|
+
target: QArray[QBit, Literal["log(phases.len, 2)"]],
|
|
331
331
|
) -> None:
|
|
332
332
|
alphas = -2 * _classical_hadamard_transform(phases) / np.sqrt(len(phases))
|
|
333
333
|
|
|
@@ -344,7 +344,7 @@ def apply_phase_table(
|
|
|
344
344
|
def inplace_prepare_complex_amplitudes(
|
|
345
345
|
magnitudes: CArray[CReal],
|
|
346
346
|
phases: list[float],
|
|
347
|
-
target: QArray[QBit, Literal["log(
|
|
347
|
+
target: QArray[QBit, Literal["log(magnitudes.len, 2)"]],
|
|
348
348
|
) -> None:
|
|
349
349
|
"""
|
|
350
350
|
|
|
@@ -367,7 +367,7 @@ def inplace_prepare_complex_amplitudes(
|
|
|
367
367
|
def prepare_complex_amplitudes(
|
|
368
368
|
magnitudes: CArray[CReal],
|
|
369
369
|
phases: list[float],
|
|
370
|
-
out: Output[QArray[QBit, Literal["log(
|
|
370
|
+
out: Output[QArray[QBit, Literal["log(magnitudes.len, 2)"]]],
|
|
371
371
|
) -> None:
|
|
372
372
|
"""
|
|
373
373
|
|
|
@@ -25,7 +25,7 @@ def free(in_: Permutable[Input[QArray[QBit]]]) -> None:
|
|
|
25
25
|
def prepare_state(
|
|
26
26
|
probabilities: CArray[CReal],
|
|
27
27
|
bound: CReal,
|
|
28
|
-
out: Output[QArray[QBit, Literal["log(
|
|
28
|
+
out: Output[QArray[QBit, Literal["log(probabilities.len, 2)"]]],
|
|
29
29
|
) -> None:
|
|
30
30
|
"""
|
|
31
31
|
[Qmod core-library function]
|
|
@@ -54,7 +54,7 @@ def prepare_state(
|
|
|
54
54
|
def prepare_amplitudes(
|
|
55
55
|
amplitudes: CArray[CReal],
|
|
56
56
|
bound: CReal,
|
|
57
|
-
out: Output[QArray[QBit, Literal["log(
|
|
57
|
+
out: Output[QArray[QBit, Literal["log(amplitudes.len, 2)"]]],
|
|
58
58
|
) -> None:
|
|
59
59
|
"""
|
|
60
60
|
[Qmod core-library function]
|
|
@@ -83,7 +83,7 @@ def prepare_amplitudes(
|
|
|
83
83
|
def inplace_prepare_state(
|
|
84
84
|
probabilities: CArray[CReal],
|
|
85
85
|
bound: CReal,
|
|
86
|
-
target: QArray[QBit, Literal["log(
|
|
86
|
+
target: QArray[QBit, Literal["log(probabilities.len, 2)"]],
|
|
87
87
|
) -> None:
|
|
88
88
|
"""
|
|
89
89
|
[Qmod core-library function]
|
|
@@ -106,7 +106,7 @@ def inplace_prepare_state(
|
|
|
106
106
|
def inplace_prepare_amplitudes(
|
|
107
107
|
amplitudes: CArray[CReal],
|
|
108
108
|
bound: CReal,
|
|
109
|
-
target: QArray[QBit, Literal["log(
|
|
109
|
+
target: QArray[QBit, Literal["log(amplitudes.len, 2)"]],
|
|
110
110
|
) -> None:
|
|
111
111
|
"""
|
|
112
112
|
[Qmod core-library function]
|
|
@@ -129,7 +129,7 @@ def inplace_prepare_amplitudes(
|
|
|
129
129
|
def inplace_prepare_amplitudes_approx(
|
|
130
130
|
amplitudes: CArray[CReal],
|
|
131
131
|
bound: CReal,
|
|
132
|
-
target: QArray[QBit, Literal["log(
|
|
132
|
+
target: QArray[QBit, Literal["log(amplitudes.len, 2)"]],
|
|
133
133
|
) -> None:
|
|
134
134
|
pass
|
|
135
135
|
|
|
@@ -138,7 +138,7 @@ def inplace_prepare_amplitudes_approx(
|
|
|
138
138
|
def prepare_amplitudes_approx(
|
|
139
139
|
amplitudes: CArray[CReal],
|
|
140
140
|
bound: CReal,
|
|
141
|
-
out: Output[QArray[QBit, Literal["log(
|
|
141
|
+
out: Output[QArray[QBit, Literal["log(amplitudes.len, 2)"]]],
|
|
142
142
|
) -> None:
|
|
143
143
|
pass
|
|
144
144
|
|
|
@@ -147,7 +147,7 @@ def prepare_amplitudes_approx(
|
|
|
147
147
|
def inplace_prepare_state_approx(
|
|
148
148
|
probabilities: CArray[CReal],
|
|
149
149
|
bound: CReal,
|
|
150
|
-
target: QArray[QBit, Literal["log(
|
|
150
|
+
target: QArray[QBit, Literal["log(probabilities.len, 2)"]],
|
|
151
151
|
) -> None:
|
|
152
152
|
pass
|
|
153
153
|
|
|
@@ -156,6 +156,6 @@ def inplace_prepare_state_approx(
|
|
|
156
156
|
def prepare_state_approx(
|
|
157
157
|
probabilities: CArray[CReal],
|
|
158
158
|
bound: CReal,
|
|
159
|
-
out: Output[QArray[QBit, Literal["log(
|
|
159
|
+
out: Output[QArray[QBit, Literal["log(probabilities.len, 2)"]]],
|
|
160
160
|
) -> None:
|
|
161
161
|
pass
|
|
@@ -16,7 +16,7 @@ from classiq.qmod.qmod_variable import (
|
|
|
16
16
|
@qfunc(external=True)
|
|
17
17
|
def unitary(
|
|
18
18
|
elements: CArray[CArray[CReal]],
|
|
19
|
-
target: QArray[QBit, Literal["log(
|
|
19
|
+
target: QArray[QBit, Literal["log(elements[0].len, 2)"]],
|
|
20
20
|
) -> None:
|
|
21
21
|
"""
|
|
22
22
|
[Qmod core-library function]
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import warnings
|
|
2
|
+
|
|
3
|
+
from classiq.interface.exceptions import ClassiqDeprecationWarning
|
|
4
|
+
|
|
1
5
|
from classiq.qmod.builtins.structs import (
|
|
2
6
|
FockHamiltonianProblem,
|
|
3
7
|
MoleculeProblem,
|
|
@@ -13,6 +17,16 @@ def molecule_ucc(
|
|
|
13
17
|
excitations: CArray[CInt],
|
|
14
18
|
qbv: QArray[QBit],
|
|
15
19
|
) -> None:
|
|
20
|
+
warnings.warn(
|
|
21
|
+
(
|
|
22
|
+
"The function `molecule_ucc` is deprecated and will no "
|
|
23
|
+
"longer be supported starting on 2025-09-18 at the earliest. "
|
|
24
|
+
"For more information on Classiq's chemistry application, see "
|
|
25
|
+
"https://docs.classiq.io/latest/explore/applications/chemistry/classiq_chemistry_application/classiq_chemistry_application/."
|
|
26
|
+
),
|
|
27
|
+
category=ClassiqDeprecationWarning,
|
|
28
|
+
stacklevel=2,
|
|
29
|
+
)
|
|
16
30
|
pass
|
|
17
31
|
|
|
18
32
|
|
|
@@ -22,6 +36,16 @@ def molecule_hva(
|
|
|
22
36
|
reps: CInt,
|
|
23
37
|
qbv: QArray[QBit],
|
|
24
38
|
) -> None:
|
|
39
|
+
warnings.warn(
|
|
40
|
+
(
|
|
41
|
+
"The function `molecule_hva` is deprecated and will no "
|
|
42
|
+
"longer be supported starting on 2025-09-18 at the earliest. "
|
|
43
|
+
"For more information on Classiq's chemistry application, see "
|
|
44
|
+
"https://docs.classiq.io/latest/explore/applications/chemistry/classiq_chemistry_application/classiq_chemistry_application/."
|
|
45
|
+
),
|
|
46
|
+
category=ClassiqDeprecationWarning,
|
|
47
|
+
stacklevel=2,
|
|
48
|
+
)
|
|
25
49
|
pass
|
|
26
50
|
|
|
27
51
|
|
|
@@ -30,6 +54,16 @@ def molecule_hartree_fock(
|
|
|
30
54
|
molecule_problem: MoleculeProblem,
|
|
31
55
|
qbv: QArray[QBit],
|
|
32
56
|
) -> None:
|
|
57
|
+
warnings.warn(
|
|
58
|
+
(
|
|
59
|
+
"The function `molecule_hartree_fock` is deprecated and will no "
|
|
60
|
+
"longer be supported starting on 2025-09-18 at the earliest. "
|
|
61
|
+
"For more information on Classiq's chemistry application, see "
|
|
62
|
+
"https://docs.classiq.io/latest/explore/applications/chemistry/classiq_chemistry_application/classiq_chemistry_application/."
|
|
63
|
+
),
|
|
64
|
+
category=ClassiqDeprecationWarning,
|
|
65
|
+
stacklevel=2,
|
|
66
|
+
)
|
|
33
67
|
pass
|
|
34
68
|
|
|
35
69
|
|
|
@@ -39,6 +73,16 @@ def fock_hamiltonian_ucc(
|
|
|
39
73
|
excitations: CArray[CInt],
|
|
40
74
|
qbv: QArray[QBit],
|
|
41
75
|
) -> None:
|
|
76
|
+
warnings.warn(
|
|
77
|
+
(
|
|
78
|
+
"The function `fock_hamiltonian_ucc` is deprecated and will no "
|
|
79
|
+
"longer be supported starting on 2025-09-18 at the earliest. "
|
|
80
|
+
"For more information on Classiq's chemistry application, see "
|
|
81
|
+
"https://docs.classiq.io/latest/explore/applications/chemistry/classiq_chemistry_application/classiq_chemistry_application/."
|
|
82
|
+
),
|
|
83
|
+
category=ClassiqDeprecationWarning,
|
|
84
|
+
stacklevel=2,
|
|
85
|
+
)
|
|
42
86
|
pass
|
|
43
87
|
|
|
44
88
|
|
|
@@ -48,6 +92,16 @@ def fock_hamiltonian_hva(
|
|
|
48
92
|
reps: CInt,
|
|
49
93
|
qbv: QArray[QBit],
|
|
50
94
|
) -> None:
|
|
95
|
+
warnings.warn(
|
|
96
|
+
(
|
|
97
|
+
"The function `fock_hamiltonian_hva` is deprecated and will no "
|
|
98
|
+
"longer be supported starting on 2025-09-18 at the earliest. "
|
|
99
|
+
"For more information on Classiq's chemistry application, see "
|
|
100
|
+
"https://docs.classiq.io/latest/explore/applications/chemistry/classiq_chemistry_application/classiq_chemistry_application/."
|
|
101
|
+
),
|
|
102
|
+
category=ClassiqDeprecationWarning,
|
|
103
|
+
stacklevel=2,
|
|
104
|
+
)
|
|
51
105
|
pass
|
|
52
106
|
|
|
53
107
|
|
|
@@ -56,4 +110,14 @@ def fock_hamiltonian_hartree_fock(
|
|
|
56
110
|
fock_hamiltonian_problem: FockHamiltonianProblem,
|
|
57
111
|
qbv: QArray[QBit],
|
|
58
112
|
) -> None:
|
|
113
|
+
warnings.warn(
|
|
114
|
+
(
|
|
115
|
+
"The function `fock_hamiltonian_hartree_fock` is deprecated and will no "
|
|
116
|
+
"longer be supported starting on 2025-09-18 at the earliest. "
|
|
117
|
+
"For more information on Classiq's chemistry application, see "
|
|
118
|
+
"https://docs.classiq.io/latest/explore/applications/chemistry/classiq_chemistry_application/classiq_chemistry_application/."
|
|
119
|
+
),
|
|
120
|
+
category=ClassiqDeprecationWarning,
|
|
121
|
+
stacklevel=2,
|
|
122
|
+
)
|
|
59
123
|
pass
|
|
@@ -14,7 +14,7 @@ from classiq.qmod.qmod_variable import QArray, QBit
|
|
|
14
14
|
def single_pauli_exponent(
|
|
15
15
|
pauli_string: CArray[Pauli],
|
|
16
16
|
coefficient: CReal,
|
|
17
|
-
qbv: QArray[QBit, Literal["
|
|
17
|
+
qbv: QArray[QBit, Literal["pauli_string.len"]],
|
|
18
18
|
) -> None:
|
|
19
19
|
"""
|
|
20
20
|
[Qmod core-library function]
|
|
@@ -33,9 +33,7 @@ def single_pauli_exponent(
|
|
|
33
33
|
def commuting_paulis_exponent(
|
|
34
34
|
pauli_operator: CArray[PauliTerm],
|
|
35
35
|
evolution_coefficient: CReal,
|
|
36
|
-
qbv: QArray[
|
|
37
|
-
QBit, Literal["get_field(get_field(pauli_operator[0], 'pauli'), 'len')"]
|
|
38
|
-
],
|
|
36
|
+
qbv: QArray[QBit, Literal["pauli_operator[0].pauli.len"]],
|
|
39
37
|
) -> None:
|
|
40
38
|
"""
|
|
41
39
|
[Qmod core-library function]
|
|
@@ -113,11 +111,11 @@ def multi_suzuki_trotter(
|
|
|
113
111
|
@qfunc(external=True)
|
|
114
112
|
def parametric_suzuki_trotter(
|
|
115
113
|
paulis: CArray[CArray[Pauli]],
|
|
116
|
-
coefficients: CArray[CReal, Literal["
|
|
114
|
+
coefficients: CArray[CReal, Literal["paulis.len"]],
|
|
117
115
|
evolution_coefficient: CReal,
|
|
118
116
|
order: CInt,
|
|
119
117
|
repetitions: CInt,
|
|
120
|
-
qbv: QArray[QBit, Literal["
|
|
118
|
+
qbv: QArray[QBit, Literal["paulis[0].len"]],
|
|
121
119
|
) -> None:
|
|
122
120
|
"""
|
|
123
121
|
[Qmod core-library function]
|
|
@@ -147,7 +145,7 @@ def sparse_suzuki_trotter(
|
|
|
147
145
|
evolution_coefficient: CReal,
|
|
148
146
|
order: CInt,
|
|
149
147
|
repetitions: CInt,
|
|
150
|
-
qbv: QArray[QBit, Literal["
|
|
148
|
+
qbv: QArray[QBit, Literal["pauli_operator.num_qubits"]],
|
|
151
149
|
) -> None:
|
|
152
150
|
"""
|
|
153
151
|
[Qmod core-library function]
|
|
@@ -174,9 +172,7 @@ def qdrift(
|
|
|
174
172
|
pauli_operator: CArray[PauliTerm],
|
|
175
173
|
evolution_coefficient: CReal,
|
|
176
174
|
num_qdrift: CInt,
|
|
177
|
-
qbv: QArray[
|
|
178
|
-
QBit, Literal["get_field(get_field(pauli_operator[0], 'pauli'), 'len')"]
|
|
179
|
-
],
|
|
175
|
+
qbv: QArray[QBit, Literal["pauli_operator[0].pauli.len"]],
|
|
180
176
|
) -> None:
|
|
181
177
|
"""
|
|
182
178
|
[Qmod core-library function]
|
|
@@ -199,9 +195,7 @@ def exponentiation_with_depth_constraint(
|
|
|
199
195
|
pauli_operator: CArray[PauliTerm],
|
|
200
196
|
evolution_coefficient: CReal,
|
|
201
197
|
max_depth: CInt,
|
|
202
|
-
qbv: QArray[
|
|
203
|
-
QBit, Literal["get_field(get_field(pauli_operator[0], 'pauli'), 'len')"]
|
|
204
|
-
],
|
|
198
|
+
qbv: QArray[QBit, Literal["pauli_operator[0].pauli.len"]],
|
|
205
199
|
) -> None:
|
|
206
200
|
"""
|
|
207
201
|
[Qmod core-library function]
|
|
@@ -11,7 +11,7 @@ from classiq.qmod.qmod_variable import QArray, QBit
|
|
|
11
11
|
@qfunc(external=True)
|
|
12
12
|
def pauli_feature_map(
|
|
13
13
|
feature_map: QSVMFeatureMapPauli,
|
|
14
|
-
qbv: QArray[QBit, Literal["
|
|
14
|
+
qbv: QArray[QBit, Literal["feature_map.feature_dimension"]],
|
|
15
15
|
) -> None:
|
|
16
16
|
pass
|
|
17
17
|
|