o
    ©Ì³iª  ã                   @   s0   d dl mZ G dd„ deƒZG dd„ deƒZdS )é    )ÚProtocolc                   @   sB   e Zd ZdZddd„Zddd„Zddd	„Zdd
d„Zddd„ZdS )ÚFTRecipeInterfacea  
    This class provides a loose structure which every LLM fine-tuning recipe
    should follow. Please note that the interface itself should not be a vehicle for
    code reuse. torchtune strictly prohibits implementation inheritance in the codebase.

    A few notes about the design and the need for this interface:
    - This interface is meant to help recipe-writers organize their code in a way
        which is easy to read, understand and extend. Minimizing code duplication is not
        the goal. Recipe-writers are encouraged to copy-paste-modify.

    - This interface is not meant to add constraints. If the interface comes in the
        way of doing stuff, it needs to be updated or a new interface should be
        written to support what might be a new "family" of recipes.
    ÚreturnNc                 K   ó   dS )zÜ
        Responsible for loading ALL of the state for the recipe from the
        checkpoint file, including state for the model, optimizer, dataloader and training
        parameters such as the epoch and seed.
        N© ©ÚselfÚkwargsr   r   úO/home/ubuntu/.local/lib/python3.10/site-packages/torchtune/recipe_interfaces.pyÚload_checkpoint   ó   z!FTRecipeInterface.load_checkpointc                 K   r   )z 
        Responsible for setting up all of the components necessary for training. This includes
        model, optimizer, loss function and dataloader.
        Nr   r   r   r   r
   Úsetup"   ó   zFTRecipeInterface.setupc                 K   r   )z„
        All of the training logic, including the core loop, loss computation, gradient
        accumulation, and backward.
        Nr   r   r   r   r
   Útrain)   r   zFTRecipeInterface.trainc                 K   r   )zÂ
        Responsible for saving ALL of the state for the recipe,
        including state for the model, optimizer, dataloader and training
        parameters such as the epoch and seed.
        Nr   r   r   r   r
   Úsave_checkpoint0   r   z!FTRecipeInterface.save_checkpointc                 K   r   )z8
        Any cleaning up needed for the recipe.
        Nr   r   r   r   r
   Úcleanup8   ó   zFTRecipeInterface.cleanup©r   N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r
   r   
   s    



r   c                   @   s.   e Zd ZdZd
dd„Zd
dd„Zd
dd	„ZdS )ÚEvalRecipeInterfacezÿ
    This class provides a loose structure which every LLM evaluation recipe
    should follow. Please note that the interface itself should not be a vehicle for
    code reuse. torchtune strictly prohibits implementation inheritance in the codebase.
    r   Nc                 K   r   )zk
        Responsible for loading ALL of the state for the recipe from the
        checkpoint file.
        Nr   r   r   r   r
   r   F   r   z#EvalRecipeInterface.load_checkpointc                 K   r   )z\
        Responsible for setting up all of the components necessary for evaluation.
        Nr   r   r   r   r
   r   M   r   zEvalRecipeInterface.setupc                 K   r   )zC
        All of the evaluation logic, including reporting.
        Nr   r   r   r   r
   ÚevaluateS   r   zEvalRecipeInterface.evaluater   )r   r   r   r   r   r   r   r   r   r   r
   r   ?   s
    

r   N)Útypingr   r   r   r   r   r   r
   Ú<module>   s   5