o
    }oi
                     @   sR   d dl Zd dlmZ d dlmZ dZejjej	edde
de
dejfd	d
ZdS )    N)llm)PruningConfigdefault)targetnamenemo_checkpoint	save_pathreturnc                 C   s<   t jtj| |t tdddddt jtjdddddd}|S )a  Create a generic pruning recipe.

    This function sets up a complete configuration for pruning, including trainer and data.

    Args:
        nemo_checkpoint (str): The path to the NeMo checkpoint to be pruned.
        save_path (str): The path to save the pruned NeMo checkpoint.

    Returns:
        run.Partial: Partial configuration for pruning.

    Python recipe usage:
        >>> import nemo_run as run
        >>> from nemo.collections import llm
        >>> from nemo.collections.llm.modelopt.recipes import prune_recipe
        >>> recipe = prune_recipe(
        ...     nemo_checkpoint="/path/to/llama3.1-8b/nemo-ckpt/",
        ...     save_path="/path/to/pruned/llama3.1-8b/nemo-ckpt/",
        ... )
        >>> recipe.devices = 8
        >>> recipe.pp_size = 8
        >>> recipe.data = run.Config(
        ...     llm.PreTrainingDataModule,
        ...     paths=["1.0", "path/to/tokenized/data"],
        ...     seq_length=8192,
        ...     micro_batch_size=1,
        ...     global_batch_size=1,  # should be equal to micro_batch_size
        ... )
        >>> recipe.pruning_config.target_ffn_hidden_size = 9216
        >>> recipe.pruning_config.target_hidden_size = 3072
        >>> ...
        >>> run.run(recipe)
       i      )
seq_lengthmicro_batch_sizeglobal_batch_sizeF)
r   r   pruning_configdevices	num_nodestp_sizepp_sizenum_train_samplesdatalegacy_ckpt)runPartialr   pruneConfigr   MockDataModule)r   r   recipe r   f/home/ubuntu/.local/lib/python3.10/site-packages/nemo/collections/llm/modelopt/recipes/prune_recipe.pyprune_recipe   s   $r   )nemo_runr   nemo.collectionsr   nemo.collections.llm.modeloptr   NAMEclifactoryr   strr   r   r   r   r   r   <module>   s   