classiq 0.43.3__py3-none-any.whl → 0.45.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.
- classiq/__init__.py +8 -3
- classiq/_internals/api_wrapper.py +2 -2
- classiq/_internals/authentication/auth0.py +1 -1
- classiq/_internals/authentication/device.py +5 -1
- classiq/_internals/authentication/token_manager.py +5 -4
- classiq/_internals/client.py +5 -8
- classiq/_internals/config.py +1 -2
- classiq/_internals/host_checker.py +34 -13
- classiq/_internals/jobs.py +3 -3
- classiq/analyzer/analyzer.py +1 -1
- classiq/analyzer/analyzer_utilities.py +1 -1
- classiq/analyzer/rb.py +1 -1
- classiq/applications/chemistry/chemistry_model_constructor.py +13 -7
- classiq/applications/combinatorial_helpers/allowed_constraints.py +4 -1
- classiq/applications/combinatorial_helpers/arithmetic/isolation.py +1 -1
- classiq/applications/combinatorial_helpers/encoding_mapping.py +1 -1
- classiq/applications/combinatorial_helpers/encoding_utils.py +2 -1
- classiq/applications/combinatorial_helpers/optimization_model.py +1 -1
- classiq/applications/combinatorial_helpers/pauli_helpers/pauli_utils.py +1 -1
- classiq/applications/combinatorial_helpers/pyomo_utils.py +1 -2
- classiq/applications/combinatorial_helpers/transformations/encoding.py +1 -1
- classiq/applications/combinatorial_helpers/transformations/fixed_variables.py +5 -4
- classiq/applications/combinatorial_helpers/transformations/ising_converter.py +1 -1
- classiq/applications/combinatorial_helpers/transformations/sign_seperation.py +1 -1
- classiq/applications/combinatorial_optimization/combinatorial_optimization_model_constructor.py +1 -1
- classiq/applications/finance/finance_model_constructor.py +4 -3
- classiq/applications/grover/grover_model_constructor.py +7 -5
- classiq/applications/hamiltonian/__init__.py +0 -0
- classiq/applications/hamiltonian/pauli_decomposition.py +113 -0
- classiq/applications/qnn/circuit_utils.py +1 -1
- classiq/applications/qnn/datasets/dataset_base_classes.py +2 -1
- classiq/applications/qnn/datasets/dataset_not.py +2 -1
- classiq/applications/qnn/qlayer.py +3 -2
- classiq/applications/qnn/torch_utils.py +2 -1
- classiq/applications/qsvm/qsvm_model_constructor.py +1 -1
- classiq/execution/execution_session.py +1 -1
- classiq/execution/jobs.py +5 -2
- classiq/interface/_version.py +1 -1
- classiq/interface/analyzer/cytoscape_graph.py +1 -2
- classiq/interface/analyzer/result.py +2 -3
- classiq/interface/ast_node.py +1 -18
- classiq/interface/backend/backend_preferences.py +11 -18
- classiq/interface/backend/ionq/ionq_quantum_program.py +1 -1
- classiq/interface/backend/pydantic_backend.py +0 -5
- classiq/interface/backend/quantum_backend_providers.py +4 -3
- classiq/interface/chemistry/fermionic_operator.py +1 -2
- classiq/interface/chemistry/ground_state_problem.py +2 -3
- classiq/interface/chemistry/molecule.py +1 -2
- classiq/interface/chemistry/operator.py +8 -10
- classiq/interface/combinatorial_optimization/encoding_types.py +1 -1
- classiq/interface/combinatorial_optimization/mht_qaoa_input.py +1 -1
- classiq/interface/combinatorial_optimization/solver_types.py +1 -1
- classiq/interface/debug_info/__init__.py +0 -0
- classiq/interface/debug_info/debug_info.py +32 -0
- classiq/{exceptions.py → interface/exceptions.py} +4 -0
- classiq/interface/executor/aws_execution_cost.py +2 -2
- classiq/interface/executor/execution_preferences.py +2 -47
- classiq/interface/executor/execution_result.py +1 -2
- classiq/interface/executor/optimizer_preferences.py +2 -3
- classiq/interface/executor/quantum_code.py +1 -2
- classiq/interface/executor/quantum_instruction_set.py +2 -2
- classiq/interface/executor/register_initialization.py +1 -2
- classiq/interface/executor/result.py +29 -14
- classiq/interface/finance/function_input.py +6 -11
- classiq/interface/generator/amplitude_loading.py +2 -3
- classiq/interface/generator/ansatz_library.py +1 -1
- classiq/interface/generator/application_apis/arithmetic_declarations.py +8 -5
- classiq/interface/generator/application_apis/chemistry_declarations.py +78 -60
- classiq/interface/generator/application_apis/combinatorial_optimization_declarations.py +19 -10
- classiq/interface/generator/application_apis/entangler_declarations.py +11 -6
- classiq/interface/generator/application_apis/finance_declarations.py +37 -44
- classiq/interface/generator/application_apis/qsvm_declarations.py +21 -15
- classiq/interface/generator/arith/arithmetic.py +10 -8
- classiq/interface/generator/arith/arithmetic_arg_type_validator.py +1 -2
- classiq/interface/generator/arith/arithmetic_expression_abc.py +22 -3
- classiq/interface/generator/arith/arithmetic_expression_parser.py +3 -4
- classiq/interface/generator/arith/arithmetic_expression_validator.py +1 -2
- classiq/interface/generator/arith/arithmetic_param_getters.py +1 -2
- classiq/interface/generator/arith/arithmetic_result_builder.py +15 -11
- classiq/interface/generator/arith/ast_node_rewrite.py +1 -1
- classiq/interface/generator/arith/binary_ops.py +7 -7
- classiq/interface/generator/arith/endianness.py +1 -1
- classiq/interface/generator/arith/extremum_operations.py +44 -21
- classiq/interface/generator/arith/logical_ops.py +1 -2
- classiq/interface/generator/arith/register_user_input.py +1 -2
- classiq/interface/generator/arith/unary_ops.py +1 -2
- classiq/interface/generator/arith/uncomputation_methods.py +1 -1
- classiq/interface/generator/chemistry_function_params.py +1 -2
- classiq/interface/generator/circuit_code/circuit_code.py +1 -2
- classiq/interface/generator/circuit_code/types_and_constants.py +1 -2
- classiq/interface/generator/commuting_pauli_exponentiation.py +1 -2
- classiq/interface/generator/constant.py +1 -1
- classiq/interface/generator/control_state.py +1 -2
- classiq/interface/generator/custom_ansatz.py +1 -2
- classiq/interface/generator/expressions/atomic_expression_functions.py +1 -0
- classiq/interface/generator/expressions/enums/finance_functions.py +4 -5
- classiq/interface/generator/expressions/evaluated_expression.py +1 -2
- classiq/interface/generator/expressions/expression.py +1 -2
- classiq/interface/generator/expressions/expression_constants.py +3 -1
- classiq/interface/generator/expressions/non_symbolic_expr.py +1 -1
- classiq/interface/generator/expressions/qmod_qarray_proxy.py +53 -70
- classiq/interface/generator/expressions/qmod_qscalar_proxy.py +2 -7
- classiq/interface/generator/expressions/qmod_qstruct_proxy.py +35 -0
- classiq/interface/generator/expressions/qmod_sized_proxy.py +1 -1
- classiq/interface/generator/expressions/sympy_supported_expressions.py +2 -1
- classiq/interface/generator/function_params.py +2 -3
- classiq/interface/generator/functions/builtins/core_library/__init__.py +4 -2
- classiq/interface/generator/functions/builtins/core_library/atomic_quantum_functions.py +41 -41
- classiq/interface/generator/functions/builtins/core_library/exponentiation_functions.py +52 -42
- classiq/interface/generator/functions/builtins/open_lib_functions.py +1095 -3347
- classiq/interface/generator/functions/builtins/quantum_operators.py +9 -22
- classiq/interface/generator/functions/classical_function_declaration.py +14 -6
- classiq/interface/generator/functions/classical_type.py +7 -114
- classiq/interface/generator/functions/concrete_types.py +55 -0
- classiq/interface/generator/functions/function_declaration.py +10 -10
- classiq/interface/generator/functions/port_declaration.py +1 -2
- classiq/interface/generator/functions/type_name.py +80 -0
- classiq/interface/generator/generated_circuit_data.py +3 -3
- classiq/interface/generator/grover_diffuser.py +1 -2
- classiq/interface/generator/grover_operator.py +1 -2
- classiq/interface/generator/hamiltonian_evolution/exponentiation.py +1 -2
- classiq/interface/generator/hamiltonian_evolution/suzuki_trotter.py +1 -2
- classiq/interface/generator/hardware/hardware_data.py +1 -2
- classiq/interface/generator/hardware_efficient_ansatz.py +2 -3
- classiq/interface/generator/hartree_fock.py +1 -2
- classiq/interface/generator/linear_pauli_rotations.py +1 -2
- classiq/interface/generator/mcmt_method.py +1 -1
- classiq/interface/generator/mcu.py +1 -2
- classiq/interface/generator/mcx.py +1 -2
- classiq/interface/generator/model/constraints.py +2 -3
- classiq/interface/generator/model/model.py +12 -2
- classiq/interface/generator/model/preferences/preferences.py +7 -3
- classiq/interface/generator/model/quantum_register.py +1 -2
- classiq/interface/generator/oracles/arithmetic_oracle.py +1 -2
- classiq/interface/generator/oracles/custom_oracle.py +1 -2
- classiq/interface/generator/oracles/oracle_abc.py +1 -2
- classiq/interface/generator/partitioned_register.py +1 -2
- classiq/interface/generator/piecewise_linear_amplitude_loading.py +1 -2
- classiq/interface/generator/preferences/optimization.py +1 -2
- classiq/interface/generator/qpe.py +1 -2
- classiq/interface/generator/qsvm.py +2 -3
- classiq/interface/generator/quantum_function_call.py +4 -2
- classiq/interface/generator/quantum_program.py +6 -7
- classiq/interface/generator/range_types.py +1 -1
- classiq/interface/generator/register_role.py +8 -2
- classiq/interface/generator/slice_parsing_utils.py +1 -2
- classiq/interface/generator/standard_gates/controlled_standard_gates.py +1 -2
- classiq/interface/generator/state_preparation/metrics.py +2 -3
- classiq/interface/generator/state_preparation/state_preparation.py +1 -2
- classiq/interface/generator/synthesis_metadata/synthesis_execution_data.py +1 -3
- classiq/interface/generator/transpiler_basis_gates.py +1 -1
- classiq/interface/generator/types/builtin_enum_declarations.py +38 -45
- classiq/interface/generator/types/builtin_struct_declarations/pauli_struct_declarations.py +1 -2
- classiq/interface/generator/types/enum_declaration.py +1 -2
- classiq/interface/generator/types/qstruct_declaration.py +17 -0
- classiq/interface/generator/types/struct_declaration.py +2 -3
- classiq/interface/generator/ucc.py +1 -2
- classiq/interface/generator/unitary_gate.py +1 -2
- classiq/interface/generator/validations/flow_graph.py +1 -2
- classiq/interface/generator/validations/validator_functions.py +1 -2
- classiq/interface/hardware.py +1 -1
- classiq/interface/helpers/validation_helpers.py +2 -19
- classiq/interface/ide/visual_model.py +10 -4
- classiq/interface/interface_version.py +1 -0
- classiq/interface/jobs.py +2 -3
- classiq/interface/model/bind_operation.py +26 -7
- classiq/interface/model/classical_parameter_declaration.py +8 -5
- classiq/interface/model/control.py +5 -5
- classiq/interface/model/handle_binding.py +185 -12
- classiq/interface/model/inplace_binary_operation.py +17 -6
- classiq/interface/model/model.py +29 -7
- classiq/interface/model/native_function_definition.py +8 -4
- classiq/interface/model/parameter.py +13 -0
- classiq/interface/model/port_declaration.py +21 -4
- classiq/interface/model/quantum_expressions/amplitude_loading_operation.py +22 -8
- classiq/interface/model/quantum_expressions/arithmetic_operation.py +30 -6
- classiq/interface/model/quantum_expressions/quantum_expression.py +4 -9
- classiq/interface/model/quantum_function_call.py +136 -194
- classiq/interface/model/quantum_function_declaration.py +147 -165
- classiq/interface/model/quantum_lambda_function.py +23 -6
- classiq/interface/model/quantum_statement.py +34 -8
- classiq/interface/model/quantum_type.py +41 -11
- classiq/interface/model/quantum_variable_declaration.py +1 -1
- classiq/interface/model/statement_block.py +2 -0
- classiq/interface/model/validation_handle.py +8 -2
- classiq/interface/server/global_versions.py +4 -4
- classiq/interface/server/routes.py +2 -0
- classiq/interface/source_reference.py +59 -0
- classiq/qmod/__init__.py +2 -3
- classiq/qmod/builtins/classical_execution_primitives.py +1 -1
- classiq/qmod/builtins/functions.py +39 -11
- classiq/qmod/builtins/operations.py +172 -41
- classiq/qmod/classical_function.py +1 -1
- classiq/qmod/declaration_inferrer.py +102 -57
- classiq/qmod/expression_query.py +1 -1
- classiq/qmod/model_state_container.py +2 -0
- classiq/qmod/native/pretty_printer.py +71 -53
- classiq/qmod/pretty_print/pretty_printer.py +98 -52
- classiq/qmod/qfunc.py +11 -5
- classiq/qmod/qmod_constant.py +1 -1
- classiq/qmod/qmod_parameter.py +27 -4
- classiq/qmod/qmod_variable.py +405 -174
- classiq/qmod/quantum_callable.py +3 -3
- classiq/qmod/quantum_expandable.py +128 -68
- classiq/qmod/quantum_function.py +24 -5
- classiq/qmod/semantics/annotation.py +13 -15
- classiq/qmod/semantics/error_manager.py +36 -10
- classiq/qmod/semantics/static_semantics_visitor.py +164 -76
- classiq/qmod/semantics/validation/func_call_validation.py +43 -97
- classiq/qmod/semantics/validation/handle_validation.py +85 -0
- classiq/qmod/semantics/validation/types_validation.py +108 -1
- classiq/qmod/symbolic.py +2 -1
- classiq/qmod/type_attribute_remover.py +32 -0
- classiq/qmod/utilities.py +26 -5
- classiq/{interface/ide/show.py → show.py} +1 -1
- {classiq-0.43.3.dist-info → classiq-0.45.0.dist-info}/METADATA +3 -3
- {classiq-0.43.3.dist-info → classiq-0.45.0.dist-info}/RECORD +219 -207
- classiq/qmod/qmod_struct.py +0 -13
- /classiq/{_internals → interface}/enum_utils.py +0 -0
- {classiq-0.43.3.dist-info → classiq-0.45.0.dist-info}/WHEEL +0 -0
@@ -1,35 +1,22 @@
|
|
1
|
-
from typing import Any
|
2
|
-
|
3
1
|
from classiq.interface.model.quantum_function_declaration import (
|
4
|
-
|
2
|
+
NamedParamsQuantumFunctionDeclaration,
|
5
3
|
QuantumOperandDeclaration,
|
6
4
|
)
|
7
5
|
|
8
|
-
|
9
|
-
def get_single_empty_operand_operator(
|
10
|
-
operator_name: str, **kwargs: Any
|
11
|
-
) -> QuantumFunctionDeclaration:
|
12
|
-
operand_field_name = "operand"
|
13
|
-
return QuantumFunctionDeclaration(
|
14
|
-
name=operator_name,
|
15
|
-
operand_declarations={
|
16
|
-
operand_field_name: QuantumOperandDeclaration(name=operand_field_name)
|
17
|
-
},
|
18
|
-
**kwargs,
|
19
|
-
)
|
20
|
-
|
21
|
-
|
22
|
-
PERMUTE_OPERATOR = QuantumFunctionDeclaration(
|
6
|
+
PERMUTE_OPERATOR = NamedParamsQuantumFunctionDeclaration(
|
23
7
|
name="permute",
|
24
|
-
|
25
|
-
|
8
|
+
positional_arg_declarations=[
|
9
|
+
QuantumOperandDeclaration(
|
26
10
|
name="functions",
|
27
11
|
is_list=True,
|
28
12
|
)
|
29
|
-
|
13
|
+
],
|
30
14
|
)
|
31
15
|
|
32
|
-
APPLY_OPERATOR =
|
16
|
+
APPLY_OPERATOR = NamedParamsQuantumFunctionDeclaration(
|
17
|
+
name="apply",
|
18
|
+
positional_arg_declarations=[QuantumOperandDeclaration(name="operand")],
|
19
|
+
)
|
33
20
|
|
34
21
|
STD_QMOD_OPERATORS = [
|
35
22
|
PERMUTE_OPERATOR,
|
@@ -1,11 +1,14 @@
|
|
1
|
-
from typing import ClassVar, Dict,
|
1
|
+
from typing import ClassVar, Dict, Optional, Sequence
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
|
5
|
-
from classiq.interface.generator.functions.
|
5
|
+
from classiq.interface.generator.functions.concrete_types import ConcreteClassicalType
|
6
6
|
from classiq.interface.generator.functions.function_declaration import (
|
7
7
|
FunctionDeclaration,
|
8
8
|
)
|
9
|
+
from classiq.interface.model.classical_parameter_declaration import (
|
10
|
+
ClassicalParameterDeclaration,
|
11
|
+
)
|
9
12
|
|
10
13
|
|
11
14
|
class ClassicalFunctionDeclaration(FunctionDeclaration):
|
@@ -13,6 +16,12 @@ class ClassicalFunctionDeclaration(FunctionDeclaration):
|
|
13
16
|
Facilitates the creation of a common classical function interface object.
|
14
17
|
"""
|
15
18
|
|
19
|
+
name: str
|
20
|
+
|
21
|
+
positional_parameters: Sequence[ClassicalParameterDeclaration] = pydantic.Field(
|
22
|
+
default_factory=list,
|
23
|
+
)
|
24
|
+
|
16
25
|
return_type: Optional[ConcreteClassicalType] = pydantic.Field(
|
17
26
|
description="The type of the classical value that is returned by the function (for classical functions)",
|
18
27
|
default=None,
|
@@ -26,10 +35,9 @@ class ClassicalFunctionDeclaration(FunctionDeclaration):
|
|
26
35
|
Dict[str, "ClassicalFunctionDeclaration"]
|
27
36
|
] = {}
|
28
37
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
pass
|
38
|
+
@property
|
39
|
+
def param_decls(self) -> Sequence[ClassicalParameterDeclaration]:
|
40
|
+
return self.positional_parameters
|
33
41
|
|
34
42
|
|
35
43
|
ClassicalFunctionDeclaration.update_forward_refs()
|
@@ -1,14 +1,18 @@
|
|
1
|
-
from typing import Any, Dict, List, Literal, Union
|
1
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Literal, Union
|
2
2
|
|
3
3
|
import pydantic
|
4
|
-
from pydantic import Extra
|
4
|
+
from pydantic import Extra
|
5
5
|
from sympy import IndexedBase, Symbol
|
6
|
-
from typing_extensions import Annotated
|
7
6
|
|
8
7
|
from classiq.interface.ast_node import HashableASTNode
|
9
8
|
from classiq.interface.generator.expressions.expression_types import RuntimeExpression
|
10
9
|
from classiq.interface.helpers.pydantic_model_helpers import values_with_discriminator
|
11
10
|
|
11
|
+
if TYPE_CHECKING:
|
12
|
+
from classiq.interface.generator.functions.concrete_types import (
|
13
|
+
ConcreteClassicalType,
|
14
|
+
)
|
15
|
+
|
12
16
|
CLASSICAL_ATTRIBUTES = {"len", "size", "is_signed", "fraction_digits"}
|
13
17
|
|
14
18
|
NamedSymbol = Union[IndexedBase, Symbol]
|
@@ -18,12 +22,6 @@ class ClassicalType(HashableASTNode):
|
|
18
22
|
def as_symbolic(self, name: str) -> Union[NamedSymbol, List[NamedSymbol]]:
|
19
23
|
return Symbol(name)
|
20
24
|
|
21
|
-
@property
|
22
|
-
def qmod_type(self) -> type:
|
23
|
-
raise NotImplementedError(
|
24
|
-
f"{self.__class__.__name__!r} has no QMOD SDK equivalent"
|
25
|
-
)
|
26
|
-
|
27
25
|
class Config:
|
28
26
|
extra = Extra.forbid
|
29
27
|
|
@@ -41,12 +39,6 @@ class Integer(ClassicalType):
|
|
41
39
|
def _set_kind(cls, values: Dict[str, Any]) -> Dict[str, Any]:
|
42
40
|
return values_with_discriminator(values, "kind", "int")
|
43
41
|
|
44
|
-
@property
|
45
|
-
def qmod_type(self) -> type:
|
46
|
-
from classiq.qmod.qmod_parameter import CInt
|
47
|
-
|
48
|
-
return CInt
|
49
|
-
|
50
42
|
|
51
43
|
class Real(ClassicalType):
|
52
44
|
kind: Literal["real"]
|
@@ -58,12 +50,6 @@ class Real(ClassicalType):
|
|
58
50
|
def _set_kind(cls, values: Dict[str, Any]) -> Dict[str, Any]:
|
59
51
|
return values_with_discriminator(values, "kind", "real")
|
60
52
|
|
61
|
-
@property
|
62
|
-
def qmod_type(self) -> type:
|
63
|
-
from classiq.qmod.qmod_parameter import CReal
|
64
|
-
|
65
|
-
return CReal
|
66
|
-
|
67
53
|
|
68
54
|
class Bool(ClassicalType):
|
69
55
|
kind: Literal["bool"]
|
@@ -72,12 +58,6 @@ class Bool(ClassicalType):
|
|
72
58
|
def _set_kind(cls, values: Dict[str, Any]) -> Dict[str, Any]:
|
73
59
|
return values_with_discriminator(values, "kind", "bool")
|
74
60
|
|
75
|
-
@property
|
76
|
-
def qmod_type(self) -> type:
|
77
|
-
from classiq.qmod.qmod_parameter import CBool
|
78
|
-
|
79
|
-
return CBool
|
80
|
-
|
81
61
|
|
82
62
|
class ClassicalList(ClassicalType):
|
83
63
|
kind: Literal["list"]
|
@@ -90,26 +70,6 @@ class ClassicalList(ClassicalType):
|
|
90
70
|
def _set_kind(cls, values: Dict[str, Any]) -> Dict[str, Any]:
|
91
71
|
return values_with_discriminator(values, "kind", "list")
|
92
72
|
|
93
|
-
@property
|
94
|
-
def qmod_type(self) -> type:
|
95
|
-
from classiq.qmod.qmod_parameter import CArray
|
96
|
-
|
97
|
-
return CArray[self.element_type.qmod_type] # type:ignore[name-defined]
|
98
|
-
|
99
|
-
|
100
|
-
class Pauli(ClassicalType):
|
101
|
-
kind: Literal["pauli"]
|
102
|
-
|
103
|
-
@pydantic.root_validator(pre=True)
|
104
|
-
def _set_kind(cls, values: Dict[str, Any]) -> Dict[str, Any]:
|
105
|
-
return values_with_discriminator(values, "kind", "pauli")
|
106
|
-
|
107
|
-
@property
|
108
|
-
def qmod_type(self) -> type:
|
109
|
-
from classiq.qmod.builtins.enums import Pauli
|
110
|
-
|
111
|
-
return Pauli
|
112
|
-
|
113
73
|
|
114
74
|
class StructMetaType(ClassicalType):
|
115
75
|
kind: Literal["type_proxy"]
|
@@ -119,27 +79,6 @@ class StructMetaType(ClassicalType):
|
|
119
79
|
return values_with_discriminator(values, "kind", "type_proxy")
|
120
80
|
|
121
81
|
|
122
|
-
class TypeName(ClassicalType):
|
123
|
-
kind: Literal["struct_instance"]
|
124
|
-
name: str = pydantic.Field(description="The type name of the instance")
|
125
|
-
|
126
|
-
@pydantic.root_validator(pre=True)
|
127
|
-
def _set_kind(cls, values: Dict[str, Any]) -> Dict[str, Any]:
|
128
|
-
return values_with_discriminator(values, "kind", "struct_instance")
|
129
|
-
|
130
|
-
@property
|
131
|
-
def qmod_type(self) -> type:
|
132
|
-
return type(self.name, (TypeName,), dict())
|
133
|
-
|
134
|
-
|
135
|
-
class Enum(TypeName):
|
136
|
-
pass
|
137
|
-
|
138
|
-
|
139
|
-
class Struct(TypeName):
|
140
|
-
pass
|
141
|
-
|
142
|
-
|
143
82
|
class ClassicalArray(ClassicalType):
|
144
83
|
kind: Literal["array"]
|
145
84
|
element_type: "ConcreteClassicalType"
|
@@ -152,14 +91,6 @@ class ClassicalArray(ClassicalType):
|
|
152
91
|
def _set_kind(cls, values: Dict[str, Any]) -> Dict[str, Any]:
|
153
92
|
return values_with_discriminator(values, "kind", "array")
|
154
93
|
|
155
|
-
@property
|
156
|
-
def qmod_type(self) -> type:
|
157
|
-
from classiq.qmod.qmod_parameter import CArray
|
158
|
-
|
159
|
-
return CArray[
|
160
|
-
self.element_type.qmod_type, self.size # type:ignore[name-defined]
|
161
|
-
]
|
162
|
-
|
163
94
|
|
164
95
|
class OpaqueHandle(ClassicalType):
|
165
96
|
pass
|
@@ -197,44 +128,6 @@ class IQAERes(OpaqueHandle):
|
|
197
128
|
return values_with_discriminator(values, "kind", "iqae_result")
|
198
129
|
|
199
130
|
|
200
|
-
class LadderOperator(ClassicalType):
|
201
|
-
kind: Literal["ladder_operator"]
|
202
|
-
|
203
|
-
@pydantic.root_validator(pre=True)
|
204
|
-
def _set_kind(cls, values: Dict[str, Any]) -> Dict[str, Any]:
|
205
|
-
return values_with_discriminator(values, "kind", "ladder_operator")
|
206
|
-
|
207
|
-
@property
|
208
|
-
def qmod_type(self) -> type:
|
209
|
-
from classiq.qmod.builtins.enums import LadderOperator
|
210
|
-
|
211
|
-
return LadderOperator
|
212
|
-
|
213
|
-
|
214
|
-
ConcreteClassicalType = Annotated[
|
215
|
-
Union[
|
216
|
-
Integer,
|
217
|
-
Real,
|
218
|
-
Bool,
|
219
|
-
ClassicalList,
|
220
|
-
Pauli,
|
221
|
-
StructMetaType,
|
222
|
-
TypeName,
|
223
|
-
ClassicalArray,
|
224
|
-
VQEResult,
|
225
|
-
Histogram,
|
226
|
-
Estimation,
|
227
|
-
LadderOperator,
|
228
|
-
IQAERes,
|
229
|
-
],
|
230
|
-
Field(discriminator="kind"),
|
231
|
-
]
|
232
|
-
ClassicalList.update_forward_refs()
|
233
|
-
ClassicalArray.update_forward_refs()
|
234
|
-
|
235
|
-
PythonClassicalTypes = (int, float, bool, list, Enum)
|
236
|
-
|
237
|
-
|
238
131
|
def as_symbolic(symbols: Dict[str, ClassicalType]) -> Dict[str, RuntimeExpression]:
|
239
132
|
return {
|
240
133
|
param_name: param_type.as_symbolic(param_name)
|
@@ -0,0 +1,55 @@
|
|
1
|
+
from typing import Union
|
2
|
+
|
3
|
+
from pydantic import Field
|
4
|
+
from typing_extensions import Annotated
|
5
|
+
|
6
|
+
from classiq.interface.generator.functions.classical_type import (
|
7
|
+
Bool,
|
8
|
+
ClassicalArray,
|
9
|
+
ClassicalList,
|
10
|
+
Estimation,
|
11
|
+
Histogram,
|
12
|
+
Integer,
|
13
|
+
IQAERes,
|
14
|
+
Real,
|
15
|
+
StructMetaType,
|
16
|
+
VQEResult,
|
17
|
+
)
|
18
|
+
from classiq.interface.generator.functions.type_name import Enum, TypeName
|
19
|
+
from classiq.interface.generator.types.qstruct_declaration import QStructDeclaration
|
20
|
+
from classiq.interface.model.quantum_type import (
|
21
|
+
QuantumBit,
|
22
|
+
QuantumBitvector,
|
23
|
+
QuantumNumeric,
|
24
|
+
RegisterQuantumType,
|
25
|
+
)
|
26
|
+
|
27
|
+
ConcreteClassicalType = Annotated[
|
28
|
+
Union[
|
29
|
+
Integer,
|
30
|
+
Real,
|
31
|
+
Bool,
|
32
|
+
ClassicalList,
|
33
|
+
StructMetaType,
|
34
|
+
TypeName,
|
35
|
+
ClassicalArray,
|
36
|
+
VQEResult,
|
37
|
+
Histogram,
|
38
|
+
Estimation,
|
39
|
+
IQAERes,
|
40
|
+
],
|
41
|
+
Field(discriminator="kind"),
|
42
|
+
]
|
43
|
+
ClassicalList.update_forward_refs(ConcreteClassicalType=ConcreteClassicalType)
|
44
|
+
ClassicalArray.update_forward_refs(ConcreteClassicalType=ConcreteClassicalType)
|
45
|
+
|
46
|
+
PythonClassicalTypes = (int, float, bool, list, Enum)
|
47
|
+
|
48
|
+
ConcreteQuantumType = Annotated[
|
49
|
+
Union[QuantumBit, QuantumBitvector, QuantumNumeric, TypeName],
|
50
|
+
Field(discriminator="kind", default_factory=QuantumBitvector),
|
51
|
+
]
|
52
|
+
QuantumBitvector.update_forward_refs(ConcreteQuantumType=ConcreteQuantumType)
|
53
|
+
TypeName.update_forward_refs(ConcreteQuantumType=ConcreteQuantumType)
|
54
|
+
QStructDeclaration.update_forward_refs(ConcreteQuantumType=ConcreteQuantumType)
|
55
|
+
RegisterQuantumType.update_forward_refs(ConcreteQuantumType=ConcreteQuantumType)
|
@@ -1,23 +1,23 @@
|
|
1
1
|
import abc
|
2
|
-
from typing import
|
2
|
+
from typing import Sequence
|
3
3
|
|
4
4
|
import pydantic
|
5
5
|
|
6
|
-
from classiq.interface.
|
7
|
-
|
6
|
+
from classiq.interface.model.classical_parameter_declaration import (
|
7
|
+
AnonClassicalParameterDeclaration,
|
8
|
+
)
|
9
|
+
from classiq.interface.model.parameter import Parameter
|
8
10
|
|
9
11
|
|
10
|
-
class FunctionDeclaration(
|
12
|
+
class FunctionDeclaration(Parameter, abc.ABC):
|
11
13
|
"""
|
12
14
|
Facilitates the creation of a common function interface object.
|
13
15
|
"""
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
param_decls
|
18
|
-
|
19
|
-
default_factory=dict,
|
20
|
-
)
|
17
|
+
@property
|
18
|
+
@abc.abstractmethod
|
19
|
+
def param_decls(self) -> Sequence[AnonClassicalParameterDeclaration]:
|
20
|
+
pass
|
21
21
|
|
22
22
|
class Config:
|
23
23
|
extra = pydantic.Extra.forbid
|
@@ -1,9 +1,8 @@
|
|
1
1
|
from typing import Any
|
2
2
|
|
3
|
+
from classiq.interface.enum_utils import StrEnum
|
3
4
|
from classiq.interface.generator.function_params import PortDirection
|
4
5
|
|
5
|
-
from classiq._internals.enum_utils import StrEnum
|
6
|
-
|
7
6
|
|
8
7
|
class PortDeclarationDirection(StrEnum):
|
9
8
|
Input = "input"
|
@@ -0,0 +1,80 @@
|
|
1
|
+
from typing import TYPE_CHECKING, Any, Dict, Literal, Mapping, Optional
|
2
|
+
|
3
|
+
import pydantic
|
4
|
+
|
5
|
+
from classiq.interface.generator.expressions.qmod_qstruct_proxy import QmodQStructProxy
|
6
|
+
from classiq.interface.generator.functions.classical_type import (
|
7
|
+
ClassicalType,
|
8
|
+
)
|
9
|
+
from classiq.interface.helpers.pydantic_model_helpers import values_with_discriminator
|
10
|
+
from classiq.interface.model.handle_binding import HandleBinding
|
11
|
+
from classiq.interface.model.quantum_type import (
|
12
|
+
QuantumType,
|
13
|
+
)
|
14
|
+
|
15
|
+
if TYPE_CHECKING:
|
16
|
+
from classiq.interface.generator.functions.concrete_types import ConcreteQuantumType
|
17
|
+
|
18
|
+
|
19
|
+
class TypeName(ClassicalType, QuantumType): # type:ignore[misc]
|
20
|
+
kind: Literal["struct_instance"]
|
21
|
+
name: str = pydantic.Field(description="The type name of the instance")
|
22
|
+
_assigned_fields: Optional[Mapping[str, "ConcreteQuantumType"]] = (
|
23
|
+
pydantic.PrivateAttr(default=None)
|
24
|
+
)
|
25
|
+
|
26
|
+
@pydantic.root_validator(pre=True)
|
27
|
+
def _set_kind(cls, values: Dict[str, Any]) -> Dict[str, Any]:
|
28
|
+
return values_with_discriminator(values, "kind", "struct_instance")
|
29
|
+
|
30
|
+
def _update_size_in_bits_from_declaration(self) -> None:
|
31
|
+
fields_types = list(self.fields.values())
|
32
|
+
for field_type in fields_types:
|
33
|
+
field_type._update_size_in_bits_from_declaration()
|
34
|
+
if all(field_type.has_size_in_bits for field_type in fields_types):
|
35
|
+
self._size_in_bits = sum(
|
36
|
+
field_type.size_in_bits for field_type in fields_types
|
37
|
+
)
|
38
|
+
|
39
|
+
def get_proxy(self, handle: "HandleBinding") -> "QmodQStructProxy":
|
40
|
+
from classiq.interface.generator.expressions.qmod_qstruct_proxy import (
|
41
|
+
QmodQStructProxy,
|
42
|
+
)
|
43
|
+
|
44
|
+
return QmodQStructProxy(
|
45
|
+
handle=handle, struct_name=self.name, fields=self.fields
|
46
|
+
)
|
47
|
+
|
48
|
+
@property
|
49
|
+
def qmod_type_name(self) -> str:
|
50
|
+
return self.name
|
51
|
+
|
52
|
+
@property
|
53
|
+
def type_name(self) -> str:
|
54
|
+
return self.name
|
55
|
+
|
56
|
+
@property
|
57
|
+
def fields(self) -> Mapping[str, "ConcreteQuantumType"]:
|
58
|
+
from classiq.qmod.model_state_container import QMODULE
|
59
|
+
|
60
|
+
if self._assigned_fields is None:
|
61
|
+
qstruct_fields = QMODULE.qstruct_decls[self.name].fields
|
62
|
+
self._assigned_fields = {
|
63
|
+
field_name: field_type.copy()
|
64
|
+
for field_name, field_type in qstruct_fields.items()
|
65
|
+
}
|
66
|
+
|
67
|
+
return self._assigned_fields
|
68
|
+
|
69
|
+
def _set_fields(self, fields: Mapping[str, "ConcreteQuantumType"]) -> None:
|
70
|
+
from classiq.qmod.model_state_container import QMODULE
|
71
|
+
|
72
|
+
QMODULE.qstruct_decls[self.name].fields = fields
|
73
|
+
|
74
|
+
|
75
|
+
class Enum(TypeName):
|
76
|
+
pass
|
77
|
+
|
78
|
+
|
79
|
+
class Struct(TypeName):
|
80
|
+
pass
|
@@ -21,7 +21,7 @@ VISUALIZATION_HIDE_LIST = [
|
|
21
21
|
"control",
|
22
22
|
"mcx",
|
23
23
|
"iteration",
|
24
|
-
"
|
24
|
+
"stmt_block",
|
25
25
|
]
|
26
26
|
|
27
27
|
|
@@ -94,9 +94,9 @@ class GeneratedCircuitData(pydantic.BaseModel):
|
|
94
94
|
return cls(width=0)
|
95
95
|
|
96
96
|
|
97
|
-
class
|
97
|
+
class FunctionDebugInfoInterface(pydantic.BaseModel):
|
98
98
|
generated_function: Optional[GeneratedFunction]
|
99
|
-
children: List["
|
99
|
+
children: List["FunctionDebugInfoInterface"]
|
100
100
|
relative_qubits: Tuple[int, ...]
|
101
101
|
absolute_qubits: Optional[Tuple[int, ...]]
|
102
102
|
is_basis_gate: Optional[bool]
|
@@ -2,6 +2,7 @@ from typing import Any, Dict, List, Set, Tuple, Union
|
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
|
5
|
+
from classiq.interface.exceptions import ClassiqValueError
|
5
6
|
from classiq.interface.generator.arith.register_user_input import RegisterUserInput
|
6
7
|
from classiq.interface.generator.function_params import (
|
7
8
|
ArithmeticIODict,
|
@@ -11,8 +12,6 @@ from classiq.interface.generator.function_params import (
|
|
11
12
|
from classiq.interface.generator.state_preparation import StatePreparation
|
12
13
|
from classiq.interface.generator.user_defined_function_params import CustomFunction
|
13
14
|
|
14
|
-
from classiq.exceptions import ClassiqValueError
|
15
|
-
|
16
15
|
GroverStatePreparation = Union[StatePreparation, CustomFunction]
|
17
16
|
|
18
17
|
|
@@ -2,6 +2,7 @@ from typing import Any, Dict, Optional
|
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
|
5
|
+
from classiq.interface.exceptions import ClassiqValueError
|
5
6
|
from classiq.interface.generator.function_params import (
|
6
7
|
FunctionParams,
|
7
8
|
FunctionParamsDiscriminator,
|
@@ -18,8 +19,6 @@ from classiq.interface.generator.oracles.oracle_function_param_list import (
|
|
18
19
|
from classiq.interface.generator.range_types import NonNegativeFloatRange
|
19
20
|
from classiq.interface.generator.state_preparation import Metrics, StatePreparation
|
20
21
|
|
21
|
-
from classiq.exceptions import ClassiqValueError
|
22
|
-
|
23
22
|
_DEFAULT_ORACLE_DISCRIMINATOR: FunctionParamsDiscriminator = (
|
24
23
|
ArithmeticOracle.discriminator()
|
25
24
|
)
|
@@ -4,12 +4,11 @@ import pydantic
|
|
4
4
|
|
5
5
|
from classiq.interface.chemistry import operator
|
6
6
|
from classiq.interface.chemistry.operator import PauliOperator
|
7
|
+
from classiq.interface.enum_utils import StrEnum
|
7
8
|
from classiq.interface.generator.hamiltonian_evolution.hamiltonian_evolution import (
|
8
9
|
HamiltonianEvolution,
|
9
10
|
)
|
10
11
|
|
11
|
-
from classiq._internals.enum_utils import StrEnum
|
12
|
-
|
13
12
|
|
14
13
|
class ExponentiationOptimization(StrEnum):
|
15
14
|
MINIMIZE_DEPTH = "MINIMIZE_DEPTH"
|
@@ -2,13 +2,12 @@ import pydantic
|
|
2
2
|
|
3
3
|
from classiq.interface.chemistry import operator
|
4
4
|
from classiq.interface.chemistry.operator import PauliOperator
|
5
|
+
from classiq.interface.exceptions import ClassiqValueError
|
5
6
|
from classiq.interface.generator.hamiltonian_evolution.hamiltonian_evolution import (
|
6
7
|
HamiltonianEvolution,
|
7
8
|
)
|
8
9
|
from classiq.interface.generator.parameters import ParameterFloatType
|
9
10
|
|
10
|
-
from classiq.exceptions import ClassiqValueError
|
11
|
-
|
12
11
|
|
13
12
|
class SuzukiParameters(pydantic.BaseModel):
|
14
13
|
order: pydantic.PositiveInt = pydantic.Field(
|
@@ -5,6 +5,7 @@ from typing import Any, Dict, List, MutableSet, Optional
|
|
5
5
|
import pydantic
|
6
6
|
|
7
7
|
from classiq.interface.backend.backend_preferences import BackendPreferences
|
8
|
+
from classiq.interface.exceptions import ClassiqValueError
|
8
9
|
from classiq.interface.generator.transpiler_basis_gates import (
|
9
10
|
DEFAULT_BASIS_GATES,
|
10
11
|
DEFAULT_ROUTING_BASIS_GATES,
|
@@ -14,8 +15,6 @@ from classiq.interface.generator.transpiler_basis_gates import (
|
|
14
15
|
)
|
15
16
|
from classiq.interface.helpers.custom_pydantic_types import PydanticNonNegIntTuple
|
16
17
|
|
17
|
-
from classiq.exceptions import ClassiqValueError
|
18
|
-
|
19
18
|
ConnectivityMap = List[PydanticNonNegIntTuple]
|
20
19
|
BACKEND_VALIDATION_ERROR_MESSAGE = (
|
21
20
|
"Backend service provider and backend name should be specified together."
|
@@ -3,6 +3,8 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
|
3
3
|
|
4
4
|
import pydantic
|
5
5
|
|
6
|
+
from classiq.interface.enum_utils import StrEnum
|
7
|
+
from classiq.interface.exceptions import ClassiqValueError
|
6
8
|
from classiq.interface.generator import function_params
|
7
9
|
from classiq.interface.generator.arith.register_user_input import RegisterUserInput
|
8
10
|
from classiq.interface.generator.function_params import (
|
@@ -15,9 +17,6 @@ from classiq.interface.generator.transpiler_basis_gates import (
|
|
15
17
|
)
|
16
18
|
from classiq.interface.helpers.custom_pydantic_types import PydanticNonNegIntTuple
|
17
19
|
|
18
|
-
from classiq._internals.enum_utils import StrEnum
|
19
|
-
from classiq.exceptions import ClassiqValueError
|
20
|
-
|
21
20
|
ConnectivityMap = List[PydanticNonNegIntTuple]
|
22
21
|
|
23
22
|
|
@@ -7,12 +7,11 @@ from classiq.interface.chemistry.ground_state_problem import (
|
|
7
7
|
HamiltonianProblem,
|
8
8
|
MoleculeProblem,
|
9
9
|
)
|
10
|
+
from classiq.interface.exceptions import ClassiqValueError
|
10
11
|
from classiq.interface.generator.chemistry_function_params import (
|
11
12
|
ChemistryFunctionParams,
|
12
13
|
)
|
13
14
|
|
14
|
-
from classiq.exceptions import ClassiqValueError
|
15
|
-
|
16
15
|
|
17
16
|
class HartreeFock(ChemistryFunctionParams):
|
18
17
|
@pydantic.validator("gs_problem")
|
@@ -2,11 +2,10 @@ from typing import TYPE_CHECKING, Any, Dict, List
|
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
|
5
|
+
from classiq.interface.exceptions import ClassiqValueError
|
5
6
|
from classiq.interface.generator import function_params
|
6
7
|
from classiq.interface.generator.arith.register_user_input import RegisterArithmeticInfo
|
7
8
|
|
8
|
-
from classiq.exceptions import ClassiqValueError
|
9
|
-
|
10
9
|
STATE = "state"
|
11
10
|
TARGET = "target"
|
12
11
|
|
@@ -2,13 +2,12 @@ from typing import Any, Dict, Optional, cast
|
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
|
5
|
+
from classiq.interface.exceptions import ClassiqValueError
|
5
6
|
from classiq.interface.generator.arith.register_user_input import RegisterUserInput
|
6
7
|
from classiq.interface.generator.control_state import ControlState
|
7
8
|
from classiq.interface.generator.function_params import FunctionParams
|
8
9
|
from classiq.interface.generator.parameters import ParameterFloatType
|
9
10
|
|
10
|
-
from classiq.exceptions import ClassiqValueError
|
11
|
-
|
12
11
|
CTRL = "CTRL"
|
13
12
|
TARGET = "TARGET"
|
14
13
|
|
@@ -2,12 +2,11 @@ from typing import Any, Dict, List, Optional
|
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
|
5
|
+
from classiq.interface.exceptions import ClassiqValueError
|
5
6
|
from classiq.interface.generator.arith.register_user_input import RegisterUserInput
|
6
7
|
from classiq.interface.generator.control_state import ControlState
|
7
8
|
from classiq.interface.generator.function_params import FunctionParams
|
8
9
|
|
9
|
-
from classiq.exceptions import ClassiqValueError
|
10
|
-
|
11
10
|
CTRL = "CTRL_IN"
|
12
11
|
TARGET_QUBIT = "TARGET_QUBIT"
|
13
12
|
|
@@ -4,11 +4,10 @@ from typing import Dict, Optional, Union
|
|
4
4
|
import pydantic
|
5
5
|
from pydantic import BaseModel, Extra
|
6
6
|
|
7
|
+
from classiq.interface.enum_utils import StrEnum
|
8
|
+
from classiq.interface.exceptions import ClassiqValueError
|
7
9
|
from classiq.interface.generator.transpiler_basis_gates import TranspilerBasisGates
|
8
10
|
|
9
|
-
from classiq._internals.enum_utils import StrEnum
|
10
|
-
from classiq.exceptions import ClassiqValueError
|
11
|
-
|
12
11
|
UNCONSTRAINED = -1
|
13
12
|
|
14
13
|
|