Skip to content

Commit

Permalink
Avoid iterating over nodes in Split2QUnitaries if there are no unitar…
Browse files Browse the repository at this point in the history
…ies (#13384)

This commit adds a check to the start of the split_2q_unitaries rust
function that is the core of the Split2QUnitaries transpiler pass to do
a lookup if there are any `UnitaryGate` objects in the dag without
iterating over the dag. The pass only will split unitary gates so we
can avoid checking the name of each gate individually if we know there
aren't any up front.
  • Loading branch information
mtreinish authored Oct 31, 2024
1 parent 8a97ef7 commit 4bd2dd8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/accelerate/src/split_2q_unitaries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ pub fn split_2q_unitaries(
dag: &mut DAGCircuit,
requested_fidelity: f64,
) -> PyResult<()> {
if !dag.get_op_counts().contains_key("unitary") {
return Ok(());
}
let nodes: Vec<NodeIndex> = dag.op_nodes(false).collect();

for node in nodes {
Expand Down

0 comments on commit 4bd2dd8

Please sign in to comment.