classiq 0.52.0__py3-none-any.whl → 0.54.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 +1 -3
- classiq/_analyzer_extras/_ipywidgets_async_extension.py +2 -1
- classiq/_internals/__init__.py +0 -20
- classiq/_internals/api_wrapper.py +23 -17
- classiq/_internals/async_utils.py +1 -3
- classiq/_internals/authentication/auth0.py +5 -5
- classiq/_internals/authentication/device.py +5 -4
- classiq/_internals/authentication/password_manager.py +3 -3
- classiq/_internals/authentication/token_manager.py +3 -2
- classiq/_internals/client.py +11 -13
- classiq/_internals/config.py +2 -2
- classiq/_internals/jobs.py +7 -6
- classiq/_internals/type_validation.py +9 -9
- classiq/analyzer/__init__.py +1 -3
- classiq/analyzer/analyzer.py +8 -7
- classiq/analyzer/analyzer_utilities.py +8 -8
- classiq/analyzer/rb.py +11 -11
- classiq/applications/__init__.py +1 -3
- classiq/applications/chemistry/__init__.py +1 -3
- classiq/applications/chemistry/ansatz_parameters.py +4 -4
- classiq/applications/chemistry/chemistry_model_constructor.py +10 -9
- classiq/applications/combinatorial_helpers/combinatorial_problem_utils.py +26 -9
- classiq/applications/combinatorial_helpers/encoding_mapping.py +10 -10
- classiq/applications/combinatorial_helpers/encoding_utils.py +4 -4
- classiq/applications/combinatorial_helpers/memory.py +5 -7
- classiq/applications/combinatorial_helpers/optimization_model.py +43 -24
- classiq/applications/combinatorial_helpers/pauli_helpers/pauli_utils.py +4 -6
- classiq/applications/combinatorial_helpers/pyomo_utils.py +95 -24
- classiq/applications/combinatorial_helpers/sympy_utils.py +2 -2
- classiq/applications/combinatorial_helpers/transformations/encoding.py +8 -8
- classiq/applications/combinatorial_helpers/transformations/fixed_variables.py +5 -5
- classiq/applications/combinatorial_helpers/transformations/ising_converter.py +7 -9
- classiq/applications/combinatorial_helpers/transformations/penalty.py +1 -2
- classiq/applications/combinatorial_helpers/transformations/sign_seperation.py +1 -2
- classiq/applications/combinatorial_helpers/transformations/slack_variables.py +1 -2
- classiq/applications/combinatorial_optimization/__init__.py +1 -3
- classiq/applications/combinatorial_optimization/combinatorial_optimization_config.py +2 -2
- classiq/applications/combinatorial_optimization/examples/__init__.py +1 -3
- classiq/applications/finance/__init__.py +1 -3
- classiq/applications/grover/__init__.py +1 -3
- classiq/applications/grover/grover_model_constructor.py +7 -9
- classiq/applications/hamiltonian/pauli_decomposition.py +6 -6
- classiq/applications/qnn/__init__.py +1 -3
- classiq/applications/qnn/circuit_utils.py +5 -5
- classiq/applications/qnn/datasets/__init__.py +1 -3
- classiq/applications/qnn/datasets/dataset_base_classes.py +5 -4
- classiq/applications/qnn/datasets/dataset_parity.py +2 -2
- classiq/applications/qnn/gradients/simple_quantum_gradient.py +2 -1
- classiq/applications/qnn/qlayer.py +25 -6
- classiq/applications/qnn/torch_utils.py +2 -2
- classiq/applications/qnn/types.py +5 -5
- classiq/applications/qsvm/qsvm.py +1 -3
- classiq/applications/qsvm/qsvm_data_generation.py +3 -3
- classiq/applications/qsvm/qsvm_model_constructor.py +5 -5
- classiq/execution/__init__.py +3 -3
- classiq/execution/all_hardware_devices.py +1 -3
- classiq/execution/execution_session.py +57 -16
- classiq/execution/iqcc.py +1 -1
- classiq/execution/jobs.py +4 -4
- classiq/execution/qaoa.py +84 -0
- classiq/execution/qnn.py +3 -3
- classiq/executor.py +4 -4
- classiq/interface/_version.py +1 -1
- classiq/interface/analyzer/analysis_params.py +9 -10
- classiq/interface/analyzer/cytoscape_graph.py +5 -5
- classiq/interface/analyzer/result.py +17 -17
- classiq/interface/applications/qsvm.py +6 -10
- classiq/interface/backend/backend_preferences.py +4 -3
- classiq/interface/backend/ionq/ionq_quantum_program.py +4 -5
- classiq/interface/backend/pydantic_backend.py +1 -2
- classiq/interface/chemistry/fermionic_operator.py +5 -5
- classiq/interface/chemistry/ground_state_problem.py +7 -8
- classiq/interface/chemistry/molecule.py +4 -4
- classiq/interface/chemistry/operator.py +11 -13
- classiq/interface/combinatorial_optimization/examples/ascending_sequence.py +1 -3
- classiq/interface/combinatorial_optimization/examples/integer_portfolio_optimization.py +2 -4
- classiq/interface/combinatorial_optimization/examples/knapsack.py +3 -3
- classiq/interface/combinatorial_optimization/examples/mht.py +2 -3
- classiq/interface/combinatorial_optimization/examples/portfolio_variations.py +2 -2
- classiq/interface/combinatorial_optimization/examples/set_cover.py +1 -2
- classiq/interface/combinatorial_optimization/mht_qaoa_input.py +5 -7
- classiq/interface/combinatorial_optimization/optimization_problem.py +2 -2
- classiq/interface/combinatorial_optimization/result.py +1 -3
- classiq/interface/debug_info/debug_info.py +8 -7
- classiq/interface/exceptions.py +11 -7
- classiq/interface/execution/iqcc.py +1 -3
- classiq/interface/execution/jobs.py +2 -2
- classiq/interface/execution/primitives.py +3 -3
- classiq/interface/executor/aws_execution_cost.py +4 -4
- classiq/interface/executor/execution_request.py +2 -3
- classiq/interface/executor/execution_result.py +3 -3
- classiq/interface/executor/iqae_result.py +3 -5
- classiq/interface/executor/optimizer_preferences.py +2 -2
- classiq/interface/executor/quantum_code.py +6 -6
- classiq/interface/executor/register_initialization.py +2 -4
- classiq/interface/executor/result.py +35 -28
- classiq/interface/executor/vqe_result.py +8 -8
- classiq/interface/finance/function_input.py +2 -2
- classiq/interface/finance/gaussian_model_input.py +5 -5
- classiq/interface/finance/log_normal_model_input.py +2 -2
- classiq/interface/finance/model_input.py +1 -2
- classiq/interface/generator/adjacency.py +1 -3
- classiq/interface/generator/ansatz_library.py +4 -4
- classiq/interface/generator/application_apis/finance_declarations.py +1 -1
- classiq/interface/generator/arith/argument_utils.py +3 -3
- classiq/interface/generator/arith/arithmetic.py +7 -7
- classiq/interface/generator/arith/arithmetic_arg_type_validator.py +5 -5
- classiq/interface/generator/arith/arithmetic_expression_abc.py +11 -11
- classiq/interface/generator/arith/arithmetic_expression_parser.py +8 -7
- classiq/interface/generator/arith/arithmetic_expression_validator.py +8 -8
- classiq/interface/generator/arith/arithmetic_operations.py +4 -3
- classiq/interface/generator/arith/arithmetic_param_getters.py +6 -6
- classiq/interface/generator/arith/arithmetic_result_builder.py +9 -9
- classiq/interface/generator/arith/ast_node_rewrite.py +2 -1
- classiq/interface/generator/arith/binary_ops.py +10 -13
- classiq/interface/generator/arith/extremum_operations.py +3 -2
- classiq/interface/generator/arith/logical_ops.py +7 -6
- classiq/interface/generator/arith/number_utils.py +4 -4
- classiq/interface/generator/arith/register_user_input.py +4 -4
- classiq/interface/generator/arith/unary_ops.py +2 -1
- classiq/interface/generator/builtin_api_builder.py +2 -1
- classiq/interface/generator/circuit_code/circuit_code.py +4 -4
- classiq/interface/generator/circuit_code/types_and_constants.py +3 -5
- classiq/interface/generator/complex_type.py +1 -2
- classiq/interface/generator/control_state.py +2 -2
- classiq/interface/generator/custom_ansatz.py +1 -3
- classiq/interface/generator/distance.py +3 -5
- classiq/interface/generator/excitations.py +3 -2
- classiq/interface/generator/expressions/enums/finance_functions.py +1 -3
- classiq/interface/generator/expressions/evaluated_expression.py +4 -3
- classiq/interface/generator/expressions/expression.py +4 -5
- classiq/interface/generator/expressions/expression_constants.py +4 -4
- classiq/interface/generator/expressions/qmod_qarray_proxy.py +2 -1
- classiq/interface/generator/expressions/qmod_qscalar_proxy.py +2 -1
- classiq/interface/generator/expressions/qmod_qstruct_proxy.py +2 -1
- classiq/interface/generator/expressions/qmod_sized_proxy.py +2 -1
- classiq/interface/generator/expressions/qmod_struct_instance.py +2 -1
- classiq/interface/generator/expressions/sympy_supported_expressions.py +11 -13
- classiq/interface/generator/finance.py +2 -2
- classiq/interface/generator/function_param_library.py +6 -6
- classiq/interface/generator/function_params.py +13 -19
- classiq/interface/generator/functions/classical_function_declaration.py +4 -3
- classiq/interface/generator/functions/classical_type.py +13 -13
- classiq/interface/generator/functions/concrete_types.py +1 -2
- classiq/interface/generator/functions/function_declaration.py +1 -1
- classiq/interface/generator/functions/qmod_python_interface.py +2 -1
- classiq/interface/generator/functions/type_name.py +3 -2
- classiq/interface/generator/generated_circuit_data.py +34 -22
- classiq/interface/generator/grover_diffuser.py +7 -7
- classiq/interface/generator/grover_operator.py +2 -2
- classiq/interface/generator/hardware/hardware_data.py +7 -6
- classiq/interface/generator/hardware_efficient_ansatz.py +8 -8
- classiq/interface/generator/identity.py +5 -6
- classiq/interface/generator/linear_pauli_rotations.py +6 -6
- classiq/interface/generator/mcu.py +2 -2
- classiq/interface/generator/mcx.py +6 -6
- classiq/interface/generator/model/__init__.py +1 -3
- classiq/interface/generator/model/constraints.py +2 -2
- classiq/interface/generator/model/model.py +5 -6
- classiq/interface/generator/model/preferences/preferences.py +7 -6
- classiq/interface/generator/model/quantum_register.py +6 -11
- classiq/interface/generator/oracles/arithmetic_oracle.py +1 -2
- classiq/interface/generator/oracles/custom_oracle.py +2 -2
- classiq/interface/generator/oracles/oracle_abc.py +6 -5
- classiq/interface/generator/partitioned_register.py +6 -5
- classiq/interface/generator/piecewise_linear_amplitude_loading.py +8 -7
- classiq/interface/generator/qpe.py +4 -4
- classiq/interface/generator/qsvm.py +3 -3
- classiq/interface/generator/quantum_function_call.py +24 -29
- classiq/interface/generator/quantum_program.py +9 -9
- classiq/interface/generator/register_role.py +2 -4
- classiq/interface/generator/slice_parsing_utils.py +4 -3
- classiq/interface/generator/standard_gates/standard_gates.py +3 -3
- classiq/interface/generator/state_preparation/bell_state_preparation.py +3 -3
- classiq/interface/generator/state_preparation/distributions.py +6 -5
- classiq/interface/generator/state_preparation/metrics.py +2 -4
- classiq/interface/generator/state_preparation/state_preparation.py +4 -4
- classiq/interface/generator/synthesis_metadata/synthesis_execution_data.py +3 -3
- classiq/interface/generator/transpiler_basis_gates.py +2 -2
- classiq/interface/generator/types/enum_declaration.py +2 -3
- classiq/interface/generator/types/qstruct_declaration.py +2 -1
- classiq/interface/generator/types/struct_declaration.py +3 -2
- classiq/interface/generator/ucc.py +2 -1
- classiq/interface/generator/unitary_gate.py +2 -2
- classiq/interface/generator/user_defined_function_params.py +1 -1
- classiq/interface/generator/validations/flow_graph.py +6 -5
- classiq/interface/generator/validations/validator_functions.py +3 -2
- classiq/interface/generator/visitor.py +9 -14
- classiq/interface/hardware.py +5 -6
- classiq/interface/helpers/custom_encoders.py +2 -2
- classiq/interface/helpers/custom_pydantic_types.py +8 -9
- classiq/interface/helpers/dotdict.py +18 -0
- classiq/interface/helpers/hashable_mixin.py +3 -2
- classiq/interface/helpers/hashable_pydantic_base_model.py +2 -1
- classiq/interface/helpers/pydantic_model_helpers.py +4 -3
- classiq/interface/helpers/validation_helpers.py +2 -2
- classiq/interface/ide/ide_data.py +11 -15
- classiq/interface/ide/visual_model.py +33 -22
- classiq/interface/jobs.py +2 -2
- classiq/interface/model/bind_operation.py +5 -4
- classiq/interface/model/classical_parameter_declaration.py +2 -2
- classiq/interface/model/handle_binding.py +3 -2
- classiq/interface/model/inplace_binary_operation.py +2 -1
- classiq/interface/model/model.py +12 -11
- classiq/interface/model/native_function_definition.py +10 -0
- classiq/interface/model/port_declaration.py +2 -2
- classiq/interface/model/quantum_expressions/amplitude_loading_operation.py +3 -2
- classiq/interface/model/quantum_expressions/arithmetic_operation.py +3 -2
- classiq/interface/model/quantum_expressions/quantum_expression.py +8 -7
- classiq/interface/model/quantum_function_call.py +9 -14
- classiq/interface/model/quantum_function_declaration.py +10 -12
- classiq/interface/model/quantum_lambda_function.py +3 -16
- classiq/interface/model/quantum_statement.py +4 -3
- classiq/interface/model/quantum_type.py +5 -5
- classiq/interface/model/statement_block.py +2 -3
- classiq/interface/model/validation_handle.py +5 -4
- classiq/interface/server/global_versions.py +3 -3
- classiq/model_expansions/atomic_expression_functions_defs.py +3 -2
- classiq/model_expansions/call_to_model_converter.py +190 -0
- classiq/model_expansions/capturing/captured_var_manager.py +4 -6
- classiq/model_expansions/capturing/propagated_var_stack.py +7 -7
- classiq/model_expansions/closure.py +17 -9
- classiq/model_expansions/evaluators/arg_type_match.py +3 -2
- classiq/model_expansions/evaluators/argument_types.py +3 -3
- classiq/model_expansions/evaluators/control.py +3 -3
- classiq/model_expansions/evaluators/parameter_types.py +7 -7
- classiq/model_expansions/evaluators/quantum_type_utils.py +2 -1
- classiq/model_expansions/evaluators/type_type_match.py +1 -1
- classiq/model_expansions/expression_evaluator.py +10 -9
- classiq/model_expansions/expression_renamer.py +6 -6
- classiq/model_expansions/function_builder.py +19 -12
- classiq/model_expansions/generative_functions.py +3 -2
- classiq/model_expansions/interpreter.py +31 -19
- classiq/model_expansions/model_tables.py +14 -14
- classiq/model_expansions/quantum_operations/bind.py +2 -4
- classiq/model_expansions/quantum_operations/classicalif.py +1 -1
- classiq/model_expansions/quantum_operations/control.py +2 -4
- classiq/model_expansions/quantum_operations/emitter.py +10 -13
- classiq/model_expansions/quantum_operations/expression_operation.py +23 -16
- classiq/model_expansions/quantum_operations/inplace_binary_operation.py +164 -38
- classiq/model_expansions/quantum_operations/phase.py +6 -6
- classiq/model_expansions/quantum_operations/quantum_assignment_operation.py +25 -5
- classiq/model_expansions/quantum_operations/quantum_function_call.py +41 -2
- classiq/model_expansions/quantum_operations/repeat.py +1 -3
- classiq/model_expansions/scope.py +11 -10
- classiq/model_expansions/scope_initialization.py +6 -5
- classiq/model_expansions/sympy_conversion/expression_to_sympy.py +6 -6
- classiq/model_expansions/sympy_conversion/sympy_to_python.py +2 -2
- classiq/model_expansions/visitors/variable_references.py +5 -4
- classiq/qmod/__init__.py +2 -0
- classiq/qmod/builtins/classical_execution_primitives.py +9 -9
- classiq/qmod/builtins/functions/__init__.py +75 -53
- classiq/qmod/builtins/functions/amplitude_estimation.py +4 -1
- classiq/qmod/builtins/functions/arithmetic.py +14 -1
- classiq/qmod/builtins/functions/discrete_sine_cosine_transform.py +86 -6
- classiq/qmod/builtins/functions/grover.py +41 -45
- classiq/qmod/builtins/functions/hea.py +60 -4
- classiq/qmod/builtins/functions/linear_pauli_rotation.py +26 -4
- classiq/qmod/builtins/functions/modular_exponentiation.py +90 -29
- classiq/qmod/builtins/functions/operators.py +1 -1
- classiq/qmod/builtins/functions/qaoa_penalty.py +14 -5
- classiq/qmod/builtins/functions/qft_functions.py +57 -0
- classiq/qmod/builtins/functions/qpe.py +20 -4
- classiq/qmod/builtins/functions/qsvt.py +49 -4
- classiq/qmod/builtins/functions/standard_gates.py +18 -18
- classiq/qmod/builtins/functions/state_preparation.py +92 -10
- classiq/qmod/builtins/functions/swap_test.py +7 -1
- classiq/qmod/builtins/functions/utility_functions.py +43 -0
- classiq/qmod/builtins/functions/variational.py +53 -0
- classiq/qmod/builtins/operations.py +4 -5
- classiq/qmod/cfunc.py +2 -2
- classiq/qmod/classical_function.py +3 -7
- classiq/qmod/create_model_function.py +19 -8
- classiq/qmod/declaration_inferrer.py +7 -10
- classiq/qmod/expression_query.py +3 -3
- classiq/qmod/generative.py +2 -1
- classiq/qmod/model_state_container.py +5 -7
- classiq/qmod/native/__init__.py +1 -3
- classiq/qmod/native/expression_to_qmod.py +9 -8
- classiq/qmod/native/pretty_printer.py +6 -5
- classiq/qmod/pretty_print/__init__.py +1 -3
- classiq/qmod/pretty_print/expression_to_python.py +13 -12
- classiq/qmod/pretty_print/pretty_printer.py +13 -12
- classiq/qmod/python_classical_type.py +8 -4
- classiq/qmod/qfunc.py +4 -4
- classiq/qmod/qmod_parameter.py +3 -1
- classiq/qmod/qmod_variable.py +11 -10
- classiq/qmod/quantum_expandable.py +32 -15
- classiq/qmod/quantum_function.py +34 -5
- classiq/qmod/semantics/annotation.py +1 -1
- classiq/qmod/semantics/error_manager.py +8 -7
- classiq/qmod/semantics/static_semantics_visitor.py +19 -24
- classiq/qmod/semantics/validation/constants_validation.py +1 -1
- classiq/qmod/semantics/validation/func_call_validation.py +2 -2
- classiq/qmod/semantics/validation/main_validation.py +33 -0
- classiq/qmod/semantics/validation/types_validation.py +2 -1
- classiq/qmod/symbolic.py +5 -8
- classiq/qmod/symbolic_type.py +2 -2
- classiq/qmod/synthesize_separately.py +16 -0
- {classiq-0.52.0.dist-info → classiq-0.54.0.dist-info}/METADATA +1 -1
- {classiq-0.52.0.dist-info → classiq-0.54.0.dist-info}/RECORD +302 -295
- classiq/qmod/builtins/functions/qft.py +0 -23
- {classiq-0.52.0.dist-info → classiq-0.54.0.dist-info}/WHEEL +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
import logging
|
2
2
|
from collections import defaultdict
|
3
|
-
from typing import
|
3
|
+
from typing import Optional
|
4
4
|
|
5
5
|
import numpy as np
|
6
6
|
|
@@ -15,7 +15,7 @@ def generate_data(
|
|
15
15
|
range_max: float = 2 * np.pi,
|
16
16
|
std: float = 0.5,
|
17
17
|
sources: Optional[np.ndarray] = None,
|
18
|
-
) ->
|
18
|
+
) -> dict[int, np.ndarray]:
|
19
19
|
if sources is None:
|
20
20
|
sources = np.random.uniform(
|
21
21
|
range_min, range_max, (amount_of_sources, dimension)
|
@@ -36,7 +36,7 @@ def generate_data(
|
|
36
36
|
return results
|
37
37
|
|
38
38
|
|
39
|
-
def data_dict_to_data_and_labels(data_dict: dict) ->
|
39
|
+
def data_dict_to_data_and_labels(data_dict: dict) -> tuple[np.ndarray, np.ndarray]:
|
40
40
|
data = []
|
41
41
|
labels = []
|
42
42
|
for k, v in data_dict.items():
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import Any
|
1
|
+
from typing import Any
|
2
2
|
|
3
3
|
from classiq.interface.applications.qsvm import DataList, LabelsInt
|
4
4
|
from classiq.interface.exceptions import ClassiqValueError
|
@@ -22,19 +22,19 @@ _OUTPUT_VARIABLE_NAME = "qsvm_results"
|
|
22
22
|
|
23
23
|
def _bloch_sphere_feature_map_function_params(
|
24
24
|
bloch_feature_dimension: int,
|
25
|
-
) ->
|
25
|
+
) -> tuple[list[Expression], str]:
|
26
26
|
return [
|
27
27
|
Expression(expr=f"{bloch_feature_dimension}")
|
28
28
|
], f"ceiling({bloch_feature_dimension}/2)"
|
29
29
|
|
30
30
|
|
31
31
|
def _pauli_feature_map_function_params(
|
32
|
-
paulis:
|
32
|
+
paulis: list[list[Pauli]],
|
33
33
|
entanglement: QSVMFeatureMapEntanglement,
|
34
34
|
alpha: int,
|
35
35
|
reps: int,
|
36
36
|
feature_dimension: int,
|
37
|
-
) ->
|
37
|
+
) -> tuple[list[Expression], str]:
|
38
38
|
paulis_str = (
|
39
39
|
"["
|
40
40
|
+ ",".join(
|
@@ -61,7 +61,7 @@ def _pauli_feature_map_function_params(
|
|
61
61
|
|
62
62
|
def get_qsvm_qmain_body(
|
63
63
|
feature_map_function_name: str, **kwargs: Any
|
64
|
-
) ->
|
64
|
+
) -> list[QuantumFunctionCall]:
|
65
65
|
if feature_map_function_name == "bloch_sphere_feature_map":
|
66
66
|
params, size_expr = _bloch_sphere_feature_map_function_params(**kwargs)
|
67
67
|
elif feature_map_function_name == "pauli_feature_map":
|
classiq/execution/__init__.py
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
from typing import List
|
2
|
-
|
3
1
|
from ..executor import * # noqa: F403
|
4
2
|
from ..executor import __all__ as _exec_all
|
5
3
|
from ..interface.backend.backend_preferences import * # noqa: F403
|
@@ -12,6 +10,7 @@ from ..interface.executor.vqe_result import VQESolverResult
|
|
12
10
|
from .execution_session import ExecutionSession
|
13
11
|
from .iqcc import generate_iqcc_token, generate_iqcc_token_async
|
14
12
|
from .jobs import ExecutionJob, get_execution_jobs, get_execution_jobs_async
|
13
|
+
from .qaoa import execute_qaoa
|
15
14
|
from .qnn import execute_qnn
|
16
15
|
|
17
16
|
__all__ = (
|
@@ -26,6 +25,7 @@ __all__ = (
|
|
26
25
|
"get_execution_jobs",
|
27
26
|
"get_execution_jobs_async",
|
28
27
|
"ExecutionSession",
|
28
|
+
"execute_qaoa",
|
29
29
|
"execute_qnn",
|
30
30
|
"generate_iqcc_token",
|
31
31
|
"generate_iqcc_token_async",
|
@@ -33,5 +33,5 @@ __all__ = (
|
|
33
33
|
)
|
34
34
|
|
35
35
|
|
36
|
-
def __dir__() ->
|
36
|
+
def __dir__() -> list[str]:
|
37
37
|
return __all__
|
@@ -1,12 +1,10 @@
|
|
1
|
-
from typing import List
|
2
|
-
|
3
1
|
from classiq.interface.hardware import HardwareInformation
|
4
2
|
|
5
3
|
from classiq._internals import async_utils
|
6
4
|
from classiq._internals.api_wrapper import ApiWrapper
|
7
5
|
|
8
6
|
|
9
|
-
def get_all_hardware_devices() ->
|
7
|
+
def get_all_hardware_devices() -> list[HardwareInformation]:
|
10
8
|
"""
|
11
9
|
Returns a list of all hardware devices known to Classiq.
|
12
10
|
"""
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import json
|
2
|
-
from typing import Any, Callable,
|
2
|
+
from typing import Any, Callable, Optional, Union, cast
|
3
|
+
|
4
|
+
import numpy as np
|
3
5
|
|
4
6
|
from classiq.interface.chemistry.operator import PauliOperator, pauli_integers_to_str
|
5
7
|
from classiq.interface.exceptions import ClassiqValueError
|
@@ -8,6 +10,7 @@ from classiq.interface.executor.execution_preferences import ExecutionPreference
|
|
8
10
|
from classiq.interface.executor.result import (
|
9
11
|
EstimationResult,
|
10
12
|
ExecutionDetails,
|
13
|
+
ParsedState,
|
11
14
|
)
|
12
15
|
from classiq.interface.generator.functions.qmod_python_interface import QmodPyStruct
|
13
16
|
from classiq.interface.generator.quantum_program import QuantumProgram
|
@@ -25,12 +28,12 @@ from classiq.qmod.builtins.classical_execution_primitives import (
|
|
25
28
|
)
|
26
29
|
from classiq.synthesis import SerializedQuantumProgram
|
27
30
|
|
28
|
-
Hamiltonian = Union[
|
31
|
+
Hamiltonian = Union[list[QmodPyStruct], list[PauliTerm]]
|
29
32
|
Program = Union[SerializedQuantumProgram, QuantumProgram]
|
30
|
-
ParsedExecutionParams =
|
31
|
-
ExecutionParameters = Optional[Union[ExecutionParams,
|
33
|
+
ParsedExecutionParams = dict[str, Union[float, int]]
|
34
|
+
ExecutionParameters = Optional[Union[ExecutionParams, list[ExecutionParams]]]
|
32
35
|
ParsedExecutionParameters = Optional[
|
33
|
-
Union[ParsedExecutionParams,
|
36
|
+
Union[ParsedExecutionParams, list[ParsedExecutionParams]]
|
34
37
|
]
|
35
38
|
|
36
39
|
|
@@ -52,11 +55,11 @@ def _deserialize_program(program: Program) -> QuantumProgram:
|
|
52
55
|
)
|
53
56
|
|
54
57
|
|
55
|
-
def hamiltonian_to_pauli_terms(hamiltonian: Hamiltonian) ->
|
58
|
+
def hamiltonian_to_pauli_terms(hamiltonian: Hamiltonian) -> list[PauliTerm]:
|
56
59
|
if isinstance(hamiltonian[0], PauliTerm):
|
57
|
-
return cast(
|
60
|
+
return cast(list[PauliTerm], hamiltonian)
|
58
61
|
else:
|
59
|
-
return _pauli_dict_to_pauli_terms(cast(
|
62
|
+
return _pauli_dict_to_pauli_terms(cast(list[QmodPyStruct], hamiltonian))
|
60
63
|
|
61
64
|
|
62
65
|
def to_hamiltonian_str(hamiltonian: Hamiltonian) -> str:
|
@@ -75,8 +78,8 @@ def _hamiltonian_to_pauli_operator(hamiltonian: Hamiltonian) -> PauliOperator:
|
|
75
78
|
|
76
79
|
|
77
80
|
def serialize(
|
78
|
-
item: Union[float, int,
|
79
|
-
) -> Union[str,
|
81
|
+
item: Union[float, int, tuple[int, ...], tuple[float, ...]]
|
82
|
+
) -> Union[str, list]:
|
80
83
|
if isinstance(item, tuple):
|
81
84
|
return list(item)
|
82
85
|
return str(item)
|
@@ -123,7 +126,7 @@ def create_sample_execution_code(operation: str, **kwargs: Any) -> str:
|
|
123
126
|
return f"\nresult = {operation}({parameters})" + SAVE_RESULT
|
124
127
|
|
125
128
|
|
126
|
-
operation_handlers:
|
129
|
+
operation_handlers: dict[str, Callable[[str], str]] = {
|
127
130
|
"estimate": create_estimate_execution_code,
|
128
131
|
"batch_estimate": create_estimate_execution_code,
|
129
132
|
"sample": create_sample_execution_code,
|
@@ -215,7 +218,7 @@ class ExecutionSession:
|
|
215
218
|
)
|
216
219
|
return execute(SerializedQuantumProgram(self.qprog))
|
217
220
|
|
218
|
-
def batch_sample(self, parameters:
|
221
|
+
def batch_sample(self, parameters: list[ExecutionParams]) -> list[ExecutionDetails]:
|
219
222
|
"""
|
220
223
|
Samples the quantum program multiple times with the given parameters for each iteration. The number of samples is determined by the length of the parameters list.
|
221
224
|
|
@@ -228,7 +231,7 @@ class ExecutionSession:
|
|
228
231
|
job = self.submit_batch_sample(parameters=parameters)
|
229
232
|
return job.get_batch_sample_result()
|
230
233
|
|
231
|
-
def submit_batch_sample(self, parameters:
|
234
|
+
def submit_batch_sample(self, parameters: list[ExecutionParams]) -> ExecutionJob:
|
232
235
|
"""
|
233
236
|
Initiates an execution job with the `batch_sample` primitive.
|
234
237
|
|
@@ -297,8 +300,8 @@ class ExecutionSession:
|
|
297
300
|
return execute(SerializedQuantumProgram(self.qprog))
|
298
301
|
|
299
302
|
def batch_estimate(
|
300
|
-
self, hamiltonian: Hamiltonian, parameters:
|
301
|
-
) ->
|
303
|
+
self, hamiltonian: Hamiltonian, parameters: list[ExecutionParams]
|
304
|
+
) -> list[EstimationResult]:
|
302
305
|
"""
|
303
306
|
Estimates the expectation value of the given Hamiltonian multiple times using the quantum program, with the given parameters for each iteration. The number of estimations is determined by the length of the parameters list.
|
304
307
|
|
@@ -313,7 +316,7 @@ class ExecutionSession:
|
|
313
316
|
return job.get_batch_estimate_result()
|
314
317
|
|
315
318
|
def submit_batch_estimate(
|
316
|
-
self, hamiltonian: Hamiltonian, parameters:
|
319
|
+
self, hamiltonian: Hamiltonian, parameters: list[ExecutionParams]
|
317
320
|
) -> ExecutionJob:
|
318
321
|
"""
|
319
322
|
Initiates an execution job with the `batch_estimate` primitive.
|
@@ -340,3 +343,41 @@ class ExecutionSession:
|
|
340
343
|
)
|
341
344
|
)
|
342
345
|
return execute(SerializedQuantumProgram(self.qprog))
|
346
|
+
|
347
|
+
def estimate_cost(
|
348
|
+
self,
|
349
|
+
cost_func: Callable[[ParsedState], float],
|
350
|
+
parameters: Optional[ExecutionParams] = None,
|
351
|
+
quantile: float = 1.0,
|
352
|
+
) -> float:
|
353
|
+
"""
|
354
|
+
Estimates circuit cost using a classical cost function.
|
355
|
+
|
356
|
+
Args:
|
357
|
+
cost_func: classical circuit sample cost function
|
358
|
+
parameters: execution parameters sent to 'sample'
|
359
|
+
quantile: drop cost values outside the specified quantile
|
360
|
+
|
361
|
+
Returns:
|
362
|
+
cost estimation
|
363
|
+
|
364
|
+
See Also:
|
365
|
+
sample
|
366
|
+
"""
|
367
|
+
if quantile < 0 or quantile > 1:
|
368
|
+
raise ClassiqValueError("'quantile' must be between 0 and 1")
|
369
|
+
res = self.sample(parameters)
|
370
|
+
|
371
|
+
counts = np.array(res.parsed_counts)
|
372
|
+
costs = np.vectorize(lambda sample: cost_func(sample.state))(counts)
|
373
|
+
shots = np.vectorize(lambda sample: sample.shots)(counts)
|
374
|
+
|
375
|
+
if quantile == 1:
|
376
|
+
return float(np.average(costs, weights=shots))
|
377
|
+
costs = np.repeat(costs, shots)
|
378
|
+
sort_idx = costs.argsort()
|
379
|
+
sort_idx = sort_idx[: int(quantile * len(costs))]
|
380
|
+
costs = costs[sort_idx]
|
381
|
+
if costs.size == 0:
|
382
|
+
return np.nan
|
383
|
+
return float(np.average(costs))
|
classiq/execution/iqcc.py
CHANGED
classiq/execution/jobs.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import webbrowser
|
2
2
|
from datetime import datetime
|
3
|
-
from typing import Any,
|
3
|
+
from typing import Any, Optional, Union
|
4
4
|
from urllib.parse import urljoin
|
5
5
|
|
6
6
|
from classiq.interface.exceptions import (
|
@@ -150,7 +150,7 @@ class ExecutionJob:
|
|
150
150
|
return result.details[0]
|
151
151
|
raise ClassiqExecutionResultError("sample")
|
152
152
|
|
153
|
-
def get_batch_sample_result(self) ->
|
153
|
+
def get_batch_sample_result(self) -> list[ExecutionDetails]:
|
154
154
|
"""
|
155
155
|
Returns the job's result as a single batch_sample result after validation. If the result is not yet available, waits for it.
|
156
156
|
|
@@ -195,7 +195,7 @@ class ExecutionJob:
|
|
195
195
|
return result.results[0]
|
196
196
|
raise ClassiqExecutionResultError("estimate")
|
197
197
|
|
198
|
-
def get_batch_estimate_result(self) ->
|
198
|
+
def get_batch_estimate_result(self) -> list[EstimationResult]:
|
199
199
|
"""
|
200
200
|
Returns the job's result as a single batch_estimate result after validation. If the result is not yet available, waits for it.
|
201
201
|
|
@@ -271,7 +271,7 @@ class ExecutionJob:
|
|
271
271
|
|
272
272
|
async def get_execution_jobs_async(
|
273
273
|
offset: int = 0, limit: int = 50
|
274
|
-
) ->
|
274
|
+
) -> list[ExecutionJob]:
|
275
275
|
result = await ApiWrapper().call_query_execution_jobs(offset=offset, limit=limit)
|
276
276
|
return [ExecutionJob(details) for details in result.results]
|
277
277
|
|
@@ -0,0 +1,84 @@
|
|
1
|
+
import math
|
2
|
+
from typing import Callable, Optional
|
3
|
+
|
4
|
+
import numpy as np
|
5
|
+
import scipy
|
6
|
+
|
7
|
+
from classiq.interface.executor.execution_preferences import ExecutionPreferences
|
8
|
+
from classiq.interface.executor.result import ExecutionDetails
|
9
|
+
from classiq.interface.model.model import SerializedModel
|
10
|
+
|
11
|
+
from classiq.execution import ExecutionSession
|
12
|
+
from classiq.qmod.builtins.functions import (
|
13
|
+
RX,
|
14
|
+
allocate,
|
15
|
+
apply_to_all,
|
16
|
+
hadamard_transform,
|
17
|
+
)
|
18
|
+
from classiq.qmod.builtins.operations import phase, repeat
|
19
|
+
from classiq.qmod.cparam import CReal
|
20
|
+
from classiq.qmod.create_model_function import create_model
|
21
|
+
from classiq.qmod.qfunc import qfunc
|
22
|
+
from classiq.qmod.qmod_parameter import CArray
|
23
|
+
from classiq.qmod.qmod_variable import Output, QVar
|
24
|
+
from classiq.synthesis import SerializedQuantumProgram, synthesize
|
25
|
+
|
26
|
+
|
27
|
+
def execute_qaoa(
|
28
|
+
problem_vars: type[QVar],
|
29
|
+
cost_func: Callable,
|
30
|
+
num_layers: int,
|
31
|
+
maxiter: int,
|
32
|
+
execution_preferences: Optional[ExecutionPreferences] = None,
|
33
|
+
) -> tuple[SerializedModel, SerializedQuantumProgram, ExecutionDetails]:
|
34
|
+
"""
|
35
|
+
Implements a simple QAOA algorithm, including the creation and synthesis of the QAOA
|
36
|
+
ansatz and the classical optimization loop.
|
37
|
+
|
38
|
+
Args:
|
39
|
+
problem_vars: the quantum type (scalar, array, or struct) of the problem variable(s)
|
40
|
+
cost_func: the arithmetic expression that evaluates the cost given an instance of the problem_vars type
|
41
|
+
num_layers: the number of layers of the QAOA ansatz
|
42
|
+
maxiter: the maximum number of iterations for the classical optimization loop
|
43
|
+
execution_preferences: the execution settings for running the QAOA ansatz
|
44
|
+
|
45
|
+
Returns:
|
46
|
+
a tuple containing the model of the QAOA ansatz, the corresponding synthesized quantum program,
|
47
|
+
and the result of the execution with the optimized parameters
|
48
|
+
"""
|
49
|
+
|
50
|
+
@qfunc
|
51
|
+
def main(
|
52
|
+
params: CArray[CReal, num_layers * 2], # type:ignore[valid-type]
|
53
|
+
v: Output[problem_vars], # type:ignore[valid-type]
|
54
|
+
) -> None:
|
55
|
+
allocate(v.size, v) # type:ignore[attr-defined]
|
56
|
+
hadamard_transform(v)
|
57
|
+
repeat(
|
58
|
+
num_layers,
|
59
|
+
lambda i: [ # type:ignore[arg-type]
|
60
|
+
phase(-cost_func(v), params[i]), # type:ignore[func-returns-value]
|
61
|
+
apply_to_all(lambda q: RX(params[num_layers + i], q), v),
|
62
|
+
],
|
63
|
+
)
|
64
|
+
|
65
|
+
model = create_model(main)
|
66
|
+
qprog = synthesize(model)
|
67
|
+
|
68
|
+
es = ExecutionSession(qprog, execution_preferences)
|
69
|
+
initial_params = (
|
70
|
+
np.concatenate((np.linspace(0, 1, num_layers), np.linspace(1, 0, num_layers)))
|
71
|
+
* math.pi
|
72
|
+
)
|
73
|
+
final_params = scipy.optimize.minimize(
|
74
|
+
lambda params: es.estimate_cost(
|
75
|
+
lambda state: cost_func(state["v"]),
|
76
|
+
{"params": params.tolist()},
|
77
|
+
),
|
78
|
+
x0=initial_params,
|
79
|
+
method="COBYLA",
|
80
|
+
options={"maxiter": maxiter},
|
81
|
+
).x.tolist()
|
82
|
+
result = es.sample({"params": final_params})
|
83
|
+
|
84
|
+
return model, qprog, result
|
classiq/execution/qnn.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import functools
|
2
|
-
from typing import
|
2
|
+
from typing import Optional
|
3
3
|
|
4
4
|
import more_itertools
|
5
5
|
|
@@ -24,7 +24,7 @@ _MAX_ARGUMENTS_SIZE = 1024
|
|
24
24
|
|
25
25
|
def _execute_qnn_estimate(
|
26
26
|
session: ExecutionSession,
|
27
|
-
arguments:
|
27
|
+
arguments: list[Arguments],
|
28
28
|
observable: PauliOperator,
|
29
29
|
) -> ResultsCollection:
|
30
30
|
hamiltonian = pauli_operator_to_hamiltonian(observable.pauli_list)
|
@@ -42,7 +42,7 @@ def _execute_qnn_estimate(
|
|
42
42
|
|
43
43
|
def _execute_qnn_sample(
|
44
44
|
session: ExecutionSession,
|
45
|
-
arguments:
|
45
|
+
arguments: list[Arguments],
|
46
46
|
) -> ResultsCollection:
|
47
47
|
return [
|
48
48
|
TaggedExecutionDetails(
|
classiq/executor.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"""Executor module, implementing facilities for executing quantum programs using Classiq platform."""
|
2
2
|
|
3
|
-
from typing import
|
3
|
+
from typing import Union
|
4
4
|
|
5
5
|
from typing_extensions import TypeAlias
|
6
6
|
|
@@ -18,8 +18,8 @@ from classiq.execution.jobs import ExecutionJob
|
|
18
18
|
from classiq.synthesis import SerializedQuantumProgram
|
19
19
|
|
20
20
|
BatchExecutionResult: TypeAlias = Union[ExecutionDetails, BaseException]
|
21
|
-
ProgramAndResult: TypeAlias =
|
22
|
-
BackendPreferencesAndResult: TypeAlias =
|
21
|
+
ProgramAndResult: TypeAlias = tuple[QuantumCode, BatchExecutionResult]
|
22
|
+
BackendPreferencesAndResult: TypeAlias = tuple[
|
23
23
|
BackendPreferencesTypes, int, BatchExecutionResult
|
24
24
|
]
|
25
25
|
|
@@ -46,7 +46,7 @@ def execute(quantum_program: SerializedQuantumProgram) -> ExecutionJob:
|
|
46
46
|
Returns:
|
47
47
|
ExecutionJob: The result of the execution.
|
48
48
|
|
49
|
-
For examples please see [Execution Documentation](https://docs.classiq.io/latest/
|
49
|
+
For examples please see [Execution Documentation](https://docs.classiq.io/latest/user-guide/executor/)
|
50
50
|
"""
|
51
51
|
return async_utils.run(execute_async(quantum_program))
|
52
52
|
|
classiq/interface/_version.py
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
from typing import
|
1
|
+
from typing import Annotated, Optional
|
2
2
|
|
3
3
|
import numpy
|
4
4
|
import pydantic
|
5
5
|
from pydantic import ConfigDict, Field, StringConstraints
|
6
|
-
from typing_extensions import Annotated
|
7
6
|
|
8
7
|
from classiq.interface.backend.quantum_backend_providers import AnalyzerProviderVendor
|
9
8
|
from classiq.interface.chemistry.ground_state_problem import MoleculeProblem
|
@@ -30,17 +29,17 @@ class AnalysisParams(pydantic.BaseModel):
|
|
30
29
|
|
31
30
|
|
32
31
|
class HardwareListParams(pydantic.BaseModel):
|
33
|
-
devices: Optional[
|
32
|
+
devices: Optional[list[PydanticNonEmptyString]] = pydantic.Field(
|
34
33
|
default=None, description="Devices"
|
35
34
|
)
|
36
|
-
providers:
|
35
|
+
providers: list[Provider]
|
37
36
|
from_ide: bool = Field(default=False)
|
38
37
|
|
39
38
|
@pydantic.field_validator("providers")
|
40
39
|
@classmethod
|
41
40
|
def set_default_providers(
|
42
|
-
cls, providers: Optional[
|
43
|
-
) ->
|
41
|
+
cls, providers: Optional[list[AnalyzerProviderVendor]]
|
42
|
+
) -> list[AnalyzerProviderVendor]:
|
44
43
|
if providers is None:
|
45
44
|
providers = list(AnalyzerProviderVendor)
|
46
45
|
return providers
|
@@ -65,7 +64,7 @@ class GateNamsMapping(pydantic.BaseModel):
|
|
65
64
|
|
66
65
|
|
67
66
|
class LatexParams(AnalysisParams):
|
68
|
-
gate_names:
|
67
|
+
gate_names: list[GateNamsMapping] = pydantic.Field(
|
69
68
|
default=..., description="List of gate names as apper in the qasm"
|
70
69
|
)
|
71
70
|
|
@@ -96,12 +95,12 @@ class CircuitAnalysisHardwareParams(AnalysisParams):
|
|
96
95
|
|
97
96
|
class AnalysisRBParams(pydantic.BaseModel):
|
98
97
|
hardware: str
|
99
|
-
counts:
|
100
|
-
|
98
|
+
counts: list[
|
99
|
+
dict[
|
101
100
|
str, Annotated[int, Annotated[int, Field(strict=True, gt=0, le=MAX_COUNTS)]]
|
102
101
|
]
|
103
102
|
]
|
104
|
-
num_clifford:
|
103
|
+
num_clifford: list[
|
105
104
|
Annotated[int, Annotated[int, Field(strict=True, gt=0, le=MAX_NUM_CLIFFORD)]]
|
106
105
|
]
|
107
106
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import Any,
|
1
|
+
from typing import Any, Optional
|
2
2
|
|
3
3
|
import pydantic
|
4
4
|
|
@@ -25,7 +25,7 @@ class CytoScapeEdgeData(pydantic.BaseModel):
|
|
25
25
|
|
26
26
|
@pydantic.model_validator(mode="before")
|
27
27
|
@classmethod
|
28
|
-
def _validate_values(cls, values:
|
28
|
+
def _validate_values(cls, values: dict[str, Any]) -> dict[str, Any]:
|
29
29
|
values["source"] = str(values["source"]) or " "
|
30
30
|
values["target"] = str(values["target"]) or " "
|
31
31
|
return values
|
@@ -38,7 +38,7 @@ class CytoScapeEdge(pydantic.BaseModel):
|
|
38
38
|
|
39
39
|
|
40
40
|
class CytoScapeNode(pydantic.BaseModel):
|
41
|
-
data:
|
41
|
+
data: dict[str, Any] = pydantic.Field(
|
42
42
|
default=...,
|
43
43
|
description="Data of the Node, such as label, and color, can be of free form",
|
44
44
|
)
|
@@ -48,11 +48,11 @@ class CytoScapeNode(pydantic.BaseModel):
|
|
48
48
|
|
49
49
|
|
50
50
|
class CytoScapeGraph(pydantic.BaseModel):
|
51
|
-
nodes:
|
51
|
+
nodes: list[CytoScapeNode] = pydantic.Field(
|
52
52
|
default_factory=list,
|
53
53
|
description="Nodes of the Graph",
|
54
54
|
)
|
55
|
-
edges:
|
55
|
+
edges: list[CytoScapeEdge] = pydantic.Field(
|
56
56
|
default_factory=list,
|
57
57
|
description="Edges of the Graph",
|
58
58
|
)
|
@@ -1,9 +1,9 @@
|
|
1
|
-
from typing import
|
1
|
+
from typing import Annotated, Literal, Optional, Union
|
2
2
|
from uuid import UUID
|
3
3
|
|
4
4
|
import pydantic
|
5
5
|
from pydantic import Field
|
6
|
-
from typing_extensions import
|
6
|
+
from typing_extensions import Self
|
7
7
|
|
8
8
|
from classiq.interface.analyzer.analysis_params import MAX_FILE_LENGTH
|
9
9
|
from classiq.interface.enum_utils import StrEnum
|
@@ -11,7 +11,7 @@ from classiq.interface.exceptions import ClassiqValueError
|
|
11
11
|
from classiq.interface.helpers.custom_pydantic_types import PydanticNonEmptyString
|
12
12
|
from classiq.interface.helpers.versioned_model import VersionedModel
|
13
13
|
|
14
|
-
Match =
|
14
|
+
Match = list[list[int]]
|
15
15
|
|
16
16
|
|
17
17
|
class GraphStatus(StrEnum):
|
@@ -29,8 +29,8 @@ class RbResults(VersionedModel):
|
|
29
29
|
average_error: float
|
30
30
|
A: float
|
31
31
|
B: float
|
32
|
-
success_probability:
|
33
|
-
parameters_error:
|
32
|
+
success_probability: list[float]
|
33
|
+
parameters_error: tuple[float, ...]
|
34
34
|
|
35
35
|
|
36
36
|
class DataID(pydantic.BaseModel):
|
@@ -58,19 +58,19 @@ class BasisGates(StrEnum):
|
|
58
58
|
|
59
59
|
|
60
60
|
class HardwareComparisonInformation(pydantic.BaseModel):
|
61
|
-
devices:
|
61
|
+
devices: list[str] = pydantic.Field(
|
62
62
|
default=..., description="Device which is used for the transpilation."
|
63
63
|
)
|
64
|
-
providers:
|
64
|
+
providers: list[str] = pydantic.Field(
|
65
65
|
default=..., description="Provider cloud of the device."
|
66
66
|
)
|
67
|
-
depth:
|
67
|
+
depth: list[pydantic.NonNegativeInt] = pydantic.Field(
|
68
68
|
default=..., description="Circuit depth."
|
69
69
|
)
|
70
|
-
multi_qubit_gate_count:
|
70
|
+
multi_qubit_gate_count: list[pydantic.NonNegativeInt] = pydantic.Field(
|
71
71
|
default=..., description="Number of multi qubit gates."
|
72
72
|
)
|
73
|
-
total_gate_count:
|
73
|
+
total_gate_count: list[pydantic.NonNegativeInt] = pydantic.Field(
|
74
74
|
default=..., description="Number of total gates."
|
75
75
|
)
|
76
76
|
|
@@ -105,32 +105,32 @@ class SingleHardwareInformation(pydantic.BaseModel):
|
|
105
105
|
|
106
106
|
class HardwareComparisonData(VersionedModel):
|
107
107
|
kind: Literal["hardware_comparison"] = Field(default="hardware_comparison")
|
108
|
-
data:
|
108
|
+
data: list[SingleHardwareInformation]
|
109
109
|
|
110
110
|
|
111
111
|
HardwareComparisonGraphType = Annotated[
|
112
112
|
Union[HardwareComparisonData, GraphResult], Field(discriminator="kind")
|
113
113
|
]
|
114
114
|
|
115
|
-
_HARDWARE_COMPARISON_TABLE_COLUMNS_NAMES:
|
115
|
+
_HARDWARE_COMPARISON_TABLE_COLUMNS_NAMES: dict[str, str] = {
|
116
116
|
s.upper(): s.capitalize() for s in SingleHardwareInformation.model_fields
|
117
117
|
}
|
118
118
|
|
119
119
|
|
120
120
|
class HardwareComparisonDataColumns(pydantic.BaseModel):
|
121
|
-
columns:
|
121
|
+
columns: dict[str, str] = _HARDWARE_COMPARISON_TABLE_COLUMNS_NAMES
|
122
122
|
|
123
123
|
|
124
124
|
class AvailableHardware(pydantic.BaseModel):
|
125
|
-
ibm_quantum: Optional[
|
125
|
+
ibm_quantum: Optional[dict[PydanticNonEmptyString, bool]] = pydantic.Field(
|
126
126
|
default=None,
|
127
127
|
description="available IBM Quantum devices with boolean indicates if a given device has enough qubits.",
|
128
128
|
)
|
129
|
-
azure_quantum: Optional[
|
129
|
+
azure_quantum: Optional[dict[PydanticNonEmptyString, bool]] = pydantic.Field(
|
130
130
|
default=None,
|
131
131
|
description="available Azure Quantum devices with boolean indicates if a given device has enough qubits.",
|
132
132
|
)
|
133
|
-
amazon_braket: Optional[
|
133
|
+
amazon_braket: Optional[dict[PydanticNonEmptyString, bool]] = pydantic.Field(
|
134
134
|
default=None,
|
135
135
|
description="available Amazon Braket devices with boolean indicates if a given device has enough qubits.",
|
136
136
|
)
|
@@ -163,7 +163,7 @@ class QuantumCircuitProperties(pydantic.BaseModel):
|
|
163
163
|
|
164
164
|
|
165
165
|
class NativeQuantumCircuitProperties(QuantumCircuitProperties):
|
166
|
-
native_gates:
|
166
|
+
native_gates: set[BasisGates] = pydantic.Field(
|
167
167
|
default=..., description="Native gates used for decomposition"
|
168
168
|
)
|
169
169
|
|