o
    پi0                     @   s   d dl mZmZ d dlmZ zd dl mZ W n ey!   edw d dlmZ G dd deZ	G dd	 d	eZ
G d
d deddZG dd deZee
e dS )    )AutoProcessorPretrainedConfig)ProcessingKwargs)Qwen2_5_VLProcessorzOQwen2_5_VLProcessor can not be found. Please upgrade your transformers version.)DeepseekV2Configc                       s|   e Zd ZU dZeed< 										
								ddededededededededededef fddZ	  Z
S )DotsVisionConfigdots_vit
model_type     *                  h㈵>Fflash_attention_2{Gz?T	embed_dimhidden_sizeintermediate_sizenum_hidden_layersnum_attention_headsnum_channels
patch_sizespatial_merge_sizetemporal_patch_sizerms_norm_epsuse_biasc                    s|   t  jdi | || _|| _|| _|| _|| _|| _|| _|| _	|	| _
|
| _|| _|| _|| _|| _|| _|| _|| _d S )N )super__init__r   r   r   r   r   r   r   r   r   r   r   attn_implementationinitializer_rangeinit_merger_std	is_causal	post_normgradient_checkpointing)selfr   r   r   r   r   r   r   r   r   r   r   r#   r$   r%   r&   r'   r(   kwargs	__class__r    O/home/ubuntu/.local/lib/python3.10/site-packages/sglang/srt/configs/dots_vlm.pyr"      s$   
zDotsVisionConfig.__init__)r
   r
   r   r   r   r   r   r   r   r   Fr   r   r   FTF)__name__
__module____qualname__r	   str__annotations__intfloatboolr"   __classcell__r    r    r+   r-   r      sT   
 	
r   c                       s    e Zd ZdZ fddZ  ZS )DotsVLMConfigdots_vlmc                    sf   t  jdi | |di }|dd| _|dd| _tdi || _tdi || _dg| _	d S )Nvision_configimage_token_idi/ video_token_idiD DotsVLMForCausalLMr    )
r!   r"   get
im_span_idvideo_span_idr   r9   r   language_configarchitectures)r)   r*   r9   r+   r    r-   r"   =   s   zDotsVLMConfig.__init__)r.   r/   r0   r	   r"   r6   r    r    r+   r-   r7   :   s    r7   c                   @   s   e Zd ZdddiiZdS )DotsVLMProcessorKwargstext_kwargspaddingFN)r.   r/   r0   	_defaultsr    r    r    r-   rB   G   s
    rB   F)totalc                       s6   e Zd ZdZddgZdgZdZ	d	 fdd	Z  ZS )
DotsVLMProcessora!  
    Constructs a DotsVLM processor which derives from Qwen2_5_VLProcessor, but overrides the image and video token ids.
    Besides, its tokenizer is a LlamaTokenizerFast instead of Qwen2TokenizerFast.
    [`DotsVLMProcessor`] offers all the functionalities of [`DotsVisionConfig`] and [`LlamaTokenizerFast`]. See the
    [`~DotsVLMProcessor.__call__`] and [`~DotsVLMProcessor.decode`] for more information.
    Args:
        image_processor ([`Qwen2VLImageProcessor`], *optional*):
            The image processor is a required input.
        tokenizer ([`LlamaTokenizerFast`], *optional*):
            The tokenizer is a required input.
        chat_template (`str`, *optional*): A Jinja template which will be used to convert lists of messages
            in a chat into a tokenizable string.
    image_processor	tokenizerchat_template)LlamaTokenizerLlamaTokenizerFastNc                    s   t  j|||d t|dsdn|j| _t|dsdn|j| _t|ds&dn|j| _t|ds1d	n|j| _t|d
d r>|jn|	| jd | _t|dd rS|j
| _
d S |	| jd | _
d S )N)rJ   image_tokenz
<|imgpad|>video_tokenz<|video_pad|>	img_tokenz<|img|>endofimg_tokenz<|endofimg|>r:   r   r;   )r!   r"   hasattrrM   rN   rO   rP   getattrr:   encoder;   )r)   rH   rI   rJ   r*   r+   r    r-   r"   d   s0   

zDotsVLMProcessor.__init__)NNN)	r.   r/   r0   __doc__
attributesvalid_kwargstokenizer_classr"   r6   r    r    r+   r-   rG   O   s    rG   N)transformersr   r   transformers.processing_utilsr   r   ImportErrorsglang.srt.configs.deepseekvl2r   r   r7   rB   rG   registerr    r    r    r-   <module>   s    ,7