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
@@ -3,15 +3,16 @@ from typing import List
|
|
3
3
|
|
4
4
|
import pydantic
|
5
5
|
|
6
|
+
from classiq.interface.exceptions import ClassiqValueError
|
6
7
|
from classiq.interface.executor.execution_preferences import ExecutionPreferences
|
7
8
|
from classiq.interface.generator.constant import Constant
|
8
9
|
from classiq.interface.generator.function_params import ArithmeticIODict
|
9
10
|
from classiq.interface.generator.types.enum_declaration import EnumDeclaration
|
11
|
+
from classiq.interface.generator.types.qstruct_declaration import QStructDeclaration
|
10
12
|
from classiq.interface.generator.types.struct_declaration import StructDeclaration
|
11
13
|
from classiq.interface.helpers.validation_helpers import is_list_unique
|
12
14
|
from classiq.interface.helpers.versioned_model import VersionedModel
|
13
|
-
|
14
|
-
from classiq.exceptions import ClassiqValueError
|
15
|
+
from classiq.interface.model.quantum_type import RegisterQuantumTypeDict
|
15
16
|
|
16
17
|
TYPE_LIBRARY_DUPLICATED_TYPE_NAMES = (
|
17
18
|
"Cannot have multiple struct types with the same name"
|
@@ -33,6 +34,11 @@ class ClassiqBaseModel(VersionedModel, ABC):
|
|
33
34
|
description="user-defined structs",
|
34
35
|
)
|
35
36
|
|
37
|
+
qstructs: List[QStructDeclaration] = pydantic.Field(
|
38
|
+
default_factory=list,
|
39
|
+
description="user-defined quantum structs",
|
40
|
+
)
|
41
|
+
|
36
42
|
constants: List[Constant] = pydantic.Field(
|
37
43
|
default_factory=list,
|
38
44
|
)
|
@@ -58,3 +64,7 @@ class ExecutionModel(ClassiqBaseModel):
|
|
58
64
|
description="Mapping between a measured register name and its arithmetic type",
|
59
65
|
default_factory=dict,
|
60
66
|
)
|
67
|
+
circuit_output_types: RegisterQuantumTypeDict = pydantic.Field(
|
68
|
+
description="Mapping between a measured register name and its qmod type",
|
69
|
+
default=dict(),
|
70
|
+
)
|
@@ -11,6 +11,8 @@ from classiq.interface.backend.quantum_backend_providers import (
|
|
11
11
|
AllBackendsNameByVendor,
|
12
12
|
ProviderVendor,
|
13
13
|
)
|
14
|
+
from classiq.interface.enum_utils import StrEnum
|
15
|
+
from classiq.interface.exceptions import ClassiqValueError
|
14
16
|
from classiq.interface.generator.arith.machine_precision import (
|
15
17
|
DEFAULT_MACHINE_PRECISION,
|
16
18
|
)
|
@@ -22,9 +24,6 @@ from classiq.interface.generator.model.preferences.randomness import create_rand
|
|
22
24
|
from classiq.interface.hardware import Provider
|
23
25
|
from classiq.interface.helpers.custom_pydantic_types import PydanticMachinePrecision
|
24
26
|
|
25
|
-
from classiq._internals.enum_utils import StrEnum
|
26
|
-
from classiq.exceptions import ClassiqValueError
|
27
|
-
|
28
27
|
if TYPE_CHECKING:
|
29
28
|
VisualizationLevel: TypeAlias = Optional[int]
|
30
29
|
else:
|
@@ -127,6 +126,11 @@ class Preferences(pydantic.BaseModel, extra=pydantic.Extra.forbid):
|
|
127
126
|
"transpiled circuit and its depth",
|
128
127
|
)
|
129
128
|
|
129
|
+
solovay_kitaev_max_iterations: Optional[pydantic.PositiveInt] = pydantic.Field(
|
130
|
+
None,
|
131
|
+
description="Maximum iterations for the Solovay-Kitaev algorithm (if applied).",
|
132
|
+
)
|
133
|
+
|
130
134
|
timeout_seconds: pydantic.PositiveInt = pydantic.Field(
|
131
135
|
default=300, description="Generation timeout in seconds"
|
132
136
|
)
|
@@ -11,6 +11,7 @@ from typing import ( # type: ignore[attr-defined]
|
|
11
11
|
_GenericAlias,
|
12
12
|
)
|
13
13
|
|
14
|
+
from classiq.interface.exceptions import ClassiqQRegError
|
14
15
|
from classiq.interface.generator.arith.register_user_input import (
|
15
16
|
RegisterArithmeticInfo,
|
16
17
|
RegisterUserInput,
|
@@ -18,8 +19,6 @@ from classiq.interface.generator.arith.register_user_input import (
|
|
18
19
|
from classiq.interface.generator.function_params import ArithmeticIODict, IOName
|
19
20
|
from classiq.interface.generator.register_role import RegisterRole
|
20
21
|
|
21
|
-
from classiq.exceptions import ClassiqQRegError
|
22
|
-
|
23
22
|
if sys.version_info >= (3, 9):
|
24
23
|
from types import GenericAlias as TypesGenericAlias
|
25
24
|
|
@@ -4,6 +4,7 @@ from typing import Dict
|
|
4
4
|
|
5
5
|
import numexpr # type: ignore[import]
|
6
6
|
|
7
|
+
from classiq.interface.exceptions import ClassiqArithmeticError, ClassiqValueError
|
7
8
|
from classiq.interface.generator.arith import number_utils
|
8
9
|
from classiq.interface.generator.arith.arithmetic import Arithmetic
|
9
10
|
from classiq.interface.generator.arith.arithmetic_expression_abc import (
|
@@ -17,8 +18,6 @@ from classiq.interface.generator.oracles.oracle_abc import (
|
|
17
18
|
VariableTypedResultMap,
|
18
19
|
)
|
19
20
|
|
20
|
-
from classiq.exceptions import ClassiqArithmeticError, ClassiqValueError
|
21
|
-
|
22
21
|
|
23
22
|
class ArithmeticOracle(OracleABC[float], ArithmeticExpressionABC):
|
24
23
|
@staticmethod
|
@@ -2,6 +2,7 @@ from typing import Any, Dict
|
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
|
5
|
+
from classiq.interface.exceptions import ClassiqValueError
|
5
6
|
from classiq.interface.generator.function_params import parse_function_params_values
|
6
7
|
from classiq.interface.generator.oracles.oracle_abc import (
|
7
8
|
ArithmeticIODict,
|
@@ -11,8 +12,6 @@ from classiq.interface.generator.oracles.oracle_abc import (
|
|
11
12
|
)
|
12
13
|
from classiq.interface.generator.user_defined_function_params import CustomFunction
|
13
14
|
|
14
|
-
from classiq.exceptions import ClassiqValueError
|
15
|
-
|
16
15
|
QubitState = str
|
17
16
|
|
18
17
|
|
@@ -3,13 +3,12 @@ from typing import Dict, Generic, List, Optional, Sequence, TypeVar
|
|
3
3
|
|
4
4
|
import numpy as np
|
5
5
|
|
6
|
+
from classiq.interface.exceptions import ClassiqOracleError
|
6
7
|
from classiq.interface.executor.result import State
|
7
8
|
from classiq.interface.generator.arith.register_user_input import RegisterUserInput
|
8
9
|
from classiq.interface.generator.function_params import ArithmeticIODict, FunctionParams
|
9
10
|
from classiq.interface.generator.generated_circuit_data import IOQubitMapping
|
10
11
|
|
11
|
-
from classiq.exceptions import ClassiqOracleError
|
12
|
-
|
13
12
|
ProblemResultType = TypeVar("ProblemResultType")
|
14
13
|
|
15
14
|
VariableBinResultMap = Dict[str, State]
|
@@ -2,10 +2,9 @@ import itertools
|
|
2
2
|
from dataclasses import dataclass
|
3
3
|
from typing import Iterator, List, Optional, Tuple
|
4
4
|
|
5
|
+
from classiq.interface.exceptions import ClassiqValueError
|
5
6
|
from classiq.interface.generator.slice_parsing_utils import parse_io_slicing
|
6
7
|
|
7
|
-
from classiq.exceptions import ClassiqValueError
|
8
|
-
|
9
8
|
|
10
9
|
@dataclass(frozen=True)
|
11
10
|
class PartitionedRegister:
|
@@ -3,14 +3,13 @@ from typing import Any, Dict, Generic, List, Sequence, Tuple, TypeVar
|
|
3
3
|
|
4
4
|
import pydantic
|
5
5
|
|
6
|
+
from classiq.interface.exceptions import ClassiqError
|
6
7
|
from classiq.interface.generator.arith.register_user_input import RegisterArithmeticInfo
|
7
8
|
from classiq.interface.generator.function_params import FunctionParams
|
8
9
|
from classiq.interface.helpers.hashable_pydantic_base_model import (
|
9
10
|
HashablePydanticBaseModel,
|
10
11
|
)
|
11
12
|
|
12
|
-
from classiq.exceptions import ClassiqError
|
13
|
-
|
14
13
|
STATE_NAME: str = "state"
|
15
14
|
TARGET_NAME: str = "target"
|
16
15
|
_REL_TOLERANCE: float = 0.01
|
@@ -1,11 +1,10 @@
|
|
1
1
|
from pydantic import BaseModel
|
2
2
|
|
3
|
+
from classiq.interface.enum_utils import StrEnum
|
3
4
|
from classiq.interface.helpers.custom_pydantic_types import (
|
4
5
|
PydanticNonOneProbabilityFloat,
|
5
6
|
)
|
6
7
|
|
7
|
-
from classiq._internals.enum_utils import StrEnum
|
8
|
-
|
9
8
|
|
10
9
|
# it seems to be ambiguous in this class. it is Identical to the Metrics, up to the
|
11
10
|
# attribute RANDOM, However RANDOM isn't really used or treated in any part of the code.
|
@@ -2,6 +2,7 @@ from typing import Any, Dict, Optional, Tuple
|
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
|
5
|
+
from classiq.interface.exceptions import ClassiqMismatchIOsError, ClassiqValueError
|
5
6
|
from classiq.interface.generator.arith.register_user_input import RegisterArithmeticInfo
|
6
7
|
from classiq.interface.generator.function_param_list_without_self_reference import (
|
7
8
|
function_param_library_without_self_reference,
|
@@ -17,8 +18,6 @@ from classiq.interface.generator.hamiltonian_evolution.exponentiation import (
|
|
17
18
|
)
|
18
19
|
from classiq.interface.generator.user_defined_function_params import CustomFunction
|
19
20
|
|
20
|
-
from classiq.exceptions import ClassiqMismatchIOsError, ClassiqValueError
|
21
|
-
|
22
21
|
PHASE_ESTIMATION_DEFAULT_OUTPUT_NAME = "PHASE_ESTIMATION"
|
23
22
|
CUSTOM_FUNCTIONS_IO_MISMATCH_ERROR = (
|
24
23
|
"Custom function provided to the QPE has different input and output names."
|
@@ -3,6 +3,8 @@ from typing import List, Literal, Optional, Union
|
|
3
3
|
import numpy as np
|
4
4
|
import pydantic
|
5
5
|
|
6
|
+
from classiq.interface.enum_utils import StrEnum
|
7
|
+
from classiq.interface.exceptions import ClassiqQSVMError, ClassiqValueError
|
6
8
|
from classiq.interface.generator.arith.register_user_input import RegisterUserInput
|
7
9
|
from classiq.interface.generator.function_params import (
|
8
10
|
DEFAULT_INPUT_NAME,
|
@@ -13,9 +15,6 @@ from classiq.interface.helpers.hashable_pydantic_base_model import (
|
|
13
15
|
HashablePydanticBaseModel,
|
14
16
|
)
|
15
17
|
|
16
|
-
from classiq._internals.enum_utils import StrEnum
|
17
|
-
from classiq.exceptions import ClassiqQSVMError, ClassiqValueError
|
18
|
-
|
19
18
|
VALID_PAULI_LETTERS = ("I", "X", "Y", "Z")
|
20
19
|
|
21
20
|
|
@@ -18,10 +18,12 @@ from typing import (
|
|
18
18
|
Tuple,
|
19
19
|
Union,
|
20
20
|
)
|
21
|
+
from uuid import UUID, uuid4
|
21
22
|
|
22
23
|
import pydantic
|
23
24
|
from pydantic import BaseModel, Extra
|
24
25
|
|
26
|
+
from classiq.interface.exceptions import ClassiqControlError, ClassiqValueError
|
25
27
|
from classiq.interface.generator import function_param_list, function_params as f_params
|
26
28
|
from classiq.interface.generator.arith.arithmetic import Arithmetic
|
27
29
|
from classiq.interface.generator.compiler_keywords import EXPANDED_KEYWORD
|
@@ -47,8 +49,6 @@ from classiq.interface.helpers.hashable_pydantic_base_model import (
|
|
47
49
|
HashablePydanticBaseModel,
|
48
50
|
)
|
49
51
|
|
50
|
-
from classiq.exceptions import ClassiqControlError, ClassiqValueError
|
51
|
-
|
52
52
|
DEFAULT_SUFFIX_LEN: int = 6
|
53
53
|
BAD_INPUT_ERROR_MSG = "Bad input name given"
|
54
54
|
BAD_OUTPUT_ERROR_MSG = "Bad output name given"
|
@@ -150,6 +150,8 @@ class SynthesisQuantumFunctionCall(BaseModel):
|
|
150
150
|
"If not set, determined automatically.",
|
151
151
|
)
|
152
152
|
|
153
|
+
uuid: UUID = pydantic.Field(default_factory=uuid4)
|
154
|
+
|
153
155
|
def __eq__(self, other: Any) -> bool:
|
154
156
|
return (
|
155
157
|
isinstance(other, SynthesisQuantumFunctionCall) and self.name == other.name
|
@@ -6,6 +6,10 @@ from typing import Dict, List, Optional, Tuple, Union
|
|
6
6
|
import pydantic
|
7
7
|
from typing_extensions import TypeAlias
|
8
8
|
|
9
|
+
from classiq.interface.exceptions import (
|
10
|
+
ClassiqMissingOutputFormatError,
|
11
|
+
ClassiqStateInitializationError,
|
12
|
+
)
|
9
13
|
from classiq.interface.executor import quantum_code
|
10
14
|
from classiq.interface.executor.quantum_instruction_set import QuantumInstructionSet
|
11
15
|
from classiq.interface.executor.register_initialization import RegisterInitialization
|
@@ -17,7 +21,7 @@ from classiq.interface.generator.circuit_code.types_and_constants import (
|
|
17
21
|
CodeAndSyntax,
|
18
22
|
)
|
19
23
|
from classiq.interface.generator.generated_circuit_data import (
|
20
|
-
|
24
|
+
FunctionDebugInfoInterface,
|
21
25
|
GeneratedCircuitData,
|
22
26
|
)
|
23
27
|
from classiq.interface.generator.hardware.hardware_data import SynthesisHardwareData
|
@@ -28,11 +32,6 @@ from classiq.interface.generator.synthesis_metadata.synthesis_duration import (
|
|
28
32
|
from classiq.interface.helpers.versioned_model import VersionedModel
|
29
33
|
from classiq.interface.ide.ide_data import CircuitMetrics
|
30
34
|
|
31
|
-
from classiq.exceptions import (
|
32
|
-
ClassiqMissingOutputFormatError,
|
33
|
-
ClassiqStateInitializationError,
|
34
|
-
)
|
35
|
-
|
36
35
|
RegisterName: TypeAlias = str
|
37
36
|
InitialConditions: TypeAlias = Dict[RegisterName, int]
|
38
37
|
|
@@ -59,7 +58,7 @@ class QuantumProgram(VersionedModel, CircuitCodeInterface):
|
|
59
58
|
transpiled_circuit: Optional[TranspiledCircuitData]
|
60
59
|
creation_time: str = pydantic.Field(default_factory=datetime.utcnow().isoformat)
|
61
60
|
synthesis_duration: Optional[SynthesisStepDurations]
|
62
|
-
debug_info: Optional[List[
|
61
|
+
debug_info: Optional[List[FunctionDebugInfoInterface]]
|
63
62
|
program_id: str = pydantic.Field(default_factory=get_uuid_as_str)
|
64
63
|
|
65
64
|
def _hardware_agnostic_program_code(self) -> CodeAndSyntax:
|
@@ -4,7 +4,7 @@ from typing import Any, Dict, Generic, Optional, TypeVar
|
|
4
4
|
import pydantic
|
5
5
|
from pydantic.generics import GenericModel
|
6
6
|
|
7
|
-
from classiq.exceptions import ClassiqValueError
|
7
|
+
from classiq.interface.exceptions import ClassiqValueError
|
8
8
|
|
9
9
|
RangeType = TypeVar("RangeType", int, float)
|
10
10
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from typing import Set
|
2
2
|
|
3
|
-
from classiq.
|
3
|
+
from classiq.interface.enum_utils import StrEnum
|
4
4
|
|
5
5
|
|
6
6
|
class RegisterRole(StrEnum):
|
@@ -10,6 +10,7 @@ class RegisterRole(StrEnum):
|
|
10
10
|
ZERO_INPUT = "zero_input"
|
11
11
|
ZERO_OUTPUT = "zero_output"
|
12
12
|
GARBAGE_OUTPUT = "garbage_output"
|
13
|
+
EXPLICIT_ZERO_INPUT = "explicit_zero_input"
|
13
14
|
|
14
15
|
@staticmethod
|
15
16
|
def output_roles(include_garbage: bool = False) -> Set["RegisterRole"]:
|
@@ -24,4 +25,9 @@ class RegisterRole(StrEnum):
|
|
24
25
|
|
25
26
|
@staticmethod
|
26
27
|
def input_roles() -> Set["RegisterRole"]:
|
27
|
-
return {
|
28
|
+
return {
|
29
|
+
RegisterRole.INPUT,
|
30
|
+
RegisterRole.ZERO_INPUT,
|
31
|
+
RegisterRole.AUXILIARY,
|
32
|
+
RegisterRole.EXPLICIT_ZERO_INPUT,
|
33
|
+
}
|
@@ -1,10 +1,9 @@
|
|
1
1
|
import re
|
2
2
|
from typing import Match, Optional, Tuple
|
3
3
|
|
4
|
+
from classiq.interface.exceptions import ClassiqValueError
|
4
5
|
from classiq.interface.generator.function_params import NAME_REGEX
|
5
6
|
|
6
|
-
from classiq.exceptions import ClassiqValueError
|
7
|
-
|
8
7
|
NAME = "name"
|
9
8
|
SLICING = "slicing"
|
10
9
|
SEPARATOR = ":"
|
@@ -2,6 +2,7 @@ from typing import Any, Dict, Literal, Optional, 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.control_state import ControlState
|
7
8
|
from classiq.interface.generator.standard_gates.standard_gates import (
|
@@ -9,8 +10,6 @@ from classiq.interface.generator.standard_gates.standard_gates import (
|
|
9
10
|
_StandardGate,
|
10
11
|
)
|
11
12
|
|
12
|
-
from classiq.exceptions import ClassiqValueError
|
13
|
-
|
14
13
|
CONTROLLED_GATE_CONTROL: str = "CTRL"
|
15
14
|
CONTROLLED_GATE_TARGET: str = DEFAULT_STANDARD_GATE_ARG_NAME
|
16
15
|
DEFAULT_NUM_CTRL_QUBITS: int = 1
|
@@ -1,12 +1,11 @@
|
|
1
1
|
from typing import FrozenSet
|
2
2
|
|
3
|
+
from classiq.interface.enum_utils import StrEnum
|
4
|
+
from classiq.interface.exceptions import ClassiqValueError
|
3
5
|
from classiq.interface.generator.preferences.optimization import (
|
4
6
|
StatePrepOptimizationMethod,
|
5
7
|
)
|
6
8
|
|
7
|
-
from classiq._internals.enum_utils import StrEnum
|
8
|
-
from classiq.exceptions import ClassiqValueError
|
9
|
-
|
10
9
|
_AMPLITUDE_SUPPORTING_METRICS: FrozenSet = frozenset(
|
11
10
|
{"L2", "L1", "MAX_PROBABILITY", "TOTAL_VARIATION"}
|
12
11
|
)
|
@@ -3,6 +3,7 @@ from typing import Any, Dict, Optional, Union
|
|
3
3
|
import numpy as np
|
4
4
|
import pydantic
|
5
5
|
|
6
|
+
from classiq.interface.exceptions import ClassiqValueError
|
6
7
|
from classiq.interface.generator.range_types import NonNegativeFloatRange
|
7
8
|
from classiq.interface.generator.state_preparation.distributions import (
|
8
9
|
PMF,
|
@@ -21,8 +22,6 @@ from classiq.interface.generator.validations.validator_functions import (
|
|
21
22
|
validate_amplitudes,
|
22
23
|
)
|
23
24
|
|
24
|
-
from classiq.exceptions import ClassiqValueError
|
25
|
-
|
26
25
|
|
27
26
|
class StatePreparation(StatePreparationABC):
|
28
27
|
amplitudes: Optional[Amplitudes] = pydantic.Field(
|
@@ -1,11 +1,9 @@
|
|
1
|
-
from typing import Dict,
|
1
|
+
from typing import Dict, Optional, Set
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
|
5
5
|
from classiq.interface.backend.pydantic_backend import PydanticExecutionParameter
|
6
6
|
|
7
|
-
CPARAM_EXECUTION_SUFFIX: Final[str] = "_param"
|
8
|
-
|
9
7
|
|
10
8
|
class FunctionExecutionData(pydantic.BaseModel):
|
11
9
|
power_parameter: Optional[PydanticExecutionParameter] = pydantic.Field(default=None)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
from enum import IntEnum
|
2
|
+
|
1
3
|
from classiq.interface.chemistry.elements import ELEMENTS
|
2
4
|
from classiq.interface.chemistry.ground_state_problem import FermionMapping
|
3
5
|
from classiq.interface.generator.types.enum_declaration import EnumDeclaration
|
@@ -14,56 +16,47 @@ FERMION_MAPPING = EnumDeclaration(
|
|
14
16
|
},
|
15
17
|
)
|
16
18
|
|
17
|
-
FINANCE_FUNCTION_TYPE = EnumDeclaration(
|
18
|
-
name="FinanceFunctionType",
|
19
|
-
members={
|
20
|
-
"VAR": 0,
|
21
|
-
"SHORTFALL": 1,
|
22
|
-
"X_SQUARE": 2,
|
23
|
-
"EUROPEAN_CALL_OPTION": 3,
|
24
|
-
},
|
25
|
-
)
|
26
19
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
},
|
33
|
-
)
|
20
|
+
class FinanceFunctionType(IntEnum):
|
21
|
+
VAR = 0
|
22
|
+
SHORTFALL = 1
|
23
|
+
X_SQUARE = 2
|
24
|
+
EUROPEAN_CALL_OPTION = 3
|
34
25
|
|
35
|
-
OPTIMIZER = EnumDeclaration(
|
36
|
-
name="Optimizer",
|
37
|
-
members={
|
38
|
-
"COBYLA": 1,
|
39
|
-
"SPSA": 2,
|
40
|
-
"L_BFGS_B": 3,
|
41
|
-
"NELDER_MEAD": 4,
|
42
|
-
"ADAM": 5,
|
43
|
-
},
|
44
|
-
)
|
45
26
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
27
|
+
class LadderOperator(IntEnum):
|
28
|
+
PLUS = 0
|
29
|
+
MINUS = 1
|
30
|
+
|
31
|
+
|
32
|
+
class Optimizer(IntEnum):
|
33
|
+
COBYLA = 1
|
34
|
+
SPSA = 2
|
35
|
+
L_BFGS_B = 3
|
36
|
+
NELDER_MEAD = 4
|
37
|
+
ADAM = 5
|
38
|
+
|
39
|
+
|
40
|
+
class Pauli(IntEnum):
|
41
|
+
I = 0 # noqa: E741
|
42
|
+
X = 1
|
43
|
+
Y = 2
|
44
|
+
Z = 3
|
45
|
+
|
46
|
+
|
47
|
+
class QSVMFeatureMapEntanglement(IntEnum):
|
48
|
+
FULL = 0
|
49
|
+
LINEAR = 1
|
50
|
+
CIRCULAR = 2
|
51
|
+
SCA = 3
|
52
|
+
PAIRWISE = 4
|
55
53
|
|
56
|
-
QSVM_FEATURE_MAP_ENTANGLEMENT = EnumDeclaration(
|
57
|
-
name="QSVMFeatureMapEntanglement",
|
58
|
-
members={
|
59
|
-
"FULL": 0,
|
60
|
-
"LINEAR": 1,
|
61
|
-
"CIRCULAR": 2,
|
62
|
-
"SCA": 3,
|
63
|
-
"PAIRWISE": 4,
|
64
|
-
},
|
65
|
-
)
|
66
54
|
|
67
55
|
for enum_decl in list(vars().values()):
|
68
56
|
if isinstance(enum_decl, EnumDeclaration):
|
69
57
|
EnumDeclaration.BUILTIN_ENUM_DECLARATIONS[enum_decl.name] = enum_decl
|
58
|
+
elif isinstance(enum_decl, type) and issubclass(enum_decl, IntEnum):
|
59
|
+
EnumDeclaration.BUILTIN_ENUM_DECLARATIONS[enum_decl.__name__] = EnumDeclaration(
|
60
|
+
name=enum_decl.__name__,
|
61
|
+
members={enum_val.name: enum_val.value for enum_val in enum_decl},
|
62
|
+
)
|
@@ -2,10 +2,9 @@ import functools
|
|
2
2
|
|
3
3
|
from classiq.interface.generator.functions.classical_type import (
|
4
4
|
ClassicalList,
|
5
|
-
Enum,
|
6
5
|
Real,
|
7
|
-
Struct,
|
8
6
|
)
|
7
|
+
from classiq.interface.generator.functions.type_name import Enum, Struct
|
9
8
|
from classiq.interface.generator.types.struct_declaration import StructDeclaration
|
10
9
|
from classiq.interface.helpers.pydantic_model_helpers import nameables_to_dict
|
11
10
|
|
@@ -5,8 +5,7 @@ from typing import ClassVar, Dict
|
|
5
5
|
import pydantic
|
6
6
|
|
7
7
|
from classiq.interface.ast_node import HashableASTNode
|
8
|
-
|
9
|
-
from classiq.exceptions import ClassiqValueError
|
8
|
+
from classiq.interface.exceptions import ClassiqValueError
|
10
9
|
|
11
10
|
|
12
11
|
class EnumDeclaration(HashableASTNode):
|
@@ -0,0 +1,17 @@
|
|
1
|
+
from typing import TYPE_CHECKING, Mapping
|
2
|
+
|
3
|
+
import pydantic
|
4
|
+
|
5
|
+
from classiq.interface.ast_node import HashableASTNode
|
6
|
+
|
7
|
+
if TYPE_CHECKING:
|
8
|
+
from classiq.interface.generator.functions.concrete_types import ConcreteQuantumType
|
9
|
+
|
10
|
+
|
11
|
+
class QStructDeclaration(HashableASTNode):
|
12
|
+
name: str
|
13
|
+
|
14
|
+
fields: Mapping[str, "ConcreteQuantumType"] = pydantic.Field(
|
15
|
+
default_factory=dict,
|
16
|
+
description="Dictionary of field names and their quantum types",
|
17
|
+
)
|
@@ -3,9 +3,8 @@ from typing import Any, ClassVar, Dict, Mapping
|
|
3
3
|
import pydantic
|
4
4
|
|
5
5
|
from classiq.interface.ast_node import HashableASTNode
|
6
|
-
from classiq.interface.
|
7
|
-
|
8
|
-
from classiq.exceptions import ClassiqValueError
|
6
|
+
from classiq.interface.exceptions import ClassiqValueError
|
7
|
+
from classiq.interface.generator.functions.concrete_types import ConcreteClassicalType
|
9
8
|
|
10
9
|
|
11
10
|
class StructDeclaration(HashableASTNode):
|
@@ -2,6 +2,7 @@ from typing import Iterable, Optional
|
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
|
5
|
+
from classiq.interface.exceptions import ClassiqValueError
|
5
6
|
from classiq.interface.generator.chemistry_function_params import (
|
6
7
|
ChemistryFunctionParams,
|
7
8
|
)
|
@@ -10,8 +11,6 @@ from classiq.interface.generator.excitations import (
|
|
10
11
|
EXCITATIONS_TYPE_EXACT,
|
11
12
|
)
|
12
13
|
|
13
|
-
from classiq.exceptions import ClassiqValueError
|
14
|
-
|
15
14
|
_EXCITATIONS_DICT = {"s": 1, "d": 2, "t": 3, "q": 4}
|
16
15
|
|
17
16
|
DEFAULT_EXCITATIONS = [1, 2]
|
@@ -3,11 +3,10 @@ from typing import List, Union
|
|
3
3
|
import numpy as np
|
4
4
|
import pydantic
|
5
5
|
|
6
|
+
from classiq.interface.exceptions import ClassiqValueError
|
6
7
|
from classiq.interface.generator import complex_type, function_params
|
7
8
|
from classiq.interface.generator.arith.register_user_input import RegisterArithmeticInfo
|
8
9
|
|
9
|
-
from classiq.exceptions import ClassiqValueError
|
10
|
-
|
11
10
|
DataNumber = Union[complex_type.Complex, float, int]
|
12
11
|
DataArray = List[List[DataNumber]]
|
13
12
|
|
@@ -5,14 +5,13 @@ from typing import Collection, Iterable, List, Mapping, Optional, TypeVar
|
|
5
5
|
|
6
6
|
import networkx as nx
|
7
7
|
|
8
|
+
from classiq.interface.exceptions import ClassiqValueError
|
8
9
|
from classiq.interface.generator.quantum_function_call import (
|
9
10
|
SynthesisQuantumFunctionCall,
|
10
11
|
WireName,
|
11
12
|
)
|
12
13
|
from classiq.interface.helpers.custom_pydantic_types import PydanticNonEmptyString
|
13
14
|
|
14
|
-
from classiq.exceptions import ClassiqValueError
|
15
|
-
|
16
15
|
IO_MULTI_USE_ERROR_MSG = "Input and output names can only be used once"
|
17
16
|
UNCONNECTED_WIRES_ERROR_MSG = "Wires connected only on one end"
|
18
17
|
UNCONNECTED_FLOW_IO_ERROR_MSG = "Flow IOs not connected to inner calls"
|
@@ -2,10 +2,9 @@ from typing import Iterable, List, Sequence, Sized, Tuple, TypeVar
|
|
2
2
|
|
3
3
|
import numpy as np
|
4
4
|
|
5
|
+
from classiq.interface.exceptions import ClassiqValueError
|
5
6
|
from classiq.interface.helpers.custom_pydantic_types import PydanticProbabilityFloat
|
6
7
|
|
7
|
-
from classiq.exceptions import ClassiqValueError
|
8
|
-
|
9
8
|
NOT_SUM_TO_ONE_ERROR = "Probabilities do not sum to 1"
|
10
9
|
|
11
10
|
SUM_TO_ONE_SENSITIVITY = 8
|