When swap(q1,q2) is implemented by a decomposition to 3 CNOTs and those are decomposed to Ym90;CZ;Y90, then q1 (or otherwise q2, this depends on the details of the decomposition) idles during the first of the 10 cycles of the effective duration of this decomposition on starmon. This means that when q1 is free earlier in the past than q2 that interchanging the operands of swap(q1,q2) to swap(q2,q1) extends the circuit less so is better.
This optimization is implemented in the generic (target independent) part of the router although it is specific to a particular target (starmon).
Adding introspection could solve this: at the first use of this optimization, it is tested by decomposing swap(q1,q2) (and also move(q1,q2)) and 'scheduling' those sequences of primitives; by inspecting the schedule one could detect this idling; and this could be indicated in an attribute of the class for later use.
When swap(q1,q2) is implemented by a decomposition to 3 CNOTs and those are decomposed to Ym90;CZ;Y90, then q1 (or otherwise q2, this depends on the details of the decomposition) idles during the first of the 10 cycles of the effective duration of this decomposition on starmon. This means that when q1 is free earlier in the past than q2 that interchanging the operands of swap(q1,q2) to swap(q2,q1) extends the circuit less so is better. This optimization is implemented in the generic (target independent) part of the router although it is specific to a particular target (starmon). Adding introspection could solve this: at the first use of this optimization, it is tested by decomposing swap(q1,q2) (and also move(q1,q2)) and 'scheduling' those sequences of primitives; by inspecting the schedule one could detect this idling; and this could be indicated in an attribute of the class for later use.