Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dta2-255 consistent naming #139

Merged
merged 14 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions benchmarks/test_get_qsp_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import pytest

from benchq.algorithms.time_evolution import _n_block_encodings_for_time_evolution
from benchq.problem_embeddings import get_qsp_program
from benchq.problem_embedding import get_qsp_program
from benchq.problem_ingestion import (
generate_jw_qubit_hamiltonian_from_mol_data,
get_hamiltonian_from_file,
get_vlasov_hamiltonian,
)
from benchq.problem_ingestion.molecule_instance_generation import (
from benchq.problem_ingestion.hamiltonians.molecule_instance_generation import (
generate_hydrogen_chain_instance,
)

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/test_substrate_scheduler_performance.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import networkx as nx
import pytest

from benchq.resource_estimation.graph_estimator import substrate_scheduler
from benchq.resource_estimators.graph_estimators import substrate_scheduler


@pytest.mark.parametrize("preset", ["fast", "optimized"])
Expand Down
12 changes: 6 additions & 6 deletions examples/ex_10_lde_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
from orquestra.quantum.circuits import GateOperation, load_circuit, save_circuit
from orquestra.quantum.decompositions._decomposition import DecompositionRule

from benchq.algorithms.block_encodings.offset_tridiagonal import (
from benchq.problem_ingestion.block_encodings.offset_tridiagonal import (
get_offset_tridagonal_block_encoding,
)
from benchq.algorithms.lde_solver import get_kappa, long_time_propagator
from benchq.algorithms.utils.convex_optimization import optimize_chebyshev_coeff
from benchq.algorithms.utils.qsp_solver import qsp_solver
from benchq.algorithms.lde_solver.lde_solver import get_kappa, long_time_propagator
from benchq.problem_embedding.qsp.get_qsp_polynomial import optimize_chebyshev_coeff
from benchq.problem_embedding.qsp.get_qsp_phases import get_qsp_phases
from benchq.compilation import (
pyliqtr_transpile_to_clifford_t,
transpile_to_native_gates,
)
from benchq.compilation.transpile_to_native_gates import decompose_benchq_circuit
from benchq.data_structures import get_program_from_circuit
from benchq.algorithms.data_structures import get_program_from_circuit


class Remove_Multicontrol(DecompositionRule[GateOperation]):
Expand Down Expand Up @@ -120,7 +120,7 @@ def run_time_marching():
except AssertionError:
print("Not possible to construct a block encoding for the given entries")
exit()
phases, _ = qsp_solver(chev_coeff, parity=1, options={"criteria": 1e-3})
phases, _ = get_qsp_phases(chev_coeff, parity=1, options={"criteria": 1e-3})
# construct a time-marching circuit for the given parameters set
time_marching_cir = long_time_propagator(
phases,
Expand Down
13 changes: 8 additions & 5 deletions examples/ex_11_utility_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@

from benchq.algorithms.time_evolution import qsp_time_evolution_algorithm
from benchq.compilation import get_ruby_slippers_compiler
from benchq.data_structures import DETAILED_ION_TRAP_ARCHITECTURE_MODEL, DecoderModel
from benchq.problem_ingestion.hamiltonian_generation import (
from benchq.quantum_hardware_modeling import DETAILED_ION_TRAP_ARCHITECTURE_MODEL
from benchq.decoder_modeling import DecoderModel
from benchq.problem_ingestion.hamiltonians.lanl_maglab import (
generate_cubic_hamiltonian,
generate_kitaev_hamiltonian,
generate_triangular_hamiltonian,
)
from benchq.resource_estimation.graph import (
from benchq.resource_estimators.graph_estimators import (
ExtrapolationResourceEstimator,
create_big_graph_from_subcircuits,
remove_isolated_nodes,
run_custom_extrapolation_pipeline,
transpile_to_native_gates,
)
from benchq.resource_estimation.openfermion_re import get_physical_cost
from benchq.resource_estimators.footprint_estimators.openfermion_estimator import (
footprint_estimator,
)


def get_resources(lattice_type: str, size: int, decoder_data_file: str):
Expand Down Expand Up @@ -81,7 +84,7 @@ def get_resources(lattice_type: str, size: int, decoder_data_file: str):
algorithm_implementation.error_budget.transpilation_failure_tolerance,
)

footprint_resources = get_physical_cost(
footprint_resources = footprint_estimator(
algorithm_implementation.program.num_data_qubits,
num_t=total_t_gates,
architecture_model=my_estimator.hw_model,
Expand Down
6 changes: 3 additions & 3 deletions examples/ex_1_from_qasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
from orquestra.integrations.qiskit.conversions import import_from_qiskit
from qiskit.circuit import QuantumCircuit

from benchq.data_structures import (
BASIC_SC_ARCHITECTURE_MODEL,
from benchq.algorithms.data_structures import (
AlgorithmImplementation,
ErrorBudget,
get_program_from_circuit,
)
from benchq.resource_estimation.graph_estimator import (
from benchq.quantum_hardware_modeling import BASIC_SC_ARCHITECTURE_MODEL
from benchq.resource_estimators.graph_estimators import (
GraphResourceEstimator,
create_big_graph_from_subcircuits,
run_custom_resource_estimation_pipeline,
Expand Down
6 changes: 3 additions & 3 deletions examples/ex_2_time_evolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
from pprint import pprint

from benchq.algorithms.time_evolution import qsp_time_evolution_algorithm
from benchq.data_structures import BASIC_SC_ARCHITECTURE_MODEL
from benchq.quantum_hardware_modeling import BASIC_SC_ARCHITECTURE_MODEL
from benchq.problem_ingestion import get_vlasov_hamiltonian
from benchq.problem_ingestion.hamiltonian_generation import (
from benchq.problem_ingestion.hamiltonians.hiesenburg import (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "hiesenburg" to "heisenberg"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

generate_1d_heisenberg_hamiltonian,
)
from benchq.resource_estimation.graph_estimator import (
from benchq.resource_estimators.graph_estimators import (
GraphResourceEstimator,
create_big_graph_from_subcircuits,
run_custom_resource_estimation_pipeline,
Expand Down
9 changes: 6 additions & 3 deletions examples/ex_3_packages_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
from pprint import pprint

from benchq.algorithms.time_evolution import qsp_time_evolution_algorithm
from benchq.data_structures import BASIC_SC_ARCHITECTURE_MODEL, DecoderModel
from benchq.quantum_hardware_modeling import BASIC_SC_ARCHITECTURE_MODEL
from benchq.decoder_modeling import DecoderModel
from benchq.problem_ingestion import get_vlasov_hamiltonian
from benchq.resource_estimation.footprint_estimator.azure import AzureResourceEstimator
from benchq.resource_estimation.graph_estimator import (
from benchq.resource_estimators.footprint_estimators.azure_estimator import (
AzureResourceEstimator,
)
from benchq.resource_estimators.graph_estimators import (
GraphResourceEstimator,
create_big_graph_from_subcircuits,
run_custom_resource_estimation_pipeline,
Expand Down
7 changes: 4 additions & 3 deletions examples/ex_4_fast_graph_estimates.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
from pprint import pprint

from benchq.algorithms.time_evolution import qsp_time_evolution_algorithm
from benchq.data_structures import DETAILED_ION_TRAP_ARCHITECTURE_MODEL, DecoderModel
from benchq.problem_ingestion.hamiltonian_generation import (
from benchq.quantum_hardware_modeling import DETAILED_ION_TRAP_ARCHITECTURE_MODEL
from benchq.decoder_modeling import DecoderModel
from benchq.problem_ingestion.hamiltonians.lanl_maglab import (
generate_triangular_hamiltonian,
)
from benchq.resource_estimation.default_pipelines import run_fast_graph_estimate
from benchq.resource_estimators.default_estimators import run_fast_graph_estimate
from benchq.timing import measure_time


Expand Down
10 changes: 6 additions & 4 deletions examples/ex_5_orquestra/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
from orquestra import sdk

from benchq.algorithms.time_evolution import qsp_time_evolution_algorithm
from benchq.data_structures import ErrorBudget
from benchq.data_structures.hardware_architecture_models import (
from benchq.algorithms.data_structures import ErrorBudget
from benchq.quantum_hardware_modeling.hardware_architecture_models import (
BASIC_SC_ARCHITECTURE_MODEL,
)
from benchq.problem_ingestion import get_vlasov_hamiltonian
from benchq.resource_estimation.footprint_estimator.azure import AzureResourceEstimator
from benchq.resource_estimation.graph_estimator import (
from benchq.resource_estimators.footprint_estimators.azure_estimator import (
AzureResourceEstimator,
)
from benchq.resource_estimators.graph_estimators import (
GraphResourceEstimator,
create_big_graph_from_subcircuits,
run_custom_resource_estimation_pipeline,
Expand Down
18 changes: 10 additions & 8 deletions examples/ex_6_orquestra_customized/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@
from orquestra import sdk

from benchq.algorithms.time_evolution import qsp_time_evolution_algorithm
from benchq.data_structures import (
BASIC_ION_TRAP_ARCHITECTURE_MODEL,
BASIC_SC_ARCHITECTURE_MODEL,
BasicArchitectureModel,
from benchq.algorithms.data_structures import (
ErrorBudget,
QuantumProgram,
)
from benchq.algorithms import AlgorithmImplementation
from benchq.resource_estimation.graph_estimators import GraphPartition
from benchq.resource_estimation.resource_info import GraphResourceInfo
from benchq.quantum_hardware_modeling import (
BASIC_SC_ARCHITECTURE_MODEL,
BASIC_ION_TRAP_ARCHITECTURE_MODEL,
BasicArchitectureModel,
)
from benchq.algorithms.data_structures import AlgorithmImplementation
from benchq.resource_estimators.graph_estimators import GraphPartition
from benchq.resource_estimators.resource_info import GraphResourceInfo
from benchq.problem_ingestion import get_vlasov_hamiltonian
from benchq.resource_estimation.graph_estimators import (
from benchq.resource_estimators.graph_estimators import (
GraphResourceEstimator,
create_big_graph_from_subcircuits,
transpile_to_native_gates,
Expand Down
8 changes: 4 additions & 4 deletions examples/ex_7_mlflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
from orquestra.integrations.qiskit.conversions import import_from_qiskit
from qiskit.circuit import QuantumCircuit

from benchq.data_structures import (
BASIC_SC_ARCHITECTURE_MODEL,
from benchq.algorithms.data_structures import (
AlgorithmImplementation,
ErrorBudget,
get_program_from_circuit,
)
from benchq.mlflow import log_input_objects_to_mlflow, log_resource_info_to_mlflow
from benchq.resource_estimation.graph_estimator import (
from benchq.quantum_hardware_modeling import BASIC_SC_ARCHITECTURE_MODEL
from benchq.data_logging import log_input_objects_to_mlflow, log_resource_info_to_mlflow
from benchq.resource_estimators.graph_estimators import (
GraphResourceEstimator,
create_big_graph_from_subcircuits,
run_custom_resource_estimation_pipeline,
Expand Down
8 changes: 4 additions & 4 deletions examples/ex_8_remote_mlflow/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
from orquestra import sdk

from benchq.algorithms.time_evolution import qsp_time_evolution_algorithm
from benchq.data_structures import ErrorBudget
from benchq.data_structures.hardware_architecture_models import (
from benchq.algorithms.data_structures import ErrorBudget
from benchq.quantum_hardware_modeling.hardware_architecture_models import (
BASIC_SC_ARCHITECTURE_MODEL,
)
from benchq.mlflow.data_logging import (
from benchq.data_logging import (
log_input_objects_to_mlflow,
log_resource_info_to_mlflow,
)
from benchq.problem_ingestion import get_vlasov_hamiltonian
from benchq.resource_estimation.graph import (
from benchq.resource_estimators.graph_estimators import (
GraphResourceEstimator,
create_big_graph_from_subcircuits,
run_custom_resource_estimation_pipeline,
Expand Down
2 changes: 1 addition & 1 deletion examples/ex_9_scf_mlflow/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""
from orquestra import sdk

from benchq.problem_ingestion.molecule_instance_generation import (
from benchq.problem_ingestion.hamiltonians.molecule_instance_generation import (
generate_hydrogen_chain_instance,
)

Expand Down
24 changes: 12 additions & 12 deletions examples/toy_problem_demo.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module = [
'scipy.*',
'sympy.*',
'rapidjson',
'mlflow.*',
'networkx.*',
'openfermion.*',
'openfermionpyscf.*',
Expand All @@ -43,6 +44,7 @@ module = [
'h5py.*',
'numba.*',
'juliapkg.*',
'urllib3.*',
]
ignore_missing_imports = true

Expand Down
12 changes: 4 additions & 8 deletions src/benchq/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
################################################################################
# © Copyright 2022 Zapata Computing Inc.
################################################################################
from .data_structures import (
BasicArchitectureModel,
QuantumProgram,
get_program_from_circuit,
)
from .algorithms import (
from .algorithms.data_structures import (
AlgorithmImplementation,
QuantumProgram,
get_algorithm_implementation_from_circuit,
get_program_from_circuit,
)

from .data_structures.hardware_architecture_models import (
from .quantum_hardware_modeling.hardware_architecture_models import (
BASIC_ION_TRAP_ARCHITECTURE_MODEL,
BASIC_SC_ARCHITECTURE_MODEL,
)
10 changes: 0 additions & 10 deletions src/benchq/algorithms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
from .qaoa import qaoa_algorithm
from .time_evolution import (
qsp_time_evolution_algorithm,
trotter_time_evolution_algorithm,
)

from .algorithm_implementation import (
AlgorithmImplementation,
get_algorithm_implementation_from_circuit,
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
################################################################################
# © Copyright 2022-2023 Zapata Computing Inc.
################################################################################
from .error_budget import ErrorBudget
from .hardware_architecture_models import (
BASIC_ION_TRAP_ARCHITECTURE_MODEL,
BASIC_SC_ARCHITECTURE_MODEL,
DETAILED_ION_TRAP_ARCHITECTURE_MODEL,
BasicArchitectureModel,
DetailedArchitectureModel,
DetailedIonTrapModel,

from .algorithm_implementation import (
AlgorithmImplementation,
get_algorithm_implementation_from_circuit,
)

# Data structures used to represent algorithms and how they are implemented
from .error_budget import ErrorBudget
from .graph_partition import GraphPartition
from .quantum_program import QuantumProgram, get_program_from_circuit
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from orquestra.quantum.circuits import Circuit

from ..data_structures.error_budget import ErrorBudget
from ..resource_estimation.graph_estimators.graph_partition import GraphPartition
from ..data_structures.quantum_program import QuantumProgram, get_program_from_circuit
from .error_budget import ErrorBudget
from .graph_partition import GraphPartition
from .quantum_program import QuantumProgram, get_program_from_circuit

T = TypeVar("T", QuantumProgram, GraphPartition)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from orquestra.quantum.circuits import Circuit as OrquestraCircuit
from qiskit.circuit import QuantumCircuit as QiskitCircuit

from ...data_structures.quantum_program import QuantumProgram
from .quantum_program import QuantumProgram

AnyCircuit = Union[OrquestraCircuit, CirqCircuit, QiskitCircuit]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from orquestra.integrations.cirq.conversions import to_openfermion
from orquestra.quantum.operators import PauliRepresentation

from ..conversions import openfermion_to_pyliqtr
from ..data_structures import AlgorithmImplementation, ErrorBudget
from ..problem_embeddings import get_qsp_program
from ...algorithms.data_structures import AlgorithmImplementation, ErrorBudget
from ...conversions import openfermion_to_pyliqtr
from ...problem_embedding import get_qsp_program


def _n_block_encodings(hamiltonian: PauliRepresentation, precision: float):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import math

import numpy as np
from orquestra.quantum.circuits import Circuit

from benchq.block_encodings.utils.offset_trdiagonal_utils import controlled_clock
from benchq.problem_ingestion.block_encodings.utils.offset_trdiagonal_utils import (
controlled_clock,
)


def get_add_l(L) -> Circuit:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from orquestra.quantum.circuits import PHASE, RZ, SX, Circuit, X
from qiskit import QuantumCircuit, transpile

from .lin_and_dong_qsp import build_qsp_circuit
from .utils.compression_gadget import get_add_dagger, get_add_l
from ...problem_embedding.qsp._lin_and_dong_qsp import build_qsp_circuit
from .compression_gadget import get_add_dagger, get_add_l


def get_kappa(matrix_norm: float, time_interval: float) -> float:
Expand Down
Loading
Loading