o
    }oi                     @   sv   d dl Zd dlZd dlmZmZ d dlmZ d dlm	Z	 d dl
mZmZ d dlmZ d dlmZmZ G dd	 d	ZdS )
    N)finetunepretrain)MockDataModule)SquadDataModule)Nemotron4Config340BNemotronModelnemotron4_340b)
AutoResumeTrainerc                   @   sZ   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S )TestNemotron4_340Bclass)scopec                 C   s   t S Nr   )self r   e/home/ubuntu/.local/lib/python3.10/site-packages/tests/collections/llm/recipes/test_nemotron4_340b.pyrecipe_module   s   z TestNemotron4_340B.recipe_modulec                 C   s*   |  }t|tjsJ |jtksJ d S r   )model
isinstancerunConfig__fn_or_cls__r   )r   r   r   r   r   r   
test_model   s   zTestNemotron4_340B.test_modelc                 C   sh   |  }|j}t|tjsJ |jtksJ |jdksJ |jdks$J |j	dks+J |j
dks2J d S )N`   i H     )r   configr   r   r   r   r   
num_layershidden_size
seq_lengthnum_attention_heads)r   r   r   nemotron_configr   r   r   test_model_config_parameters$   s   z/TestNemotron4_340B.test_model_config_parametersc                 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 t|jtjs>J |jjtksFJ |jjdksNJ |jjdksVJ |jjdks^J d S )Nr   i 	     )pretrain_reciper   r   Partialr   r   r   r   r   trainerr   datar   r   global_batch_sizemicro_batch_sizer   r   reciper   r   r   test_pretrain_recipe.   s   z'TestNemotron4_340B.test_pretrain_recipeznum_nodes,num_gpus_per_node))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&   r0   devices)r   r   r0   r1   r+   r   r   r   2test_pretrain_recipe_with_different_configurations<   s   zETestNemotron4_340B.test_pretrain_recipe_with_different_configurationsc                 C   s   |j dd}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s7J t|jtjs@J |jjtksHJ |jjdksPJ |jjdksXJ |jjdks`J d S )Nr/   )r0   i      r#   )finetune_reciper   r   r%   r   r   r   r   r   r&   r   r'   r   r   r(   r)   r*   r   r   r   test_finetune_recipeB   s   z'TestNemotron4_340B.test_finetune_recipeN)__name__
__module____qualname__pytestfixturer   r   r"   r,   markparametrizer3   r6   r   r   r   r   r      s    



r   )nemo_runr   r:   nemo.collections.llm.apir   r   "nemo.collections.llm.gpt.data.mockr   #nemo.collections.llm.gpt.data.squadr   'nemo.collections.llm.gpt.model.nemotronr   r   nemo.collections.llm.recipesr	   nemo.lightningr
   r   r   r   r   r   r   <module>   s   