o
    }oi                     @   sR   d dl Zd dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
 G dd dZdS )    N)SpecterDataModule)finetunee5_340m)Trainerc                   @   sb   e Zd Zejdddd Zdd Zdd Zd	d
 Zej	
dg ddd Zdd Zdd ZdS )TestE5_340Mclass)scopec                 C   s   t S Nr   )self r   ^/home/ubuntu/.local/lib/python3.10/site-packages/tests/collections/llm/recipes/test_e5_340m.pyrecipe_module   s   zTestE5_340M.recipe_modulec                 C   s   |  }t|tjsJ d S r
   )model
isinstancerunConfig)r   r   model_configr   r   r   
test_model   s   zTestE5_340M.test_modelc                 C   s   |  }t|tjsJ |jtksJ t|jtjsJ |jjtks$J t|j	tjs-J |j	jt
ks5J |j	jdks=J |j	jdksEJ |j	jdksMJ d S )Ni          )finetune_reciper   r   Partial__fn_or_cls__r   trainerr   r   datar   
seq_lengthglobal_batch_sizemicro_batch_sizer   r   reciper   r   r   test_finetune_recipe#   s   z TestE5_340M.test_finetune_recipec                 C   sD   |j dddd}|jjdksJ |jjdksJ |jjdks J d S )Ni      @   )r   r   r   )r   r   r   r   r   r   r   r   r   'test_finetune_recipe_with_custom_values/   s   z3TestE5_340M.test_finetune_recipe_with_custom_valuesznum_nodes,num_gpus_per_node))   r"   )   r   )r   r&   c                 C   s2   |j ||d}|jj|ksJ |jj|ksJ d S )N)	num_nodesnum_gpus_per_node)r   r   r'   devices)r   r   r'   r(   r    r   r   r   2test_finetune_recipe_with_different_configurations9   s   z>TestE5_340M.test_finetune_recipe_with_different_configurationsc                 C   s@   t jtdd |jdd W d    d S 1 sw   Y  d S )NzE5 only supports SFT.)matchlorapeft_scheme)pytestraisesAssertionErrorr   )r   r   r   r   r   test_finetune_recipe_with_peft?   s   "z*TestE5_340M.test_finetune_recipe_with_peftc                 C   s,   |j d d}t|dr|jd u sJ d S d S )Nr-   peft)r   hasattrr3   r   r   r   r   !test_finetune_recipe_without_peftC   s    z-TestE5_340M.test_finetune_recipe_without_peftN)__name__
__module____qualname__r/   fixturer   r   r!   r$   markparametrizer*   r2   r5   r   r   r   r   r      s    



r   )nemo_runr   r/   nemo.collections.llmr   nemo.collections.llm.apir   nemo.collections.llm.recipesr   nemo.lightningr   r   r   r   r   r   <module>   s   