o
    پi.                     @   s`   d dl mZmZmZ d dlmZmZ d dlmZ ee	Z
eG dd dZeG dd dZdS )	    )	dataclassfieldfields)AnyDict)init_loggerc                   @   s^   e Zd ZU eedZeeeeef  ed< ee	dZ
eeef ed< defddZdd Zd	S )

ArchConfigdefault_factorystacked_params_mappingextra_attrsnamec                 C   sH   t | d}|d}|d ur||v r|| S td| jj d| d)N__dict__r   '' object has no attribute ')object__getattribute__getAttributeError	__class____name__)selfr   dextras r   ]/home/ubuntu/.local/lib/python3.10/site-packages/sglang/multimodal_gen/configs/models/base.py__getattr__   s   
zArchConfig.__getattr__c                 C   sV   |t | jv rt| || d S t| d}|d}|d u r%i }||d< |||< d S )Nr   r   )type__dataclass_fields__r   __setattr__r   r   )r   keyvaluer   r   r   r   r   r      s   
zArchConfig.__setattr__N)r   
__module____qualname__r   listr   tuplestr__annotations__dictr   r   r   r   r   r   r   r   r   r      s   
 	r   c                   @   sl   e Zd ZU eedZeed< dd Zdd Zdd Z	d	e
eef d
dfddZd	e
eef d
dfddZdS )ModelConfigr	   arch_configc                 C   s4   t | j|rt| j|S tdt| j d| d)Nr   r   )hasattrr*   getattrr   r   r   )r   r   r   r   r   r   4   s
   zModelConfig.__getattr__c                 C   s   | j  }|S N)r   copyr   stater   r   r   __getstate__<   s   
zModelConfig.__getstate__c                 C   s   | j | d S r-   )r   updater/   r   r   r   __setstate__B   s   zModelConfig.__setstate__source_model_dictreturnNc                 C   sP   | j }dd t|D }| D ]
\}}t||| qt|dr&|  dS dS )z;
        Update arch_config with source_model_dict
        c                 S      h | ]}|j qS r   r   .0fr   r   r   	<setcomp>L       z0ModelConfig.update_model_arch.<locals>.<setcomp>__post_init__N)r*   r   itemssetattrr+   r=   )r   r4   r*   valid_fieldsr    r!   r   r   r   update_model_archG   s   
zModelConfig.update_model_archc                 C   s   d|vsJ ddd t | D }| D ]\}}||v r$t| || qtdt| j| td| t| dr@| 	  d S d S )Nr*   z2Source model config shouldn't contain arch_config.c                 S   r6   r   r7   r8   r   r   r   r;   ]   r<   z2ModelConfig.update_model_config.<locals>.<setcomp>z%s does not contain field '%s'!zInvalid field: r=   )
r   r>   r?   loggerwarningr   r   r   r+   r=   )r   r4   r@   r    r!   r   r   r   update_model_configX   s   

zModelConfig.update_model_config)r   r"   r#   r   r   r*   r'   r   r1   r3   r(   r&   r   rA   rD   r   r   r   r   r)   +   s   
 r)   N)dataclassesr   r   r   typingr   r   1sglang.multimodal_gen.runtime.utils.logging_utilsr   r   rB   r   r)   r   r   r   r   <module>   s   