
    i7                    4   S r SSKJr  SSKrSSKrSSKJr  SSKJrJ	r	J
r
JrJ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KJrJr  SSKJrJr  SSKJr  SSKJ r   \RB                  " \"5      r# SSSSSSS.               SS jjjr$    SS jr%g)zk
Converters from BackendConfiguration and BackendProperties
model (BackendV1) to Target model (BackendV2).
    )annotationsN)Any)CONTROL_FLOW_OP_NAMES	ForLoopOpIfElseOpSwitchCaseOpWhileLoopOp)Gate)Instruction)get_standard_gate_name_mapping)	Parameter)QubitProperties)InstructionPropertiesTarget)BackendConfigurationBackendProperties)BackendPropertyError)is_fractional_gateT)include_control_flowinclude_fractional_gatescustom_name_mapping	add_delayfilter_faultyc                  SU;   a  [         R                  " S5        / SQn[        5       n	U(       a  U	R                  U5        [        [
        [        [        S.n
SU R                  0n[        U S5      (       a  U R                  US'   [        U S5      (       a  UR                  U R                  5        [        [        U S/ 5      5      n[        [        U S	/ 5      5      n[        U S
/ 5      nU R                   Vs0 s H  oR                  U_M     nn[        R!                  U[        U5      UR#                  [$        5      5      n0 n[        5       n[        5       n/ nU GH  nUU
;   a0  U(       d'  [&        R)                  SU5        UR+                  U5        M:  UU	;   aL  U	U   nU(       d9  [-        U5      (       a)  [&        R)                  SU5        UR+                  U5        M  UUU'   M  UU;   a[  UU   n[/        [1        [2        [        US/ 5      5      5      n[        US/ 5      n[5        UU(       a  [7        US   5      OSUS9UU'   M  [         R                  " SU S3[8        5        UR+                  U5        GM      U H  nUR;                  U5        M     U H  nUR=                  S5      nUR=                  S5      nUR=                  S5      nUR=                  S5      nU Vs/ s H  n[3        U5      PM     nn[?        WUUUS9nUUU'   URA                  U5        M     [B        RE                  U5      n U HJ  nUU;   d  M  [        UU   SS5      =n(       d  M$  [B        RE                  [1        [F        U5      5      U U'   ML     U(       Ga8  S*S jn![I        U RJ                  5       V"s1 s H  n"URM                  U"5      (       a  M  U"iM     nn"/ n#[I        SU RJ                  5       Hf  n$ URO                  U$S9n%U#R+                  [S        U%R=                  SS5      S   U%R=                  SS5      S   U%R=                  SS5      S   S95        Mh     U#US'   U GH  n URU                  U5      RW                  5        H  u  n&n'U(       aN  [        R#                  UU&5      (       d  URY                  UU&5      (       d   U U   U&	 URA                  UU&45        M[  U U   c  0 U U'   [[        U!" U'S5      U!" U'S 5      S!9U U   U&'   M     []        U U   [B        5      (       aD  [_        S" U U   Ra                  5        5       5      (       a  [&        R)                  S#U5        GM  GM  GM     0 U S$'   [I        U RJ                  5       HB  n(U(       a  U(U;   a  M  URO                  U(5      n)[[        U!" U)S%5      U!" U)S&5      S!9U S$   U(4'   MD     U HE  n*U U*   b  M  [I        U RJ                  5       V"s0 s H  n"U(       a  U"U;  d  M  U"4S_M     sn"U U*'   MG     [e        S+0 UD6n+U HQ  n,U,S':X  a	  U(       d  M  U,U
;   a  U+Rg                  U
U,   U,S(9  M-  U+Rg                  UU,   U R=                  U,S5      U,S)9  MS     U+$ s  snf s  snf s  sn"f ! [P         a     GM  f = f! [P         a     GNf = f! [b         a     GM\  f = fs  sn"f ),a  Decode transpiler target from backend data set.

This function generates :class:`.Target`` instance from intermediate
legacy objects such as :class:`.BackendProperties` and :class:`.BackendConfiguration`.
These objects were components of the legacy :class:`.BackendV1` model.

Args:
    configuration: Backend configuration as ``BackendConfiguration``
    properties: Backend property dictionary or ``BackendProperties``
    include_control_flow: Set True to include control flow instructions.
    include_fractional_gates: Set True to include fractioanl gates.
    custom_name_mapping: A name mapping must be supplied for the operation
        not included in Qiskit Standard Gate name mapping, otherwise the operation
        will be dropped in the resulting ``Target`` object.
    add_delay: If True, adds delay to the instruction set.
    filter_faulty: If True, this filters the non-operational qubits.

Returns:
    A ``Target`` instance.
defaultszVBackend defaults have been completely from removed IBM Backends. They will be ignored.)measuredelayreset)if_else
while_loopfor_loopswitch_case
num_qubitsdttiming_constraintsbasis_gatessupported_instructionsinstruction_signatureszControl flow %s is found but the dynamic circuits are disabled for this backend. This instruction is excluded from the backend Target.zwGate %s is found but the fractional gates are disabled for this backend. This gate is excluded from the backend Target.
parameterscoupling_mapr   )namer#   paramszNo gate definition for z can be found and is being excluded from the generated target. You can use `custom_name_mapping` to provide a definition for this operation.r+   
num_clbits)r+   r#   r-   r,   Nc                @    U R                  US 5      =n(       a  US   $ g )Nr   )get)	prop_dict	prop_namendvals      d/home/james-whalen/.local/lib/python3.13/site-packages/qiskit_ibm_runtime/utils/backend_converter.py
_get_value%convert_to_target.<locals>._get_value   s$    !i66u6Qx    )qubitT1)NNT2	frequencyt1t2r:   qubit_properties
gate_errorgate_length)errordurationc              3  (   #    U  H  oS L v   M
     g 7fN ).0vs     r3   	<genexpr>$convert_to_target.<locals>.<genexpr>  s      A'C!I'Cs   zGate properties of instruction %s are not provided for every qubits. This gate is ideal for some qubits and the rest is with finite error. Created backend target may confuse error-aware circuit optimization.r   readout_errorreadout_lengthr   )instructionr+   )rL   
propertiesr+   )r0   dictr1   strreturnr   rE   )4warningswarnr   updater   r	   r   r   n_qubitshasattrr$   r%   setgetattrgatesr+   unionintersectionr   loggerinfoappendr   listmapr   r
   lenRuntimeWarningremover/   r   addrN   fromkeystupleranger#   is_qubit_operationalqubit_propertyKeyErrorr   gate_propertyitemsis_gate_operationalr   
isinstanceanyvaluesr   r   add_instruction)-configurationrM   r   r   r   r   r   kwargsrequiredqiskit_inst_mappingqiskit_control_flow_mappingin_datar&   r'   r(   gategate_configsall_instructionsinst_name_map
faulty_opsfaulty_qubitsunsupported_instructionsr+   qiskit_gatethis_configr,   r*   	signaturer#   r-   param_namesrL   prop_name_mapr4   qr>   qir0   qubits
param_dict	qubit_idx
qubit_propoptarget	inst_names-                                                r3   convert_to_targetr   .   s   > Vd	
 -H 9:""#67 !#	# ]334G }d##%((}233}778 gm]B?@K 8PRT!UV$]4LbQ0=0C0CD0CIItO0CLDyyH++,AB MJEM! !..'L
 )//5&&-d3K,2D[2Q2QE
 )//5"-M$\!
 't,K#ilB)OPQF";CL"&3?3|A/Q#M$ MM)$ 03 3 	 %++D1W !Z )% )
 ,	}}V$]]<0
]]<0
mmL1.9:kd)D/k:!*F
 *dT" ,& MM"23M <&|D'9>4PP|P
 '+mmC|4L&Md# ! 	 ]556
6!j>]>]^_>`A6 	 
 =334B&55B5?	 ## }}T<8; }}T<8;'mm#\ 5  '7"#$D%*4*B*B+%'+&FJ %((??)==dFKK! !.d 3F ; #f~6 $T*2 /1d+2G(\B!+J!F3M$'/'+. mD1488S A'4T':'A'A'CA > >
 KK_ 	>83 %R $&i }778I)}"<#229=J5J _=#J0@A6M)$i\2	 9 $ }778!8A$-)? d
8!M"  gF%		33""7	B # 
 ""))4(,,Y= #  & MY EL ;B
  4  ( ! !. ( &!sn   ;Y:)Y?/ZZ1Z	#AZ,ZBZ,/Z>Z>	
ZZ
Z)%Z,(Z))Z,,
Z;:Z;c           	     R   / n[        U R                  5       HU  u  p# U R                  U5      n U R	                  U5      n U R                  U5      nUR                  [        UUUS95        MW     U$ ! [         a    Sn NRf = f! [         a    Sn NRf = f! [         a    Sn NRf = f)zIUses BackendProperties to construct and return a list of QubitProperties.Nr;   )	enumerater   r<   r   r=   r:   r]   r   )rM   qubit_propsr7   _t_1t_2r:   s          r3   qubit_props_list_from_propsr   ;  s     *,Kj//0	--&C	--&C	",,U3I 	#	
 1( # $ 	C	 $ 	C	 $ 	I	s4   A3BB3BBBBB&%B&rD   )rq   r   rM   r   r   boolr   r   r   zdict[str, Any] | Noner   r   r   r   rP   r   )rM   r   rP   zlist[QubitProperties])&__doc__
__future__r   loggingrQ   typingr   qiskit.circuit.controlflowr   r   r   r   r	   qiskit.circuit.gater
   qiskit.circuitr   %qiskit.circuit.library.standard_gatesr   qiskit.circuit.parameterr   qiskit.providers.backendr   qiskit.transpiler.targetr   r   qiskit_ibm_runtime.modelsr   r   $qiskit_ibm_runtime.models.exceptionsr   qiskit_ibm_runtime.utils.utilsr   	getLogger__name__r[   r   r   rE   r6   r3   <module>r      s   
 #     % & P . 4 B M E = 
		8	$
 %)J "&%)15J'J!J 	J
 #J /J J J JZ!r6   