o
    9wir                     @   s  d dl Z d dlZd dlZd dlmZmZmZm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 d dlmZ d dlmZ d d	lmZ d dddd
d
dd
d
d
d
ddedee dee dee dededee dededededeee eeef f fddZdS )    N)DictListOptionalTuple)RequirementCachecompare_version)Version)XLAAccelerator)num_cuda_devices)MPSAccelerator)_DEEPSPEED_AVAILABLE)_TORCH_GREATER_EQUAL_2_4F)min_cuda_gpus	min_torch	max_torch
min_python	bf16_cudatpumpsskip_windows
standalone	deepspeeddynamor   r   r   r   r   r   r   r   r   r   r   returnc              
   C   s*  g }i }| rt  | k r|d|   d|d< |r/tdtj|ddr/|d| dtj d |rGtdtj|ddrG|d	| dtj d |ritj	j
 d
tj	j d
tj	j }t|t|k ri|d|  |rztj outj  }W n& ttfy } zdt|vpdt|v}|r|d}W Y d}~nd}~ww |r|d |rtjdkr|d |rt s|d d|d< |dur|rt s|d n|st r|d |rtdddkr|d d|d< |	rtrtstdds|d |
rddlm} | s|d  ||fS )!a  Construct reasons for pytest skipif.

    Args:
        min_cuda_gpus: Require this number of gpus and that the ``PL_RUN_CUDA_TESTS=1`` environment variable is set.
        min_torch: Require that PyTorch is greater or equal than this version.
        max_torch: Require that PyTorch is less than this version.
        min_python: Require that Python is greater or equal than this version.
        bf16_cuda: Require that CUDA device supports bf16.
        tpu: Require that TPU is available.
        mps: If True: Require that MPS (Apple Silicon) is available,
            if False: Explicitly Require that MPS is not available
        skip_windows: Skip for Windows platform.
        standalone: Mark the test as standalone, our CI will run it in a separate process.
            This requires that the ``PL_RUN_STANDALONE_TESTS=1`` environment variable is set.
        deepspeed: Require that microsoft/DeepSpeed is installed.
        dynamo: Require that `torch.dynamo` is supported.

    zGPUs>=Tr   torch)use_base_versionztorch>=z, z
 installedztorch<.zpython>=zFound no NVIDIA driverzTorch not compiled with CUDANzCUDA device bf16win32zunimplemented on WindowsTPUr   MPSznot MPSPL_RUN_STANDALONE_TESTS01zStandalone executionr   zdeepspeed.utils)module	Deepspeedr   )is_dynamo_supportedztorch.dynamo)r
   appendr   operatorltr   __version__gesysversion_infomajorminormicror   cudais_availableis_bf16_supportedAssertionErrorRuntimeErrorstrplatformr	   r   osgetenvr   r   r   torch._dynamo.eval_framer%   )r   r   r   r   r   r   r   r   r   r   r   reasonskwargs
py_versioncondexis_unrelatedr%    r@   f/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/lightning/fabric/utilities/testing/_runif.py_runif_reasons   sl    
 






rB   )r'   r7   r+   typingr   r   r   r   r    lightning_utilities.core.importsr   r   packaging.versionr   lightning.fabric.acceleratorsr	   "lightning.fabric.accelerators.cudar
   !lightning.fabric.accelerators.mpsr   %lightning.fabric.strategies.deepspeedr   "lightning.fabric.utilities.importsr   intr5   boolrB   r@   r@   r@   rA   <module>   s`   	
