classiq 0.37.0__py3-none-any.whl → 0.38.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 +2 -2
- classiq/_analyzer_extras/_ipywidgets_async_extension.py +1 -1
- classiq/_analyzer_extras/interactive_hardware.py +3 -3
- classiq/_internals/api_wrapper.py +24 -16
- classiq/_internals/async_utils.py +1 -74
- classiq/_internals/authentication/device.py +9 -4
- classiq/_internals/authentication/password_manager.py +25 -10
- classiq/_internals/authentication/token_manager.py +2 -2
- classiq/_internals/client.py +13 -5
- classiq/_internals/jobs.py +10 -7
- classiq/analyzer/analyzer.py +26 -28
- classiq/analyzer/analyzer_utilities.py +5 -5
- classiq/analyzer/rb.py +4 -5
- classiq/analyzer/show_interactive_hack.py +6 -6
- classiq/applications/benchmarking/mirror_benchmarking.py +9 -6
- classiq/applications/combinatorial_optimization/__init__.py +5 -0
- classiq/applications/qnn/circuit_utils.py +2 -2
- classiq/applications/qnn/gradients/quantum_gradient.py +2 -2
- classiq/applications/qnn/types.py +2 -2
- classiq/applications/qsvm/qsvm.py +4 -7
- classiq/applications/qsvm/qsvm_data_generation.py +2 -5
- classiq/applications_model_constructors/__init__.py +9 -1
- classiq/applications_model_constructors/chemistry_model_constructor.py +9 -16
- classiq/applications_model_constructors/combinatorial_helpers/__init__.py +0 -0
- classiq/applications_model_constructors/combinatorial_helpers/allowed_constraints.py +20 -0
- classiq/applications_model_constructors/combinatorial_helpers/arithmetic/__init__.py +0 -0
- classiq/applications_model_constructors/combinatorial_helpers/arithmetic/arithmetic_expression.py +35 -0
- classiq/applications_model_constructors/combinatorial_helpers/arithmetic/isolation.py +42 -0
- classiq/applications_model_constructors/combinatorial_helpers/combinatorial_problem_utils.py +130 -0
- classiq/applications_model_constructors/combinatorial_helpers/encoding_mapping.py +107 -0
- classiq/applications_model_constructors/combinatorial_helpers/encoding_utils.py +122 -0
- classiq/applications_model_constructors/combinatorial_helpers/memory.py +79 -0
- classiq/applications_model_constructors/combinatorial_helpers/multiple_comp_basis_sp.py +34 -0
- classiq/applications_model_constructors/combinatorial_helpers/optimization_model.py +166 -0
- classiq/applications_model_constructors/combinatorial_helpers/pauli_helpers/__init__.py +0 -0
- classiq/applications_model_constructors/combinatorial_helpers/pauli_helpers/pauli_sparsing.py +31 -0
- classiq/applications_model_constructors/combinatorial_helpers/pauli_helpers/pauli_utils.py +65 -0
- classiq/applications_model_constructors/combinatorial_helpers/py.typed +0 -0
- classiq/applications_model_constructors/combinatorial_helpers/pyomo_utils.py +243 -0
- classiq/applications_model_constructors/combinatorial_helpers/sympy_utils.py +22 -0
- classiq/applications_model_constructors/combinatorial_helpers/transformations/__init__.py +0 -0
- classiq/applications_model_constructors/combinatorial_helpers/transformations/encoding.py +194 -0
- classiq/applications_model_constructors/combinatorial_helpers/transformations/fixed_variables.py +144 -0
- classiq/applications_model_constructors/combinatorial_helpers/transformations/ising_converter.py +124 -0
- classiq/applications_model_constructors/combinatorial_helpers/transformations/penalty.py +32 -0
- classiq/applications_model_constructors/combinatorial_helpers/transformations/penalty_support.py +41 -0
- classiq/applications_model_constructors/combinatorial_helpers/transformations/sign_seperation.py +75 -0
- classiq/applications_model_constructors/combinatorial_helpers/transformations/slack_variables.py +90 -0
- classiq/applications_model_constructors/combinatorial_optimization_model_constructor.py +48 -91
- classiq/applications_model_constructors/finance_model_constructor.py +4 -17
- classiq/applications_model_constructors/grover_model_constructor.py +20 -91
- classiq/applications_model_constructors/libraries/qmci_library.py +17 -19
- classiq/builtin_functions/standard_gates.py +1 -1
- classiq/exceptions.py +43 -1
- classiq/executor.py +10 -9
- classiq/interface/_version.py +1 -1
- classiq/interface/analyzer/analysis_params.py +6 -3
- classiq/interface/analyzer/result.py +12 -4
- classiq/interface/applications/qsvm.py +13 -1
- classiq/interface/backend/backend_preferences.py +4 -2
- classiq/interface/backend/pydantic_backend.py +3 -1
- classiq/interface/backend/quantum_backend_providers.py +1 -0
- classiq/interface/chemistry/fermionic_operator.py +15 -13
- classiq/interface/chemistry/ground_state_problem.py +18 -3
- classiq/interface/chemistry/molecule.py +8 -6
- classiq/interface/chemistry/operator.py +20 -14
- classiq/interface/combinatorial_optimization/examples/ascending_sequence.py +1 -1
- classiq/interface/combinatorial_optimization/examples/greater_than_ilp.py +1 -1
- classiq/interface/combinatorial_optimization/examples/ilp.py +2 -1
- classiq/interface/combinatorial_optimization/examples/integer_portfolio_optimization.py +2 -2
- classiq/interface/combinatorial_optimization/examples/mds.py +2 -1
- classiq/interface/combinatorial_optimization/examples/mht.py +3 -3
- classiq/interface/combinatorial_optimization/examples/mis.py +4 -1
- classiq/interface/combinatorial_optimization/examples/mvc.py +2 -1
- classiq/interface/combinatorial_optimization/examples/set_cover.py +2 -1
- classiq/interface/combinatorial_optimization/examples/tsp.py +4 -3
- classiq/interface/combinatorial_optimization/examples/tsp_digraph.py +6 -2
- classiq/interface/combinatorial_optimization/mht_qaoa_input.py +9 -3
- classiq/interface/executor/aws_execution_cost.py +4 -3
- classiq/interface/executor/estimation.py +2 -2
- classiq/interface/executor/execution_preferences.py +5 -34
- classiq/interface/executor/execution_request.py +19 -17
- classiq/interface/executor/optimizer_preferences.py +22 -13
- classiq/interface/executor/{quantum_program.py → quantum_code.py} +21 -15
- classiq/interface/executor/quantum_instruction_set.py +2 -1
- classiq/interface/executor/register_initialization.py +1 -3
- classiq/interface/executor/result.py +41 -10
- classiq/interface/executor/vqe_result.py +1 -1
- classiq/interface/finance/function_input.py +17 -4
- classiq/interface/finance/gaussian_model_input.py +3 -1
- classiq/interface/finance/log_normal_model_input.py +3 -1
- classiq/interface/finance/model_input.py +2 -0
- classiq/interface/generator/amplitude_loading.py +6 -3
- classiq/interface/generator/application_apis/__init__.py +1 -0
- classiq/interface/generator/application_apis/arithmetic_declarations.py +14 -0
- classiq/interface/generator/arith/argument_utils.py +14 -4
- classiq/interface/generator/arith/arithmetic.py +3 -1
- classiq/interface/generator/arith/arithmetic_arg_type_validator.py +12 -13
- classiq/interface/generator/arith/arithmetic_expression_abc.py +4 -1
- classiq/interface/generator/arith/arithmetic_expression_parser.py +8 -2
- classiq/interface/generator/arith/arithmetic_expression_validator.py +16 -2
- classiq/interface/generator/arith/arithmetic_operations.py +5 -10
- classiq/interface/generator/arith/ast_node_rewrite.py +1 -1
- classiq/interface/generator/arith/binary_ops.py +202 -54
- classiq/interface/generator/arith/extremum_operations.py +5 -3
- classiq/interface/generator/arith/logical_ops.py +4 -2
- classiq/interface/generator/arith/machine_precision.py +3 -0
- classiq/interface/generator/arith/number_utils.py +34 -44
- classiq/interface/generator/arith/register_user_input.py +21 -1
- classiq/interface/generator/arith/unary_ops.py +16 -25
- classiq/interface/generator/chemistry_function_params.py +4 -4
- classiq/interface/generator/commuting_pauli_exponentiation.py +3 -1
- classiq/interface/generator/compiler_keywords.py +4 -0
- classiq/interface/generator/complex_type.py +3 -10
- classiq/interface/generator/control_state.py +5 -3
- classiq/interface/generator/credit_risk_example/linear_gci.py +10 -3
- classiq/interface/generator/credit_risk_example/weighted_adder.py +14 -4
- classiq/interface/generator/expressions/atomic_expression_functions.py +5 -3
- classiq/interface/generator/expressions/evaluated_expression.py +18 -4
- classiq/interface/generator/expressions/expression.py +1 -1
- classiq/interface/generator/expressions/qmod_qscalar_proxy.py +33 -0
- classiq/interface/generator/expressions/sympy_supported_expressions.py +2 -1
- classiq/interface/generator/finance.py +1 -1
- classiq/interface/generator/function_params.py +7 -6
- classiq/interface/generator/functions/__init__.py +1 -1
- classiq/interface/generator/functions/core_lib_declarations/quantum_functions/std_lib_functions.py +505 -138
- classiq/interface/generator/functions/core_lib_declarations/quantum_operators.py +25 -99
- classiq/interface/generator/functions/foreign_function_definition.py +12 -4
- classiq/interface/generator/functions/function_implementation.py +8 -4
- classiq/interface/generator/functions/native_function_definition.py +4 -2
- classiq/interface/generator/functions/register.py +4 -2
- classiq/interface/generator/functions/register_mapping_data.py +14 -10
- classiq/interface/generator/generated_circuit_data.py +2 -2
- classiq/interface/generator/grover_operator.py +5 -3
- classiq/interface/generator/hamiltonian_evolution/suzuki_trotter.py +5 -1
- classiq/interface/generator/hardware/hardware_data.py +6 -4
- classiq/interface/generator/hardware_efficient_ansatz.py +25 -8
- classiq/interface/generator/hartree_fock.py +3 -1
- classiq/interface/generator/linear_pauli_rotations.py +3 -1
- classiq/interface/generator/mcu.py +5 -3
- classiq/interface/generator/mcx.py +7 -5
- classiq/interface/generator/model/constraints.py +2 -1
- classiq/interface/generator/model/model.py +11 -19
- classiq/interface/generator/model/preferences/preferences.py +4 -3
- classiq/interface/generator/oracles/custom_oracle.py +4 -2
- classiq/interface/generator/oracles/oracle_abc.py +2 -2
- classiq/interface/generator/qpe.py +6 -4
- classiq/interface/generator/qsvm.py +5 -8
- classiq/interface/generator/quantum_function_call.py +21 -16
- classiq/interface/generator/{generated_circuit.py → quantum_program.py} +10 -14
- classiq/interface/generator/range_types.py +3 -1
- classiq/interface/generator/slice_parsing_utils.py +8 -3
- classiq/interface/generator/standard_gates/controlled_standard_gates.py +4 -2
- classiq/interface/generator/state_preparation/metrics.py +2 -1
- classiq/interface/generator/state_preparation/state_preparation.py +7 -5
- classiq/interface/generator/state_propagator.py +16 -5
- classiq/interface/generator/types/builtin_struct_declarations/__init__.py +0 -1
- classiq/interface/generator/types/struct_declaration.py +8 -3
- classiq/interface/generator/ucc.py +6 -4
- classiq/interface/generator/unitary_gate.py +7 -3
- classiq/interface/generator/validations/flow_graph.py +6 -4
- classiq/interface/generator/validations/validator_functions.py +6 -4
- classiq/interface/hardware.py +2 -2
- classiq/interface/helpers/custom_encoders.py +3 -0
- classiq/interface/helpers/pydantic_model_helpers.py +0 -6
- classiq/interface/helpers/validation_helpers.py +1 -1
- classiq/interface/helpers/versioned_model.py +4 -1
- classiq/interface/ide/show.py +2 -2
- classiq/interface/jobs.py +72 -3
- classiq/interface/model/bind_operation.py +18 -11
- classiq/interface/model/call_synthesis_data.py +68 -0
- classiq/interface/model/inplace_binary_operation.py +2 -2
- classiq/interface/model/model.py +27 -21
- classiq/interface/model/native_function_definition.py +3 -5
- classiq/interface/model/quantum_expressions/amplitude_loading_operation.py +9 -4
- classiq/interface/model/quantum_expressions/control_state.py +2 -2
- classiq/interface/model/quantum_function_call.py +25 -139
- classiq/interface/model/quantum_function_declaration.py +8 -0
- classiq/interface/model/quantum_if_operation.py +2 -3
- classiq/interface/model/quantum_lambda_function.py +64 -0
- classiq/interface/model/quantum_type.py +57 -56
- classiq/interface/model/quantum_variable_declaration.py +1 -1
- classiq/interface/model/statement_block.py +32 -0
- classiq/interface/model/validations/handles_validator.py +14 -12
- classiq/interface/model/within_apply_operation.py +11 -0
- classiq/interface/pyomo_extension/pyomo_sympy_bimap.py +4 -1
- classiq/interface/server/routes.py +5 -0
- classiq/model/function_handler.py +5 -9
- classiq/model/model.py +2 -19
- classiq/qmod/__init__.py +13 -6
- classiq/qmod/builtins/classical_execution_primitives.py +27 -36
- classiq/qmod/builtins/classical_functions.py +24 -14
- classiq/qmod/builtins/functions.py +162 -145
- classiq/qmod/builtins/operations.py +24 -35
- classiq/qmod/builtins/structs.py +15 -15
- classiq/qmod/cfunc.py +42 -0
- classiq/qmod/classical_function.py +6 -14
- classiq/qmod/declaration_inferrer.py +12 -21
- classiq/qmod/expression_query.py +23 -0
- classiq/qmod/model_state_container.py +2 -0
- classiq/qmod/native/__init__.py +0 -0
- classiq/qmod/native/expression_to_qmod.py +189 -0
- classiq/qmod/native/pretty_printer.py +311 -0
- classiq/qmod/qfunc.py +27 -0
- classiq/qmod/qmod_constant.py +76 -0
- classiq/qmod/qmod_parameter.py +34 -12
- classiq/qmod/qmod_struct.py +3 -3
- classiq/qmod/qmod_variable.py +102 -18
- classiq/qmod/quantum_expandable.py +16 -16
- classiq/qmod/quantum_function.py +37 -8
- classiq/qmod/symbolic.py +47 -4
- classiq/qmod/symbolic_expr.py +9 -0
- classiq/qmod/utilities.py +13 -0
- classiq/qmod/write_qmod.py +39 -0
- classiq/quantum_functions/__init__.py +2 -2
- classiq/quantum_functions/annotation_parser.py +9 -11
- classiq/quantum_functions/function_parser.py +1 -1
- classiq/quantum_functions/quantum_function.py +3 -3
- classiq/quantum_register.py +17 -9
- {classiq-0.37.0.dist-info → classiq-0.38.0.dist-info}/METADATA +2 -1
- {classiq-0.37.0.dist-info → classiq-0.38.0.dist-info}/RECORD +222 -186
- {classiq-0.37.0.dist-info → classiq-0.38.0.dist-info}/WHEEL +1 -1
- classiq/interface/generator/expressions/qmod_qnum_proxy.py +0 -22
- classiq/interface/generator/types/builtin_struct_declarations/qaoa_declarations.py +0 -23
- classiq/interface/generator/types/combinatorial_problem.py +0 -26
- classiq/interface/model/numeric_reinterpretation.py +0 -25
- classiq/interface/model/operator_synthesis_data.py +0 -48
- classiq/model/function_handler.pyi +0 -152
@@ -25,7 +25,7 @@ from classiq.interface.generator.functions.port_declaration import (
|
|
25
25
|
from classiq.interface.generator.identity import Identity
|
26
26
|
from classiq.interface.generator.quantum_function_call import (
|
27
27
|
SynthesisQuantumFunctionCall,
|
28
|
-
|
28
|
+
WireDict,
|
29
29
|
)
|
30
30
|
from classiq.interface.generator.slice_parsing_utils import parse_io_slicing
|
31
31
|
from classiq.interface.generator.user_defined_function_params import CustomFunction
|
@@ -46,8 +46,6 @@ SupportedInputArgs = Union[
|
|
46
46
|
QReg,
|
47
47
|
]
|
48
48
|
|
49
|
-
WireNameDict = Dict[IOName, WireName]
|
50
|
-
|
51
49
|
_SAME_INPUT_NAME_ERROR_MSG: str = "Cannot create multiple inputs with the same name"
|
52
50
|
_INPUT_AS_OUTPUT_ERROR_MSG: str = "Can't connect input directly to output"
|
53
51
|
ILLEGAL_INPUT_OR_SLICING_ERROR_MSG: str = "is not a valid input name/slice"
|
@@ -64,7 +62,7 @@ class FunctionHandler(abc.ABC):
|
|
64
62
|
def __init__(self) -> None:
|
65
63
|
self._function_library: Optional[FunctionLibrary] = None
|
66
64
|
self._port_declarations: Dict[IOName, SynthesisPortDeclaration] = dict()
|
67
|
-
self._external_port_wiring: Dict[PortDirection,
|
65
|
+
self._external_port_wiring: Dict[PortDirection, WireDict] = {
|
68
66
|
PortDirection.Input: dict(),
|
69
67
|
PortDirection.Output: dict(),
|
70
68
|
}
|
@@ -72,11 +70,11 @@ class FunctionHandler(abc.ABC):
|
|
72
70
|
self._logic_flow_builder: LogicFlowBuilder = LogicFlowBuilder()
|
73
71
|
|
74
72
|
@property
|
75
|
-
def input_wires(self) ->
|
73
|
+
def input_wires(self) -> WireDict:
|
76
74
|
return self._external_port_wiring[PortDirection.Input]
|
77
75
|
|
78
76
|
@property
|
79
|
-
def output_wires(self) ->
|
77
|
+
def output_wires(self) -> WireDict:
|
80
78
|
return self._external_port_wiring[PortDirection.Output]
|
81
79
|
|
82
80
|
def _verify_unique_inputs(self, input_names: Iterable[IOName]) -> None:
|
@@ -372,9 +370,7 @@ class FunctionHandler(abc.ABC):
|
|
372
370
|
call: SynthesisQuantumFunctionCall,
|
373
371
|
out_wires: Mapping[IOName, QReg],
|
374
372
|
) -> Dict[IOName, QReg]:
|
375
|
-
if not all(
|
376
|
-
output_name in call.output_regs_dict.keys() for output_name in out_wires
|
377
|
-
):
|
373
|
+
if not all(output_name in call.output_regs_dict for output_name in out_wires):
|
378
374
|
raise ClassiqWiringError(ILLEGAL_OUTPUT_ERROR_MSG)
|
379
375
|
output_dict = {}
|
380
376
|
for output_name, reg_user_input in call.output_regs_dict.items():
|
classiq/model/model.py
CHANGED
@@ -3,9 +3,7 @@
|
|
3
3
|
from __future__ import annotations
|
4
4
|
|
5
5
|
import logging
|
6
|
-
import
|
7
|
-
from contextlib import nullcontext
|
8
|
-
from typing import IO, Any, ContextManager, Dict, List, Mapping, Optional, Union, cast
|
6
|
+
from typing import Any, Dict, List, Mapping, Optional, cast
|
9
7
|
|
10
8
|
from classiq.interface.chemistry.operator import PauliOperator
|
11
9
|
from classiq.interface.executor.execution_preferences import (
|
@@ -25,7 +23,6 @@ from classiq.interface.generator.quantum_function_call import (
|
|
25
23
|
SynthesisQuantumFunctionCall,
|
26
24
|
)
|
27
25
|
|
28
|
-
from classiq._internals.async_utils import AsyncifyABC
|
29
26
|
from classiq.exceptions import ClassiqError, ClassiqValueError
|
30
27
|
from classiq.model import function_handler
|
31
28
|
from classiq.quantum_functions.function_library import FunctionLibrary
|
@@ -33,8 +30,6 @@ from classiq.quantum_register import QReg, QRegGenericAlias
|
|
33
30
|
|
34
31
|
_logger = logging.getLogger(__name__)
|
35
32
|
|
36
|
-
_SupportedIO = Union[IO, str]
|
37
|
-
|
38
33
|
# TODO: Add docstrings for auto generated methods.
|
39
34
|
|
40
35
|
|
@@ -56,23 +51,11 @@ def _pauli_operator_to_qmod(hamiltonian: PauliOperator) -> str:
|
|
56
51
|
)
|
57
52
|
|
58
53
|
|
59
|
-
def _file_handler(fp: Optional[_SupportedIO], mode: str = "r") -> ContextManager[IO]:
|
60
|
-
if fp is None:
|
61
|
-
temp_file = tempfile.NamedTemporaryFile(mode, suffix=".qmod", delete=False)
|
62
|
-
print(f"Using temporary file: {temp_file.name!r}")
|
63
|
-
return temp_file
|
64
|
-
|
65
|
-
if isinstance(fp, str):
|
66
|
-
return open(fp, mode)
|
67
|
-
|
68
|
-
return nullcontext(fp)
|
69
|
-
|
70
|
-
|
71
54
|
DEFAULT_RESULT_NAME = "result"
|
72
55
|
DEFAULT_AMPLITUDE_ESTIMATION_RESULT_NAME = "estimation"
|
73
56
|
|
74
57
|
|
75
|
-
class Model(function_handler.FunctionHandler
|
58
|
+
class Model(function_handler.FunctionHandler):
|
76
59
|
"""Facility to generate circuits, based on the model."""
|
77
60
|
|
78
61
|
def __init__(self, **kwargs: Any) -> None:
|
classiq/qmod/__init__.py
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
from . import symbolic
|
2
2
|
from .builtins import * # noqa: F403
|
3
3
|
from .builtins import __all__ as _builtins_all
|
4
|
-
from .
|
4
|
+
from .cfunc import cfunc
|
5
|
+
from .expression_query import get_expression_numeric_attributes
|
6
|
+
from .qfunc import qfunc
|
7
|
+
from .qmod_constant import QConstant
|
5
8
|
from .qmod_parameter import Array, QParam
|
6
|
-
from .qmod_struct import
|
9
|
+
from .qmod_struct import struct
|
7
10
|
from .qmod_variable import Input, Output, QArray, QBit, QNum
|
8
11
|
from .quantum_callable import QCallable, QCallableList
|
9
|
-
from .quantum_function import
|
12
|
+
from .quantum_function import create_model
|
13
|
+
from .write_qmod import write_qmod
|
10
14
|
|
11
15
|
__all__ = [
|
12
16
|
"QParam",
|
@@ -18,9 +22,12 @@ __all__ = [
|
|
18
22
|
"QNum",
|
19
23
|
"QCallable",
|
20
24
|
"QCallableList",
|
21
|
-
"
|
22
|
-
"
|
23
|
-
"
|
25
|
+
"QConstant",
|
26
|
+
"struct",
|
27
|
+
"qfunc",
|
28
|
+
"cfunc",
|
24
29
|
"create_model",
|
25
30
|
"symbolic",
|
31
|
+
"write_qmod",
|
32
|
+
"get_expression_numeric_attributes",
|
26
33
|
] + _builtins_all
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import Dict, List, Optional
|
1
|
+
from typing import Dict, List, Optional, Union
|
2
2
|
|
3
3
|
from classiq.interface.executor.execution_preferences import QaeWithQpeEstimationMethod
|
4
4
|
from classiq.interface.executor.iqae_result import IQAEResult
|
@@ -6,32 +6,38 @@ from classiq.interface.executor.result import EstimationResult, ExecutionDetails
|
|
6
6
|
from classiq.interface.executor.vqe_result import VQESolverResult
|
7
7
|
from classiq.interface.generator.expressions.enums import Optimizer
|
8
8
|
from classiq.interface.generator.functions.qmod_python_interface import QmodPyStruct
|
9
|
-
from classiq.interface.generator.types.combinatorial_problem import (
|
10
|
-
CombinatorialOptimizationStructDeclaration,
|
11
|
-
)
|
12
9
|
|
13
10
|
from classiq.applications.qsvm.qsvm import Data, Labels
|
11
|
+
from classiq.exceptions import ClassiqError
|
12
|
+
|
13
|
+
ExecutionParams = Dict[str, Union[float, int]]
|
14
|
+
|
15
|
+
_CALL_IN_QFUNC_ERROR = (
|
16
|
+
'Cannot call "{}" in a quantum context. "{}" is a classical execution primitive.'
|
17
|
+
)
|
18
|
+
|
14
19
|
|
15
|
-
|
20
|
+
def _raise_error(primitive_name: str) -> None:
|
21
|
+
raise ClassiqError(_CALL_IN_QFUNC_ERROR.format(primitive_name, primitive_name))
|
16
22
|
|
17
23
|
|
18
24
|
def save(values_to_save: dict) -> None:
|
19
|
-
|
25
|
+
_raise_error("save")
|
20
26
|
|
21
27
|
|
22
|
-
def sample( # type: ignore
|
28
|
+
def sample( # type: ignore[return]
|
23
29
|
execution_params: Optional[ExecutionParams] = None,
|
24
30
|
) -> ExecutionDetails:
|
25
|
-
|
31
|
+
_raise_error("sample")
|
26
32
|
|
27
33
|
|
28
|
-
def estimate( # type: ignore
|
34
|
+
def estimate( # type: ignore[return]
|
29
35
|
hamiltonian: List[QmodPyStruct], execution_params: Optional[ExecutionParams] = None
|
30
36
|
) -> EstimationResult:
|
31
|
-
|
37
|
+
_raise_error("estimate")
|
32
38
|
|
33
39
|
|
34
|
-
def vqe( # type: ignore
|
40
|
+
def vqe( # type: ignore[return]
|
35
41
|
hamiltonian: List[QmodPyStruct],
|
36
42
|
maximize: bool,
|
37
43
|
initial_point: List[int],
|
@@ -42,56 +48,43 @@ def vqe( # type: ignore
|
|
42
48
|
skip_compute_variance: bool,
|
43
49
|
alpha_cvar: float,
|
44
50
|
) -> VQESolverResult:
|
45
|
-
|
51
|
+
_raise_error("vqe")
|
46
52
|
|
47
53
|
|
48
|
-
def qae_with_qpe_result_post_processing( # type: ignore
|
54
|
+
def qae_with_qpe_result_post_processing( # type: ignore[return]
|
49
55
|
estimation_register_size: int,
|
50
56
|
estimation_method: QaeWithQpeEstimationMethod,
|
51
57
|
result: ExecutionDetails,
|
52
58
|
) -> float:
|
53
|
-
|
59
|
+
_raise_error("qae_with_qpe_result_post_processing")
|
54
60
|
|
55
61
|
|
56
|
-
def qsvm_full_run( # type: ignore
|
62
|
+
def qsvm_full_run( # type: ignore[return]
|
57
63
|
train_data: Data,
|
58
64
|
train_labels: Labels,
|
59
65
|
test_data: Data,
|
60
66
|
test_labels: Labels,
|
61
67
|
predict_data: Data,
|
62
68
|
) -> QmodPyStruct:
|
63
|
-
|
69
|
+
_raise_error("qsvm_full_run")
|
64
70
|
|
65
71
|
|
66
|
-
def iqae( # type: ignore
|
72
|
+
def iqae( # type: ignore[return]
|
67
73
|
epsilon: float,
|
68
74
|
alpha: float,
|
69
75
|
execution_params: Optional[ExecutionParams] = None,
|
70
76
|
) -> IQAEResult:
|
71
|
-
|
77
|
+
_raise_error("iqae")
|
72
78
|
|
73
79
|
|
74
|
-
def molecule_ground_state_solution_post_process( # type: ignore
|
80
|
+
def molecule_ground_state_solution_post_process( # type: ignore[return]
|
75
81
|
problem: QmodPyStruct, vqe_result: VQESolverResult
|
76
82
|
) -> QmodPyStruct:
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
def optimization_problem_to_hamiltonian( # type: ignore
|
81
|
-
problem_struct: CombinatorialOptimizationStructDeclaration, penalty_energy: float
|
82
|
-
) -> List[QmodPyStruct]:
|
83
|
-
pass
|
84
|
-
|
85
|
-
|
86
|
-
def get_optimization_solution( # type: ignore
|
87
|
-
problem_struct: CombinatorialOptimizationStructDeclaration,
|
88
|
-
vqe_result: VQESolverResult,
|
89
|
-
penalty_energy: float,
|
90
|
-
) -> List[QmodPyStruct]:
|
91
|
-
pass
|
83
|
+
_raise_error("molecule_ground_state_solution_post_process")
|
92
84
|
|
93
85
|
|
94
86
|
__all__ = [
|
87
|
+
"ExecutionParams",
|
95
88
|
"save",
|
96
89
|
"sample",
|
97
90
|
"estimate",
|
@@ -100,8 +93,6 @@ __all__ = [
|
|
100
93
|
"qsvm_full_run",
|
101
94
|
"iqae",
|
102
95
|
"molecule_ground_state_solution_post_process",
|
103
|
-
"optimization_problem_to_hamiltonian",
|
104
|
-
"get_optimization_solution",
|
105
96
|
]
|
106
97
|
|
107
98
|
|
@@ -8,23 +8,16 @@ from classiq.qmod.symbolic import symbolic_function
|
|
8
8
|
from .structs import *
|
9
9
|
|
10
10
|
|
11
|
-
def compute_qaoa_initial_point(
|
12
|
-
hamiltonian: QParam[List[PauliTerm]],
|
13
|
-
repetitions: QParam[int],
|
14
|
-
) -> QParam[List[float]]:
|
15
|
-
return symbolic_function(hamiltonian, repetitions)
|
16
|
-
|
17
|
-
|
18
11
|
def molecule_problem_to_hamiltonian(
|
19
12
|
problem: QParam[MoleculeProblem],
|
20
13
|
) -> QParam[List[PauliTerm]]:
|
21
|
-
return symbolic_function(problem)
|
14
|
+
return symbolic_function(problem, return_type=QParam[List[PauliTerm]])
|
22
15
|
|
23
16
|
|
24
17
|
def fock_hamiltonian_problem_to_hamiltonian(
|
25
18
|
problem: QParam[FockHamiltonianProblem],
|
26
19
|
) -> QParam[List[PauliTerm]]:
|
27
|
-
return symbolic_function(problem)
|
20
|
+
return symbolic_function(problem, return_type=QParam[List[PauliTerm]])
|
28
21
|
|
29
22
|
|
30
23
|
def grid_entangler_graph(
|
@@ -32,13 +25,18 @@ def grid_entangler_graph(
|
|
32
25
|
schmidt_rank: QParam[int],
|
33
26
|
grid_randomization: QParam[bool],
|
34
27
|
) -> QParam[List[List[int]]]:
|
35
|
-
return symbolic_function(
|
28
|
+
return symbolic_function(
|
29
|
+
num_qubits,
|
30
|
+
schmidt_rank,
|
31
|
+
grid_randomization,
|
32
|
+
return_type=QParam[List[List[int]]],
|
33
|
+
)
|
36
34
|
|
37
35
|
|
38
36
|
def hypercube_entangler_graph(
|
39
37
|
num_qubits: QParam[int],
|
40
38
|
) -> QParam[List[List[int]]]:
|
41
|
-
return symbolic_function(num_qubits)
|
39
|
+
return symbolic_function(num_qubits, return_type=QParam[List[List[int]]])
|
42
40
|
|
43
41
|
|
44
42
|
def log_normal_finance_post_process(
|
@@ -46,7 +44,9 @@ def log_normal_finance_post_process(
|
|
46
44
|
estimation_method: QParam[FinanceFunction],
|
47
45
|
probability: QParam[float],
|
48
46
|
) -> QParam[float]:
|
49
|
-
return symbolic_function(
|
47
|
+
return symbolic_function(
|
48
|
+
finance_model, estimation_method, probability, return_type=QParam[float]
|
49
|
+
)
|
50
50
|
|
51
51
|
|
52
52
|
def gaussian_finance_post_process(
|
@@ -54,15 +54,25 @@ def gaussian_finance_post_process(
|
|
54
54
|
estimation_method: QParam[FinanceFunction],
|
55
55
|
probability: QParam[float],
|
56
56
|
) -> QParam[float]:
|
57
|
-
return symbolic_function(
|
57
|
+
return symbolic_function(
|
58
|
+
finance_model, estimation_method, probability, return_type=QParam[float]
|
59
|
+
)
|
60
|
+
|
61
|
+
|
62
|
+
def qft_const_adder_phase(
|
63
|
+
bit_index: QParam[int],
|
64
|
+
value: QParam[int],
|
65
|
+
reg_len: QParam[int],
|
66
|
+
) -> QParam[float]:
|
67
|
+
return symbolic_function(bit_index, value, reg_len, return_type=QParam[float])
|
58
68
|
|
59
69
|
|
60
70
|
__all__ = [
|
61
|
-
"compute_qaoa_initial_point",
|
62
71
|
"molecule_problem_to_hamiltonian",
|
63
72
|
"fock_hamiltonian_problem_to_hamiltonian",
|
64
73
|
"grid_entangler_graph",
|
65
74
|
"hypercube_entangler_graph",
|
66
75
|
"log_normal_finance_post_process",
|
67
76
|
"gaussian_finance_post_process",
|
77
|
+
"qft_const_adder_phase",
|
68
78
|
]
|