o
    Ti                     @   s`   d dl mZmZ d dlmZmZmZ d dlmZ ddl	m
Z
 G dd deZG dd	 d	eZd
S )    )ABCabstractstaticmethod)AnyDictType)DeepSpeedConfigModel   )DSModuleBasec                   @   s6   e Zd ZU dZeed< eed< i Zeee	f ed< dS )ConfigBundlezi
    A config bundle is a collection of configs that are used to instantiate a model implementation.
    nameconfigimplementation_configN)
__name__
__module____qualname____doc__str__annotations__r   r   r   r    r   r   b/home/ubuntu/.local/lib/python3.10/site-packages/deepspeed/inference/v2/modules/module_registry.pyr
      s
   
 r
   c                   @   sR   e Zd ZdZededefddZede	e fddZ
ededd	fd
dZd	S )DSModuleRegistryBasez]
    Class holding logic for tracking the DSModule implementations of a given interface.
    config_bundlereturnc                 C   sh   |j | jvrtd|j  d| j | j|j  }||js)td|j d| | j|j  |j|jS )z>
        Given a DSModule key, attempt to instantiate
        zUnknown DSModule: z, cls.registry=zConfig z is not supported by )r   registryKeyErrorsupports_configr   
ValueErrorr   )clsr   target_implementationr   r   r   instantiate_config   s   z'DSModuleRegistryBase.instantiate_configc                   C   s   t d)zA
        Return the class associated with this registry.
        z3Must associated a DSModule class with its registry.)NotImplementedErrorr   r   r   r   associated_class)   s   z%DSModuleRegistryBase.associated_classchild_classNc                 C   sB   t ||  std|   d| d|   || j| < |S )z7
        Register a module with this registry.
        z Can only register subclasses of z, z does not inherit from )
issubclassr!   	TypeErrorr   r   )r   r"   r   r   r   register_module0   s   z$DSModuleRegistryBase.register_module)r   r   r   r   classmethodr
   r	   r   r   r   r!   r%   r   r   r   r   r      s    r   N)abcr   r   typingr   r   r   deepspeed.runtime.config_utilsr   	ds_moduler	   r
   r   r   r   r   r   <module>   s   	