o
    }oi}                     @   sL   d dl mZ d dlZd dlmZ ededdd Zeddd	 ZdS )
    )patchN)torchrunztorch.cuda.is_availableztorch.cuda.device_countc                 C   sH   d|_ d| _ tdd}|jdksJ |jdksJ |jddiks"J dS )z5Test torchrun factory with automatic device detectionT   devicesr   TORCH_NCCL_AVOID_RECORD_STREAMS1N)return_valuer   ntasks_per_nodelauncherenv_vars)mock_device_countmock_cuda_availableconfig r   _/home/ubuntu/.local/lib/python3.10/site-packages/tests/collections/llm/recipes/test_executor.py#test_torchrun_with_explicit_devices   s   
r   c                 C   sP   d| _ tt}tdd W d   n1 sw   Y  dt|jv s&J dS )zWTest torchrun factory raises error when CUDA is not available and devices not specifiedFNr   z,Cannot infer the 'ntasks_per_node' parameter)r	   pytestraisesRuntimeErrorr   strvalue)r   exc_infor   r   r   'test_torchrun_raises_error_without_cuda$   s
   r   )unittest.mockr   r   )nemo.collections.llm.recipes.run.executorr   r   r   r   r   r   r   <module>   s   