Ë
    ÿÍ:jo  ã                   óÌ  — d dl Z d dlmZ d dlmZ d dlmZmZmZm	Z	 d dl
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
lmZ d dlmZmZmZmZmZmZmZmZ d dl m!Z!m"Z"m#Z#m$Z$m%Z%m&Z& d dl'm(Z( d dl)m*Z* d dl+m,Z,m-Z-m.Z.m/Z/m0Z0 d dl1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9 d dl:m;Z; d dl<m=Z=m>Z> d dl?m@Z@ d dlAmBZBmCZC d dlDmEZE d dlFmGZG eee!ef   ZH G d„ d«      ZIdee,   dee.   fd„ZJdeKfd„ZLy)é    N)ÚCounter)ÚIterable)ÚAnyÚOptionalÚUnionÚcast)Úget_args)ÚACCELERATOR_REGISTRY)ÚAccelerator)ÚCUDAAccelerator)ÚMPSAccelerator)ÚXLAAccelerator)ÚBitsandbytesPrecisionÚCheckpointIOÚDeepSpeedPrecisionÚHalfPrecisionÚMixedPrecisionÚ	PrecisionÚTransformerEnginePrecisionÚXLAPrecision)ÚClusterEnvironmentÚLightningEnvironmentÚLSFEnvironmentÚMPIEnvironmentÚSLURMEnvironmentÚTorchElasticEnvironment)ÚDoublePrecision)ÚFSDPPrecision)Ú_PRECISION_INPUTÚ_PRECISION_INPUT_INTÚ_PRECISION_INPUT_STRÚ_PRECISION_INPUT_STR_ALIASÚ%_PRECISION_INPUT_STR_ALIAS_CONVERSION)ÚSTRATEGY_REGISTRYÚDeepSpeedStrategyÚParallelStrategyÚSingleDeviceStrategyÚSingleDeviceXLAStrategyÚStrategyÚXLAFSDPStrategyÚXLAStrategy)Ú_DDP_FORK_ALIASES)Ú_FSDP_ALIASESÚFSDPStrategy)ÚModelParallelStrategy)Úrank_zero_infoÚrank_zero_warn)Ú_determine_root_gpu_device)Ú_IS_INTERACTIVEc                   óš  — e Zd ZdZ	 	 	 	 	 	 ddeeef   deeef   deee	   ee	f   de	de
e   de
eeee   f      d	dfd
„Zdeeef   deeef   de
e   de
eeee   f      d	df
d„Zdeee	   ee	f   de	d	dfd„Zed	efd„«       Zed	efd„«       Zdd„Zdd„Zd	efd„Zd	eeef   fd„Zdd„Zdd„Zd	efd„Zdd„Zedededed	efd„«       Zy)Ú
_Connectoraf  The Connector parses several Fabric arguments and instantiates the Strategy including its owned components.

        A. accelerator flag could be:
            1. accelerator class
            2. accelerator str
            3. accelerator auto

        B. strategy flag could be:
            1. strategy class
            2. strategy str registered with STRATEGY_REGISTRY
            3. strategy str in _strategy_type enum which listed in each strategy as
               backend (registered these too, and _strategy_type could be deprecated)

        C. plugins flag could be:
            1. precision class (should be removed, and precision flag should allow user pass classes)
            2. checkpoint_io class
            3. cluster_environment class

    priorities which to take when:
        A. Class > str
        B. Strategy > Accelerator/precision/plugins

    NÚacceleratorÚstrategyÚdevicesÚ	num_nodesÚ	precisionÚpluginsÚreturnc                 ó¢  — | j                  d|d¬«      }| j                  d|d¬«      }| j                  d|d¬«      }t        | j                  d|d¬«      «      }| j                  d|d ¬«      }t        j                  «       | _        t        j                  «       | _        d| _        d| _	        d	| _
        d | _        d | _        g | _        d | _        | j                  ||||¬
«       | j!                  ||¬«       | j                  dk(  r| j#                  «       | _	        n$| j                  dk(  r| j%                  «       | _	        | j'                  «        | j)                  «       | _        | j                  dk(  r| j-                  «       | _        | j/                  «        | j1                  «        | j3                  «       | _        | j7                  «        y )Nr6   Úauto)Údefaultr7   r8   r9   é   r:   ú32-true)r7   r6   r:   r;   )r8   r9   Úgpu)Ú_argument_from_envÚintr$   Úavailable_strategiesÚ_registered_strategiesr
   Úavailable_acceleratorsÚ_registered_acceleratorsÚ_strategy_flagÚ_accelerator_flagÚ_precision_inputÚ_precision_instanceÚ_cluster_environment_flagÚ_parallel_devicesÚcheckpoint_ioÚ!_check_config_and_set_final_flagsÚ(_check_device_config_and_set_final_flagsÚ_choose_auto_acceleratorÚ_choose_gpu_accelerator_backendÚ*_set_parallel_devices_and_init_acceleratorÚ$_choose_and_init_cluster_environmentÚcluster_environmentÚ_choose_strategyÚ_check_strategy_and_fallbackÚ_init_strategyÚ_check_and_init_precisionr:   Ú_lazy_init_strategy)Úselfr6   r7   r8   r9   r:   r;   s          úo/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/lightning_fabric/connector.pyÚ__init__z_Connector.__init__c   sÉ  € ð ×-Ñ-¨m¸[ÐRXÐ-ÓYˆØ×*Ñ*¨:°xÈÐ*ÓPˆØ×)Ñ)¨)°WÀfÐ)ÓMˆÜ˜×/Ñ/°¸YÐPQÐ/ÓRÓSˆ	Ø×+Ñ+¨K¸ÈDÐ+ÓQˆ	ô '8×&LÑ&LÓ&NˆÔ#Ü(<×(SÑ(SÓ(UˆÔ%ð
 5;ˆÔØ:@ˆÔØ6?ˆÔØ8<ˆÔ ØSWˆÔ&ØFHˆÔØ59ˆÔà×.Ñ.ØØ#ØØð	 	/ô 	
ð 	×5Ñ5¸gÐQZÐ5Ô[ð ×!Ñ! VÒ+Ø%)×%BÑ%BÓ%DˆDÕ"Ø×#Ñ# uÒ,Ø%)×%IÑ%IÓ%KˆDÔ"à×7Ñ7Ô9ð 8<×7`Ñ7`Ó7bˆÔ ð ×Ñ &Ò(Ø"&×"7Ñ"7Ó"9ˆDÔà×)Ñ)Ô+Ø×ÑÔð ×7Ñ7Ó9ˆŒð 	× Ñ Õ"ó    c                 ó˜
  — |�t        |t        «      s|gn|}t        |t        «      r|j                  «       }|| _        |dk7  r-|| j
                  vrt        |t        «      st        d|›d�«      ‚|| j                  vr?|dvr;t        |t        «      s+t        d|›ddj                  | j                  «      › d	�«      ‚t        |t        «      xr d
|v }t        |t        «      xr d|v }t        |t        «      xr d|v }t        |t        «      xs
 |xs |xs |}t        j                  «       xr |dv xs t        |t        «      }	|	r|rt        d|› d�«      ‚|| _        t        |«      }
|�r=t!        «       }|D ]©  }t        |t"        «      r#|| _        |t"        j&                  xx   dz  cc<   Œ6t        |t(        «      r#|| _        |t(        j&                  xx   dz  cc<   Œit        |t,        «      r#|| _        |t,        j&                  xx   dz  cc<   Œœt1        d|› d�«      ‚ |j3                  «       D ��cg c]  \  }}|dkD  sŒ|‘Œ }}}|rt        ddj                  |«      › d�«      ‚|j5                  t"        j&                  «      r|
�t        d|
› d| j$                  › d�«      ‚|
€dn|
| _        t        | j                  t        «      �rr| j                  j8                  r5| j                  dk7  rt        d«      ‚| j                  j8                  | _        | j                  j:                  r2| j$                  rt        d«      ‚| j                  j:                  | _        | j                  j<                  r2| j*                  rt        d«      ‚| j                  j<                  | _        t?        | j                  dd«      r2| j.                  rt        d«      ‚t?        | j                  d«      | _        tA        | j                  d«      �r6| j                  jB                  �r| j                  jB                  d   jD                  d k(  r[| j                  rH| j                  d!vr:t        d"| j                  jF                  j&                  › d#| j                  › d$�«      ‚d | _        | j                  jB                  d   jD                  d%k(  r[| j                  rH| j                  d&vr:t        d'| j                  jF                  j&                  › d#| j                  › d$�«      ‚d%| _        | j                  jB                  | _$        yyyyc c}}w )(a¯  This method checks:

        1. strategy: whether the strategy name is valid, and sets the internal flags if it is.
        2. accelerator: if the value of the accelerator argument is a type of accelerator (instance or string),
            set self._accelerator_flag accordingly.
        3. precision: The final value of the precision flag may be determined either by the precision argument or
            by a plugin instance.
        4. plugins: The list of plugins may contain a Precision plugin, CheckpointIO, ClusterEnvironment and others.
            Additionally, other flags such as `precision` can populate the list with the
            corresponding plugin instances.

        Nr>   z1You selected an invalid strategy name: `strategy=zÞ`. It must be either a string or an instance of `lightning_fabric.strategies.Strategy`. Example choices: auto, ddp, ddp_spawn, deepspeed, dp, ... Find a complete list of options in our documentation at https://lightning.ai)r>   rB   z7You selected an invalid accelerator name: `accelerator=z`. Available names are: auto, ú, ú.ÚddpÚdpÚ	deepspeed)Úmpsr>   rB   NzYou set `strategy=z�` but strategies from the DDP family are not supported on the MPS accelerator. Either explicitly set `accelerator='cpu'` or change the strategy.r@   zFound invalid type for plugin z?. Expected one of: Precision, CheckpointIO, ClusterEnvironment.zReceived multiple values for z> flags in `plugins`. Expected one value for each type at most.zReceived both `precision=z` and `plugins=z`. Choose one.rA   zLaccelerator set through both strategy class and accelerator flag, choose onezAprecision set through both strategy class and plugins, choose onezEcheckpoint_io set through both strategy class and plugins, choose onerV   zKcluster_environment set through both strategy class and plugins, choose oneÚparallel_devicesr   Úcpu)r>   rh   z!CPU parallel_devices set through z class, but accelerator set to z, please choose one device typeÚcuda)r>   ri   rB   z!GPU parallel_devices set through )%Ú
isinstancer   ÚstrÚlowerrI   rF   r)   Ú
ValueErrorrH   r   Újoinr&   r   Úis_availablerJ   Ú"_convert_precision_to_unified_argsr   r   rL   Ú__name__r   rO   r   rM   Ú	TypeErrorÚitemsÚgetrK   Ú_acceleratorÚ
_precisionÚ_checkpoint_ioÚgetattrÚhasattrrg   ÚtypeÚ	__class__rN   )r\   r7   r6   r:   r;   Ú
is_ddp_strÚ	is_dp_strÚis_deepspeed_strÚis_parallel_strategyÚis_mps_acceleratorÚprecision_inputÚplugins_flags_typesÚpluginÚkÚvÚduplicated_plugin_keys                   r]   rP   z,_Connector._check_config_and_set_final_flags¤   sO  € ð& ÐÜ'1°'¼8Ô'D�w‘iÈ'ˆGä�h¤Ô$Ø—~‘~Ó'ˆHà&ˆÔà�vÒ (°$×2MÑ2MÑ"MÔV`ÐaiÔksÔVtÜØCÀHÀ<ð P`ð `óð ð ˜t×<Ñ<Ñ<Ø ?Ñ2Ü˜{¬KÔ8äØIÈ+Èð Y/Ø/3¯y©y¸×9VÑ9VÓ/WÐ.XÐXYð[óð ô   ¬#Ó.ÒD°5¸HÐ3Dˆ
Ü˜x¬Ó-ÒB°$¸(Ð2Bˆ	Ü% h´Ó4ÒP¸ÈÐ9PÐÜ)¨(Ô4DÓEÒtÈÒtÐW`ÒtÐdtÐÜ+×8Ñ8Ó:ò 
ØÐ7Ð7Òb¼:ÀkÔSaÓ;bð 	ñ Ñ"6ÜØ$ X Jð /fð góð ð
 "-ˆÔä<¸YÓGˆâÜ29³)ÐØ!ò �Ü˜f¤iÔ0Ø/5�DÔ,Ø'¬	×(:Ñ(:Ó;¸qÑ@Ô;Ü ¬Ô5Ø)/�DÔ&Ø'¬×(=Ñ(=Ó>À!ÑCÔ>Ü Ô(:Ô;Ø5;�DÔ2Ø'Ô(:×(CÑ(CÓDÈÑIÔDä#Ø8¸¸ð A<ð <óð ðð  4G×3LÑ3LÓ3N×$X©4¨1¨aÐRSÐVWÓRW¢QÐ$XÐ!Ñ$XÙ$Ü Ø3°D·I±IÐ>SÓ4TÐ3Uð VAð Aóð ð
 #×&Ñ&¤y×'9Ñ'9Ô:¸Ð?ZÜ Ø/°Ð/@ÀÐPT×PhÑPhÐOiÐiwÐxóð ð .=Ð-D¡	È/ˆÔô
 �d×)Ñ)¬8Õ4Ø×"Ñ"×/Ò/Ø×)Ñ)¨VÒ3Ü$Ð%sÓtÐtØ)-×)<Ñ)<×)IÑ)I�Ô&Ø×"Ñ"×-Ò-à×+Ò+Ü$Ð%hÓiÐiØ+/×+>Ñ+>×+IÑ+I�Ô(Ø×"Ñ"×1Ò1Ø×%Ò%Ü$Ð%lÓmÐmØ%)×%8Ñ%8×%GÑ%G�Ô"Ü�t×*Ñ*Ð,AÀ4ÔHØ×1Ò1Ü$Ð%rÓsÐsÜ18¸×9LÑ9LÐNcÓ1d�Ô.ä�t×*Ñ*Ð,>Õ?ÀD×DWÑDW×DhÓDhØ×&Ñ&×7Ñ7¸Ñ:×?Ñ?À5ÒHØ×-Ò-°$×2HÑ2HÐP_Ñ2_Ü(Ø?À×@SÑ@S×@]Ñ@]×@fÑ@fÐ?gð h7Ø7;×7MÑ7MÐ6NÐNmðoóð ð .3�DÔ*Ø×&Ñ&×7Ñ7¸Ñ:×?Ñ?À6ÒIØ×-Ò-°$×2HÑ2HÐPgÑ2gÜ(Ø?À×@SÑ@S×@]Ñ@]×@fÑ@fÐ?gð h7Ø7;×7MÑ7MÐ6NÐNmðoóð ð .4�DÔ*Ø)-×)<Ñ)<×)MÑ)M�Õ&ð EiÐ?ð' 5ùó# %Ys   È;UÉ	Uc                 óN  — t        |t        «      r|dk  rt        d|› d�«      ‚|| _        || _        | j                  g ddfv rbt        | j
                  t        «      r | j
                  j                  j                  n| j
                  }t        d| j                  ›d|› d�«      ‚y )	Nr@   z0`num_nodes` must be a positive integer, but got rb   r   Ú0z`Fabric(devices=z$)` value is not a valid input using z accelerator.)	rj   rD   rm   Ú_num_nodes_flagÚ_devices_flagrJ   r   r{   Ú__qualname__)r\   r8   r9   Úaccelerator_names       r]   rQ   z3_Connector._check_device_config_and_set_final_flags*  s¸   € Ü˜)¤SÔ)¨Y¸ª]ÜÐOÐPYÈ{ÐZ[Ð\Ó]Ð]à(ˆÔØ$ˆÔà×Ñ " a¨ Ñ-ô ˜d×4Ñ4´kÔBð ×&Ñ&×0Ñ0×=Ò=à×+Ñ+ð ô
 Ø" 4×#5Ñ#5Ð"8ð 9Ø*Ð+¨=ð:óð ð .r_   c                  ó‚   — t        j                  «       ryt        j                  «       ryt        j                  «       ryy)zTChoose the accelerator type (str) based on availability when ``accelerator='auto'``.Útpurf   ri   rh   )r   ro   r   r   © r_   r]   rR   z#_Connector._choose_auto_accelerator<  s4   € ô ×&Ñ&Ô(ØÜ×&Ñ&Ô(ØÜ×'Ñ'Ô)ØØr_   c                  ól   — t        j                  «       ryt        j                  «       ryt        d«      ‚)Nrf   ri   zNo supported gpu backend found!)r   ro   r   ÚRuntimeErrorr�   r_   r]   rS   z*_Connector._choose_gpu_accelerator_backendG  s,   € ä×&Ñ&Ô(ØÜ×'Ñ'Ô)ØÜÐ<Ó=Ð=r_   c                 ón  — t        | j                  t        «      r| j                  | _        n2| j                  €J ‚t	        j
                  | j                  «      | _        | j                  j                  }|j                  «       sO| j                  D �cg c]  }t        |   d   j                  «       r|‘Œ  }}t        d|j                  › d|› d�«      ‚| j                  «        |j                  | j                  «      | _        | j                  s!|j                  | j                  «      | _        y y c c}w )Nr6   ú`zª` can not run on your system since the accelerator is not available. The following accelerator(s) is available and can be passed into `accelerator` argument of `Fabric`: rb   )rj   rJ   r   r6   r
   rt   r{   ro   rH   r‘   r‹   Ú _set_devices_flag_if_auto_passedÚparse_devicesrŠ   rN   Úget_parallel_devices)r\   Úaccelerator_clsÚacc_strÚavailable_accelerators       r]   rT   z5_Connector._set_parallel_devices_and_init_acceleratorO  s(  € Ü�d×,Ñ,¬kÔ:Ø,0×,BÑ,BˆDÕà×)Ñ)Ð5Ð5Ð5Ü3×7Ñ7¸×8NÑ8NÓOˆDÔØ×*Ñ*×4Ñ4ˆà×+Ñ+Ô-ð  $×<Ñ<ö%àÜ'¨Ñ0°Ñ?×LÑLÔNò ð%Ð!ð %ô
 Ø�O×0Ñ0Ð1ð 2ð 4Ð4°Að7óð ð 	×-Ñ-Ô/à,×:Ñ:¸4×;MÑ;MÓNˆÔØ×%Ò%Ø%4×%IÑ%IÈ$×J\ÑJ\Ó%]ˆDÕ"ð &ùò%s   Â#D2c                 óp  — | j                   dk7  ry t        r�t        | j                  t        «      rg| j                  j                  «       dkD  rJd| _         t        d| j                  j                  «       › d| j                  j                  «       › d�«       y | j                  j                  «       | _         y )Nr>   r@   zFabric will use only 1 of zm GPUs because it is running inside an interactive / notebook environment. You may try to set `Fabric(devices=zŒ)` but please note that multi-GPU inside interactive / notebook environments is considered experimental and unstable. Your mileage may vary.)rŠ   r3   rj   r6   r   Úauto_device_countr0   ©r\   s    r]   r”   z+_Connector._set_devices_flag_if_auto_passedj  s¥   € Ø×Ñ Ò'ØåÜ˜4×+Ñ+¬_Ô=Ø× Ñ ×2Ñ2Ó4°qÒ8à!"ˆDÔÜØ,¨T×-=Ñ-=×-OÑ-OÓ-QÐ,Rð S^à×#Ñ#×5Ñ5Ó7Ð8ð 9iðiõð "&×!1Ñ!1×!CÑ!CÓ!EˆDÕr_   c                 óÊ   — t        | j                  t        «      r| j                  S t        t        t
        t        fD ]  }|j                  «       sŒ |«       c S  t        «       S )N)	rj   rM   r   r   r   r   r   Údetectr   )r\   Úenv_types     r]   rU   z/_Connector._choose_and_init_cluster_environment|  s]   € Ü�d×4Ñ4Ô6HÔIØ×1Ñ1Ð1ô $ÜÜÜð
ò 	"ˆHð �‰Õ Ù“zÒ!ð	"ô $Ó%Ð%r_   c                 ó8  — | j                   dk(  st        | j                   t        «      r>| j                  rt	        | j                  «      dkD  ryt        | j                  d   ¬«      S | j                  dkD  ryt	        | j                  «      dk  rlt        | j                   t        t        f«      s(t        | j                   t        «      r$| j                   dv rt        | j                  «      }nd}t        |¬«      S t	        | j                  «      dkD  rt        ry	y)
NrŽ   r@   Úxlar   )Údevicerc   )ri   rB   rf   rh   Úddp_fork)rJ   rj   r   rN   Úlenr(   r‰   r   r   rk   r2   r'   r3   )r\   r¢   s     r]   rW   z_Connector._choose_strategyŠ  sæ   € Ø×!Ñ! UÒ*¬j¸×9OÑ9OÔQ_Ô.`Ø×%Ò%¬#¨d×.DÑ.DÓ*EÈÒ*IØä*°$×2HÑ2HÈÑ2KÔLÐLØ×Ñ !Ò#ØÜˆt×%Ñ%Ó&¨!Ò+Ü˜$×0Ñ0´?ÄNÐ2SÔTÜ˜4×1Ñ1´3Ô7¸D×<RÑ<RÐVlÑ<lä3°D×4JÑ4JÓK‘à�ä'¨vÔ6Ð6Üˆt×%Ñ%Ó&¨Ò*­ØØr_   c                 óÂ  — t        | j                  t        «      rdn| j                  }|dk(  r| j                  dk(  rd}|dk(  r| j                  dk(  rt	        |›d�«       d}|t
        v r/d	t        j                  j                  «       vrt        d
|› d�«      ‚|t        v st        | j                  «      t        u r| j                  dvrt        d«      ‚|r|| _        yy)zªChecks edge cases when the strategy selection was a string input, and we need to fall back to a different
        choice depending on other parameters or the environment.Ú ÚfsdprŽ   Úxla_fsdprd   rh   z: is not supported on CPUs, hence setting `strategy='ddp'`.rc   ÚforkzYou selected `Fabric(strategy='zo')` but process forking is not supported on this platform. We recommend `Fabric(strategy='ddp_spawn')` instead.)ri   rB   z’You selected the FSDP strategy but FSDP is only available on GPU. Set `Fabric(accelerator='gpu', ...)` to continue or select a different strategy.N)rj   rI   r)   rJ   r1   r,   ÚtorchÚmultiprocessingÚget_all_start_methodsrm   r-   rz   r.   )r\   Ústrategy_flags     r]   rX   z'_Connector._check_strategy_and_fallbackŸ  sõ   € ô
 )¨×)<Ñ)<¼hÔG™ÈT×M`ÑM`ˆð ˜FÒ" t×'=Ñ'=ÀÒ'FØ&ˆMØ˜DÒ  T×%;Ñ%;¸uÒ%DÜ˜mÐ.Ð.hÐiÔjØ!ˆMØÔ-Ñ-°&Ä×@UÑ@U×@kÑ@kÓ@mÑ2mÜØ1°-°ð ARð Sóð ð
 œ]Ñ*¬d°4×3FÑ3FÓ.GÌ<Ñ.WØ×$Ñ$¨OÑ;Üð?óð ñ Ø"/ˆDÕð r_   c                 óè   — t        | j                  t        t        f«      sJ ‚t        | j                  t        «      r%t	        j
                  | j                  «      | _        y| j                  | _        y)zNInstantiate the Strategy given depending on the setting of ``_strategy_flag``.N)rj   rI   rk   r)   r$   rt   r7   rœ   s    r]   rY   z_Connector._init_strategy»  sS   € ô ˜$×-Ñ-´´X¨Ô?Ð?Ð?Ü�d×)Ñ)¬3Ô/Ü-×1Ñ1°$×2EÑ2EÓFˆD�Mà ×/Ñ/ˆD�Mr_   c                 ó&  — t        | j                  t        «      rKt        | j                  t        «      r%t        | j                  t
        «      st        d«      ‚| j                  S t        | j                  t        t        t        f«      rt        | j                  «      S t        | j                  t        «      rt        | j                  «      S t        | j                  t        «      rt!        | j                  ¬«      S d}t        | j                  t"        «      r9| j                  |vr+t%        d| j                  ›ddj'                  |«      › d�«      ‚| j                  dv rt)        | j                  «      S | j                  d	k(  r
t        «       S | j                  d
k(  r
t+        «       S | j                  dk(  rt-        t.        j0                  ¬«      S | j                  dk(  rt-        t.        j2                  ¬«      S | j                  dk(  r!| j4                  dk(  rt7        d«       d| _        | j                  dv rOt9        | j                  dk(  rdnd«       | j4                  dv r| j4                  nd}t;        | j                  |¬«      S t        d«      ‚)Nz,Bitsandbytes is only supported on CUDA GPUs.)r:   )rA   ú
bf16-mixedú	bf16-trueú16-truezDThe `ModelParallelStrategy` does not support `Fabric(..., precision=z()`. Choose a different precision among: ra   rb   )r²   r±   rA   z64-trueztransformer-engine)Úweights_dtypeztransformer-engine-float16ú16-mixedrh   z�You passed `Fabric(accelerator='cpu', precision='16-mixed')` but AMP with fp16 is not supported on CPU. Using `precision='bf16-mixed'` instead.r°   )r´   r°   z,Using 16-bit Automatic Mixed Precision (AMP)z.Using bfloat16 Automatic Mixed Precision (AMP))rh   rf   ri   )r:   r¢   zNo precision set)rj   rL   r   r   r6   r   r‘   r7   r(   r+   r*   r   rK   r%   r   r.   r   r/   rm   rn   r   r   r   rª   Úbfloat16Úfloat16rJ   r1   r0   r   )r\   Úmp_precision_supportedr¢   s      r]   rZ   z$_Connector._check_and_init_precisionÄ  s;  € Ü�d×.Ñ.´	Ô:Ü˜$×2Ñ2Ô4IÔJÔS]Ø× Ñ ¤/ôTô #Ð#QÓRÐRØ×+Ñ+Ð+Ü�d—m‘mÔ&=¼{ÌOÐ%\Ô]Ü × 5Ñ 5Ó6Ð6Ü�d—m‘mÔ%6Ô7Ü% d×&;Ñ&;Ó<Ð<Ü�d—m‘m¤\Ô2Ü ¨4×+@Ñ+@ÔAÐAØ!RÐÜ�d—m‘mÔ%:Ô;À×@UÑ@UÐ]sÑ@sÜØVÐW[×WlÑWlÐVoð p8Ø8<¿	¹	ÐBXÓ8YÐ7ZÐZ[ð]óð ð × Ñ Ð$<Ñ<Ü  ×!6Ñ!6Ó7Ð7Ø× Ñ  IÒ-Ü“;ÐØ× Ñ  IÒ-Ü"Ó$Ð$Ø× Ñ Ð$8Ò8Ü-¼E¿N¹NÔKÐKØ× Ñ Ð$@Ò@Ü-¼E¿M¹MÔJÐJà× Ñ  JÒ.°4×3IÑ3IÈUÒ3RÜð?ôð %1ˆDÔ!à× Ñ Ð$>Ñ>Üà×(Ñ(¨JÒ6ñ ?àEôð
 04×/EÑ/EÈÑ/W�T×+Ò+Ð]cˆFÜ!¨D×,AÑ,AÈ&ÔQÐQäÐ-Ó.Ð.r_   c                 óÚ  — | j                   | j                  _         | j                  r| j                  | j                  _        | j                  r| j                  | j                  _        t	        | j                  d«      rL| j                  j
                  €| j
                  | j                  _        | j                  j
                  | _        t	        | j                  d«      rM| j                  j                  r| j                  j                  | _        n| j                  | j                  _        t	        | j                  d«      r| j                  | j                  _	        t	        | j                  d«      r| j                  j                  «        | j                  j                  «        t        rO| j                  j                  r9| j                  j                  j                  st        d| j                   ›d�«      ‚t#        | j                   t$        «      rSt#        | j                  t&        t(        t*        f«      s-t-        d| j                  j.                  j0                  › d	�«      ‚yy)
zFLazily set missing attributes on the previously instantiated strategy.rV   Nrg   r9   Ú_set_world_ranksz`Fabric(strategy=a  )` is not compatible with an interactive environment. Run your code as a script, or choose one of the compatible strategies: `Fabric(strategy='dp'|'ddp_notebook')`. In case you are spawning processes yourself, make sure to include the Fabric creation inside the worker function.zsThe `XLAAccelerator` can only be used with a `SingleDeviceXLAStrategy`, `XLAStrategy`, or `XLAFSDPStrategy`. Found rb   )r6   r7   r:   rO   ry   rV   rg   rN   r‰   Ú
_num_nodesr¹   Ú_configure_launcherr3   ÚlauncherÚis_interactive_compatibler‘   rI   rj   r   r(   r+   r*   rm   r{   rq   rœ   s    r]   r[   z_Connector._lazy_init_strategyô  sÄ  € à$(×$4Ñ$4ˆ�‰Ô!Ø�>Š>Ø&*§n¡nˆD�M‰MÔ#Ø×ÒØ*.×*<Ñ*<ˆD�M‰MÔ'Ü�4—=‘=Ð"7Ô8Ø�}‰}×0Ñ0Ð8Ø48×4LÑ4L�—‘Ô1Ø'+§}¡}×'HÑ'HˆDÔ$Ü�4—=‘=Ð"4Ô5Ø�}‰}×-Ò-Ø)-¯©×)GÑ)G�Õ&à15×1GÑ1G�—‘Ô.Ü�4—=‘= +Ô.Ø'+×';Ñ';ˆD�M‰MÔ$Ü�4—=‘=Ð"4Ô5Ø�M‰M×*Ñ*Ô,Ø�‰×)Ñ)Ô+å˜tŸ}™}×5Ò5¸d¿m¹m×>TÑ>T×>nÒ>nÜØ# D×$7Ñ$7Ð#:ð ;8ð 8óð ô �d×&Ñ&¬Ô7Ä
Ø�M‰MÔ3´[Ä/ÐRôA
ô ð-Ø-1¯]©]×-DÑ-D×-MÑ-MÐ,NÈaðQóð ðA
Ð7r_   ÚnameÚcurrentr?   c                 ó   — t         j                  j                  d| j                  «       z   «      }|€|S |�G|t	        |«      k7  r9t	        |«      t	        |«      k7  r"t        «       rt        d| › d|›d| › d|› d�	«      ‚|S )NÚLT_zYour code has `Fabric(ú=z+, ...)` but it conflicts with the value `--zZ` set through the CLI.  Remove it either from the CLI or from the Lightning Fabric object.)ÚosÚenvironrt   Úupperrk   Ú_is_using_clirm   )r¾   r¿   r?   Ú	env_values       r]   rC   z_Connector._argument_from_env  s‘   € ä#%§:¡:§>¡>°%¸$¿*¹*»,Ñ2FÓ#Gˆ	àÐØˆNàÐ  Y´#°g³,Ò%>Ä3ÀwÃ<ÔSVÐW^ÓS_ÒC_ÔdqÔdsÜØ(¨¨¨a°¨{ð ;Ø�V˜1˜Y˜Kð (VðVóð ð
 Ðr_   )r>   r>   r>   r@   NN)r<   N) rq   Ú
__module__r‹   Ú__doc__r   rk   r   r)   ÚlistrD   r   r   Ú_PLUGIN_INPUTr   r^   rP   rQ   ÚstaticmethodrR   rS   rT   r”   r   rU   rW   rX   rY   r   rZ   r[   r   rC   r�   r_   r]   r5   r5   J   sð  „ ñð4 06Ø)/Ø.4ØØ04ØKOñ?#à˜3 Ð+Ñ,ð?#ð ˜˜X˜Ñ&ð?#ð �t˜C‘y # sÐ*Ñ+ð	?#ð
 ð?#ð Ð,Ñ-ð?#ð ˜% ¨x¸Ñ/FÐ FÑGÑHð?#ð 
ó?#ðBDNà˜˜X˜Ñ&ðDNð ˜3 Ð+Ñ,ðDNð Ð,Ñ-ð	DNð
 ˜% ¨x¸Ñ/FÐ FÑGÑHðDNð 
óDNðLÀÀdÈ3ÁiÐQTÐVYÐFYÑ@Zð Ðgjð Ðosó ð$ ð cò ó ðð ð>¨Sò >ó ð>ó^ó6Fð$&Ð6Hó &ð %¨°#¨Ñ"6ó ó*0ó80ð./¨9ó ./ó`'ðR ð ð ¨sð ¸Sð ÀSò ó ñr_   r5   r:   r<   c                 ó^  — | €y t        t        «      t        t        «      z   t        t        «      z   }| |vrt	        dt        | «      › d|› �«      ‚t        | «      } | t        t        «      v r2t        | «      d d dvrt        d| › dt        |    › d�«       t        |    } t        t        | «      S )Nz
Precision z' is invalid. Allowed precision values: é   )Ú32Ú64z`precision=za` is supported for historical reasons but its usage is discouraged. Please set your precision to z	 instead!)
r	   r!   r    r"   rm   Úreprrk   r1   r#   r   )r:   Úsupported_precisions     r]   rp   rp   -  sÉ   € ØÐØô 	Ô%Ó&¬Ô2FÓ)GÑGÌ(ÔSmÓJnÑnð ð Ð+Ñ+Ü˜:¤d¨9£oÐ%6Ð6]Ð^qÐ]rÐsÓtÐtä�I“€Ià”HÔ7Ó8Ñ8Üˆy‹>˜"˜1Ð \Ñ1ÜØ˜i˜[ð )0Ü0UÐV_Ñ0`Ð/aÐajðlôô :¸)ÑDˆ	ÜÔ$ iÓ0Ð0r_   c                  óf   — t        t        t        j                  j	                  dd«      «      «      S )NÚLT_CLI_USEDrˆ   )ÚboolrD   rÃ   rÄ   rt   r�   r_   r]   rÆ   rÆ   C  s!   € Ü””B—J‘J—N‘N =°#Ó6Ó7Ó8Ð8r_   )MrÃ   Úcollectionsr   Úcollections.abcr   Útypingr   r   r   r   rª   Útyping_extensionsr	   Úlightning_fabric.acceleratorsr
   Ú)lightning_fabric.accelerators.acceleratorr   Ú"lightning_fabric.accelerators.cudar   Ú!lightning_fabric.accelerators.mpsr   Ú!lightning_fabric.accelerators.xlar   Úlightning_fabric.pluginsr   r   r   r   r   r   r   r   Ú%lightning_fabric.plugins.environmentsr   r   r   r   r   r   Ú)lightning_fabric.plugins.precision.doubler   Ú'lightning_fabric.plugins.precision.fsdpr   Ú,lightning_fabric.plugins.precision.precisionr   r    r!   r"   r#   Úlightning_fabric.strategiesr$   r%   r&   r'   r(   r)   r*   r+   Úlightning_fabric.strategies.ddpr,   Ú lightning_fabric.strategies.fsdpr-   r.   Ú*lightning_fabric.strategies.model_parallelr/   Úlightning_fabric.utilitiesr0   r1   Ú(lightning_fabric.utilities.device_parserr2   Ú"lightning_fabric.utilities.importsr3   rË   r5   rp   rÕ   rÆ   r�   r_   r]   ú<module>rë      sÅ   ðó 
Ý Ý $ß -Ó -ã Ý &å >Ý AÝ >Ý <Ý <÷	÷ 	ó 	÷÷ õ FÝ A÷õ ÷	÷ 	ó 	õ >ß HÝ Lß EÝ OÝ >à�iÐ!3°\ÐAÑB€÷`ñ `ðF1°(Ð;KÑ2Lð 1ÐQYÐZnÑQoó 1ð,9�tô 9r_   