iqm.error_reduction_tools.twirling.twirling_modifiers.insert_twirling_pi_rotation

iqm.error_reduction_tools.twirling.twirling_modifiers.insert_twirling_pi_rotation#

iqm.error_reduction_tools.twirling.twirling_modifiers.insert_twirling_pi_rotation(registers, qubit, theta, phi, xi)#

Insert a new π rotation (to the right) after the current R gate for twirling.

Implements the identity:

--[R(θ, φ)]--[R(π, ξ)]-- = --[R(θ+π, φ)]--[RZ(2(ξ - φ))]--

followed by commuting the resulting RZ through the now-pending R(π, …):

extra_phi ← ξ - 2(ξ - φ)

The π-rotation counter is incremented and the RZ remainder is stored in virtual_z for later absorption.

Parameters:
  • registers (TrackingRegisters) – Tracking registers (extra_pi, virtual_z, extra_phi are updated).

  • qubit (str) – Qubit identifier.

  • theta (float) – Polar rotation angle of the current gate.

  • phi (float) – Phase angle of the current gate.

  • xi (float) – Phase of the inserted π rotation.

Returns:

Updated theta value.

Return type:

float