
    ցj                     V    S SK r S SKrS SKrS SKJrJr  S SKJrJr  Sr	SS jr
S rS rg)	    N)Versionparse)default_config_fileload_config_from_filezQRun commands across TPU VMs for initial setup before running `accelerate launch`.c                    U b  U R                  S[        S9nO[        R                  " S[        S9nUR	                  SS5      nUR                  S[        S SS9  UR                  S	S S
S9  UR                  SS SS9  UR	                  SS5      nUR                  SSSS9  UR                  SS SS9  UR                  SSSSS9  UR                  SSSS9  UR                  SSSS9  UR                  S SS!S9  U b  UR                  [        S"9  U$ )#Nz
tpu-config)descriptionzAccelerate tpu-config commandzConfig Argumentsz=Arguments that can be configured through `accelerate config`.z--config_filez.Path to the config file to use for accelerate.)typedefaulthelpz
--tpu_namez\The name of the TPU to use. If not specified, will use the TPU specified in the config file.)r
   r   z
--tpu_zonez]The zone of the TPU to use. If not specified, will use the zone specified in the config file.zTPU Argumentsz)Arguments for options ran inside the TPU.z--use_alpha
store_truezWWhether to use `gcloud alpha` when running the TPU training script instead of `gcloud`.)actionr   z--command_filezJThe path to the file containing the commands to run on the pod on startup.	--commandappend+z:A command to run on the pod. Can be passed multiple times.)r   nargsr   z--install_acceleratez<Whether to install accelerate on the pod. Defaults to False.z--accelerate_versionlatestzThe version of accelerate to install on the pod. If not specified, will use the latest pypi version. Specify 'dev' to install from GitHub.z--debugzGIf set, will print the command that would be run instead of running it.)func)	
add_parser_descriptionargparseArgumentParseradd_argument_groupadd_argumentstrset_defaultstpu_command_launcher)
subparsersparserconfig_argspod_argss       Q/mnt/workspace/venv-train/lib/python3.13/site-packages/accelerate/commands/tpu.pytpu_command_parserr"      s   &&|&N(()HVbc++[K =	   k  
 l  
 ((:efHf  
 Y  
 I	   K  
  Z  
 ,-v   !56M    c                 l   S nU R                   c(  [        R                  R                  [        5      (       a  [        U R                   5      nU R                  (       d/  UR                  b"  U R                  (       d  UR                  U l        U R                  (       d  UR                  b  UR                  U l        U R                  (       d  UR                  U l	        U R                  (       d  UR                  U l
        U R                  S:X  a  SU l        OTU R                  S:X  a  SU l        O<[        [        U R                  5      [        5      (       a  SU R                   3U l        U R                  (       d  U R                  (       d  [        S5      eU R                  (       aB  [!        U R                  5       nUR#                  5       R%                  5       /U l        S S S 5        [        U R                  S   [&        5      (       a,  U R                   VVs/ s H  o3  H  oDPM     M     snnU l        S/nU R(                  (       a  US	U R                   3/-  nXPR                  -  nS
R+                  U5      U l        S/nU R,                  (       a  US/-  nUSSSSU R                  SU R                  SU R                  SS/-  nU R.                  (       a  [1        SSR+                  U5       35        g [2        R4                  " U5        [1        S5        g ! , (       d  f       GNA= fs  snnf )Ndevz1git+https://github.com/huggingface/accelerate.gitr   zaccelerate -Uzaccelerate==zFYou must specify either a command file or a command to run on the pod.r   zcd /usr/sharezpip install z; gcloudalphacomputetpusztpu-vmsshz--zoner   z--workerallzRunning  zSuccessfully setup pod.)config_fileospathisfiler   r   command_filecommandcommandstpu_nametpu_zoneaccelerate_version
isinstancer   r   
ValueErroropenread
splitlineslistinstall_acceleratejoin	use_alphadebugprint
subprocessrun)argsdefaultsfcmdlinenew_cmds         r!   r   r   Z   ss   H #rww~~6I'J'J()9)9:  X%:%:%Ft|| ( 5 5D|| 1 1 =#,,DL}}$--DM}}$--DM%'"U		 	 H	,"1	E$112G	<	<$01H1H0I"JT\\abb$##$FFH//12DL % $,,q/4(((,EEGl4#:#:";<==||G99W%DL *C~~y C zz#()NN3	
#$G %$
 Fs   ?%LL0
L-c                  N    [        5       n U R                  5       n[        U5        g N)r"   
parse_argsr   )r   rD   s     r!   mainrM      s     !FDr#   rK   )r   r.   rB   packaging.versionr   r   &accelerate.commands.config.config_argsr   r   r   r"   r   rM    r#   r!   <module>rQ      s/   "  	  , ] c:z<%~r#   