classiq 0.38.0__py3-none-any.whl → 0.65.4__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 +47 -32
- classiq/_analyzer_extras/_ipywidgets_async_extension.py +2 -1
- classiq/_internals/api_wrapper.py +235 -97
- classiq/_internals/async_utils.py +1 -3
- classiq/_internals/authentication/auth0.py +26 -10
- classiq/_internals/authentication/authentication.py +11 -0
- classiq/_internals/authentication/device.py +10 -5
- classiq/_internals/authentication/password_manager.py +18 -6
- classiq/_internals/authentication/token_manager.py +10 -5
- classiq/_internals/client.py +94 -33
- classiq/_internals/config.py +3 -4
- classiq/_internals/host_checker.py +38 -15
- classiq/_internals/jobs.py +60 -57
- classiq/_internals/type_validation.py +9 -9
- classiq/analyzer/__init__.py +1 -3
- classiq/analyzer/analyzer.py +24 -19
- classiq/analyzer/analyzer_utilities.py +10 -10
- classiq/analyzer/rb.py +15 -15
- classiq/analyzer/show_interactive_hack.py +27 -4
- classiq/analyzer/url_utils.py +2 -3
- classiq/applications/__init__.py +3 -12
- classiq/applications/chemistry/__init__.py +14 -10
- classiq/applications/chemistry/ansatz_parameters.py +4 -4
- classiq/{applications_model_constructors → applications/chemistry}/chemistry_model_constructor.py +165 -158
- classiq/applications/chemistry/ground_state_problem.py +1 -1
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/allowed_constraints.py +4 -1
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/arithmetic/arithmetic_expression.py +1 -1
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/arithmetic/isolation.py +1 -1
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/combinatorial_problem_utils.py +51 -15
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/encoding_mapping.py +12 -12
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/encoding_utils.py +8 -6
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/memory.py +7 -11
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/optimization_model.py +67 -40
- classiq/applications/combinatorial_helpers/pauli_helpers/pauli_utils.py +46 -0
- classiq/applications/combinatorial_helpers/pyomo_utils.py +447 -0
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/sympy_utils.py +2 -2
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/transformations/encoding.py +15 -20
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/transformations/fixed_variables.py +14 -15
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/transformations/ising_converter.py +11 -15
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/transformations/penalty.py +1 -2
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/transformations/penalty_support.py +3 -7
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/transformations/sign_seperation.py +2 -3
- classiq/{applications_model_constructors → applications}/combinatorial_helpers/transformations/slack_variables.py +5 -8
- classiq/applications/combinatorial_optimization/__init__.py +20 -6
- classiq/applications/combinatorial_optimization/combinatorial_optimization_config.py +2 -2
- classiq/{applications_model_constructors → applications/combinatorial_optimization}/combinatorial_optimization_model_constructor.py +35 -33
- classiq/applications/combinatorial_optimization/combinatorial_problem.py +229 -0
- classiq/applications/combinatorial_optimization/examples/__init__.py +1 -3
- classiq/applications/finance/__init__.py +4 -5
- classiq/{applications_model_constructors → applications/finance}/finance_model_constructor.py +48 -42
- classiq/applications/grover/__init__.py +9 -0
- classiq/{applications_model_constructors → applications/grover}/grover_model_constructor.py +52 -51
- classiq/applications/hamiltonian/pauli_decomposition.py +113 -0
- classiq/applications/libraries/qmci_library.py +22 -0
- classiq/applications/qnn/__init__.py +2 -4
- classiq/applications/qnn/circuit_utils.py +6 -6
- classiq/applications/qnn/datasets/__init__.py +9 -11
- classiq/applications/qnn/datasets/dataset_base_classes.py +7 -5
- classiq/applications/qnn/datasets/dataset_not.py +2 -1
- classiq/applications/qnn/datasets/dataset_parity.py +2 -2
- classiq/applications/qnn/gradients/quantum_gradient.py +1 -1
- classiq/applications/qnn/gradients/simple_quantum_gradient.py +2 -1
- classiq/applications/qnn/qlayer.py +30 -10
- classiq/applications/qnn/torch_utils.py +4 -3
- classiq/applications/qnn/types.py +5 -5
- classiq/applications/qsvm/__init__.py +6 -4
- classiq/applications/qsvm/qsvm.py +3 -6
- classiq/applications/qsvm/qsvm_data_generation.py +3 -3
- classiq/{applications_model_constructors → applications/qsvm}/qsvm_model_constructor.py +30 -28
- classiq/execution/__init__.py +8 -3
- classiq/execution/all_hardware_devices.py +11 -0
- classiq/execution/execution_session.py +400 -0
- classiq/execution/iqcc.py +63 -0
- classiq/execution/jobs.py +197 -25
- classiq/execution/qnn.py +79 -0
- classiq/executor.py +20 -115
- classiq/interface/_version.py +1 -1
- classiq/interface/analyzer/analysis_params.py +43 -13
- classiq/interface/analyzer/cytoscape_graph.py +15 -9
- classiq/interface/analyzer/result.py +28 -32
- classiq/interface/applications/qsvm.py +20 -29
- classiq/interface/ast_node.py +16 -0
- classiq/interface/backend/backend_preferences.py +390 -121
- classiq/interface/backend/ionq/ionq_quantum_program.py +15 -23
- classiq/interface/backend/pydantic_backend.py +25 -22
- classiq/interface/backend/quantum_backend_providers.py +69 -16
- classiq/interface/chemistry/fermionic_operator.py +30 -21
- classiq/interface/chemistry/ground_state_problem.py +28 -25
- classiq/interface/chemistry/molecule.py +14 -10
- classiq/interface/chemistry/operator.py +64 -231
- classiq/interface/combinatorial_optimization/encoding_types.py +1 -1
- 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 +10 -6
- 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 +8 -9
- classiq/interface/combinatorial_optimization/optimization_problem.py +2 -2
- classiq/interface/combinatorial_optimization/result.py +1 -3
- classiq/interface/combinatorial_optimization/solver_types.py +1 -1
- classiq/interface/debug_info/debug_info.py +86 -0
- classiq/{exceptions.py → interface/exceptions.py} +37 -9
- classiq/interface/execution/iqcc.py +19 -0
- classiq/interface/execution/jobs.py +15 -12
- classiq/interface/execution/primitives.py +18 -0
- classiq/interface/executor/constants.py +1 -0
- classiq/interface/executor/execution_preferences.py +26 -114
- classiq/interface/executor/execution_request.py +24 -46
- classiq/interface/executor/execution_result.py +30 -8
- classiq/interface/executor/iqae_result.py +4 -6
- classiq/interface/executor/optimizer_preferences.py +17 -14
- classiq/interface/executor/quantum_code.py +28 -24
- classiq/interface/executor/quantum_instruction_set.py +2 -2
- classiq/interface/executor/register_initialization.py +11 -14
- classiq/interface/executor/result.py +83 -56
- classiq/interface/executor/vqe_result.py +10 -10
- classiq/interface/finance/function_input.py +35 -25
- classiq/interface/finance/gaussian_model_input.py +5 -5
- classiq/interface/finance/log_normal_model_input.py +4 -4
- classiq/interface/finance/model_input.py +4 -4
- classiq/interface/generator/adjacency.py +1 -3
- classiq/interface/generator/amplitude_loading.py +22 -12
- classiq/interface/generator/ansatz_library.py +5 -5
- classiq/interface/generator/application_apis/arithmetic_declarations.py +8 -5
- classiq/interface/generator/application_apis/chemistry_declarations.py +27 -187
- classiq/interface/generator/application_apis/combinatorial_optimization_declarations.py +18 -21
- classiq/interface/generator/application_apis/entangler_declarations.py +11 -6
- classiq/interface/generator/application_apis/finance_declarations.py +48 -69
- classiq/interface/generator/application_apis/qsvm_declarations.py +0 -70
- classiq/interface/generator/arith/argument_utils.py +46 -5
- classiq/interface/generator/arith/arithmetic.py +35 -16
- classiq/interface/generator/arith/arithmetic_arg_type_validator.py +6 -7
- classiq/interface/generator/arith/arithmetic_expression_abc.py +66 -25
- classiq/interface/generator/arith/arithmetic_expression_parser.py +11 -11
- classiq/interface/generator/arith/arithmetic_expression_validator.py +47 -43
- classiq/interface/generator/arith/arithmetic_operations.py +14 -6
- classiq/interface/generator/arith/arithmetic_param_getters.py +7 -8
- classiq/interface/generator/arith/arithmetic_result_builder.py +21 -17
- classiq/interface/generator/arith/ast_node_rewrite.py +3 -2
- classiq/interface/generator/arith/binary_ops.py +218 -130
- classiq/interface/generator/arith/endianness.py +1 -1
- classiq/interface/generator/arith/extremum_operations.py +96 -25
- classiq/interface/generator/arith/logical_ops.py +14 -12
- classiq/interface/generator/arith/number_utils.py +12 -6
- classiq/interface/generator/arith/register_user_input.py +60 -37
- classiq/interface/generator/arith/unary_ops.py +49 -29
- classiq/interface/generator/arith/uncomputation_methods.py +1 -1
- classiq/interface/generator/builtin_api_builder.py +2 -9
- classiq/interface/generator/chemistry_function_params.py +3 -3
- classiq/interface/generator/circuit_code/circuit_code.py +7 -7
- classiq/interface/generator/circuit_code/types_and_constants.py +4 -7
- classiq/interface/generator/commuting_pauli_exponentiation.py +7 -7
- classiq/interface/generator/compiler_keywords.py +5 -1
- classiq/interface/generator/complex_type.py +13 -18
- classiq/interface/generator/constant.py +3 -4
- classiq/interface/generator/control_state.py +34 -29
- classiq/interface/generator/copy.py +47 -0
- classiq/interface/generator/custom_ansatz.py +2 -5
- classiq/interface/generator/distance.py +3 -5
- classiq/interface/generator/excitations.py +3 -2
- classiq/interface/generator/expressions/atomic_expression_functions.py +21 -5
- classiq/interface/generator/expressions/enums/__init__.py +0 -10
- classiq/interface/generator/expressions/enums/finance_functions.py +12 -22
- classiq/interface/generator/expressions/evaluated_expression.py +5 -5
- classiq/interface/generator/expressions/expression.py +26 -14
- classiq/interface/generator/expressions/expression_constants.py +9 -3
- classiq/interface/generator/expressions/non_symbolic_expr.py +119 -0
- classiq/interface/generator/expressions/qmod_qarray_proxy.py +99 -0
- classiq/interface/generator/expressions/qmod_qscalar_proxy.py +34 -8
- classiq/interface/generator/expressions/qmod_qstruct_proxy.py +36 -0
- classiq/interface/generator/expressions/qmod_sized_proxy.py +30 -2
- classiq/interface/generator/expressions/qmod_struct_instance.py +14 -2
- classiq/interface/generator/expressions/sympy_supported_expressions.py +19 -11
- classiq/interface/generator/finance.py +2 -2
- classiq/interface/generator/function_param_library.py +6 -6
- classiq/interface/generator/function_param_list_without_self_reference.py +2 -10
- classiq/interface/generator/function_params.py +36 -64
- classiq/interface/generator/functions/__init__.py +0 -22
- classiq/interface/generator/functions/builtins/internal_operators.py +16 -0
- classiq/interface/generator/functions/classical_function_declaration.py +18 -9
- classiq/interface/generator/functions/classical_type.py +47 -166
- classiq/interface/generator/functions/concrete_types.py +55 -0
- classiq/interface/generator/functions/function_declaration.py +13 -14
- classiq/interface/generator/functions/port_declaration.py +1 -13
- classiq/interface/generator/functions/qmod_python_interface.py +2 -1
- classiq/interface/generator/functions/type_name.py +90 -0
- classiq/interface/generator/generated_circuit_data.py +153 -20
- classiq/interface/generator/grover_diffuser.py +32 -25
- classiq/interface/generator/grover_operator.py +34 -25
- classiq/interface/generator/hamiltonian_evolution/exponentiation.py +4 -6
- classiq/interface/generator/hamiltonian_evolution/qdrift.py +4 -4
- classiq/interface/generator/hamiltonian_evolution/suzuki_trotter.py +9 -9
- classiq/interface/generator/hardware/hardware_data.py +72 -34
- classiq/interface/generator/hardware_efficient_ansatz.py +20 -16
- classiq/interface/generator/hartree_fock.py +13 -5
- classiq/interface/generator/identity.py +10 -6
- classiq/interface/generator/linear_pauli_rotations.py +32 -20
- classiq/interface/generator/mcmt_method.py +1 -1
- classiq/interface/generator/mcu.py +17 -15
- classiq/interface/generator/mcx.py +24 -17
- classiq/interface/generator/model/__init__.py +2 -5
- classiq/interface/generator/model/constraints.py +26 -8
- classiq/interface/generator/model/model.py +27 -190
- classiq/interface/generator/model/preferences/preferences.py +115 -41
- classiq/{quantum_register.py → interface/generator/model/quantum_register.py} +14 -17
- classiq/interface/generator/oracles/arithmetic_oracle.py +2 -4
- classiq/interface/generator/oracles/custom_oracle.py +15 -13
- classiq/interface/generator/oracles/oracle_abc.py +7 -7
- classiq/interface/generator/partitioned_register.py +7 -7
- classiq/interface/generator/piecewise_linear_amplitude_loading.py +45 -29
- classiq/interface/generator/preferences/optimization.py +1 -2
- classiq/interface/generator/qpe.py +41 -30
- classiq/interface/generator/qsvm.py +9 -10
- classiq/interface/generator/quantum_function_call.py +88 -73
- classiq/interface/generator/quantum_program.py +41 -24
- classiq/interface/generator/range_types.py +11 -12
- classiq/interface/generator/register_role.py +18 -6
- classiq/interface/generator/slice_parsing_utils.py +5 -5
- classiq/interface/generator/standard_gates/controlled_standard_gates.py +30 -39
- classiq/interface/generator/standard_gates/standard_angle_metaclass.py +2 -6
- classiq/interface/generator/standard_gates/standard_gates.py +3 -3
- classiq/interface/generator/standard_gates/u_gate.py +7 -10
- classiq/interface/generator/state_preparation/bell_state_preparation.py +3 -3
- classiq/interface/generator/state_preparation/computational_basis_state_preparation.py +2 -1
- classiq/interface/generator/state_preparation/distributions.py +16 -15
- classiq/interface/generator/state_preparation/metrics.py +4 -7
- classiq/interface/generator/state_preparation/state_preparation.py +25 -20
- classiq/interface/generator/synthesis_metadata/synthesis_duration.py +0 -4
- classiq/interface/generator/synthesis_metadata/synthesis_execution_data.py +20 -6
- classiq/interface/generator/transpiler_basis_gates.py +7 -3
- classiq/interface/generator/types/builtin_enum_declarations.py +178 -0
- classiq/interface/generator/types/compilation_metadata.py +6 -0
- classiq/interface/generator/types/enum_declaration.py +54 -0
- classiq/interface/generator/types/qstruct_declaration.py +18 -0
- classiq/interface/generator/types/struct_declaration.py +7 -11
- classiq/interface/generator/ucc.py +5 -4
- classiq/interface/generator/unitary_gate.py +5 -5
- classiq/interface/generator/user_defined_function_params.py +4 -1
- classiq/interface/generator/validations/flow_graph.py +7 -7
- classiq/interface/generator/validations/validator_functions.py +4 -4
- classiq/interface/generator/visitor.py +23 -16
- classiq/interface/hardware.py +29 -8
- classiq/interface/helpers/classproperty.py +8 -0
- classiq/interface/helpers/custom_encoders.py +2 -2
- classiq/interface/helpers/custom_pydantic_types.py +40 -50
- classiq/interface/helpers/datastructures.py +26 -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 +7 -5
- classiq/interface/helpers/validation_helpers.py +3 -20
- classiq/interface/helpers/versioned_model.py +1 -4
- classiq/interface/ide/ide_data.py +16 -20
- classiq/interface/ide/visual_model.py +130 -0
- classiq/interface/interface_version.py +1 -0
- classiq/interface/jobs.py +29 -69
- classiq/interface/model/allocate.py +16 -0
- classiq/interface/model/bind_operation.py +32 -9
- classiq/interface/model/classical_if.py +15 -0
- classiq/interface/model/classical_parameter_declaration.py +33 -3
- classiq/interface/model/control.py +45 -0
- classiq/interface/model/handle_binding.py +298 -20
- classiq/interface/model/inplace_binary_operation.py +29 -24
- classiq/interface/model/invert.py +12 -0
- classiq/interface/model/model.py +69 -61
- classiq/interface/model/native_function_definition.py +17 -20
- classiq/interface/model/parameter.py +13 -0
- classiq/interface/model/phase_operation.py +11 -0
- classiq/interface/model/port_declaration.py +27 -9
- classiq/interface/model/power.py +14 -0
- classiq/interface/model/quantum_expressions/amplitude_loading_operation.py +30 -18
- classiq/interface/model/quantum_expressions/arithmetic_operation.py +51 -14
- classiq/interface/model/quantum_expressions/quantum_expression.py +12 -35
- classiq/interface/model/quantum_function_call.py +141 -343
- classiq/interface/model/quantum_function_declaration.py +190 -157
- classiq/interface/model/quantum_lambda_function.py +33 -32
- classiq/interface/model/quantum_statement.py +71 -12
- classiq/interface/model/quantum_type.py +177 -40
- classiq/interface/model/quantum_variable_declaration.py +3 -25
- classiq/interface/model/repeat.py +15 -0
- classiq/interface/model/statement_block.py +40 -14
- classiq/interface/model/validation_handle.py +13 -6
- classiq/interface/model/variable_declaration_statement.py +3 -1
- classiq/interface/model/within_apply_operation.py +7 -5
- classiq/interface/server/global_versions.py +6 -7
- classiq/interface/server/routes.py +17 -21
- classiq/interface/source_reference.py +59 -0
- classiq/model_expansions/atomic_expression_functions_defs.py +253 -0
- classiq/model_expansions/capturing/__init__.py +0 -0
- classiq/model_expansions/capturing/captured_vars.py +435 -0
- classiq/model_expansions/capturing/mangling_utils.py +56 -0
- classiq/model_expansions/closure.py +171 -0
- classiq/model_expansions/debug_flag.py +3 -0
- classiq/model_expansions/evaluators/__init__.py +0 -0
- classiq/model_expansions/evaluators/arg_type_match.py +158 -0
- classiq/model_expansions/evaluators/argument_types.py +42 -0
- classiq/model_expansions/evaluators/classical_expression.py +36 -0
- classiq/model_expansions/evaluators/control.py +144 -0
- classiq/model_expansions/evaluators/parameter_types.py +226 -0
- classiq/model_expansions/evaluators/quantum_type_utils.py +239 -0
- classiq/model_expansions/evaluators/type_type_match.py +90 -0
- classiq/model_expansions/expression_evaluator.py +135 -0
- classiq/model_expansions/expression_renamer.py +76 -0
- classiq/model_expansions/function_builder.py +247 -0
- classiq/model_expansions/generative_functions.py +158 -0
- classiq/model_expansions/interpreters/__init__.py +0 -0
- classiq/model_expansions/interpreters/base_interpreter.py +263 -0
- classiq/model_expansions/interpreters/frontend_generative_interpreter.py +28 -0
- classiq/model_expansions/interpreters/generative_interpreter.py +249 -0
- classiq/model_expansions/model_tables.py +18 -0
- classiq/model_expansions/quantum_operations/__init__.py +9 -0
- classiq/model_expansions/quantum_operations/bind.py +60 -0
- classiq/model_expansions/quantum_operations/call_emitter.py +266 -0
- classiq/model_expansions/quantum_operations/classicalif.py +53 -0
- classiq/model_expansions/quantum_operations/declarative_call_emitter.py +87 -0
- classiq/model_expansions/quantum_operations/emitter.py +181 -0
- classiq/model_expansions/quantum_operations/quantum_function_call.py +33 -0
- classiq/model_expansions/quantum_operations/repeat.py +56 -0
- classiq/model_expansions/quantum_operations/shallow_emitter.py +180 -0
- classiq/model_expansions/quantum_operations/variable_decleration.py +28 -0
- classiq/model_expansions/scope.py +240 -0
- classiq/model_expansions/scope_initialization.py +150 -0
- classiq/model_expansions/sympy_conversion/__init__.py +0 -0
- classiq/model_expansions/sympy_conversion/arithmetics.py +49 -0
- classiq/model_expansions/sympy_conversion/expression_to_sympy.py +179 -0
- classiq/model_expansions/sympy_conversion/sympy_to_python.py +123 -0
- classiq/model_expansions/transformers/__init__.py +0 -0
- classiq/model_expansions/transformers/ast_renamer.py +26 -0
- classiq/model_expansions/transformers/var_splitter.py +299 -0
- classiq/model_expansions/utils/__init__.py +0 -0
- classiq/model_expansions/utils/counted_name_allocator.py +11 -0
- classiq/model_expansions/utils/handles_collector.py +33 -0
- classiq/model_expansions/visitors/__init__.py +0 -0
- classiq/model_expansions/visitors/boolean_expression_transformers.py +214 -0
- classiq/model_expansions/visitors/variable_references.py +144 -0
- classiq/open_library/__init__.py +4 -0
- classiq/open_library/functions/__init__.py +130 -0
- classiq/open_library/functions/amplitude_estimation.py +30 -0
- classiq/open_library/functions/discrete_sine_cosine_transform.py +181 -0
- classiq/open_library/functions/grover.py +157 -0
- classiq/open_library/functions/hea.py +115 -0
- classiq/open_library/functions/linear_pauli_rotation.py +82 -0
- classiq/open_library/functions/modular_exponentiation.py +201 -0
- classiq/open_library/functions/qaoa_penalty.py +117 -0
- classiq/open_library/functions/qft_functions.py +54 -0
- classiq/open_library/functions/qpe.py +46 -0
- classiq/open_library/functions/qsvt.py +331 -0
- classiq/open_library/functions/state_preparation.py +301 -0
- classiq/open_library/functions/swap_test.py +27 -0
- classiq/open_library/functions/utility_functions.py +81 -0
- classiq/open_library/functions/variational.py +52 -0
- classiq/qmod/__init__.py +10 -10
- classiq/qmod/builtins/__init__.py +19 -2
- classiq/qmod/builtins/classical_execution_primitives.py +36 -14
- classiq/qmod/builtins/classical_functions.py +39 -43
- classiq/qmod/builtins/constants.py +10 -0
- classiq/qmod/builtins/enums.py +208 -0
- classiq/qmod/builtins/functions/__init__.py +137 -0
- classiq/qmod/builtins/functions/allocation.py +150 -0
- classiq/qmod/builtins/functions/arithmetic.py +55 -0
- classiq/qmod/builtins/functions/benchmarking.py +8 -0
- classiq/qmod/builtins/functions/chemistry.py +91 -0
- classiq/qmod/builtins/functions/exponentiation.py +105 -0
- classiq/qmod/builtins/functions/finance.py +34 -0
- classiq/qmod/builtins/functions/operators.py +16 -0
- classiq/qmod/builtins/functions/qsvm.py +24 -0
- classiq/qmod/builtins/functions/standard_gates.py +651 -0
- classiq/qmod/builtins/operations.py +373 -40
- classiq/qmod/builtins/structs.py +103 -80
- classiq/qmod/cfunc.py +2 -2
- classiq/qmod/classical_function.py +4 -8
- classiq/qmod/cparam.py +64 -0
- classiq/qmod/create_model_function.py +56 -0
- classiq/qmod/declaration_inferrer.py +143 -101
- classiq/qmod/expression_query.py +20 -4
- classiq/qmod/generative.py +42 -0
- classiq/qmod/model_state_container.py +18 -6
- classiq/qmod/native/__init__.py +7 -0
- classiq/qmod/native/expression_to_qmod.py +16 -11
- classiq/qmod/native/pretty_printer.py +187 -97
- classiq/qmod/pretty_print/__init__.py +7 -0
- classiq/qmod/pretty_print/expression_to_python.py +222 -0
- classiq/qmod/pretty_print/pretty_printer.py +572 -0
- classiq/qmod/python_classical_type.py +67 -0
- classiq/qmod/qfunc.py +60 -8
- classiq/qmod/qmod_constant.py +93 -26
- classiq/qmod/qmod_parameter.py +68 -59
- classiq/qmod/qmod_variable.py +468 -155
- classiq/qmod/quantum_callable.py +17 -7
- classiq/qmod/quantum_expandable.py +269 -96
- classiq/qmod/quantum_function.py +196 -41
- classiq/qmod/semantics/__init__.py +0 -0
- classiq/qmod/semantics/annotation/__init__.py +0 -0
- classiq/qmod/semantics/annotation/call_annotation.py +92 -0
- classiq/qmod/semantics/annotation/qstruct_annotator.py +23 -0
- classiq/qmod/semantics/error_manager.py +88 -0
- classiq/qmod/semantics/lambdas.py +25 -0
- classiq/qmod/semantics/static_semantics_visitor.py +384 -0
- classiq/qmod/semantics/validation/__init__.py +0 -0
- classiq/qmod/semantics/validation/constants_validation.py +16 -0
- classiq/qmod/semantics/validation/func_call_validation.py +99 -0
- classiq/qmod/semantics/validation/function_name_collisions_validation.py +23 -0
- classiq/qmod/semantics/validation/handle_validation.py +85 -0
- classiq/qmod/semantics/validation/main_validation.py +33 -0
- classiq/qmod/semantics/validation/types_validation.py +128 -0
- classiq/qmod/symbolic.py +147 -123
- classiq/qmod/symbolic_expr.py +27 -12
- classiq/qmod/symbolic_type.py +2 -5
- classiq/qmod/type_attribute_remover.py +32 -0
- classiq/qmod/utilities.py +98 -4
- classiq/qmod/write_qmod.py +17 -3
- classiq/synthesis.py +210 -22
- {classiq-0.38.0.dist-info → classiq-0.65.4.dist-info}/METADATA +16 -9
- classiq-0.65.4.dist-info/RECORD +521 -0
- classiq/_internals/_qfunc_ext.py +0 -6
- classiq/applications/benchmarking/__init__.py +0 -9
- classiq/applications/benchmarking/mirror_benchmarking.py +0 -70
- classiq/applications/numpy_utils.py +0 -37
- classiq/applications_model_constructors/__init__.py +0 -25
- classiq/applications_model_constructors/combinatorial_helpers/multiple_comp_basis_sp.py +0 -34
- classiq/applications_model_constructors/combinatorial_helpers/pauli_helpers/pauli_utils.py +0 -65
- classiq/applications_model_constructors/combinatorial_helpers/pyomo_utils.py +0 -243
- classiq/applications_model_constructors/libraries/ampltitude_estimation_library.py +0 -11
- classiq/applications_model_constructors/libraries/qmci_library.py +0 -107
- classiq/builtin_functions/__init__.py +0 -43
- classiq/builtin_functions/amplitude_loading.py +0 -3
- classiq/builtin_functions/binary_ops.py +0 -1
- classiq/builtin_functions/exponentiation.py +0 -5
- classiq/builtin_functions/qpe.py +0 -4
- classiq/builtin_functions/qsvm.py +0 -7
- classiq/builtin_functions/range_types.py +0 -5
- classiq/builtin_functions/standard_gates.py +0 -1
- classiq/builtin_functions/state_preparation.py +0 -6
- classiq/builtin_functions/suzuki_trotter.py +0 -3
- classiq/interface/executor/aws_execution_cost.py +0 -73
- classiq/interface/executor/error_mitigation.py +0 -6
- classiq/interface/generator/credit_risk_example/linear_gci.py +0 -122
- classiq/interface/generator/credit_risk_example/weighted_adder.py +0 -69
- classiq/interface/generator/expressions/enums/chemistry.py +0 -28
- classiq/interface/generator/expressions/enums/classical_enum.py +0 -5
- classiq/interface/generator/expressions/enums/ladder_operator.py +0 -16
- classiq/interface/generator/expressions/enums/optimizers.py +0 -9
- classiq/interface/generator/expressions/enums/pauli.py +0 -8
- classiq/interface/generator/expressions/enums/qsvm_feature_map_entanglement.py +0 -9
- classiq/interface/generator/functions/core_lib_declarations/quantum_functions/__init__.py +0 -18
- classiq/interface/generator/functions/core_lib_declarations/quantum_functions/atomic_quantum_functions.py +0 -641
- classiq/interface/generator/functions/core_lib_declarations/quantum_functions/exponentiation_functions.py +0 -89
- classiq/interface/generator/functions/core_lib_declarations/quantum_functions/std_lib_functions.py +0 -1229
- classiq/interface/generator/functions/core_lib_declarations/quantum_operators.py +0 -95
- classiq/interface/generator/functions/foreign_function_definition.py +0 -114
- classiq/interface/generator/functions/function_implementation.py +0 -107
- classiq/interface/generator/functions/native_function_definition.py +0 -155
- classiq/interface/generator/functions/quantum_function_declaration.py +0 -69
- classiq/interface/generator/functions/register.py +0 -44
- classiq/interface/generator/functions/register_mapping_data.py +0 -106
- classiq/interface/generator/inequality_mixer.py +0 -51
- classiq/interface/generator/model/classical_main_validator.py +0 -106
- classiq/interface/generator/range_mixer.py +0 -56
- classiq/interface/generator/state_propagator.py +0 -74
- classiq/interface/generator/types/builtin_struct_declarations/__init__.py +0 -1
- classiq/interface/generator/types/builtin_struct_declarations/pauli_struct_declarations.py +0 -22
- classiq/interface/ide/show.py +0 -34
- classiq/interface/model/call_synthesis_data.py +0 -68
- 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/interface/model/resolvers/function_call_resolver.py +0 -43
- classiq/interface/model/validations/handle_validation_base.py +0 -55
- classiq/interface/model/validations/handles_validator.py +0 -156
- classiq/interface/model/validations/port_to_wire_name_generator.py +0 -12
- classiq/model/__init__.py +0 -14
- classiq/model/composite_function_generator.py +0 -33
- classiq/model/function_handler.py +0 -462
- classiq/model/logic_flow.py +0 -149
- classiq/model/logic_flow_change_handler.py +0 -71
- classiq/model/model.py +0 -229
- classiq/qmod/builtins/functions.py +0 -913
- classiq/qmod/qmod_struct.py +0 -37
- classiq/quantum_functions/__init__.py +0 -17
- classiq/quantum_functions/annotation_parser.py +0 -205
- classiq/quantum_functions/decorators.py +0 -22
- classiq/quantum_functions/function_library.py +0 -181
- classiq/quantum_functions/function_parser.py +0 -74
- classiq/quantum_functions/quantum_function.py +0 -236
- classiq-0.38.0.dist-info/RECORD +0 -454
- /classiq/{applications_model_constructors → applications}/combinatorial_helpers/__init__.py +0 -0
- /classiq/{applications_model_constructors → applications}/combinatorial_helpers/arithmetic/__init__.py +0 -0
- /classiq/{applications_model_constructors → applications}/combinatorial_helpers/pauli_helpers/__init__.py +0 -0
- /classiq/{applications_model_constructors → applications}/combinatorial_helpers/pauli_helpers/pauli_sparsing.py +0 -0
- /classiq/{applications_model_constructors → applications}/combinatorial_helpers/py.typed +0 -0
- /classiq/{applications_model_constructors/combinatorial_helpers/transformations → applications/combinatorial_helpers/solvers}/__init__.py +0 -0
- /classiq/{applications_model_constructors/libraries → applications/combinatorial_helpers/transformations}/__init__.py +0 -0
- /classiq/{interface/generator/credit_risk_example → applications/hamiltonian}/__init__.py +0 -0
- /classiq/{interface/generator/functions/core_lib_declarations → applications/libraries}/__init__.py +0 -0
- /classiq/interface/{model/resolvers → debug_info}/__init__.py +0 -0
- /classiq/{_internals → interface}/enum_utils.py +0 -0
- /classiq/interface/{model/validations → generator/functions/builtins}/__init__.py +0 -0
- /classiq/{interface/generator/functions/core_lib_declarations/quantum_functions/chemistry_functions.py → model_expansions/__init__.py} +0 -0
- {classiq-0.38.0.dist-info → classiq-0.65.4.dist-info}/WHEEL +0 -0
classiq/_internals/jobs.py
CHANGED
@@ -1,24 +1,20 @@
|
|
1
1
|
import json
|
2
2
|
import logging
|
3
|
-
from
|
3
|
+
from collections.abc import Iterable
|
4
|
+
from typing import Callable, Optional, TypeVar
|
4
5
|
|
5
6
|
import httpx
|
6
7
|
import pydantic
|
7
8
|
|
8
|
-
from classiq.interface.
|
9
|
-
|
10
|
-
JobDescriptionUnion,
|
11
|
-
JobID,
|
12
|
-
JSONObject,
|
13
|
-
)
|
9
|
+
from classiq.interface.exceptions import ClassiqAPIError
|
10
|
+
from classiq.interface.jobs import JobDescription, JobID, JSONObject
|
14
11
|
|
15
12
|
from classiq._internals.async_utils import poll_for
|
16
|
-
from classiq._internals.client import client
|
13
|
+
from classiq._internals.client import client
|
17
14
|
from classiq._internals.config import SDKMode
|
18
|
-
from classiq.exceptions import ClassiqAPIError
|
19
15
|
|
20
16
|
_URL_PATH_SEP = "/"
|
21
|
-
GeneralJobDescription =
|
17
|
+
GeneralJobDescription = JobDescription[JSONObject]
|
22
18
|
_logger = logging.getLogger(__name__)
|
23
19
|
T = TypeVar("T")
|
24
20
|
|
@@ -42,26 +38,24 @@ def _join_url_path(*parts: str) -> str:
|
|
42
38
|
def _general_job_description_parser(
|
43
39
|
json_response: JSONObject,
|
44
40
|
) -> Optional[GeneralJobDescription]:
|
45
|
-
job_description =
|
46
|
-
if job_description.
|
47
|
-
return job_description
|
41
|
+
job_description = GeneralJobDescription.model_validate(json_response)
|
42
|
+
if job_description.status.is_final():
|
43
|
+
return job_description
|
48
44
|
return None
|
49
45
|
|
50
46
|
|
51
47
|
class JobPoller:
|
52
|
-
INITIAL_INTERVAL_SEC = 1
|
53
|
-
INTERVAL_FACTOR =
|
54
|
-
FINAL_INTERVAL_SEC =
|
48
|
+
INITIAL_INTERVAL_SEC = 0.1
|
49
|
+
INTERVAL_FACTOR = 1.5
|
50
|
+
FINAL_INTERVAL_SEC = 25
|
55
51
|
DEV_INTERVAL = 0.05
|
56
52
|
|
57
53
|
def __init__(
|
58
54
|
self,
|
59
55
|
base_url: str,
|
60
|
-
required_headers: Optional[Set[str]] = None,
|
61
56
|
use_versioned_url: bool = True,
|
62
|
-
additional_headers: Optional[
|
57
|
+
additional_headers: Optional[dict[str, str]] = None,
|
63
58
|
) -> None:
|
64
|
-
self._required_headers = required_headers or set()
|
65
59
|
self._additional_headers = additional_headers
|
66
60
|
client_instance = client()
|
67
61
|
self._base_url = (
|
@@ -69,11 +63,10 @@ class JobPoller:
|
|
69
63
|
if use_versioned_url
|
70
64
|
else base_url
|
71
65
|
)
|
72
|
-
self._async_client = client_instance.async_client()
|
73
66
|
self._mode = client_instance.config.mode
|
74
67
|
|
75
68
|
def _parse_job_id_response(self, response: httpx.Response) -> JobID:
|
76
|
-
return JobID.
|
69
|
+
return JobID.model_validate(response.json())
|
77
70
|
|
78
71
|
def _make_poll_url(self, job_id: JobID) -> str:
|
79
72
|
return _join_url_path(self._base_url, job_id.job_id)
|
@@ -82,37 +75,33 @@ class JobPoller:
|
|
82
75
|
def _make_cancel_url(poll_url: str) -> str:
|
83
76
|
return _join_url_path(poll_url, "cancel")
|
84
77
|
|
85
|
-
def _update_headers(self, response: httpx.Response) -> None:
|
86
|
-
for header in self._required_headers:
|
87
|
-
try:
|
88
|
-
self._async_client.headers[header] = response.headers[header]
|
89
|
-
except KeyError as exc:
|
90
|
-
raise ClassiqAPIError(
|
91
|
-
f"Response to {self._base_url} is missing header {header}"
|
92
|
-
) from exc
|
93
|
-
|
94
|
-
@try_again_on_failure
|
95
78
|
async def _request(
|
96
|
-
self,
|
79
|
+
self,
|
80
|
+
http_client: httpx.AsyncClient,
|
81
|
+
http_method: str,
|
82
|
+
url: str,
|
83
|
+
body: Optional[dict] = None,
|
97
84
|
) -> httpx.Response:
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
85
|
+
return await client().request(
|
86
|
+
http_client=http_client,
|
87
|
+
method=http_method,
|
88
|
+
url=url,
|
89
|
+
json=body,
|
90
|
+
headers=self._additional_headers,
|
102
91
|
)
|
103
|
-
client().handle_response(response)
|
104
|
-
return response
|
105
92
|
|
106
|
-
async def _submit(
|
107
|
-
|
93
|
+
async def _submit(
|
94
|
+
self, http_client: httpx.AsyncClient, body: dict
|
95
|
+
) -> httpx.Response:
|
96
|
+
return await self._request(
|
97
|
+
http_client=http_client, http_method="POST", url=self._base_url, body=body
|
98
|
+
)
|
108
99
|
|
109
100
|
def _interval_sec(self) -> Iterable[float]:
|
110
101
|
if self._mode == SDKMode.DEV:
|
111
102
|
while True:
|
112
103
|
yield self.DEV_INTERVAL
|
113
104
|
else:
|
114
|
-
for _ in range(10):
|
115
|
-
yield self.INITIAL_INTERVAL_SEC
|
116
105
|
interval = self.INITIAL_INTERVAL_SEC
|
117
106
|
while True:
|
118
107
|
yield interval
|
@@ -120,13 +109,16 @@ class JobPoller:
|
|
120
109
|
|
121
110
|
async def _poll(
|
122
111
|
self,
|
112
|
+
http_client: httpx.AsyncClient,
|
123
113
|
poll_url: str,
|
124
114
|
timeout_sec: Optional[float],
|
125
115
|
response_parser: Callable[[JSONObject], Optional[T]] = _general_job_description_parser, # type: ignore[assignment]
|
126
116
|
) -> T:
|
127
117
|
async def poller() -> JSONObject:
|
128
118
|
nonlocal self, poll_url
|
129
|
-
raw_response = await self._request(
|
119
|
+
raw_response = await self._request(
|
120
|
+
http_client=http_client, http_method="GET", url=poll_url
|
121
|
+
)
|
130
122
|
return raw_response.json()
|
131
123
|
|
132
124
|
async for json_response in poll_for(
|
@@ -142,39 +134,50 @@ class JobPoller:
|
|
142
134
|
job_id: JobID,
|
143
135
|
timeout_sec: Optional[float],
|
144
136
|
response_parser: Callable[[JSONObject], Optional[T]] = _general_job_description_parser, # type: ignore[assignment]
|
137
|
+
http_client: Optional[httpx.AsyncClient] = None,
|
145
138
|
) -> T:
|
146
139
|
poll_url = self._make_poll_url(job_id=job_id)
|
147
|
-
async with
|
140
|
+
async with client().use_client_or_create(http_client) as async_client:
|
148
141
|
return await self._poll(
|
142
|
+
http_client=async_client,
|
149
143
|
poll_url=poll_url,
|
150
144
|
response_parser=response_parser,
|
151
145
|
timeout_sec=timeout_sec,
|
152
146
|
)
|
153
147
|
|
154
|
-
async def _cancel(self, poll_url: str) -> None:
|
148
|
+
async def _cancel(self, http_client: httpx.AsyncClient, poll_url: str) -> None:
|
155
149
|
_logger.info("Cancelling job %s", poll_url, exc_info=True)
|
156
150
|
cancel_url = self._make_cancel_url(poll_url)
|
157
|
-
await self._request(http_method="PUT", url=cancel_url)
|
151
|
+
await self._request(http_client=http_client, http_method="PUT", url=cancel_url)
|
158
152
|
|
159
153
|
async def run(
|
160
|
-
self,
|
154
|
+
self,
|
155
|
+
body: dict,
|
156
|
+
timeout_sec: Optional[float],
|
157
|
+
http_client: Optional[httpx.AsyncClient] = None,
|
161
158
|
) -> GeneralJobDescription:
|
162
|
-
async with
|
163
|
-
submit_response = await self._submit(body=body)
|
159
|
+
async with client().use_client_or_create(http_client) as async_client:
|
160
|
+
submit_response = await self._submit(http_client=async_client, body=body)
|
164
161
|
job_id = self._parse_job_id_response(response=submit_response)
|
165
162
|
poll_url = self._make_poll_url(job_id=job_id)
|
166
|
-
self._update_headers(response=submit_response)
|
167
163
|
try:
|
168
|
-
return await self._poll(
|
164
|
+
return await self._poll(
|
165
|
+
http_client=async_client,
|
166
|
+
poll_url=poll_url,
|
167
|
+
timeout_sec=timeout_sec,
|
168
|
+
)
|
169
169
|
except Exception:
|
170
|
-
await self._cancel(poll_url=poll_url)
|
170
|
+
await self._cancel(http_client=async_client, poll_url=poll_url)
|
171
171
|
raise
|
172
172
|
|
173
173
|
async def run_pydantic(
|
174
|
-
self,
|
174
|
+
self,
|
175
|
+
model: pydantic.BaseModel,
|
176
|
+
timeout_sec: Optional[float],
|
177
|
+
http_client: Optional[httpx.AsyncClient] = None,
|
175
178
|
) -> GeneralJobDescription:
|
176
179
|
# TODO: we can't use model.dict() - it doesn't serialize complex class.
|
177
|
-
# This was added because JSON serializer doesn't serialize complex
|
178
|
-
# We should add support for smarter json serialization.
|
179
|
-
body = json.loads(model.
|
180
|
-
return await self.run(body, timeout_sec)
|
180
|
+
# This was added because JSON serializer doesn't serialize complex and UUID,
|
181
|
+
# while pydantic does. We should add support for smarter json serialization.
|
182
|
+
body = json.loads(model.model_dump_json())
|
183
|
+
return await self.run(body, timeout_sec, http_client=http_client)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import Any,
|
1
|
+
from typing import Any, TypeVar, Union, overload
|
2
2
|
|
3
3
|
T = TypeVar("T")
|
4
4
|
U = TypeVar("U")
|
@@ -10,37 +10,37 @@ U = TypeVar("U")
|
|
10
10
|
|
11
11
|
@overload
|
12
12
|
def validate_type(
|
13
|
-
obj: Any, expected_type:
|
13
|
+
obj: Any, expected_type: type[T], operation: str, exception_type: type[Exception]
|
14
14
|
) -> T: ...
|
15
15
|
|
16
16
|
|
17
17
|
@overload
|
18
18
|
def validate_type(
|
19
19
|
obj: Any,
|
20
|
-
expected_type:
|
20
|
+
expected_type: tuple[type[T], type[U]],
|
21
21
|
operation: str,
|
22
|
-
exception_type:
|
22
|
+
exception_type: type[Exception],
|
23
23
|
) -> Union[T, U]: ...
|
24
24
|
|
25
25
|
|
26
26
|
@overload
|
27
27
|
def validate_type(
|
28
28
|
obj: Any,
|
29
|
-
expected_type:
|
29
|
+
expected_type: tuple[type[T], ...],
|
30
30
|
operation: str,
|
31
|
-
exception_type:
|
31
|
+
exception_type: type[Exception],
|
32
32
|
) -> Any: ...
|
33
33
|
|
34
34
|
|
35
35
|
def validate_type(
|
36
36
|
obj: Any,
|
37
|
-
expected_type: Union[
|
37
|
+
expected_type: Union[tuple[type, ...], type],
|
38
38
|
operation: str,
|
39
|
-
exception_type:
|
39
|
+
exception_type: type[Exception],
|
40
40
|
) -> Any:
|
41
41
|
operation = operation[0].upper() + operation[1:]
|
42
42
|
if not isinstance(obj, expected_type):
|
43
|
-
expected_types:
|
43
|
+
expected_types: tuple[type, ...]
|
44
44
|
if isinstance(expected_type, type):
|
45
45
|
expected_types = (expected_type,)
|
46
46
|
else:
|
classiq/analyzer/__init__.py
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
from typing import List
|
2
|
-
|
3
1
|
import classiq.analyzer.show_interactive_hack
|
4
2
|
from classiq.analyzer.analyzer import Analyzer
|
5
3
|
|
@@ -8,5 +6,5 @@ from ..analyzer import rb
|
|
8
6
|
__all__ = ["rb"]
|
9
7
|
|
10
8
|
|
11
|
-
def __dir__() ->
|
9
|
+
def __dir__() -> list[str]:
|
12
10
|
return ["rb"]
|
classiq/analyzer/analyzer.py
CHANGED
@@ -2,14 +2,16 @@
|
|
2
2
|
|
3
3
|
import json
|
4
4
|
import webbrowser
|
5
|
+
from collections.abc import Sequence
|
5
6
|
from importlib.util import find_spec
|
6
|
-
from typing import Any,
|
7
|
+
from typing import Any, Optional, Union
|
7
8
|
from urllib.parse import urljoin
|
8
9
|
|
9
10
|
import plotly.graph_objects as go
|
10
11
|
|
11
12
|
from classiq.interface.analyzer import analysis_params
|
12
13
|
from classiq.interface.backend.quantum_backend_providers import AnalyzerProviderVendor
|
14
|
+
from classiq.interface.exceptions import ClassiqAnalyzerError
|
13
15
|
from classiq.interface.generator import quantum_program as generator_result
|
14
16
|
|
15
17
|
from classiq._internals import async_utils, client
|
@@ -20,7 +22,6 @@ from classiq.analyzer.analyzer_utilities import (
|
|
20
22
|
ProviderNameEnum,
|
21
23
|
)
|
22
24
|
from classiq.analyzer.url_utils import circuit_page_uri, client_ide_base_url
|
23
|
-
from classiq.exceptions import ClassiqAnalyzerError
|
24
25
|
|
25
26
|
find_ipywidgets = find_spec("ipywidgets")
|
26
27
|
VBox = Any
|
@@ -38,7 +39,7 @@ class Analyzer(AnalyzerUtilities):
|
|
38
39
|
"""Init self.
|
39
40
|
|
40
41
|
Args:
|
41
|
-
circuit
|
42
|
+
circuit: The circuit to be analyzed.
|
42
43
|
"""
|
43
44
|
if circuit.qasm is None:
|
44
45
|
raise ClassiqAnalyzerError(
|
@@ -79,16 +80,18 @@ class Analyzer(AnalyzerUtilities):
|
|
79
80
|
)
|
80
81
|
|
81
82
|
def get_available_devices(
|
82
|
-
self, providers: Optional[
|
83
|
-
) ->
|
84
|
-
"""
|
83
|
+
self, providers: Optional[list[ProviderNameEnum]] = None
|
84
|
+
) -> dict[ProviderNameEnum, list[DeviceName]]:
|
85
|
+
"""Deprecated. Use get_all_hardware_devices instead.
|
86
|
+
|
87
|
+
Returns dict of the available devices by the providers. only devices
|
85
88
|
with sufficient number of qubits are returns
|
86
89
|
|
87
|
-
Args: providers
|
90
|
+
Args: providers: List of providers.
|
88
91
|
if None, the table include all the available hardware.
|
89
92
|
|
90
93
|
Returns:
|
91
|
-
available devices
|
94
|
+
available devices: dict of the available devices.
|
92
95
|
"""
|
93
96
|
if providers is None:
|
94
97
|
providers = list(AnalyzerProviderVendor)
|
@@ -107,10 +110,10 @@ class Analyzer(AnalyzerUtilities):
|
|
107
110
|
analyzer_sdk extra.
|
108
111
|
|
109
112
|
Args:
|
110
|
-
provider
|
111
|
-
device
|
113
|
+
provider: provider name.
|
114
|
+
device: device name.
|
112
115
|
Returns:
|
113
|
-
hardware_connectivity_graph
|
116
|
+
hardware_connectivity_graph: interactive graph.
|
114
117
|
"""
|
115
118
|
|
116
119
|
self._validate_analyzer_extra()
|
@@ -131,16 +134,18 @@ class Analyzer(AnalyzerUtilities):
|
|
131
134
|
def get_hardware_comparison_table(
|
132
135
|
self,
|
133
136
|
providers: Optional[Sequence[Union[str, AnalyzerProviderVendor]]] = None,
|
134
|
-
devices: Optional[
|
137
|
+
devices: Optional[list[str]] = None,
|
135
138
|
) -> None:
|
136
139
|
"""create a comparison table between the transpiled circuits result on different hardware.
|
137
140
|
The comparison table included the depth, multi qubit gates count,and total gates count of the circuits.
|
138
141
|
|
139
|
-
Args:
|
140
|
-
|
141
|
-
|
142
|
+
Args:
|
143
|
+
providers: List of providers. if None, the table include all the available hardware.
|
144
|
+
devices: List of devices. if None, the table include all the available devices of the selected
|
142
145
|
providers.
|
143
|
-
|
146
|
+
|
147
|
+
Returns:
|
148
|
+
None.
|
144
149
|
"""
|
145
150
|
if providers is None:
|
146
151
|
providers = list(AnalyzerProviderVendor)
|
@@ -155,8 +160,8 @@ class Analyzer(AnalyzerUtilities):
|
|
155
160
|
|
156
161
|
def plot_hardware_comparison_table(
|
157
162
|
self,
|
158
|
-
providers: Optional[
|
159
|
-
devices: Optional[
|
163
|
+
providers: Optional[list[Union[str, AnalyzerProviderVendor]]] = None,
|
164
|
+
devices: Optional[list[str]] = None,
|
160
165
|
) -> None:
|
161
166
|
"""plot the comparison table. if it has not been created it, it first creates the table using all the
|
162
167
|
available hardware.
|
@@ -170,7 +175,7 @@ class Analyzer(AnalyzerUtilities):
|
|
170
175
|
def _hardware_comparison_condition(
|
171
176
|
self,
|
172
177
|
providers: Optional[Sequence[Union[str, AnalyzerProviderVendor]]] = None,
|
173
|
-
devices: Optional[
|
178
|
+
devices: Optional[list[str]] = None,
|
174
179
|
) -> None:
|
175
180
|
if (
|
176
181
|
providers is not None
|
@@ -1,11 +1,11 @@
|
|
1
|
-
from typing import
|
1
|
+
from typing import Union
|
2
2
|
|
3
3
|
from classiq.interface.analyzer import analysis_params
|
4
4
|
from classiq.interface.backend.quantum_backend_providers import AnalyzerProviderVendor
|
5
|
+
from classiq.interface.exceptions import ClassiqAnalyzerError
|
5
6
|
from classiq.interface.generator.quantum_program import QuantumProgram
|
6
7
|
|
7
8
|
from classiq._internals.api_wrapper import ApiWrapper
|
8
|
-
from classiq.exceptions import ClassiqAnalyzerError
|
9
9
|
|
10
10
|
DeviceName = str
|
11
11
|
ProviderName = str
|
@@ -13,9 +13,9 @@ ProviderLowerName = str
|
|
13
13
|
HardwareGraphJson = str
|
14
14
|
Availability = bool
|
15
15
|
ProviderNameEnum = Union[ProviderName, AnalyzerProviderVendor]
|
16
|
-
AvailableDevices =
|
17
|
-
ProviderAvailableDevices =
|
18
|
-
HardwareGraphs =
|
16
|
+
AvailableDevices = dict[DeviceName, Availability]
|
17
|
+
ProviderAvailableDevices = dict[ProviderLowerName, AvailableDevices]
|
18
|
+
HardwareGraphs = dict[DeviceName, HardwareGraphJson]
|
19
19
|
|
20
20
|
|
21
21
|
class AnalyzerUtilities:
|
@@ -32,7 +32,7 @@ class AnalyzerUtilities:
|
|
32
32
|
self.hardware_graphs = hardware_graphs
|
33
33
|
|
34
34
|
async def _request_available_devices_async(
|
35
|
-
self, providers:
|
35
|
+
self, providers: list[ProviderNameEnum]
|
36
36
|
) -> None:
|
37
37
|
requested_providers = self._requested_providers_filter(providers)
|
38
38
|
if not requested_providers:
|
@@ -41,7 +41,7 @@ class AnalyzerUtilities:
|
|
41
41
|
qubit_count=self.circuit.data.width, providers=requested_providers
|
42
42
|
)
|
43
43
|
result = await ApiWrapper.call_available_devices_task(params=params)
|
44
|
-
self.available_devices.update(result.devices.
|
44
|
+
self.available_devices.update(result.devices.model_dump())
|
45
45
|
|
46
46
|
async def request_hardware_connectivity_async(
|
47
47
|
self, provider: ProviderNameEnum, device: DeviceName
|
@@ -69,8 +69,8 @@ class AnalyzerUtilities:
|
|
69
69
|
)
|
70
70
|
|
71
71
|
def _requested_providers_filter(
|
72
|
-
self, providers:
|
73
|
-
) ->
|
72
|
+
self, providers: list[ProviderNameEnum]
|
73
|
+
) -> list[ProviderNameEnum]:
|
74
74
|
return list(
|
75
75
|
filter(
|
76
76
|
lambda provider: self.available_devices.get(_to_lower_case(provider))
|
@@ -81,7 +81,7 @@ class AnalyzerUtilities:
|
|
81
81
|
|
82
82
|
def _filter_devices_by_qubits_count(
|
83
83
|
self, provider: ProviderNameEnum
|
84
|
-
) ->
|
84
|
+
) -> list[DeviceName]:
|
85
85
|
device_avail_dict = self.available_devices[_to_lower_case(provider)]
|
86
86
|
return list(
|
87
87
|
filter(lambda device: device_avail_dict[device], device_avail_dict.keys())
|
classiq/analyzer/rb.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
from enum import Enum
|
2
|
-
from typing import
|
1
|
+
from enum import Enum as PythonEnum
|
2
|
+
from typing import Optional, Union
|
3
3
|
|
4
4
|
import matplotlib.pyplot as plt
|
5
5
|
import numpy as np
|
@@ -8,14 +8,14 @@ import plotly.graph_objects as go
|
|
8
8
|
|
9
9
|
from classiq.interface.analyzer.analysis_params import AnalysisRBParams
|
10
10
|
from classiq.interface.analyzer.result import RbResults
|
11
|
+
from classiq.interface.exceptions import ClassiqAnalyzerError
|
11
12
|
|
12
13
|
from classiq._internals.api_wrapper import ApiWrapper
|
13
|
-
from classiq.exceptions import ClassiqAnalyzerError
|
14
14
|
from classiq.executor import BackendPreferencesAndResult
|
15
15
|
|
16
16
|
|
17
17
|
class RBAnalysis:
|
18
|
-
def __init__(self, experiments_data:
|
18
|
+
def __init__(self, experiments_data: list[AnalysisRBParams]) -> None:
|
19
19
|
"""Init self.
|
20
20
|
|
21
21
|
Args:
|
@@ -25,8 +25,8 @@ class RBAnalysis:
|
|
25
25
|
self.experiments_data = experiments_data
|
26
26
|
self._total_results: pd.DataFrame = pd.DataFrame()
|
27
27
|
|
28
|
-
async def _get_multiple_hardware_results_async(self) ->
|
29
|
-
total_result:
|
28
|
+
async def _get_multiple_hardware_results_async(self) -> dict[str, RbResults]:
|
29
|
+
total_result: dict[str, RbResults] = {}
|
30
30
|
for batch in self.experiments_data:
|
31
31
|
if len(batch.num_clifford) < 5:
|
32
32
|
raise ClassiqAnalyzerError(
|
@@ -38,7 +38,7 @@ class RBAnalysis:
|
|
38
38
|
return total_result
|
39
39
|
|
40
40
|
@staticmethod
|
41
|
-
def _get_df_indices(results:
|
41
|
+
def _get_df_indices(results: dict[str, RbResults]) -> list[str]:
|
42
42
|
temp_res = results.copy()
|
43
43
|
_, rb_result_keys = temp_res.popitem()
|
44
44
|
return list(rb_result_keys.__dict__.keys())
|
@@ -78,22 +78,22 @@ class RBAnalysis:
|
|
78
78
|
return fig
|
79
79
|
|
80
80
|
|
81
|
-
def _strict_string(arg: Union[
|
82
|
-
if isinstance(arg,
|
81
|
+
def _strict_string(arg: Union[PythonEnum, str]) -> str:
|
82
|
+
if isinstance(arg, PythonEnum):
|
83
83
|
return arg.value
|
84
84
|
return arg
|
85
85
|
|
86
86
|
|
87
87
|
def order_executor_data_by_hardware(
|
88
|
-
mixed_data:
|
89
|
-
) ->
|
90
|
-
hardware_names:
|
88
|
+
mixed_data: list[BackendPreferencesAndResult],
|
89
|
+
) -> list[AnalysisRBParams]:
|
90
|
+
hardware_names: set[str] = {
|
91
91
|
_strict_string(hardware.backend_name) for hardware, _, _ in mixed_data
|
92
92
|
}
|
93
|
-
counts_dicts:
|
93
|
+
counts_dicts: dict[str, list[dict[str, int]]] = {
|
94
94
|
name: list() for name in hardware_names
|
95
95
|
}
|
96
|
-
cliffords_dicts:
|
96
|
+
cliffords_dicts: dict[str, list[int]] = {name: list() for name in hardware_names}
|
97
97
|
for hardware, num_clifford, result in mixed_data:
|
98
98
|
hw_name: str = _strict_string(hardware.backend_name)
|
99
99
|
counts_dicts[hw_name].append(result.counts) # type: ignore[union-attr]
|
@@ -110,7 +110,7 @@ def order_executor_data_by_hardware(
|
|
110
110
|
|
111
111
|
|
112
112
|
def fit_to_exponential_function(
|
113
|
-
result: RbResults, num_clifford:
|
113
|
+
result: RbResults, num_clifford: list[int], ax: Optional[plt.Axes] = None
|
114
114
|
) -> None:
|
115
115
|
if ax is None:
|
116
116
|
plt.figure()
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import webbrowser
|
2
2
|
from urllib.parse import urljoin
|
3
3
|
|
4
|
+
from classiq.interface.exceptions import ClassiqAnalyzerVisualizationError
|
5
|
+
from classiq.interface.generator.model.preferences.preferences import QuantumFormat
|
4
6
|
from classiq.interface.generator.quantum_program import QuantumProgram
|
5
7
|
|
6
8
|
from classiq._internals.api_wrapper import ApiWrapper
|
@@ -8,18 +10,39 @@ from classiq._internals.async_utils import syncify_function
|
|
8
10
|
from classiq.analyzer.url_utils import circuit_page_uri, client_ide_base_url
|
9
11
|
|
10
12
|
|
11
|
-
async def handle_remote_app(circuit: QuantumProgram) -> None:
|
13
|
+
async def handle_remote_app(circuit: QuantumProgram, display_url: bool = True) -> None:
|
14
|
+
if circuit.outputs.get(QuantumFormat.QASM) is None:
|
15
|
+
raise ClassiqAnalyzerVisualizationError(
|
16
|
+
"Missing QASM transpilation: visualization is only supported "
|
17
|
+
"for QASM programs. Try adding QASM to the output formats "
|
18
|
+
"synthesis preferences"
|
19
|
+
)
|
12
20
|
circuit_dataid = await ApiWrapper.call_analyzer_app(circuit)
|
13
21
|
app_url = urljoin(
|
14
22
|
client_ide_base_url(),
|
15
23
|
circuit_page_uri(circuit_id=circuit_dataid.id, circuit_version=circuit.version),
|
16
24
|
)
|
17
|
-
|
25
|
+
|
26
|
+
if display_url:
|
27
|
+
print(f"Opening: {app_url}") # noqa: T201
|
28
|
+
|
18
29
|
webbrowser.open_new_tab(app_url)
|
19
30
|
|
20
31
|
|
21
|
-
async def _show_interactive(self: QuantumProgram) -> None:
|
22
|
-
|
32
|
+
async def _show_interactive(self: QuantumProgram, display_url: bool = True) -> None:
|
33
|
+
"""
|
34
|
+
Displays the interactive representation of the quantum program in the Classiq IDE.
|
35
|
+
|
36
|
+
Args:
|
37
|
+
self:
|
38
|
+
The serialized quantum program to be displayed.
|
39
|
+
display_url:
|
40
|
+
Whether to print the url
|
41
|
+
|
42
|
+
Links:
|
43
|
+
[Visualization tool](https://docs.classiq.io/latest/reference-manual/analyzer/quantum-program-visualization-tool/)
|
44
|
+
"""
|
45
|
+
await handle_remote_app(self, display_url)
|
23
46
|
|
24
47
|
|
25
48
|
QuantumProgram.show = syncify_function(_show_interactive) # type: ignore[attr-defined]
|
classiq/analyzer/url_utils.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import urllib
|
2
2
|
from urllib.parse import urljoin
|
3
|
-
from uuid import UUID
|
4
3
|
|
5
4
|
from classiq.interface.server import routes
|
6
5
|
|
@@ -21,7 +20,7 @@ def versioned_url_params(circuit_version: str) -> str:
|
|
21
20
|
)
|
22
21
|
|
23
22
|
|
24
|
-
def circuit_page_uri(circuit_id:
|
25
|
-
url = urljoin(f"{routes.ANALYZER_CIRCUIT_PAGE}/",
|
23
|
+
def circuit_page_uri(circuit_id: str, circuit_version: str) -> str:
|
24
|
+
url = urljoin(f"{routes.ANALYZER_CIRCUIT_PAGE}/", circuit_id)
|
26
25
|
url += versioned_url_params(circuit_version=circuit_version)
|
27
26
|
return url
|
classiq/applications/__init__.py
CHANGED
@@ -1,17 +1,8 @@
|
|
1
|
-
from
|
2
|
-
|
3
|
-
from classiq.applications import (
|
4
|
-
benchmarking,
|
5
|
-
chemistry,
|
6
|
-
combinatorial_optimization,
|
7
|
-
finance,
|
8
|
-
qsvm,
|
9
|
-
)
|
1
|
+
from classiq.applications import chemistry, combinatorial_optimization, finance, qsvm
|
10
2
|
|
11
3
|
__all__ = [
|
12
|
-
"benchmarking",
|
13
|
-
"combinatorial_optimization",
|
14
4
|
"chemistry",
|
5
|
+
"combinatorial_optimization",
|
15
6
|
"finance",
|
16
7
|
"qsvm",
|
17
8
|
]
|
@@ -20,5 +11,5 @@ __all__ = [
|
|
20
11
|
_NON_IMPORTED_PUBLIC_SUBMODULES = ["qnn"]
|
21
12
|
|
22
13
|
|
23
|
-
def __dir__() ->
|
14
|
+
def __dir__() -> list[str]:
|
24
15
|
return __all__ + _NON_IMPORTED_PUBLIC_SUBMODULES
|