diff --git a/crates/accelerate/src/unitary_synthesis.rs b/crates/accelerate/src/unitary_synthesis.rs index 0c578e61fce..1e77c0d451c 100644 --- a/crates/accelerate/src/unitary_synthesis.rs +++ b/crates/accelerate/src/unitary_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. -// #[cfg(feature = "cache_pygates")] +#[cfg(feature = "cache_pygates")] use std::cell::OnceCell; use std::f64::consts::PI; use std::hash::Hash; @@ -60,7 +60,7 @@ enum DecomposerType { #[derive(Clone, Debug)] enum UnitarySynthesisReturnType { - DAGType(DAGCircuit), + DAGType(Box), TwoQSequenceType(TwoQubitUnitarySequence), } @@ -185,7 +185,7 @@ fn dag_from_2q_gate_sequence( clbits: target_dag.cargs_interner.get_default(), params: new_params, extra_attrs: None, - // #[cfg(feature = "cache_pygates")] + #[cfg(feature = "cache_pygates")] py_op: OnceCell::new(), }; instructions.push(pi); @@ -423,7 +423,7 @@ fn py_run_default_main_loop( UnitarySynthesisReturnType::DAGType(synth_dag) => synth_dag, UnitarySynthesisReturnType::TwoQSequenceType( synth_sequence, - ) => dag_from_2q_gate_sequence(py, synth_sequence)?, + ) => Box::new(dag_from_2q_gate_sequence(py, synth_sequence)?), }; let _ = out_dag.set_global_phase(add_global_phase( @@ -1060,7 +1060,7 @@ fn synth_su4( }; match preferred_direction { - None => Ok(UnitarySynthesisReturnType::DAGType(synth_dag)), + None => Ok(UnitarySynthesisReturnType::DAGType(Box::new(synth_dag))), Some(preferred_dir) => { let mut synth_direction: Option> = None; for node in synth_dag.topological_op_nodes()? { @@ -1074,7 +1074,7 @@ fn synth_su4( } // synth direction is in the relative basis match synth_direction { - None => Ok(UnitarySynthesisReturnType::DAGType(synth_dag)), + None => Ok(UnitarySynthesisReturnType::DAGType(Box::new(synth_dag))), Some(synth_direction) => { let synth_dir = match synth_direction.as_slice() { [0, 1] => true, @@ -1090,7 +1090,7 @@ fn synth_su4( decomposer_gate_params, ) } else { - Ok(UnitarySynthesisReturnType::DAGType(synth_dag)) + Ok(UnitarySynthesisReturnType::DAGType(Box::new(synth_dag))) } } } @@ -1227,7 +1227,7 @@ fn reversed_synth_su4( let _ = target_dag.push_back(py, inst.clone()); } } - Ok(UnitarySynthesisReturnType::DAGType(target_dag)) + Ok(UnitarySynthesisReturnType::DAGType(Box::new(target_dag))) } #[pymodule]