Try to simplify and optimize a quantum circuit.

The purpose of the optimizer is to simplify the circuit to make it cheaper and faster to execute. Different backends may require different types of optimization, but in general the fewer operations a circuit has, the faster it should run. The optimizer thus should convert the circuit into a simpler equivalent circuit.

The optimizations are based on the abstract algebraic properties of the Operations constituting the circuit, e.g., combining two consecutive gates of the same gate family, and at no point should require a matrix representation of any kind. The optimization must also not change the state of the RegRefs in any way.

Currently the optimization is very simple. It

  • merges neighboring state preparations and gates belonging to the same family and acting on the same sequence of subsystems

  • cancels neighboring pairs of a gate and its inverse


seq (Sequence[Command]) – quantum circuit to optimize


optimized circuit

Return type