
    z	ia                    N    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 jrg)
zPass manager for optimization level 3, providing heavy optimization.

Level 3 pass manager: heavy optimization by noise adaptive qubit mapping and
gate cancellation using commutativity rules and unitary synthesis.
    )annotations)PassManagerConfig)StagedPassManager)common)PassManagerStagePluginManagerc           
        [        5       nU R                  nU R                  nU R                  nU R                  =(       d    SnU R
                  =(       d    SnU R                  =(       d    SnU R                  =(       d    SnU R                  =(       d    Sn	U R                  =(       d    Sn
U R                  nUR                  SXpSS9n[        R                  " UUUU	U
UUS9nUR                  SXPSS9nU(       d  U(       a  UR                  SX`SS9nUnOSnSnUR                  S	XSS9nUR                  S
XSS9nUR                  SXSS9n[        UUUUUUUS9$ )a  Level 3 pass manager: heavy optimization by noise adaptive qubit mapping and
gate cancellation using commutativity rules and unitary synthesis.

This pass manager applies the user-given initial layout. If none is given, a search
for a perfect layout (i.e. one that satisfies all 2-qubit interactions) is conducted.
If no such layout is found, and device calibration information is available, the
circuit is mapped to the qubits with best readouts and to CX gates with highest fidelity.

The pass manager then transforms the circuit to match the coupling constraints.
It is then unrolled to the basis, and any flipped cx directions are fixed.
Finally, optimizations in the form of commutative gate cancellation, resynthesis
of two-qubit unitary blocks, redundant reset removal and final layout improvements are
performed.

Args:
    pass_manager_config: configuration of the pass manager.

Returns:
    a level 3 pass manager.

Raises:
    TranspilerError: if the passmanager config is invalid.
defaultrouting   )optimization_level)layout_methodrouting_methodtranslation_methodoptimization_methodscheduling_methodbasis_gatestargetinitlayoutNtranslationoptimization
scheduling)pre_initr   r   r
   r   r   r   )r   r   coupling_mapinitial_layoutinit_methodr   r   r   r   r   r   get_passmanager_stager   #generate_control_flow_options_checkr   )pass_manager_configplugin_managerr   r   r   r   r   r   r   r   r   r   
routing_pmr   r   r   r
   r   r   scheds                       f/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/transpiler/preset_passmanagers/level3.pylevel_3_pass_managerr$      s   0 34N%11K&33L(77N%11>YK'55BM(77D9N,??L9-AANY+==J ''F  55>1 6 J
 99#%-/+H //Q 0 D ~55mQ 6 
  66)ST 7 K "77+UV 8 L 00'QR 1 E !     N)r   r   returnr   )__doc__
__future__r   $qiskit.transpiler.passmanager_configr   qiskit.transpiler.passmanagerr   %qiskit.transpiler.preset_passmanagersr   ,qiskit.transpiler.preset_passmanagers.pluginr   r$    r%   r#   <module>r.      s#   
 # B ; 8
Sr%   