
    z	i                    Z    S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
   " S S\5      rg	)
z6Transpiler pass to drop gates with negligible effects.    )annotations)
DAGCircuit)Target)TransformationPass)remove_identity_equivc                  N   ^  \ rS rSrSrSSS.     S	U 4S jjjrS
S jrSrU =r$ )RemoveIdentityEquivalent   ac  Remove gates with negligible effects.

Removes gates whose effect is close to an identity operation up to a global phase
and up to the specified tolerance. Parameterized gates are not considered by this pass.

For a cutoff fidelity :math:`f`, this pass removes gates whose average
gate fidelity with respect to the identity is below :math:`f`. Concretely,
a gate :math:`G` is removed if :math:`\bar F < f` where

.. math::

    \bar{F} = \frac{1 + d F_{\text{process}}}{1 + d},\ 

    F_{\text{process}} = \frac{|\mathrm{Tr}(G)|^2}{d^2}

where :math:`d = 2^n` is the dimension of the gate for :math:`n` qubits.
g      ?N)approximation_degreetargetc               :   > [         TU ]  5         Xl        X l        g)a  Initialize the transpiler pass.

Args:
    approximation_degree: The degree to approximate for the equivalence check. This can be a
        floating point value between 0 and 1, or ``None``. If the value is 1 this does not
        approximate above the floating point precision. For a value < 1 this is used as a
        scaling factor for the cutoff fidelity. If the value is ``None`` this approximates up
        to the fidelity for the gate specified in ``target``. In case no ``target`` is set
        we approximate up to ``16 * machine_eps`` as default to account for accumulations
        on few-qubit systems.

    target: If ``approximation_degree`` is set to ``None`` and a :class:`.Target` is provided
        for this field the tolerance for determining whether an operation is equivalent to
        identity will be set to the reported error rate in the target. If
        ``approximation_degree`` (the default) this has no effect, if
        ``approximation_degree=None`` it uses the error rate specified in the ``Target`` for
        the gate being evaluated, and a numeric value other than 1 with ``target`` set is
        used as a scaling factor of the target's error rate.
N)super__init___approximation_degree_target)selfr   r   	__class__s      u/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/transpiler/passes/optimization/remove_identity_equiv.pyr   !RemoveIdentityEquivalent.__init__*   s    , 	%9"    c                F    [        XR                  U R                  5        U$ )N)r   r   r   )r   dags     r   runRemoveIdentityEquivalent.runD   s    c#=#=t||L
r   )r   r   )r   zfloat | Noner   zNone | TargetreturnNone)r   r   r   r   )	__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes____classcell__)r   s   @r   r	   r	      s<    & 7:SW'3CP	 4 r   r	   N)r!   
__future__r   qiskit.dagcircuitr   qiskit.transpiler.targetr   qiskit.transpiler.basepassesr   (qiskit._accelerate.remove_identity_equivr   r	    r   r   <module>r*      s&    = " ( + ; J/1 /r   