§
    º³Ùg7  ã                  óN   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 dd„ZdS )zÖPass 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)ÚPassManagerStagePluginManagerÚpass_manager_configr   Úreturnr   c           
     ó  — t          ¦   «         }| j        }| j        }| j        }| j        pd}| j        pd}| j        pd}| j        pd}| j        }	| j	        pd}
| j        pd}	| j
        }|                     d|| d¬¦  «        }t          j        ||||
|	||¬¦  «        }|                     d|| d¬¦  «        }|s|r|                     d	|| d¬¦  «        }|}nd
}d
}|                     d|| d¬¦  «        }|                     d|
| d¬¦  «        }|r|j        r|�.|                     d¬¦  «        rt          j        ||d¬¦  «        }nt          j        d¬¦  «        }|                     d|	| d¬¦  «        }t#          ||||||||¬¦  «        S )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, and redundant reset removal 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ÚsabreÚ
translatorÚroutingé   )Úoptimization_level)Úlayout_methodÚrouting_methodÚtranslation_methodÚoptimization_methodÚscheduling_methodÚbasis_gatesÚtargetÚinitÚlayoutNÚtranslationÚoptimizationT)Ústrict_directionF)Úremove_reset_in_zeroÚ
scheduling)Úpre_initr   r   r   r   Úpre_optimizationr   r   )r   r   Úcoupling_mapÚinitial_layoutÚinit_methodr   r   r   r   r   r   Úget_passmanager_stager   Ú#generate_control_flow_options_checkÚis_symmetricÚget_non_global_operation_namesÚgenerate_pre_op_passmanagerr   )r   Úplugin_managerr   r!   r"   r#   r   r   r   r   r   r   Ú
routing_pmr   r   r   r   r   r   r    Úscheds                        úb/granary/edev/quantum/lib/python3.11/site-packages/qiskit/transpiler/preset_passmanagers/level3.pyÚlevel_3_pass_managerr-      s\  € õ. 3Ñ4Ô4€NØ%Ô1€KØ&Ô3€LØ(Ô7€NØ%Ô1Ð>°Y€KØ'Ô5ÐB¸€MØ(Ô7ÐB¸7€NØ,Ô?ÐOÀ<ÐØ+Ô=ÐØ-ÔAÐNÀYÐØ+Ô=ÐJÀÐØ Ô'€Fð  ×5Ò5Ø�>Ð#6È1ð 6ñ ô €Jõ
 Ô9Ø#Ø%Ø-Ø/Ø+ØØðñ ô €Hð ×/Ò/Ø�Ð0ÀQð 0ñ ô €Dð ð �~ð Ø×5Ò5Ø�mÐ%8ÈQð 6ñ 
ô 
ˆð ˆˆàˆØˆà ×6Ò6ØÐ)Ð+>ÐSTð 7ñ ô €Kð "×7Ò7ØÐ+Ð-@ÐUVð 8ñ ô €Lð 	ð Z˜\Ô6ð ZØÐ˜v×DÒDÐVZÐDÑ[Ô[Ðå!Ô=Ø�L°uð
ñ 
ô 
ÐÐõ "Ô=ÐSXÐYÑYÔYÐà×0Ò0ØÐ'Ð)<ÐQRð 1ñ ô €Eõ ØØØØØØ)Ø!Øð	ñ 	ô 	ð 	ó    N)r   r   r	   r   )Ú__doc__Ú
__future__r   Ú$qiskit.transpiler.passmanager_configr   Úqiskit.transpiler.passmanagerr   Ú%qiskit.transpiler.preset_passmanagersr   Ú,qiskit.transpiler.preset_passmanagers.pluginr   r-   © r.   r,   ú<module>r6      s›   ððð ð
 #Ð "Ð "Ð "Ð "Ð "Ø BÐ BÐ BÐ BÐ BÐ BØ ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8ðð ð ð ð ð ð
\ð \ð \ð \ð \ð \r.   