classiq 0.39.0__py3-none-any.whl → 0.41.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 +5 -2
- classiq/_internals/api_wrapper.py +3 -21
- classiq/applications/chemistry/chemistry_model_constructor.py +87 -101
- classiq/applications/combinatorial_helpers/combinatorial_problem_utils.py +7 -26
- classiq/applications/combinatorial_helpers/optimization_model.py +7 -6
- classiq/applications/combinatorial_helpers/pauli_helpers/pauli_utils.py +33 -55
- classiq/applications/combinatorial_optimization/__init__.py +4 -0
- classiq/applications/combinatorial_optimization/combinatorial_optimization_model_constructor.py +29 -26
- classiq/applications/finance/finance_model_constructor.py +23 -26
- classiq/applications/grover/grover_model_constructor.py +37 -38
- classiq/applications/qsvm/qsvm.py +1 -2
- classiq/applications/qsvm/qsvm_model_constructor.py +15 -16
- classiq/execution/__init__.py +4 -0
- classiq/execution/execution_session.py +151 -0
- classiq/execution/qnn.py +80 -0
- classiq/executor.py +2 -109
- classiq/interface/_version.py +1 -1
- classiq/interface/analyzer/analysis_params.py +11 -0
- classiq/interface/applications/qsvm.py +0 -8
- classiq/interface/ast_node.py +12 -2
- classiq/interface/backend/backend_preferences.py +30 -6
- classiq/interface/backend/quantum_backend_providers.py +11 -11
- classiq/interface/executor/execution_preferences.py +7 -67
- classiq/interface/executor/execution_result.py +22 -1
- classiq/interface/generator/application_apis/chemistry_declarations.py +2 -4
- classiq/interface/generator/application_apis/finance_declarations.py +1 -1
- classiq/interface/generator/arith/binary_ops.py +88 -25
- classiq/interface/generator/arith/unary_ops.py +28 -19
- classiq/interface/generator/expressions/atomic_expression_functions.py +6 -2
- classiq/interface/generator/expressions/enums/__init__.py +10 -0
- classiq/interface/generator/expressions/enums/classical_enum.py +5 -1
- classiq/interface/generator/expressions/expression.py +9 -2
- classiq/interface/generator/expressions/qmod_qarray_proxy.py +89 -0
- classiq/interface/generator/expressions/qmod_qscalar_proxy.py +20 -0
- classiq/interface/generator/expressions/qmod_sized_proxy.py +22 -0
- classiq/interface/generator/expressions/sympy_supported_expressions.py +10 -1
- classiq/interface/generator/functions/builtins/core_library/atomic_quantum_functions.py +8 -6
- classiq/interface/generator/functions/builtins/core_library/exponentiation_functions.py +10 -4
- classiq/interface/generator/functions/builtins/internal_operators.py +7 -62
- classiq/interface/generator/functions/builtins/open_lib_functions.py +1627 -271
- classiq/interface/generator/functions/classical_type.py +27 -17
- classiq/interface/generator/model/preferences/preferences.py +4 -2
- classiq/interface/generator/synthesis_metadata/synthesis_duration.py +0 -4
- classiq/interface/model/bind_operation.py +3 -1
- classiq/interface/model/call_synthesis_data.py +2 -13
- classiq/interface/model/classical_if.py +3 -1
- classiq/interface/model/classical_parameter_declaration.py +13 -0
- classiq/interface/model/control.py +6 -8
- classiq/interface/model/inplace_binary_operation.py +3 -1
- classiq/interface/model/invert.py +3 -1
- classiq/interface/model/port_declaration.py +8 -1
- classiq/interface/model/power.py +3 -1
- classiq/interface/model/quantum_expressions/amplitude_loading_operation.py +4 -2
- classiq/interface/model/quantum_expressions/arithmetic_operation.py +3 -1
- classiq/interface/model/quantum_expressions/quantum_expression.py +11 -1
- classiq/interface/model/quantum_function_call.py +4 -10
- classiq/interface/model/quantum_function_declaration.py +26 -4
- classiq/interface/model/quantum_lambda_function.py +1 -20
- classiq/interface/model/quantum_statement.py +9 -2
- classiq/interface/model/quantum_type.py +6 -5
- classiq/interface/model/repeat.py +3 -1
- classiq/interface/model/resolvers/function_call_resolver.py +0 -5
- classiq/interface/model/statement_block.py +19 -16
- classiq/interface/model/validations/handles_validator.py +8 -2
- classiq/interface/model/variable_declaration_statement.py +3 -1
- classiq/interface/model/within_apply_operation.py +3 -1
- classiq/interface/server/routes.py +0 -5
- classiq/qmod/__init__.py +5 -2
- classiq/qmod/builtins/classical_execution_primitives.py +22 -2
- classiq/qmod/builtins/classical_functions.py +30 -35
- classiq/qmod/builtins/functions.py +263 -153
- classiq/qmod/builtins/operations.py +50 -26
- classiq/qmod/builtins/structs.py +50 -48
- classiq/qmod/declaration_inferrer.py +32 -27
- classiq/qmod/native/__init__.py +9 -0
- classiq/qmod/native/expression_to_qmod.py +8 -4
- classiq/qmod/native/pretty_printer.py +11 -18
- classiq/qmod/pretty_print/__init__.py +9 -0
- classiq/qmod/pretty_print/expression_to_python.py +221 -0
- classiq/qmod/pretty_print/pretty_printer.py +421 -0
- classiq/qmod/qmod_constant.py +7 -7
- classiq/qmod/qmod_parameter.py +57 -33
- classiq/qmod/qmod_struct.py +2 -2
- classiq/qmod/qmod_variable.py +40 -29
- classiq/qmod/quantum_callable.py +8 -4
- classiq/qmod/quantum_expandable.py +22 -15
- classiq/qmod/quantum_function.py +15 -4
- classiq/qmod/symbolic.py +73 -68
- classiq/qmod/symbolic_expr.py +1 -1
- classiq/qmod/symbolic_type.py +1 -4
- classiq/qmod/utilities.py +29 -0
- classiq/synthesis.py +15 -16
- {classiq-0.39.0.dist-info → classiq-0.41.0.dist-info}/METADATA +5 -4
- {classiq-0.39.0.dist-info → classiq-0.41.0.dist-info}/RECORD +95 -94
- classiq/interface/executor/error_mitigation.py +0 -6
- classiq/interface/generator/functions/builtins/core_library/chemistry_functions.py +0 -0
- classiq/interface/model/common_model_types.py +0 -23
- classiq/interface/model/quantum_expressions/control_state.py +0 -38
- classiq/interface/model/quantum_if_operation.py +0 -94
- {classiq-0.39.0.dist-info → classiq-0.41.0.dist-info}/WHEEL +0 -0
@@ -1,5 +1,8 @@
|
|
1
1
|
from typing import List, Union
|
2
2
|
|
3
|
+
from pydantic import Field
|
4
|
+
from typing_extensions import Annotated
|
5
|
+
|
3
6
|
from classiq.interface.model.bind_operation import BindOperation
|
4
7
|
from classiq.interface.model.classical_if import ClassicalIf
|
5
8
|
from classiq.interface.model.control import Control
|
@@ -13,7 +16,6 @@ from classiq.interface.model.quantum_expressions.arithmetic_operation import (
|
|
13
16
|
ArithmeticOperation,
|
14
17
|
)
|
15
18
|
from classiq.interface.model.quantum_function_call import QuantumFunctionCall
|
16
|
-
from classiq.interface.model.quantum_if_operation import QuantumIf
|
17
19
|
from classiq.interface.model.quantum_lambda_function import QuantumLambdaFunction
|
18
20
|
from classiq.interface.model.repeat import Repeat
|
19
21
|
from classiq.interface.model.variable_declaration_statement import (
|
@@ -21,26 +23,27 @@ from classiq.interface.model.variable_declaration_statement import (
|
|
21
23
|
)
|
22
24
|
from classiq.interface.model.within_apply_operation import WithinApply
|
23
25
|
|
24
|
-
ConcreteQuantumStatement =
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
26
|
+
ConcreteQuantumStatement = Annotated[
|
27
|
+
Union[
|
28
|
+
QuantumFunctionCall,
|
29
|
+
ArithmeticOperation,
|
30
|
+
AmplitudeLoadingOperation,
|
31
|
+
VariableDeclarationStatement,
|
32
|
+
BindOperation,
|
33
|
+
InplaceBinaryOperation,
|
34
|
+
Repeat,
|
35
|
+
Power,
|
36
|
+
Invert,
|
37
|
+
ClassicalIf,
|
38
|
+
Control,
|
39
|
+
WithinApply,
|
40
|
+
],
|
41
|
+
Field(..., discriminator="kind"),
|
38
42
|
]
|
39
43
|
|
40
44
|
StatementBlock = List[ConcreteQuantumStatement]
|
41
45
|
|
42
46
|
Control.update_forward_refs(StatementBlock=StatementBlock)
|
43
|
-
QuantumIf.update_forward_refs(StatementBlock=StatementBlock)
|
44
47
|
QuantumLambdaFunction.update_forward_refs(StatementBlock=StatementBlock)
|
45
48
|
Repeat.update_forward_refs(StatementBlock=StatementBlock)
|
46
49
|
Power.update_forward_refs(StatementBlock=StatementBlock)
|
@@ -61,8 +61,14 @@ class HandleValidator(HandleValidationBase):
|
|
61
61
|
self._handle_apply([QuantumFunctionCall(function=call_name)])
|
62
62
|
elif isinstance(op, WithinApply):
|
63
63
|
self._handle_apply(op.action)
|
64
|
-
|
65
|
-
|
64
|
+
|
65
|
+
if isinstance(op, QuantumFunctionCall) and op.synthesis_data.is_inverse:
|
66
|
+
self._handle_inputs(op.wiring_outputs)
|
67
|
+
self._handle_outputs(op.wiring_inputs)
|
68
|
+
else:
|
69
|
+
self._handle_inputs(op.wiring_inputs)
|
70
|
+
self._handle_outputs(op.wiring_outputs)
|
71
|
+
|
66
72
|
self._handle_inouts(op.wiring_inouts)
|
67
73
|
|
68
74
|
def handle_variable_declaration(
|
@@ -1,3 +1,5 @@
|
|
1
|
+
from typing import Literal
|
2
|
+
|
1
3
|
from classiq.interface.model.quantum_statement import QuantumStatement
|
2
4
|
from classiq.interface.model.quantum_variable_declaration import (
|
3
5
|
QuantumVariableDeclaration,
|
@@ -5,4 +7,4 @@ from classiq.interface.model.quantum_variable_declaration import (
|
|
5
7
|
|
6
8
|
|
7
9
|
class VariableDeclarationStatement(QuantumStatement, QuantumVariableDeclaration):
|
8
|
-
|
10
|
+
kind: Literal["VariableDeclarationStatement"]
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import TYPE_CHECKING
|
1
|
+
from typing import TYPE_CHECKING, Literal
|
2
2
|
|
3
3
|
from classiq.interface.model.quantum_statement import QuantumOperation
|
4
4
|
|
@@ -7,5 +7,7 @@ if TYPE_CHECKING:
|
|
7
7
|
|
8
8
|
|
9
9
|
class WithinApply(QuantumOperation):
|
10
|
+
kind: Literal["WithinApply"]
|
11
|
+
|
10
12
|
compute: "StatementBlock"
|
11
13
|
action: "StatementBlock"
|
@@ -1,6 +1,5 @@
|
|
1
1
|
ANALYZER_PREFIX = "/analyzer"
|
2
2
|
CHEMISTRY_PREFIX = "/chemistry"
|
3
|
-
LEGACY_EXECUTE_PREFIX = "/execute"
|
4
3
|
EXECUTION_PREFIX = "/execution"
|
5
4
|
CONVERSION_PREFIX = "/conversion"
|
6
5
|
|
@@ -22,8 +21,6 @@ ANALYZER_OPTIONAL_DEVICES = "/graphs/available_devices"
|
|
22
21
|
ANALYZER_OPTIONAL_DEVICES_FULL_PATH = ANALYZER_PREFIX + ANALYZER_OPTIONAL_DEVICES
|
23
22
|
|
24
23
|
TASKS_SUFFIX = "/tasks"
|
25
|
-
QUANTUM_PROGRAM_SUFFIX = "/quantum_program"
|
26
|
-
ESTIMATE_SUFFIX = "/estimate"
|
27
24
|
RB = "/rb"
|
28
25
|
ANALYZER_DATA_TASK = f"{TASKS_SUFFIX}/data"
|
29
26
|
ANALYZER_QASM_TASK = f"{TASKS_SUFFIX}/qasm"
|
@@ -60,8 +57,6 @@ EXECUTION_JOBS_FULL_PATH = EXECUTION_PREFIX + EXECUTION_JOBS_SUFFIX
|
|
60
57
|
EXECUTION_JOBS_NON_VERSIONED_FULL_PATH = (
|
61
58
|
EXECUTION_NON_VERSIONED_PREFIX + EXECUTION_JOBS_SUFFIX
|
62
59
|
)
|
63
|
-
EXECUTE_QUANTUM_PROGRAM_FULL_PATH = LEGACY_EXECUTE_PREFIX + QUANTUM_PROGRAM_SUFFIX
|
64
|
-
EXECUTE_ESTIMATE_FULL_PATH = LEGACY_EXECUTE_PREFIX + ESTIMATE_SUFFIX
|
65
60
|
|
66
61
|
ANALYZER_FULL_PATH = ANALYZER_PREFIX + TASKS_SUFFIX
|
67
62
|
ANALYZER_RB_FULL_PATH = ANALYZER_PREFIX + TASK_RB_SUFFIX
|
classiq/qmod/__init__.py
CHANGED
@@ -5,7 +5,7 @@ from .cfunc import cfunc
|
|
5
5
|
from .expression_query import get_expression_numeric_attributes
|
6
6
|
from .qfunc import qfunc
|
7
7
|
from .qmod_constant import QConstant
|
8
|
-
from .qmod_parameter import Array,
|
8
|
+
from .qmod_parameter import Array, CArray, CBool, CInt, CReal
|
9
9
|
from .qmod_struct import struct
|
10
10
|
from .qmod_variable import Input, Output, QArray, QBit, QNum
|
11
11
|
from .quantum_callable import QCallable, QCallableList
|
@@ -13,8 +13,11 @@ from .quantum_function import create_model
|
|
13
13
|
from .write_qmod import write_qmod
|
14
14
|
|
15
15
|
__all__ = [
|
16
|
-
"QParam",
|
17
16
|
"Array",
|
17
|
+
"CArray",
|
18
|
+
"CBool",
|
19
|
+
"CInt",
|
20
|
+
"CReal",
|
18
21
|
"Input",
|
19
22
|
"Output",
|
20
23
|
"QArray",
|
@@ -2,7 +2,12 @@ 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
|
5
|
-
from classiq.interface.executor.result import
|
5
|
+
from classiq.interface.executor.result import (
|
6
|
+
EstimationResult,
|
7
|
+
EstimationResults,
|
8
|
+
ExecutionDetails,
|
9
|
+
MultipleExecutionDetails,
|
10
|
+
)
|
6
11
|
from classiq.interface.executor.vqe_result import VQESolverResult
|
7
12
|
from classiq.interface.generator.expressions.enums import Optimizer
|
8
13
|
from classiq.interface.generator.functions.qmod_python_interface import QmodPyStruct
|
@@ -31,16 +36,29 @@ def sample( # type: ignore[return]
|
|
31
36
|
_raise_error("sample")
|
32
37
|
|
33
38
|
|
39
|
+
def batch_sample( # type: ignore[return]
|
40
|
+
batch_execution_params: List[ExecutionParams],
|
41
|
+
) -> MultipleExecutionDetails:
|
42
|
+
_raise_error("batch_sample")
|
43
|
+
|
44
|
+
|
34
45
|
def estimate( # type: ignore[return]
|
35
46
|
hamiltonian: List[QmodPyStruct], execution_params: Optional[ExecutionParams] = None
|
36
47
|
) -> EstimationResult:
|
37
48
|
_raise_error("estimate")
|
38
49
|
|
39
50
|
|
51
|
+
def batch_estimate( # type: ignore[return]
|
52
|
+
hamiltonian: List[QmodPyStruct],
|
53
|
+
batch_execution_params: List[ExecutionParams],
|
54
|
+
) -> EstimationResults:
|
55
|
+
_raise_error("batch_estimate")
|
56
|
+
|
57
|
+
|
40
58
|
def vqe( # type: ignore[return]
|
41
59
|
hamiltonian: List[QmodPyStruct],
|
42
60
|
maximize: bool,
|
43
|
-
initial_point: List[
|
61
|
+
initial_point: List[float],
|
44
62
|
optimizer: Optimizer,
|
45
63
|
max_iteration: int,
|
46
64
|
tolerance: float,
|
@@ -87,7 +105,9 @@ __all__ = [
|
|
87
105
|
"ExecutionParams",
|
88
106
|
"save",
|
89
107
|
"sample",
|
108
|
+
"batch_sample",
|
90
109
|
"estimate",
|
110
|
+
"batch_estimate",
|
91
111
|
"vqe",
|
92
112
|
"qae_with_qpe_result_post_processing",
|
93
113
|
"qsvm_full_run",
|
@@ -1,69 +1,64 @@
|
|
1
1
|
# This file was generated automatically - do not edit manually
|
2
2
|
|
3
|
-
from
|
4
|
-
|
5
|
-
from classiq.qmod.qmod_parameter import QParam
|
3
|
+
from classiq.qmod.qmod_parameter import CArray, CBool, CInt, CReal
|
6
4
|
from classiq.qmod.symbolic import symbolic_function
|
7
5
|
|
8
6
|
from .structs import *
|
9
7
|
|
10
8
|
|
11
9
|
def qft_const_adder_phase(
|
12
|
-
bit_index:
|
13
|
-
value:
|
14
|
-
reg_len:
|
15
|
-
) ->
|
16
|
-
return symbolic_function(bit_index, value, reg_len, return_type=
|
10
|
+
bit_index: CInt,
|
11
|
+
value: CInt,
|
12
|
+
reg_len: CInt,
|
13
|
+
) -> CReal:
|
14
|
+
return symbolic_function(bit_index, value, reg_len, return_type=CReal)
|
17
15
|
|
18
16
|
|
19
17
|
def molecule_problem_to_hamiltonian(
|
20
|
-
problem:
|
21
|
-
) ->
|
22
|
-
return symbolic_function(problem, return_type=
|
18
|
+
problem: MoleculeProblem,
|
19
|
+
) -> CArray[PauliTerm]:
|
20
|
+
return symbolic_function(problem, return_type=CArray[PauliTerm])
|
23
21
|
|
24
22
|
|
25
23
|
def fock_hamiltonian_problem_to_hamiltonian(
|
26
|
-
problem:
|
27
|
-
) ->
|
28
|
-
return symbolic_function(problem, return_type=
|
24
|
+
problem: FockHamiltonianProblem,
|
25
|
+
) -> CArray[PauliTerm]:
|
26
|
+
return symbolic_function(problem, return_type=CArray[PauliTerm])
|
29
27
|
|
30
28
|
|
31
29
|
def grid_entangler_graph(
|
32
|
-
num_qubits:
|
33
|
-
schmidt_rank:
|
34
|
-
grid_randomization:
|
35
|
-
) ->
|
30
|
+
num_qubits: CInt,
|
31
|
+
schmidt_rank: CInt,
|
32
|
+
grid_randomization: CBool,
|
33
|
+
) -> CArray[CArray[CInt]]:
|
36
34
|
return symbolic_function(
|
37
|
-
num_qubits,
|
38
|
-
schmidt_rank,
|
39
|
-
grid_randomization,
|
40
|
-
return_type=QParam[List[List[int]]],
|
35
|
+
num_qubits, schmidt_rank, grid_randomization, return_type=CArray[CArray[CInt]]
|
41
36
|
)
|
42
37
|
|
43
38
|
|
44
39
|
def hypercube_entangler_graph(
|
45
|
-
num_qubits:
|
46
|
-
) ->
|
47
|
-
return symbolic_function(num_qubits, return_type=
|
40
|
+
num_qubits: CInt,
|
41
|
+
) -> CArray[CArray[CInt]]:
|
42
|
+
return symbolic_function(num_qubits, return_type=CArray[CArray[CInt]])
|
48
43
|
|
49
44
|
|
50
45
|
def log_normal_finance_post_process(
|
51
|
-
finance_model:
|
52
|
-
estimation_method:
|
53
|
-
probability:
|
54
|
-
) ->
|
46
|
+
finance_model: LogNormalModel,
|
47
|
+
estimation_method: FinanceFunction,
|
48
|
+
probability: CReal,
|
49
|
+
) -> CReal:
|
55
50
|
return symbolic_function(
|
56
|
-
finance_model, estimation_method, probability, return_type=
|
51
|
+
finance_model, estimation_method, probability, return_type=CReal
|
57
52
|
)
|
58
53
|
|
59
54
|
|
60
55
|
def gaussian_finance_post_process(
|
61
|
-
finance_model:
|
62
|
-
estimation_method:
|
63
|
-
probability:
|
64
|
-
) ->
|
56
|
+
finance_model: GaussianModel,
|
57
|
+
estimation_method: FinanceFunction,
|
58
|
+
probability: CReal,
|
59
|
+
) -> CReal:
|
65
60
|
return symbolic_function(
|
66
|
-
finance_model, estimation_method, probability, return_type=
|
61
|
+
finance_model, estimation_method, probability, return_type=CReal
|
67
62
|
)
|
68
63
|
|
69
64
|
|