Skip to content

Commit 9e3a651

Browse files
committed
Don't use a hashset for tracking processed runs
1 parent 9356125 commit 9e3a651

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

crates/transpiler/src/passes/two_qubit_peephole.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use std::sync::Mutex;
1515
#[cfg(feature = "cache_pygates")]
1616
use std::sync::OnceLock;
1717

18-
use hashbrown::HashSet;
1918
use nalgebra::U4;
2019
use num_complex::Complex64;
2120
use pyo3::Python;
@@ -40,9 +39,9 @@ use crate::passes::unitary_synthesis::{
4039
use crate::passes::{UnitarySynthesisConfig, UnitarySynthesisState};
4140
use crate::target::Target;
4241
use qiskit_circuit::PhysicalQubit;
42+
use qiskit_synthesis::linalg::nalgebra_array_view;
4343
use qiskit_synthesis::matrix::two_qubit::blocks_to_matrix;
4444
use qiskit_util::getenv_use_multiple_threads;
45-
use qiskit_synthesis::linalg::nalgebra_array_view;
4645
use thread_local::ThreadLocal;
4746

4847
type MappingIterItem = Option<(TwoQSynthesisResult, [Qubit; 2])>;
@@ -199,7 +198,7 @@ pub fn two_qubit_unitary_peephole_optimize(
199198
};
200199
let run_mapping = run_mapping?;
201200
// After we've computed all the sequences to execute now serially build up a new dag.
202-
let mut processed_runs: HashSet<usize> = HashSet::with_capacity(run_mapping.len());
201+
let mut processed_runs: Vec<bool> = vec![false; run_mapping.len()];
203202
let out_dag = dag.copy_empty_like_with_same_capacity(VarsMode::Alike, BlocksMode::Keep)?;
204203
let mut out_dag_builder = out_dag.into_builder();
205204
let node_mapping = locked_node_mapping.lock().unwrap();
@@ -212,7 +211,7 @@ pub fn two_qubit_unitary_peephole_optimize(
212211
}
213212
let run_index = node_mapping[node.index()];
214213
if run_index != usize::MAX {
215-
if processed_runs.contains(&run_index) {
214+
if processed_runs[run_index] {
216215
continue;
217216
}
218217
// If this is not a two qubit gate then there is a chance this will cause the
@@ -280,7 +279,7 @@ pub fn two_qubit_unitary_peephole_optimize(
280279
})?;
281280
}
282281
out_dag_builder.add_global_phase(&Param::Float(result.sequence.global_phase()))?;
283-
processed_runs.insert(run_index);
282+
processed_runs[run_index] = true;
284283
} else {
285284
let NodeType::Operation(ref instr) = dag.dag()[node] else {
286285
unreachable!("Must be an op node")

0 commit comments

Comments
 (0)