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

[Oxidize BasisTranslator]: Move the rest of the BasisTranslator to Rust. #13237

Merged
merged 12 commits into from
Oct 31, 2024
Merged
23 changes: 0 additions & 23 deletions crates/accelerate/src/basis/basis_translator/basis_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use std::cell::RefCell;

use hashbrown::{HashMap, HashSet};
use pyo3::prelude::*;

use crate::equivalence::{EdgeData, Equivalence, EquivalenceLibrary, Key, NodeData};
use qiskit_circuit::operations::Operation;
Expand All @@ -23,28 +22,6 @@ use rustworkx_core::traversal::{dijkstra_search, DijkstraEvent};

use super::compose_transforms::{BasisTransformIn, GateIdentifier};

/// Search for a set of transformations from source_basis to target_basis.
/// Args:
/// equiv_lib (EquivalenceLibrary): Source of valid translations
/// source_basis (Set[Tuple[gate_name: str, gate_num_qubits: int]]): Starting basis.
/// target_basis (Set[gate_name: str]): Target basis.
///
/// Returns:
/// Optional[List[Tuple[gate, equiv_params, equiv_circuit]]]: List of (gate,
/// equiv_params, equiv_circuit) tuples tuples which, if applied in order
/// will map from source_basis to target_basis. Returns None if no path
/// was found.
#[pyfunction]
#[pyo3(name = "basis_search")]
pub(crate) fn py_basis_search(
py: Python,
equiv_lib: &mut EquivalenceLibrary,
source_basis: HashSet<GateIdentifier>,
target_basis: HashSet<String>,
) -> PyObject {
basis_search(equiv_lib, &source_basis, &target_basis).into_py(py)
}

type BasisTransforms = Vec<(GateIdentifier, BasisTransformIn)>;
/// Search for a set of transformations from source_basis to target_basis.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ pub type GateIdentifier = (String, u32);
pub type BasisTransformIn = (SmallVec<[Param; 3]>, CircuitFromPython);
pub type BasisTransformOut = (SmallVec<[Param; 3]>, DAGCircuit);

#[pyfunction(name = "compose_transforms")]
pub(super) fn py_compose_transforms(
py: Python,
basis_transforms: Vec<(GateIdentifier, BasisTransformIn)>,
source_basis: HashSet<GateIdentifier>,
source_dag: &DAGCircuit,
) -> PyResult<HashMap<GateIdentifier, BasisTransformOut>> {
compose_transforms(py, &basis_transforms, &source_basis, source_dag)
}

pub(super) fn compose_transforms<'a>(
py: Python,
basis_transforms: &'a [(GateIdentifier, BasisTransformIn)],
Expand Down
Loading