
    ;iE                     z    S SK Jr  S SKrSSKJrJrJrJrJrJ	r	  SSK
JrJr  SSKJr  SrS	\4S
\4S jjrS rS rg)    )PathN   )is_hpu_availableis_mlu_availableis_musa_availableis_npu_availableis_sdaa_availableis_xpu_available   )ClusterConfigdefault_json_config_file)SubcommandHelpFormatterzFCreate a default config file for Accelerate with only a few flags set.nosave_locationc                 z   [        U5      nUR                  R                  SSS9  UR                  5       (       a  [	        SU S35        gU R                  5       n U S;  a  [        SU  35      eSU S	.n[        5       (       a8  [        R                  R                  5       nXCS
'   SUS'   US:  a  SUS'   OSUS'   [        5       (       a;  [        R                  R                  5       nXSS
'   SUS'   US:  a  SUS'   GOSUS'   GO[        5       (       a;  [        R                  R                  5       nXcS
'   SUS'   US:  a  SUS'   GOMSUS'   GOF[        5       (       a:  [        R                   R                  5       nXsS
'   SUS'   US:  a  SUS'   GOSUS'   O[        R"                  R%                  5       (       a9  [        R"                  R                  5       nXS
'   SUS'   US:  a  SUS'   OSUS'   O['        5       (       a9  [        R(                  R                  5       n	XS
'   SUS'   U	S:  a  SUS'   O_SUS'   OY[+        5       (       a9  [        R,                  R                  5       n
XS
'   SUS'   U
S:  a  SUS'   OSUS'   OSn	SUS'   SUS
'   SUS'   SUS'   SUS'   [/        S0 UD6nUR1                  U5        U$ )a  
Creates and saves a basic cluster config to be used on a local machine with potentially multiple GPUs. Will also
set CPU if it is a CPU-only machine.

Args:
    mixed_precision (`str`, *optional*, defaults to "no"):
        Mixed Precision to use. Should be one of "no", "fp16", or "bf16"
    save_location (`str`, *optional*, defaults to `default_json_config_file`):
        Optional custom save location. Should be passed to `--config_file` when using `accelerate launch`. Default
        location is inside the huggingface cache folder (`~/.cache/huggingface`) but can be overridden by setting
        the `HF_HOME` environmental variable, followed by `accelerate/default_config.yaml`.
T)parentsexist_okz Configuration already exists at zZ, will not override. Run `accelerate config` manually or pass a different `save_location`.F)r   fp16bf16fp8zL`mixed_precision` should be one of 'no', 'fp16', 'bf16', or 'fp8'. Received LOCAL_MACHINE)compute_environmentmixed_precisionnum_processesuse_cpur   	MULTI_MLUdistributed_typeNO
MULTI_SDAA
MULTI_MUSA	MULTI_HPU	MULTI_GPU	MULTI_XPU	MULTI_NPUr   debugenable_cpu_affinity )r   parentmkdirexistsprintlower
ValueErrorr   torchmludevice_countr	   sdaar   musar   hpucudais_availabler
   xpur   npur   to_json_file)r   r   pathconfignum_mlus	num_sdaas	num_musasnum_hpusnum_gpusnum_xpusnum_npuss              r/home/dmtnaga/Documents/work/airagagent/rag_env/lib/python3.13/site-packages/accelerate/commands/config/default.pywrite_basic_configrC   $   s    DKKdT2{{}}.}o  >X  Y	
 %++-O;;Z[jZkl
 	
  /*F 99))+"*!ya<)4F%&)-F%&JJ++-	"+!yq=)5F%&)-F%&			JJ++-	"+!yq=)5F%&)-F%&			99))+"*!ya<)4F%&)-F%&		 	 	"	"::**,"*!ya<)4F%&)-F%&			99))+"*!ya<)4F%&)-F%&			99))+"*!ya<)4F%&)-F%& y"#%)!"F7O$)F !$V$F
K    c                     U R                  SU[        [        S9n U R                  S[        SSS9  U R                  S/ SQ[
        S	S
S9  U R                  [        S9  U $ )Ndefault)r   helpformatter_classz--config_fileaT  The path to use to store the config file. Will default to a file named default_config.yaml in the cache location, which is the content of the environment `HF_HOME` suffixed with 'accelerate', or if you don't have such an environment variable, your cache directory ('~/.cache' or the content of `XDG_CACHE_HOME`) suffixed with 'huggingface'.r   )rF   rG   destz--mixed_precision)r   r   r   zWhether or not to use mixed precision training. Choose between FP16 and BF16 (bfloat16) training. BF16 training is only supported on Nvidia Ampere GPUs and PyTorch 1.10 or later.r   )choicestyperG   rF   )func)
add_parserdescriptionr   add_argumentr   strset_defaultsdefault_config_command)parserr   s     rB   default_command_parserrT      s    y']tuF
("
   
 &[    34MrD   c                 p    [        U R                  U R                  5      nU(       a  [        SU 35        g g )Nz"accelerate configuration saved at )rC   r   r   r+   )argsconfig_files     rB   rR   rR      s2    $T%9%94;M;MNK2;-@A rD   )pathlibr   r.   utilsr   r   r   r   r	   r
   config_argsr   r   config_utilsr   rN   rP   rC   rT   rR   r'   rD   rB   <module>r\      sJ   "    A 1 W (,BZ ^C ^B6BrD   