diff --git a/Cargo.lock b/Cargo.lock index 86ad77db9ba4..b73b9b935af5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -823,6 +823,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + [[package]] name = "gemm" version = "0.19.0" @@ -1163,7 +1169,7 @@ checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" dependencies = [ "allocator-api2", "equivalent", - "foldhash", + "foldhash 0.1.5", "rayon", "serde", ] @@ -2196,8 +2202,8 @@ dependencies = [ name = "qiskit-cext" version = "2.5.0-dev" dependencies = [ - "ahash 0.8.12", "anyhow", + "foldhash 0.2.0", "hashbrown 0.15.5", "indexmap", "nalgebra 0.34.2", @@ -2230,6 +2236,7 @@ dependencies = [ "bitfield-struct", "bytemuck", "crossterm", + "foldhash 0.2.0", "hashbrown 0.15.5", "indexmap", "itertools 0.14.0", @@ -2314,7 +2321,7 @@ dependencies = [ name = "qiskit-qasm3" version = "2.5.0-dev" dependencies = [ - "ahash 0.8.12", + "foldhash 0.2.0", "hashbrown 0.15.5", "indexmap", "lazy_static", @@ -2330,9 +2337,9 @@ dependencies = [ name = "qiskit-qpy" version = "2.5.0-dev" dependencies = [ - "ahash 0.8.12", "binrw", "bytemuck", + "foldhash 0.2.0", "hashbrown 0.15.5", "indexmap", "num-bigint", @@ -2352,10 +2359,10 @@ dependencies = [ name = "qiskit-quantum-info" version = "2.5.0-dev" dependencies = [ - "ahash 0.8.12", "approx", "bytemuck", "fixedbitset 0.5.7", + "foldhash 0.2.0", "hashbrown 0.15.5", "indexmap", "itertools 0.14.0", @@ -2380,12 +2387,12 @@ dependencies = [ name = "qiskit-synthesis" version = "2.5.0-dev" dependencies = [ - "ahash 0.8.12", "approx", "binrw", "bytemuck", "faer", "fixedbitset 0.5.7", + "foldhash 0.2.0", "hashbrown 0.15.5", "indexmap", "itertools 0.14.0", @@ -2414,11 +2421,11 @@ dependencies = [ name = "qiskit-transpiler" version = "2.5.0-dev" dependencies = [ - "ahash 0.8.12", "anyhow", "approx", "bytemuck", "fixedbitset 0.5.7", + "foldhash 0.2.0", "hashbrown 0.15.5", "indexmap", "itertools 0.14.0", @@ -2783,7 +2790,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aaeee6f84153fd6f62507fc22bfe9499c8485075b44186dcbb918166ef75116f" dependencies = [ "fixedbitset 0.5.7", - "foldhash", + "foldhash 0.1.5", "hashbrown 0.15.5", "indexmap", "ndarray", diff --git a/Cargo.toml b/Cargo.toml index 63c9607d6f0f..0fd892592f92 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ rustworkx-core = "0.17" fixedbitset = "0.5.7" approx = "0.5" itertools = "0.14.0" -ahash = "0.8.12" +foldhash = "0.2.0" rayon = "1.12" nom = "8.0" nom-unicode = "0.4" diff --git a/crates/cext/Cargo.toml b/crates/cext/Cargo.toml index 2e81339d996a..fdf897af10ab 100644 --- a/crates/cext/Cargo.toml +++ b/crates/cext/Cargo.toml @@ -22,7 +22,7 @@ qiskit-circuit-library.workspace = true qiskit-transpiler.workspace = true pyo3 = { workspace = true, optional = true } indexmap.workspace = true -ahash.workspace = true +foldhash.workspace = true smallvec.workspace = true ndarray.workspace = true nalgebra.workspace = true diff --git a/crates/cext/src/transpiler/target.rs b/crates/cext/src/transpiler/target.rs index 142e13c46075..95d89658c14f 100644 --- a/crates/cext/src/transpiler/target.rs +++ b/crates/cext/src/transpiler/target.rs @@ -497,7 +497,7 @@ impl From for PackedOperation { pub struct TargetEntry { operation: StandardOperation, params: Option>, - map: IndexMap, ahash::RandomState>, + map: IndexMap, foldhash::fast::RandomState>, name: Option, } diff --git a/crates/circuit/Cargo.toml b/crates/circuit/Cargo.toml index b9708c5170ae..750e62db854d 100644 --- a/crates/circuit/Cargo.toml +++ b/crates/circuit/Cargo.toml @@ -16,7 +16,7 @@ workspace = true qiskit-util = { workspace = true, features = ["py"] } qiskit-quantum-info.workspace = true rayon.workspace = true -ahash.workspace = true +foldhash.workspace = true rustworkx-core.workspace = true bytemuck = {workspace = true, features = ["derive"]} bitfield-struct.workspace = true @@ -32,6 +32,7 @@ nom-unicode.workspace = true nom-language.workspace = true crossterm = "0.29.0" unicode-width = "0.2" +ahash = "0.8.12" unicode-segmentation = "1.13" [dependencies.pyo3] diff --git a/crates/circuit/src/bit_locator.rs b/crates/circuit/src/bit_locator.rs index 3b4d9f8ed16b..6d6f808b7cd1 100644 --- a/crates/circuit/src/bit_locator.rs +++ b/crates/circuit/src/bit_locator.rs @@ -21,7 +21,7 @@ use pyo3::types::{IntoPyDict, PyDict}; /// the circuit. #[derive(Debug)] pub struct BitLocator { - bit_locations: IndexMap, ::ahash::RandomState>, + bit_locations: IndexMap, ::foldhash::fast::RandomState>, cached: OnceLock>, } diff --git a/crates/circuit/src/circuit_data.rs b/crates/circuit/src/circuit_data.rs index a27a7f85fb3a..a71de6f39891 100644 --- a/crates/circuit/src/circuit_data.rs +++ b/crates/circuit/src/circuit_data.rs @@ -1751,8 +1751,9 @@ impl CircuitData { /// /// # Returns /// An IndexMap containing the operation names as keys and their respective counts as values. - pub fn count_ops(&self) -> IndexMap<&str, usize, ::ahash::RandomState> { - let mut ops_count: IndexMap<&str, usize, ::ahash::RandomState> = IndexMap::default(); + pub fn count_ops(&self) -> IndexMap<&str, usize, ::foldhash::fast::RandomState> { + let mut ops_count: IndexMap<&str, usize, ::foldhash::fast::RandomState> = + IndexMap::default(); for instruction in &self.data { *ops_count.entry(instruction.op.name()).or_insert(0) += 1; } @@ -2897,7 +2898,7 @@ impl PyCircuitData { /// /// # Returns /// An IndexMap containing the operation names as keys and their respective counts as values. - pub fn count_ops(&self) -> IndexMap<&str, usize, ::ahash::RandomState> { + pub fn count_ops(&self) -> IndexMap<&str, usize, ::foldhash::fast::RandomState> { self.inner.count_ops() } diff --git a/crates/circuit/src/dag_circuit.rs b/crates/circuit/src/dag_circuit.rs index 7e0f4bfe6599..6b7d820301fc 100644 --- a/crates/circuit/src/dag_circuit.rs +++ b/crates/circuit/src/dag_circuit.rs @@ -14,7 +14,7 @@ use std::cmp::Ordering; use std::hash::Hash; use std::sync::Arc; -use ahash::RandomState; +use foldhash::fast::RandomState; use smallvec::SmallVec; use crate::bit::{ @@ -672,13 +672,13 @@ impl DAGCircuit { RegisterData::from_mapping(dict_state.get_item("qregs")?.unwrap().extract::>()?); self.cregs = RegisterData::from_mapping(dict_state.get_item("cregs")?.unwrap().extract::>()?); self.global_phase = dict_state.get_item("global_phase")?.unwrap().extract()?; self.op_names = dict_state.get_item("op_name")?.unwrap().extract()?; @@ -5813,7 +5813,7 @@ impl DAGCircuit { }; // Put the new node in-between the previously "last" nodes on each wire // and the terminal map. - let termini: IndexSet = self + let termini: IndexSet = self .qargs_interner .get(qubits_id) .iter() @@ -5869,7 +5869,7 @@ impl DAGCircuit { ) -> PyResult<(Vec, Option>)> { let (all_clbits, vars): (Vec, Option>) = { if self.may_have_additional_wires(instr) { - let mut clbits: IndexSet = + let mut clbits: IndexSet = IndexSet::from_iter(self.cargs_interner.get(instr.clbits).iter().copied()); let (additional_clbits, additional_vars) = Python::attach(|py| self.additional_wires(py, instr))?; diff --git a/crates/circuit/src/interner.rs b/crates/circuit/src/interner.rs index d89cac89a5a7..817ec7cead13 100644 --- a/crates/circuit/src/interner.rs +++ b/crates/circuit/src/interner.rs @@ -207,7 +207,9 @@ mod interned_map { /// assert_eq!(interner.get(key), &[0, 1, 2, 3, 4]); /// ``` #[derive(Default)] -pub struct Interner(IndexSet<::Owned, ::ahash::RandomState>); +pub struct Interner( + IndexSet<::Owned, ::foldhash::fast::RandomState>, +); // `Clone` and `Debug` can't use the derivation mechanism because the values that are actually // stored are of type `::Owned`, which the derive system doesn't reason about. @@ -286,7 +288,8 @@ where /// Note that the default item of the interner is always allocated and given a key immediately, /// which will use one slot of the capacity. pub fn with_capacity(capacity: usize) -> Self { - let mut set = IndexSet::with_capacity_and_hasher(capacity, ::ahash::RandomState::new()); + let mut set = + IndexSet::with_capacity_and_hasher(capacity, ::foldhash::fast::RandomState::default()); set.insert(Default::default()); Self(set) } diff --git a/crates/circuit/src/parameter/parameter_expression.rs b/crates/circuit/src/parameter/parameter_expression.rs index dc01114318c0..592f8cfd281d 100644 --- a/crates/circuit/src/parameter/parameter_expression.rs +++ b/crates/circuit/src/parameter/parameter_expression.rs @@ -135,7 +135,8 @@ impl fmt::Display for ParameterExpression { impl ParameterExpression { pub fn qpy_replay(&self) -> Vec { let mut replay = Vec::new(); - let mut unused: IndexSet<_, ahash::RandomState> = self.name_map.values().cloned().collect(); + let mut unused: IndexSet<_, foldhash::fast::RandomState> = + self.name_map.values().cloned().collect(); // The recursive inner `qpy_replay_inner` assumes it starts from a containing operation, so // fails to build a complete replay in the case it starts from a single symbol or value. match &self.expr { @@ -2077,7 +2078,7 @@ fn qpy_replay_inner( expr: &ParameterExpression, name_map: &HashMap, replay: &mut Vec, - unused: &mut IndexSet, + unused: &mut IndexSet, ) { match &expr.expr { // This function is written under the assumption that the top-level expression involves an diff --git a/crates/circuit/src/vf2.rs b/crates/circuit/src/vf2.rs index 752b6f1635ac..8a0d93cf6d83 100644 --- a/crates/circuit/src/vf2.rs +++ b/crates/circuit/src/vf2.rs @@ -897,7 +897,7 @@ where { type Item = Result< ( - IndexMap, + IndexMap, NS::Score, ), IsIsomorphicError, @@ -1250,7 +1250,7 @@ where NS: Semantics, ES: Semantics, { - fn mapping(&self) -> IndexMap { + fn mapping(&self) -> IndexMap { self.needle .mapping .iter() @@ -1824,7 +1824,7 @@ where ES: Semantics, { type Item = Result< - (IndexMap, NS::Score), + (IndexMap, NS::Score), IsIsomorphicError, >; diff --git a/crates/qasm3/Cargo.toml b/crates/qasm3/Cargo.toml index 60f2bb0961c2..c5756537b18d 100644 --- a/crates/qasm3/Cargo.toml +++ b/crates/qasm3/Cargo.toml @@ -18,7 +18,7 @@ hashbrown.workspace = true oq3_semantics = "0.7.0" oq3_syntax = "0.7.0" qiskit-circuit.workspace = true -ahash.workspace = true +foldhash.workspace = true regex = "1.12" lazy_static = "1.5" thiserror.workspace = true diff --git a/crates/qasm3/src/build.rs b/crates/qasm3/src/build.rs index 845a4ee25b6e..abaca68aa736 100644 --- a/crates/qasm3/src/build.rs +++ b/crates/qasm3/src/build.rs @@ -13,7 +13,7 @@ use pyo3::prelude::*; use pyo3::types::{PySequence, PyTuple}; -use ahash::RandomState; +use foldhash::fast::RandomState; use hashbrown::HashMap; use indexmap::IndexMap; diff --git a/crates/qpy/Cargo.toml b/crates/qpy/Cargo.toml index 9f197498ce75..d9f512489835 100644 --- a/crates/qpy/Cargo.toml +++ b/crates/qpy/Cargo.toml @@ -16,7 +16,7 @@ workspace = true indexmap.workspace = true hashbrown.workspace = true oq3_semantics = "0.7.0" -ahash.workspace = true +foldhash.workspace = true qiskit-circuit.workspace = true qiskit-quantum-info.workspace = true num-bigint.workspace = true diff --git a/crates/quantum_info/Cargo.toml b/crates/quantum_info/Cargo.toml index 7fb5daa34a08..7277d9a5a273 100644 --- a/crates/quantum_info/Cargo.toml +++ b/crates/quantum_info/Cargo.toml @@ -20,7 +20,7 @@ rustworkx-core.workspace = true thiserror.workspace = true rayon.workspace = true bytemuck.workspace = true -ahash.workspace = true +foldhash.workspace = true ndarray-einsum = "0.8.0" rand.workspace = true rand_pcg.workspace = true diff --git a/crates/quantum_info/src/sparse_observable/mod.rs b/crates/quantum_info/src/sparse_observable/mod.rs index 4c890867e61b..20c4ad156792 100644 --- a/crates/quantum_info/src/sparse_observable/mod.rs +++ b/crates/quantum_info/src/sparse_observable/mod.rs @@ -3662,7 +3662,7 @@ impl PySparseObservable { let order = order .try_iter()? .map(|obj| obj.and_then(|obj| obj.extract::())) - .collect::>>()?; + .collect::>>()?; if order.len() != in_length { return Err(PyValueError::new_err("duplicate indices in qargs")); } diff --git a/crates/quantum_info/src/sparse_pauli_op.rs b/crates/quantum_info/src/sparse_pauli_op.rs index 38b8e5675a0b..6e18ed26f71f 100644 --- a/crates/quantum_info/src/sparse_pauli_op.rs +++ b/crates/quantum_info/src/sparse_pauli_op.rs @@ -10,7 +10,7 @@ // copyright notice, and modified files need to carry a notice indicating // that they have been altered from the originals. -use ahash::RandomState; +use foldhash::fast::RandomState; use pyo3::Python; use pyo3::exceptions::{PyRuntimeError, PyValueError}; use pyo3::prelude::*; @@ -337,7 +337,7 @@ impl MatrixCompressedPaulis { let mut hash_table = IndexMap::<(u64, u64), Complex64, RandomState>::with_capacity_and_hasher( self.coeffs.len(), - RandomState::new(), + RandomState::default(), ); for (key, coeff) in self .x_like diff --git a/crates/synthesis/Cargo.toml b/crates/synthesis/Cargo.toml index 6d23106f070e..b5c4615d4e78 100644 --- a/crates/synthesis/Cargo.toml +++ b/crates/synthesis/Cargo.toml @@ -19,7 +19,7 @@ qiskit-util.workspace = true bytemuck.workspace = true num-complex.workspace = true nalgebra.workspace = true -ahash.workspace = true +foldhash.workspace = true itertools.workspace = true numpy.workspace = true rayon.workspace = true diff --git a/crates/synthesis/src/clifford/greedy_synthesis.rs b/crates/synthesis/src/clifford/greedy_synthesis.rs index 40e43946f1cf..a4a2464443e1 100644 --- a/crates/synthesis/src/clifford/greedy_synthesis.rs +++ b/crates/synthesis/src/clifford/greedy_synthesis.rs @@ -10,7 +10,7 @@ // copyright notice, and modified files need to carry a notice indicating // that they have been altered from the originals. -use ahash::RandomState; +use foldhash::fast::RandomState; use indexmap::IndexSet; use ndarray::{Array2, ArrayView2, s}; use smallvec::smallvec; @@ -198,10 +198,10 @@ impl GreedyCliffordSynthesis<'_> { gate_seq: &mut CliffordGatesVec, min_qubit: usize, ) -> Result<(), String> { - let mut a_qubits: IndexSet<_, ::ahash::RandomState> = IndexSet::default(); - let mut b_qubits: IndexSet<_, ::ahash::RandomState> = IndexSet::default(); - let mut c_qubits: IndexSet<_, ::ahash::RandomState> = IndexSet::default(); - let mut d_qubits: IndexSet<_, ::ahash::RandomState> = IndexSet::default(); + let mut a_qubits: IndexSet<_, ::foldhash::fast::RandomState> = IndexSet::default(); + let mut b_qubits: IndexSet<_, ::foldhash::fast::RandomState> = IndexSet::default(); + let mut c_qubits: IndexSet<_, ::foldhash::fast::RandomState> = IndexSet::default(); + let mut d_qubits: IndexSet<_, ::foldhash::fast::RandomState> = IndexSet::default(); for qubit in &self.unprocessed_qubits { let pauli_pair_index = pauli_pair_to_index( diff --git a/crates/transpiler/Cargo.toml b/crates/transpiler/Cargo.toml index 6221abb5f06b..696f46d7cc43 100644 --- a/crates/transpiler/Cargo.toml +++ b/crates/transpiler/Cargo.toml @@ -16,7 +16,7 @@ workspace = true rayon.workspace = true rayon-cond = "0.4.0" numpy.workspace = true -ahash.workspace = true +foldhash.workspace = true itertools.workspace = true nalgebra.workspace = true rand.workspace = true diff --git a/crates/transpiler/src/equivalence.rs b/crates/transpiler/src/equivalence.rs index 7d06fba5d5ca..8b94c5ef0b06 100644 --- a/crates/transpiler/src/equivalence.rs +++ b/crates/transpiler/src/equivalence.rs @@ -27,7 +27,7 @@ use std::{error::Error, fmt::Display}; use exceptions::CircuitError; -use ahash::RandomState; +use foldhash::fast::RandomState; use indexmap::{IndexMap, IndexSet}; use pyo3::prelude::*; use pyo3::types::{PyDict, PyList, PyString}; @@ -612,7 +612,7 @@ impl EquivalenceLibrary { slf.key_to_node_index = state .get_item("key_to_node_index")? .unwrap() - .extract::>()? + .extract::>()? .into_iter() .map(|(key, val)| (key, NodeIndex::new(val))) .collect(); @@ -793,7 +793,7 @@ fn raise_if_shape_mismatch( fn rebind_equiv(equiv: Equivalence, query_params: &[Param]) -> PyResult { let (equiv_params, mut equiv_circuit) = (equiv.params, equiv.circuit); - let param_mapping: PyResult> = + let param_mapping: PyResult> = equiv_params .iter() .zip(query_params.iter()) diff --git a/crates/transpiler/src/passes/basis_translator/basis_search.rs b/crates/transpiler/src/passes/basis_translator/basis_search.rs index c1053d6c1907..92920e5ec05f 100644 --- a/crates/transpiler/src/passes/basis_translator/basis_search.rs +++ b/crates/transpiler/src/passes/basis_translator/basis_search.rs @@ -33,22 +33,22 @@ type BasisTransforms = Vec<(GateIdentifier, BasisTransformIn)>; /// basis` are reached. pub(crate) fn basis_search( equiv_lib: &mut EquivalenceLibrary, - source_basis: &IndexSet, - target_basis: &IndexSet<&str, ahash::RandomState>, + source_basis: &IndexSet, + target_basis: &IndexSet<&str, foldhash::fast::RandomState>, ) -> Option { // Build the visitor attributes: - let mut num_gates_remaining_for_rule: IndexMap = + let mut num_gates_remaining_for_rule: IndexMap = IndexMap::default(); - let predecessors: RefCell> = + let predecessors: RefCell> = RefCell::new(IndexMap::default()); - let opt_cost_map: RefCell> = + let opt_cost_map: RefCell> = RefCell::new(IndexMap::default()); let mut basis_transforms: Vec<(GateIdentifier, BasisTransformIn)> = vec![]; // Initialize visitor attributes: initialize_num_gates_remain_for_rule(equiv_lib.graph(), &mut num_gates_remaining_for_rule); - let mut source_basis_remain: IndexSet = source_basis + let mut source_basis_remain: IndexSet = source_basis .iter() .filter_map(|(gate_name, gate_num_qubits)| { if !target_basis.contains(gate_name.as_str()) { @@ -180,7 +180,7 @@ pub(crate) fn basis_search( fn initialize_num_gates_remain_for_rule( graph: &StableDiGraph>, - source: &mut IndexMap, + source: &mut IndexMap, ) { let mut save_index = usize::MAX; // When iterating over the edges, ignore any none-valued ones by calling `flatten` diff --git a/crates/transpiler/src/passes/basis_translator/compose_transforms.rs b/crates/transpiler/src/passes/basis_translator/compose_transforms.rs index d2cbdf0c9a84..f2095d3ab8f4 100644 --- a/crates/transpiler/src/passes/basis_translator/compose_transforms.rs +++ b/crates/transpiler/src/passes/basis_translator/compose_transforms.rs @@ -42,14 +42,20 @@ static STD_INST_SET: [&str; 4] = ["barrier", "delay", "measure", "reset"]; pub(super) fn compose_transforms<'a>( basis_transforms: &'a [(GateIdentifier, BasisTransformIn)], - source_basis: &'a IndexSet, + source_basis: &'a IndexSet, source_dag: &'a DAGCircuit, -) -> Result, BasisTranslatorError> { - let mut gate_param_counts: IndexMap = +) -> Result< + IndexMap, + BasisTranslatorError, +> { + let mut gate_param_counts: IndexMap = IndexMap::default(); get_gates_num_params(source_dag, &mut gate_param_counts); - let mut mapped_instructions: IndexMap = - IndexMap::with_hasher(ahash::RandomState::default()); + let mut mapped_instructions: IndexMap< + GateIdentifier, + BasisTransformOut, + foldhash::fast::RandomState, + > = IndexMap::with_hasher(foldhash::fast::RandomState::default()); for (gate_name, gate_num_qubits) in source_basis.iter().cloned() { let num_params = gate_param_counts[&(gate_name.clone(), gate_num_qubits)]; @@ -118,7 +124,7 @@ pub(super) fn compose_transforms<'a>( }) .collect::>(); for (node, params) in nodes_to_replace { - let param_mapping: IndexMap = + let param_mapping: IndexMap = equiv_params .iter() .map(|x| match x { @@ -190,7 +196,7 @@ fn name_to_packed_operation(name: &str, num_qubits: u32) -> Option, + example_gates: &mut IndexMap, ) { for (_, inst) in dag.op_nodes(true) { if let Some(control_flow) = dag.try_view_control_flow(inst) { diff --git a/crates/transpiler/src/passes/basis_translator/mod.rs b/crates/transpiler/src/passes/basis_translator/mod.rs index 0d056b657fb7..d086500879bf 100644 --- a/crates/transpiler/src/passes/basis_translator/mod.rs +++ b/crates/transpiler/src/passes/basis_translator/mod.rs @@ -46,8 +46,8 @@ use crate::target::Qargs; use crate::target::QargsRef; use crate::target::Target; -type AhashIndexMap = IndexMap; -type AhashIndexSet = IndexSet; +type AhashIndexMap = IndexMap; +type AhashIndexSet = IndexSet; type InstMap = AhashIndexMap; type ExtraInstructionMap<'a> = AhashIndexMap<&'a PhysicalQargs, InstMap>; type PhysicalQargs = SmallVec<[PhysicalQubit; 2]>; diff --git a/crates/transpiler/src/passes/commutation_analysis.rs b/crates/transpiler/src/passes/commutation_analysis.rs index beb0d7818869..3cb0dc4213c8 100644 --- a/crates/transpiler/src/passes/commutation_analysis.rs +++ b/crates/transpiler/src/passes/commutation_analysis.rs @@ -25,8 +25,8 @@ use qiskit_circuit::dag_circuit::{DAGCircuit, NodeType, Wire}; // Custom types to store the commutation sets and node indices, // see the docstring below for more information. -type CommutationSet = IndexMap>, ::ahash::RandomState>; -type NodeIndices = IndexMap<(NodeIndex, Wire), usize, ::ahash::RandomState>; +type CommutationSet = IndexMap>, ::foldhash::fast::RandomState>; +type NodeIndices = IndexMap<(NodeIndex, Wire), usize, ::foldhash::fast::RandomState>; // the maximum number of qubits we check commutativity for const MAX_NUM_QUBITS: u32 = 3; diff --git a/crates/transpiler/src/passes/commutation_cancellation.rs b/crates/transpiler/src/passes/commutation_cancellation.rs index 670d14a4f4ee..fb943bc57b1c 100644 --- a/crates/transpiler/src/passes/commutation_cancellation.rs +++ b/crates/transpiler/src/passes/commutation_cancellation.rs @@ -125,7 +125,7 @@ pub fn cancel_commutations( */ let (commutation_set, node_indices) = analyze_commutations(dag, commutation_checker, approximation_degree)?; - let mut cancellation_sets = IndexMap::with_hasher(::ahash::RandomState::new()); + let mut cancellation_sets = IndexMap::with_hasher(::foldhash::fast::RandomState::default()); (0..dag.num_qubits() as u32).for_each(|qubit| { let wire = Qubit(qubit); diff --git a/crates/transpiler/src/passes/constrained_reschedule.rs b/crates/transpiler/src/passes/constrained_reschedule.rs index 54bbabafa6bb..04f356f71a18 100644 --- a/crates/transpiler/src/passes/constrained_reschedule.rs +++ b/crates/transpiler/src/passes/constrained_reschedule.rs @@ -14,7 +14,7 @@ use crate::TranspilerError; use crate::passes::schedule_analysis::{NodeDurations, PyNodeDurations}; use crate::target::Target; use ::hashbrown::HashSet; -use ahash::RandomState; +use foldhash::fast::RandomState; use indexmap::IndexMap; use pyo3::exceptions::PyValueError; use pyo3::prelude::*; diff --git a/crates/transpiler/src/passes/dense_layout.rs b/crates/transpiler/src/passes/dense_layout.rs index a94c07cde4c5..4966b0984fa6 100644 --- a/crates/transpiler/src/passes/dense_layout.rs +++ b/crates/transpiler/src/passes/dense_layout.rs @@ -11,7 +11,7 @@ // that they have been altered from the originals. #![allow(clippy::too_many_arguments)] -use ahash::RandomState; +use foldhash::fast::RandomState; use hashbrown::{HashMap, HashSet}; use indexmap::IndexSet; use ndarray::prelude::*; diff --git a/crates/transpiler/src/passes/inverse_cancellation.rs b/crates/transpiler/src/passes/inverse_cancellation.rs index dd5be9068983..06ea7e8ba532 100644 --- a/crates/transpiler/src/passes/inverse_cancellation.rs +++ b/crates/transpiler/src/passes/inverse_cancellation.rs @@ -10,7 +10,7 @@ // copyright notice, and modified files need to carry a notice indicating // that they have been altered from the originals. -use ahash::RandomState; +use foldhash::fast::RandomState; use hashbrown::HashSet; use indexmap::IndexMap; use pyo3::prelude::*; diff --git a/crates/transpiler/src/passes/sabre/layer.rs b/crates/transpiler/src/passes/sabre/layer.rs index 8b5dd6f4e2d6..0f873298cfb8 100644 --- a/crates/transpiler/src/passes/sabre/layer.rs +++ b/crates/transpiler/src/passes/sabre/layer.rs @@ -33,7 +33,7 @@ use super::vec_map::VecMap; #[derive(Clone, Debug)] pub struct Layer { /// Map of the (index to the) node to the qubits it acts on. - nodes: IndexMap, + nodes: IndexMap, /// Map of each qubit to the node that acts on it and the other qubit that node acts on, if this /// qubit is active (otherwise `None`). qubits: VecMap>, @@ -46,7 +46,7 @@ impl Layer { // and can only have one gate in the layer. nodes: IndexMap::with_capacity_and_hasher( num_qubits as usize / 2, - ::ahash::RandomState::default(), + ::foldhash::fast::RandomState::default(), ), qubits: vec![None; num_qubits as usize].into(), } diff --git a/crates/transpiler/src/passes/sabre/route.rs b/crates/transpiler/src/passes/sabre/route.rs index 879b4c0c7c53..763bde4c1259 100644 --- a/crates/transpiler/src/passes/sabre/route.rs +++ b/crates/transpiler/src/passes/sabre/route.rs @@ -624,8 +624,8 @@ impl State { fn populate_extended_set(&mut self, problem: RoutingProblem) { let mut next_visit = self.front_layer.iter_nodes().copied().collect::>(); let mut to_visit = Vec::new(); - let mut decremented: IndexMap = - IndexMap::with_hasher(ahash::RandomState::default()); + let mut decremented: IndexMap = + IndexMap::with_hasher(foldhash::fast::RandomState::default()); for layer in self.lookahead_layers.iter_mut() { for node in next_visit.drain(..) { for edge in problem.sabre.dag.edges_directed(node, Direction::Outgoing) { diff --git a/crates/transpiler/src/passes/schedule_analysis/alap_schedule_analysis.rs b/crates/transpiler/src/passes/schedule_analysis/alap_schedule_analysis.rs index 7c2beddef996..e6c2a6235c20 100644 --- a/crates/transpiler/src/passes/schedule_analysis/alap_schedule_analysis.rs +++ b/crates/transpiler/src/passes/schedule_analysis/alap_schedule_analysis.rs @@ -13,7 +13,7 @@ use super::TimeOps; use crate::TranspilerError; use crate::passes::schedule_analysis::{NodeDurations, PyNodeDurations}; -use ahash::RandomState; +use foldhash::fast::RandomState; use hashbrown::HashMap; use indexmap::IndexMap; use pyo3::prelude::*; diff --git a/crates/transpiler/src/passes/schedule_analysis/asap_schedule_analysis.rs b/crates/transpiler/src/passes/schedule_analysis/asap_schedule_analysis.rs index 22cc4a449a21..eff87ac48845 100644 --- a/crates/transpiler/src/passes/schedule_analysis/asap_schedule_analysis.rs +++ b/crates/transpiler/src/passes/schedule_analysis/asap_schedule_analysis.rs @@ -12,7 +12,7 @@ use crate::TranspilerError; use crate::passes::schedule_analysis::{NodeDurations, PyNodeDurations, TimeOps}; -use ahash::RandomState; +use foldhash::fast::RandomState; use hashbrown::HashMap; use indexmap::IndexMap; use pyo3::prelude::*; diff --git a/crates/transpiler/src/passes/schedule_analysis/mod.rs b/crates/transpiler/src/passes/schedule_analysis/mod.rs index 88e0599ec268..01a75b471230 100644 --- a/crates/transpiler/src/passes/schedule_analysis/mod.rs +++ b/crates/transpiler/src/passes/schedule_analysis/mod.rs @@ -17,7 +17,7 @@ use std::ops::{ Add, AddAssign, Deref, DerefMut, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Sub, SubAssign, }; -use ahash::RandomState; +use foldhash::fast::RandomState; use hashbrown::HashMap; use indexmap::IndexMap; use pyo3::{ diff --git a/crates/transpiler/src/passes/unitary_synthesis/decomposers.rs b/crates/transpiler/src/passes/unitary_synthesis/decomposers.rs index b16d527dcd13..3e9cb5517c0c 100644 --- a/crates/transpiler/src/passes/unitary_synthesis/decomposers.rs +++ b/crates/transpiler/src/passes/unitary_synthesis/decomposers.rs @@ -310,7 +310,7 @@ impl Decomposer2q { /// This exists mostly just to attach methods to and to shorten a bunch of type signatures. #[derive(Clone, Debug, Default)] struct Decomposer2qCacheInner( - IndexMap, ::ahash::RandomState>, + IndexMap, ::foldhash::fast::RandomState>, ); impl Decomposer2qCacheInner { /// Get a decomposer by known-good index. diff --git a/crates/transpiler/src/passes/unitary_synthesis/mod.rs b/crates/transpiler/src/passes/unitary_synthesis/mod.rs index 5021009b9d24..63f1fe9cccfc 100644 --- a/crates/transpiler/src/passes/unitary_synthesis/mod.rs +++ b/crates/transpiler/src/passes/unitary_synthesis/mod.rs @@ -114,7 +114,7 @@ impl Approximation { pub enum QpuConstraint<'a> { Target(&'a Target), Loose { - basis_gates: &'a IndexSet<&'a str, ::ahash::RandomState>, + basis_gates: &'a IndexSet<&'a str, ::foldhash::fast::RandomState>, coupling: &'a HashSet<[PhysicalQubit; 2]>, }, } @@ -674,7 +674,7 @@ pub fn py_unitary_synthesis( run_python_decomposers: true, }; let mut state = UnitarySynthesisState::new(config); - let mut basis_gates_set: IndexSet<&str, ::ahash::RandomState>; + let mut basis_gates_set: IndexSet<&str, ::foldhash::fast::RandomState>; let constraint = match target { Some(target) => QpuConstraint::Target(target), None => { @@ -718,7 +718,7 @@ pub fn py_synthesize_unitary_matrix( run_python_decomposers: true, }; let mut state = UnitarySynthesisState::new(config); - let mut basis_gates_set: IndexSet<&str, ::ahash::RandomState>; + let mut basis_gates_set: IndexSet<&str, ::foldhash::fast::RandomState>; let constraint = match target { Some(target) => QpuConstraint::Target(target), None => { diff --git a/crates/transpiler/src/passes/vf2/vf2_layout.rs b/crates/transpiler/src/passes/vf2/vf2_layout.rs index 200ccafd5edc..a5eca4646db6 100644 --- a/crates/transpiler/src/passes/vf2/vf2_layout.rs +++ b/crates/transpiler/src/passes/vf2/vf2_layout.rs @@ -637,7 +637,7 @@ fn map_free_qubits( fn minimize_vf2( vf2: vf2::Vf2, config: &Vf2PassConfiguration, -) -> Option> +) -> Option> where N: vf2::alias::IntoVf2Graph, H: vf2::alias::IntoVf2Graph, diff --git a/crates/transpiler/src/target/mod.rs b/crates/transpiler/src/target/mod.rs index 65916834c23a..f51f43f08729 100644 --- a/crates/transpiler/src/target/mod.rs +++ b/crates/transpiler/src/target/mod.rs @@ -25,7 +25,7 @@ pub use qubit_properties::QubitProperties; use std::{ops::Index, sync::OnceLock}; -use ahash::RandomState; +use foldhash::fast::RandomState; use hashbrown::HashMap; use hashbrown::HashSet; use indexmap::IndexMap;