Skip to content

Commit 4bd2dd8

Browse files
authored
Avoid iterating over nodes in Split2QUnitaries if there are no unitaries (#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.
1 parent 8a97ef7 commit 4bd2dd8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

crates/accelerate/src/split_2q_unitaries.rs

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ pub fn split_2q_unitaries(
2828
dag: &mut DAGCircuit,
2929
requested_fidelity: f64,
3030
) -> PyResult<()> {
31+
if !dag.get_op_counts().contains_key("unitary") {
32+
return Ok(());
33+
}
3134
let nodes: Vec<NodeIndex> = dag.op_nodes(false).collect();
3235

3336
for node in nodes {

0 commit comments

Comments
 (0)