diff --git a/src/orquestra/vqa/algorithms/__init__.py b/src/orquestra/vqa/algorithms/__init__.py new file mode 100644 index 0000000..87833f5 --- /dev/null +++ b/src/orquestra/vqa/algorithms/__init__.py @@ -0,0 +1,3 @@ +from .qaoa import QAOA +from .qcbm import QCBM +from .vqe import VQE diff --git a/src/orquestra/vqa/algorithms/qaoa.py b/src/orquestra/vqa/algorithms/qaoa.py index a15c961..ffbc953 100644 --- a/src/orquestra/vqa/algorithms/qaoa.py +++ b/src/orquestra/vqa/algorithms/qaoa.py @@ -14,9 +14,9 @@ from orquestra.quantum.operators import PauliRepresentation from scipy.optimize import OptimizeResult -from orquestra.vqa.ansatz.qaoa_farhi import QAOAFarhiAnsatz +from orquestra.vqa.ansatz import QAOAFarhiAnsatz from orquestra.vqa.api.ansatz import Ansatz -from orquestra.vqa.cost_function.cost_function import ( +from orquestra.vqa.cost_function import ( create_cost_function, substitution_based_estimation_tasks_factory, ) diff --git a/src/orquestra/vqa/algorithms/qcbm.py b/src/orquestra/vqa/algorithms/qcbm.py index c439a85..bc67698 100644 --- a/src/orquestra/vqa/algorithms/qcbm.py +++ b/src/orquestra/vqa/algorithms/qcbm.py @@ -17,7 +17,7 @@ ) from scipy.optimize import OptimizeResult -from orquestra.vqa.ansatz.qcbm import QCBMAnsatz +from orquestra.vqa.ansatz import QCBMAnsatz from orquestra.vqa.cost_function.qcbm_cost_function import create_QCBM_cost_function diff --git a/src/orquestra/vqa/algorithms/vqe.py b/src/orquestra/vqa/algorithms/vqe.py index 1b288d5..b71d013 100644 --- a/src/orquestra/vqa/algorithms/vqe.py +++ b/src/orquestra/vqa/algorithms/vqe.py @@ -20,7 +20,7 @@ from scipy.optimize import OptimizeResult from orquestra.vqa.api.ansatz import Ansatz -from orquestra.vqa.cost_function.cost_function import ( +from orquestra.vqa.cost_function import ( create_cost_function, substitution_based_estimation_tasks_factory, ) diff --git a/src/orquestra/vqa/ansatz/__init__.py b/src/orquestra/vqa/ansatz/__init__.py new file mode 100644 index 0000000..bfc3f5c --- /dev/null +++ b/src/orquestra/vqa/ansatz/__init__.py @@ -0,0 +1,15 @@ +from .kbody import XAnsatz, XZAnsatz +from .qaoa_farhi import ( + QAOAFarhiAnsatz, + create_all_x_mixer_hamiltonian, + create_farhi_qaoa_circuits, +) +from .qaoa_warm_start import WarmStartQAOAAnsatz, convert_relaxed_solution_to_angles +from .qcbm._qcbm import ( + QCBMAnsatz, + get_entangling_layer, + load_qcbm_ansatz_set, + save_qcbm_ansatz_set, +) +from .quantum_compiling import HEAQuantumCompilingAnsatz +from .singlet_uccsd import SingletUCCSDAnsatz diff --git a/src/orquestra/vqa/ansatz/qcbm/__init__.py b/src/orquestra/vqa/ansatz/qcbm/__init__.py deleted file mode 100644 index 84c7102..0000000 --- a/src/orquestra/vqa/ansatz/qcbm/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -################################################################################ -# © Copyright 2022 Zapata Computing Inc. -################################################################################ -from ._qcbm import QCBMAnsatz diff --git a/src/orquestra/vqa/cost_function/__init__.py b/src/orquestra/vqa/cost_function/__init__.py new file mode 100644 index 0000000..d61aadc --- /dev/null +++ b/src/orquestra/vqa/cost_function/__init__.py @@ -0,0 +1,10 @@ +from .cost_function import ( + add_normal_noise, + create_cost_function, + dynamic_circuit_estimation_tasks_factory, + expectation_value_estimation_tasks_factory, + fix_parameters, + substitution_based_estimation_tasks_factory, + sum_expectation_values, +) +from .qcbm_cost_function import create_QCBM_cost_function diff --git a/src/orquestra/vqa/estimation/__init__.py b/src/orquestra/vqa/estimation/__init__.py new file mode 100644 index 0000000..f9a3ef4 --- /dev/null +++ b/src/orquestra/vqa/estimation/__init__.py @@ -0,0 +1,6 @@ +from .context_selection import ( + get_context_selection_circuit_for_group, + perform_context_selection, +) +from .cvar import CvarEstimator +from .gibbs_objective import GibbsObjectiveEstimator diff --git a/src/orquestra/vqa/opt/__init__.py b/src/orquestra/vqa/opt/__init__.py new file mode 100644 index 0000000..2647f94 --- /dev/null +++ b/src/orquestra/vqa/opt/__init__.py @@ -0,0 +1,3 @@ +from .fourier_qaoa import FourierOptimizer, convert_u_v_to_gamma_beta +from .layerwise_ansatz_optimizer import LayerwiseAnsatzOptimizer, append_random_params +from .recursive_qaoa import RecursiveQAOA diff --git a/src/orquestra/vqa/testing/__init__.py b/src/orquestra/vqa/testing/__init__.py index e69de29..f7d3141 100644 --- a/src/orquestra/vqa/testing/__init__.py +++ b/src/orquestra/vqa/testing/__init__.py @@ -0,0 +1 @@ +from .mock_objects import MockAnsatz diff --git a/tests/orquestra/vqa/algorithms/qaoa_test.py b/tests/orquestra/vqa/algorithms/qaoa_test.py index 840ca6c..7b15aca 100644 --- a/tests/orquestra/vqa/algorithms/qaoa_test.py +++ b/tests/orquestra/vqa/algorithms/qaoa_test.py @@ -2,12 +2,11 @@ import pytest from orquestra.opt.optimizers import ScipyOptimizer from orquestra.quantum.operators import PauliTerm -from orquestra.quantum.runners.symbolic_simulator import SymbolicSimulator +from orquestra.quantum.runners import SymbolicSimulator -from orquestra.vqa.algorithms.qaoa import QAOA -from orquestra.vqa.ansatz.qaoa_farhi import QAOAFarhiAnsatz -from orquestra.vqa.ansatz.qaoa_warm_start import WarmStartQAOAAnsatz -from orquestra.vqa.estimation.cvar import CvarEstimator +from orquestra.vqa.algorithms import QAOA +from orquestra.vqa.ansatz import QAOAFarhiAnsatz, WarmStartQAOAAnsatz +from orquestra.vqa.estimation import CvarEstimator @pytest.fixture() diff --git a/tests/orquestra/vqa/algorithms/qcbm_test.py b/tests/orquestra/vqa/algorithms/qcbm_test.py index cce4db3..44c8430 100644 --- a/tests/orquestra/vqa/algorithms/qcbm_test.py +++ b/tests/orquestra/vqa/algorithms/qcbm_test.py @@ -5,11 +5,11 @@ from orquestra.quantum.distributions.BAS_dataset import ( get_bars_and_stripes_target_distribution, ) -from orquestra.quantum.runners.symbolic_simulator import SymbolicSimulator +from orquestra.quantum.runners import SymbolicSimulator -from orquestra.vqa.algorithms.qcbm import QCBM -from orquestra.vqa.ansatz.qcbm import QCBMAnsatz -from orquestra.vqa.estimation.cvar import CvarEstimator +from orquestra.vqa.algorithms import QCBM +from orquestra.vqa.ansatz import QCBMAnsatz +from orquestra.vqa.estimation import CvarEstimator N_LAYERS = 2 N_QUBITS = 4 diff --git a/tests/orquestra/vqa/algorithms/vqe_test.py b/tests/orquestra/vqa/algorithms/vqe_test.py index 7aaf02a..dccf25f 100644 --- a/tests/orquestra/vqa/algorithms/vqe_test.py +++ b/tests/orquestra/vqa/algorithms/vqe_test.py @@ -3,11 +3,11 @@ from orquestra.opt.optimizers import ScipyOptimizer from orquestra.quantum.api.estimation import EstimationPreprocessor from orquestra.quantum.operators import PauliTerm -from orquestra.quantum.runners.symbolic_simulator import SymbolicSimulator +from orquestra.quantum.runners import SymbolicSimulator -from orquestra.vqa.algorithms.vqe import VQE -from orquestra.vqa.ansatz.quantum_compiling import HEAQuantumCompilingAnsatz -from orquestra.vqa.estimation.cvar import CvarEstimator +from orquestra.vqa.algorithms import VQE +from orquestra.vqa.ansatz import HEAQuantumCompilingAnsatz +from orquestra.vqa.estimation import CvarEstimator from orquestra.vqa.grouping import group_greedily, group_individually from orquestra.vqa.shot_allocation import ( allocate_shots_proportionally, diff --git a/tests/orquestra/vqa/ansatz/qaoa_farhi_test.py b/tests/orquestra/vqa/ansatz/qaoa_farhi_test.py index 4c541d0..09176eb 100644 --- a/tests/orquestra/vqa/ansatz/qaoa_farhi_test.py +++ b/tests/orquestra/vqa/ansatz/qaoa_farhi_test.py @@ -7,7 +7,7 @@ from orquestra.quantum.operators import PauliSum, PauliTerm from orquestra.quantum.utils import compare_unitary -from orquestra.vqa.ansatz.qaoa_farhi import ( +from orquestra.vqa.ansatz import ( QAOAFarhiAnsatz, create_all_x_mixer_hamiltonian, create_farhi_qaoa_circuits, diff --git a/tests/orquestra/vqa/ansatz/qcbm/qcbm_ansatz_test.py b/tests/orquestra/vqa/ansatz/qcbm/qcbm_ansatz_test.py index 75e6967..5a0eaf2 100644 --- a/tests/orquestra/vqa/ansatz/qcbm/qcbm_ansatz_test.py +++ b/tests/orquestra/vqa/ansatz/qcbm/qcbm_ansatz_test.py @@ -7,12 +7,12 @@ import pytest from orquestra.quantum.circuits import RX, RZ, XX, Circuit -from orquestra.vqa.ansatz.qcbm._qcbm import ( +from orquestra.vqa.ansatz import ( QCBMAnsatz, + get_entangling_layer, load_qcbm_ansatz_set, save_qcbm_ansatz_set, ) -from orquestra.vqa.ansatz.qcbm._qcbm_utils import get_entangling_layer from orquestra.vqa.api.ansatz_test import AnsatzTests diff --git a/tests/orquestra/vqa/ansatz/quantum_compiling_test.py b/tests/orquestra/vqa/ansatz/quantum_compiling_test.py index 501887a..14d5618 100644 --- a/tests/orquestra/vqa/ansatz/quantum_compiling_test.py +++ b/tests/orquestra/vqa/ansatz/quantum_compiling_test.py @@ -3,7 +3,7 @@ ################################################################################ import pytest -from orquestra.vqa.ansatz.quantum_compiling import HEAQuantumCompilingAnsatz +from orquestra.vqa.ansatz import HEAQuantumCompilingAnsatz from orquestra.vqa.api.ansatz_test import AnsatzTests diff --git a/tests/orquestra/vqa/cost_function/cost_function_test.py b/tests/orquestra/vqa/cost_function/cost_function_test.py index 8432c06..5f1e69b 100644 --- a/tests/orquestra/vqa/cost_function/cost_function_test.py +++ b/tests/orquestra/vqa/cost_function/cost_function_test.py @@ -6,7 +6,7 @@ import numpy as np import pytest -from orquestra.quantum.estimation._estimation import ( +from orquestra.quantum.estimation import ( calculate_exact_expectation_values, estimate_expectation_values_by_averaging, ) @@ -15,7 +15,7 @@ from orquestra.quantum.runners import SymbolicSimulator from sympy import Symbol -from orquestra.vqa.cost_function.cost_function import ( +from orquestra.vqa.cost_function import ( add_normal_noise, create_cost_function, dynamic_circuit_estimation_tasks_factory, diff --git a/tests/orquestra/vqa/opt/fourier_test.py b/tests/orquestra/vqa/opt/fourier_test.py index b1958d5..7d6364a 100644 --- a/tests/orquestra/vqa/opt/fourier_test.py +++ b/tests/orquestra/vqa/opt/fourier_test.py @@ -8,13 +8,13 @@ from orquestra.opt.api.optimizer import optimization_result from orquestra.opt.api.optimizer_test import NESTED_OPTIMIZER_CONTRACTS from orquestra.opt.mock_objects import MockOptimizer, mock_cost_function -from orquestra.quantum.estimation._estimation import calculate_exact_expectation_values +from orquestra.quantum.estimation import calculate_exact_expectation_values from orquestra.quantum.operators import PauliTerm from orquestra.quantum.runners import SymbolicSimulator -from orquestra.vqa.ansatz.qaoa_farhi import QAOAFarhiAnsatz +from orquestra.vqa.ansatz import QAOAFarhiAnsatz from orquestra.vqa.api.ansatz import Ansatz -from orquestra.vqa.cost_function.cost_function import ( +from orquestra.vqa.cost_function import ( create_cost_function, substitution_based_estimation_tasks_factory, ) diff --git a/tests/orquestra/vqa/opt/recursive_qaoa_test.py b/tests/orquestra/vqa/opt/recursive_qaoa_test.py index 2282026..613d273 100644 --- a/tests/orquestra/vqa/opt/recursive_qaoa_test.py +++ b/tests/orquestra/vqa/opt/recursive_qaoa_test.py @@ -11,15 +11,13 @@ from orquestra.opt.api.optimizer_test import NESTED_OPTIMIZER_CONTRACTS from orquestra.opt.mock_objects import MockOptimizer from orquestra.quantum.api.estimation import EstimationTask -from orquestra.quantum.estimation._estimation import ( - estimate_expectation_values_by_averaging, -) +from orquestra.quantum.estimation import estimate_expectation_values_by_averaging from orquestra.quantum.operators import PauliRepresentation, PauliTerm from orquestra.quantum.runners import SymbolicSimulator -from orquestra.vqa.ansatz.qaoa_farhi import QAOAFarhiAnsatz +from orquestra.vqa.ansatz import QAOAFarhiAnsatz from orquestra.vqa.api.ansatz import Ansatz -from orquestra.vqa.cost_function.cost_function import ( +from orquestra.vqa.cost_function import ( create_cost_function, substitution_based_estimation_tasks_factory, )