
    &`io                     N    d dl mZmZ d dlmZmZmZmZ dZ G d de          Z	dS )    )ABCabstractmethod)DictListOptionalTuple"RAY_ACCEL_ENV_VAR_OVERRIDE_ON_ZEROc            	       z   e Zd ZdZeedefd                        Zeedefd                        Zeede	fd                        Z
eedee         fd                        Zeedeeeef                  fd                        Zeededeeee         f         fd	                        Zeedeee                  fd
                        Zeedee         ddfd                        Zedededee	         fd            Zedededee         fd            Zedeeeef                  fd            ZdS )AcceleratorManagerz]This class contains all the functions needed for supporting
    an accelerator family in Ray.returnc                      dS )zGet the name of the resource representing this accelerator family.

        Returns:
            The resource name: e.g., the resource name for NVIDIA GPUs is "GPU"
        N r       y/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/_private/accelerators/accelerator.pyget_resource_namez$AcceleratorManager.get_resource_name         r   c                      dS )zGet the env var that sets the ids of visible accelerators of this family.

        Returns:
            The env var for setting visible accelerator ids: e.g.,
                CUDA_VISIBLE_DEVICES for NVIDIA GPUs.
        Nr   r   r   r   #get_visible_accelerator_ids_env_varz6AcceleratorManager.get_visible_accelerator_ids_env_var   r   r   c                      dS )zGet the total number of accelerators of this family on the current node.

        Returns:
            The detected total number of accelerators of this family.
            Return 0 if the current node doesn't contain accelerators of this family.
        Nr   r   r   r   !get_current_node_num_acceleratorsz4AcceleratorManager.get_current_node_num_accelerators)   r   r   c                      dS )a  Get the type of the accelerator of this family on the current node.

        Currently Ray only supports single accelerator type of
        an accelerator family on each node.

        The result should only be used when get_current_node_num_accelerators() > 0.

        Returns:
            The detected accelerator type of this family: e.g., H100 for NVIDIA GPU.
            Return None if it's unknown or the node doesn't have
            accelerators of this family.
        Nr   r   r   r   !get_current_node_accelerator_typez4AcceleratorManager.get_current_node_accelerator_type3   r   r   c                      dS )a  Get any additional resources required for the current node.

        In case a particular accelerator type requires considerations for
        additional resources (e.g. for TPUs, providing the TPU pod type and
        TPU name), this function can be used to provide the
        additional logical resources.

        Returns:
            A dictionary representing additional resources that may be
            necessary for a particular accelerator type.
        Nr   r   r   r   %get_current_node_additional_resourcesz8AcceleratorManager.get_current_node_additional_resourcesC   r   r   quantityc                     dS )a  Validate the resource request quantity of this accelerator resource.

        Args:
            quantity: The resource request quantity to be validated.

        Returns:
            (valid, error_message) tuple: the first element of the tuple
                indicates whether the given quantity is valid or not,
                the second element is the error message
                if the given quantity is invalid.
        Nr   )r   s    r   "validate_resource_request_quantityz5AcceleratorManager.validate_resource_request_quantityR   r   r   c                      dS )zGet the ids of accelerators of this family that are visible to the current process.

        Returns:
            The list of visiable accelerator ids.
            Return None if all accelerators are visible.
        Nr   r   r   r   +get_current_process_visible_accelerator_idsz>AcceleratorManager.get_current_process_visible_accelerator_idsc   r   r   idsNc                     dS )zSet the ids of accelerators of this family that are visible to the current process.

        Args:
            ids: The ids of visible accelerators of this family.
        Nr   )r    s    r   +set_current_process_visible_accelerator_idsz>AcceleratorManager.set_current_process_visible_accelerator_idsm   r   r   instance_type	instancesc                     dS )a  Get the number of accelerators of this family on ec2 instance with given type.

        Args:
            instance_type: The ec2 instance type.
            instances: Map from ec2 instance type to instance metadata returned by
                ec2 `describe-instance-types`.

        Returns:
            The number of accelerators of this family on the ec2 instance
            with given type.
            Return None if it's unknown.
        Nr   r#   r$   s     r   !get_ec2_instance_num_acceleratorsz4AcceleratorManager.get_ec2_instance_num_acceleratorsv   s	      tr   c                     dS )a  Get the accelerator type of this family on ec2 instance with given type.

        Args:
            instance_type: The ec2 instance type.
            instances: Map from ec2 instance type to instance metadata returned by
                ec2 `describe-instance-types`.

        Returns:
            The accelerator type of this family on the ec2 instance with given type.
            Return None if it's unknown.
        Nr   r&   s     r   !get_ec2_instance_accelerator_typez4AcceleratorManager.get_ec2_instance_accelerator_type   s	     tr   c                      dS )zGet accelerator related Ray node labels of the curent node.

        Returns:
            A dictionary mapping accelerator related label keys to values.
        Nr   r   r   r   #get_current_node_accelerator_labelsz6AcceleratorManager.get_current_node_accelerator_labels   s	     tr   )__name__
__module____qualname____doc__staticmethodr   strr   r   intr   r   r   r   floatr   r   boolr   r   r   r"   dictr'   r)   r+   r   r   r   r   r      s       % % s    ^ \     ^ \ s    ^ \ x}    ^ \ 8De<L3M    ^ \ 	tXc]"	#   ^ \ $s)9L    ^ \ c t    ^ \ '+	#   \" '+	#   \  $sCx.1I    \  r   r   N)
abcr   r   typingr   r   r   r   *RAY_ACCEL_ENV_VAR_OVERRIDE_ON_ZERO_ENV_VARr   r   r   r   <module>r9      s    # # # # # # # # . . . . . . . . . . . . .R *N N N N N N N N N Nr   