
    gT	                     Z    d dl mZ d dlmZ dZd Zd	dZd Zedk    r e             dS dS )
    )CustomArgumentParser)merge_fsdp_weightsa!  Utility to merge the weights from multiple FSDP checkpoints into a single combined checkpoint. Should be used if
`SHARDED_STATE_DICT` was used for the model. Weights will be saved to `{output_path}`.

This is a CPU-bound process and requires enough RAM to load the entire model state dict.c                 T    t          | j        | j        | j         | j                   d S N)r   checkpoint_directoryoutput_pathunsafe_serializationremove_checkpoint_dir)argss    U/var/www/html/ai-engine/env/lib/python3.11/site-packages/accelerate/commands/merge.pymerge_commandr      s7    !4#39R5RTXTn        Nc                    | |                      dt                    }nt          t                    }|                    dt          d           |                    dt          d           |                    dd	d
d           |                    dddd
           | |                    t                     |S )Nzmerge-weights)descriptionr   z5A directory containing sharded weights saved by FSDP.)typehelpr   zHThe path to save the merged weights. Defaults to the current directory. z--unsafe_serializationstore_falseFzZWhether to save the merged weights as `.bin` rather than `.safetensors` (not recommended).)actiondefaultr   z--remove_checkpoint_dir
store_truez9Whether to remove the checkpoint directory after merging.)r   r   r   )func)
add_parserr   r   add_argumentstrset_defaultsr   )
subparsersparsers     r   merge_command_parserr       s    &&K&PP%+>>>
.S?vwww
W    
  i	     !H	     ///Mr   c                  h    t                      } |                                 }t          |           d S r   )r   
parse_argsr   )r   r   s     r   mainr!   >   s2    !##FD$r   __main__r   )	accelerate.commands.utilsr   accelerate.utilsr   r   r   r   r!   __name__ r   r   <module>r'      s     ; : : : : : / / / / / /\     <   zDFFFFF r   