
    .`i8                     f    d dl mZ  G d de          Z G d de          Z G d de          ZdS )	    )PretrainedConfigc                   X     e Zd ZdZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d fd	Z xZS )HunYuanVLVisionConfig
hunyuan_vlvision_configgelu    bilinearh㈵>r      N         T                   @     c                     t                      j        di | || _        || _        || _        || _        || _        || _        |s|| _        n|| _        |	| _	        |
| _
        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        d S )N )super__init__
hidden_acthidden_sizeintermediate_sizeinterpolate_modelearnable_mlp_pooling_sizenum_attention_headsnum_key_value_headsnum_channelsnum_hidden_layersout_hidden_size
patch_sizeremove_prenormspatial_merge_sizetemporal_patch_sizerms_norm_epsresize_resolutionimg_max_token_nummax_image_sizemin_image_sizevideo_max_image_sizevideo_min_image_sizeanyres_vit_max_image_sizemax_vit_seq_lentext_hidden_size)selfr   r   r   r    r+   r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r,   r-   r.   r0   r1   r/   r2   r3   r4   kwargs	__class__s                             ~/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/vllm/transformers_utils/configs/hunyuan_vl.pyr   zHunYuanVLVisionConfig.__init__   s    8 	""6"""$&!2 0*D'#6 " 	;':D$$':D$(!2.$,"4#6 (!2!2,,$8!$8!)B&. 0    )r   r	   r
   r   r   r   r   Nr   r   r   r   Tr   r   r   r   r   r   r   r   r   r   r   )__name__
__module____qualname__
model_typebase_config_keyr   __classcell__r7   s   @r8   r   r   	   s        J%O ##$   "&391 91 91 91 91 91 91 91 91 91r9   r   c                   f     e Zd ZdZdZdgZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddef fdZd Z xZ	S )HunYuanVLTextConfiga*  
    This is the configuration class to store the configuration of a [`HunYuanVLTextConfig`]. It is used to instantiate an
    HunYuan model according to the specified arguments, defining the model architecture. Instantiating a configuration
    with the defaults will yield a similar configuration to that of the HunYuan-7B.
    Hunyuan-7B-Instruct [tencent/Hunyuan-7B-Instruct](https://huggingface.co/tencent/Hunyuan-7B-Instruct).

    Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
    documentation from [`PretrainedConfig`] for more information.


    Args:
        vocab_size (`int`, *optional*, defaults to 290943):
            Vocabulary size of the HunYuan model. Defines the number of different tokens that can be represented by the
            `inputs_ids` passed when calling [`HunYuanVLTextConfig`]
        hidden_size (`int`, *optional*, defaults to 4096):
            Dimension of the hidden representations.
        intermediate_size (`int`, *optional*, defaults to 11008):
            Dimension of the MLP representations or shared MLP representations.
        num_hidden_layers (`int`, *optional*, defaults to 32):
            Number of hidden layers in the Transformer decoder.
        num_attention_heads (`int`, *optional*, defaults to 32):
            Number of attention heads for each attention layer in the Transformer decoder.
        num_key_value_heads (`int`, *optional*):
            This is the number of key_value heads that should be used to implement Grouped Query Attention. If
            `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
            `num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
            converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
            by meanpooling all the original heads within that group. For more details checkout [this
            paper](https://huggingface.co/papers/2305.13245). If it is not specified, will default to
            `num_attention_heads`.
        hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
            The non-linear activation function (function or string) in the decoder.
        max_position_embeddings (`int`, *optional*, defaults to 2048):
            The maximum sequence length that this model might ever be used with.
        initializer_range (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        rms_norm_eps (`float`, *optional*, defaults to 1e-05):
            The epsilon used by the rms normalization layers.
        use_cache (`bool`, *optional*, defaults to `True`):
            Whether or not the model should return the last key/values attentions (not used by all models). Only
            relevant if `config.is_decoder=True`.
        pad_token_id (`int`, *optional*, defaults to 0):
            Padding token id.
        bos_token_id (`int`, *optional*, defaults to 1):
            Beginning of stream token id.
        eos_token_id (`int`, *optional*, defaults to 2):
            End of stream token id.
        eod_token_id (int, *optional*, defaults to 3):
            Token ID representing the end-of-document marker. Used to indicate the termination of a text sequence.
            Example: In multi-document processing, this token helps the model distinguish between separate documents.
        pretraining_tp (`int`, *optional*, defaults to 1):
            Experimental feature. Tensor parallelism rank used during pretraining. Please refer to [this
            document](https://huggingface.co/docs/transformers/parallelism) to understand more about it. This value is
            necessary to ensure exact reproducibility of the pretraining results. Please refer to [this
            issue](https://github.com/pytorch/pytorch/issues/76232).
        tie_word_embeddings (`bool`, *optional*, defaults to `False`):
            Whether to tie weight embeddings
        rope_theta (`float`, *optional*, defaults to 10000.0):
            The base period of the RoPE embeddings.
        rope_scaling (`Dict`, *optional*):
            Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling
            strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is
            `{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update
            `max_position_embeddings` to the expected new maximum. See the following thread for more information on how
            these scaling strategies behave:
            https://www.reddit.com/r/LocalLLaMA/comments/14mrgpr/dynamically_scaled_rope_further_increases/. This is an
            experimental feature, subject to breaking API changes in future versions.
        attention_bias (`bool`, defaults to `False`, *optional*, defaults to `False`):
            Whether to use a bias in the query, key, value and output projection layers during self-attention.
        attention_dropout (`float`, *optional*, defaults to 0.0):
            The dropout ratio for the attention probabilities.
        head_dim (`int`, *optional*, defaults to 128):
            The attention head dimension.
    hunyuan_vl_textpast_key_valuesp r    +      Nsilur   {Gz?r   Tr   r   r   r   F     @        r   c                 :   || _         || _        || _        || _        || _        || _        || _        ||}|| _        || _        |	| _	        |
| _
        || _        || _        || _        || _        || _        || _         t#                      j        d||||d| d S )N)pad_token_idbos_token_ideos_token_idtie_word_embeddingsr   )
vocab_sizemax_position_embeddingsr   r   r%   r"   head_dimr#   r   initializer_ranger+   pretraining_tp	use_cache
rope_thetarope_scalingattention_biasattention_dropoutr   r   )r5   rQ   r   r   r%   r"   r#   r   rR   rT   r+   rV   rM   rN   rO   eod_token_idrU   rP   rW   rX   rY   rZ   rS   r6   r7   s                           r8   r   zHunYuanVLTextConfig.__init__   s    4 %'>$&!2!2#6  &"5#6 $!2(,"$(,!2 	
%%% 3		
 	

 	
 	
 	
 	
 	
r9   c                 b   | j         dS t          | j         t                    rt          | j                   dk    rt	          d| j                    | j                             dd          }| j                             dd          }| j                             dd          }||dvrt	          d|           ||t	          d	          |-t          |t                    r|d
k    rt	          d|           |-t          |t                    r|d
k    rt	          d|           dS dS )z<
        Validate the `rope_scaling` configuration.
        Nr   zi`rope_scaling` must be a dictionary with with two fields, `type` and `factor` or `type` and `alpha`, got typefactoralpha)lineardynamiczF`rope_scaling`'s type field must be one of ['linear', 'dynamic'], got zI`rope_scaling`'s factor or alpha field must be have one, got both of noneg      ?z9`rope_scaling`'s factor field must be a float > 1.0, got z8`rope_scaling`'s alpha field must be a float > 1.0, got )rX   
isinstancedictlen
ValueErrorgetfloat)r5   rope_scaling_typerope_scaling_factorrope_scaling_alphas       r8   _rope_scaling_validationz,HunYuanVLTextConfig._rope_scaling_validation   s    $F$+T22 	c$:K6L6LPQ6Q6QK7;7HK K   !-11&$??"/33HdCC!.227DAA$(9AV(V(V+(+ +   &+=+E#   *.66 +:MQT:T:T-*- -   )-u55 *9Ks9R9R,), ,   *)9R9Rr9   )rE   r   rF   rG   rG   NrH   r   rI   r   Tr   r   r   r   r   FrJ   NFrK   N)
r:   r;   r<   __doc__r=   keys_to_ignore_at_inferenceintr   rk   r?   r@   s   @r8   rB   rB   I   s        I IV #J#4"5 !&  $!/7
 7
 	7
 7
 7
 7
 7
 7
r& & & & & & &r9   rB   c                   X     e Zd ZdZeedZdgZ	 	 	 	 	 	 	 	 d fd	Z fdZ	 fdZ
 xZS )HunYuanVLConfigr   )r   text_configrD   N6 7 8 9 : ; c	                     t                      j        di |	 t          |t                    r | j        d         di || _        n| | j        d                     | _        t          |t                    r | j        d         di || _        n| | j        d         di |	| _        || _        || _        || _	        || _
        || _        || _        | j        j        | j        _        |	                    dd           | _        d S )Nr   rq   attn_implementationr   )r   r   rb   rc   sub_configsr   rq   image_token_idim_start_id	im_end_idim_newline_idvideo_start_idvideo_end_idr   r4   pop_attn_implementation)r5   rq   r   r|   r}   r{   r~   r   r   r6   r7   s             r8   r   zHunYuanVLConfig.__init__  s1     	""6"""mT** 	E!B!1/!B!S!S]!S!SD"!B!1/!B!D!DDk4(( 	I>t/>MMMMD >t/>HHHHD,&"*,(.2.>.J+ %+JJ/Dd$K$K!!!r9   c                     t                                          d                              d          x}	  |dvr||j        v rt	          |||           d S t                                          ||           d S )N__dict__rq   )dtype_attn_implementation_internal)r   __getattribute__rf   r   setattr__setattr__)r5   keyvaluerq   r7   s       r8   r   zHunYuanVLConfig.__setattr__,  s    !GG44Z@@DD]SSS[EEE{+++Ke,,,,,GGU+++++r9   c                    dt                                          d          v r>|dvr:t                                          d          }||j        v rt          ||          S t                                          |          S )Nrq   r   )_name_or_pathr=   r   r   )r   r   r   getattr)r5   r   rq   r7   s      r8   r   z HunYuanVLConfig.__getattribute__7  s    EGG44Z@@@@S Q
 F
 F
  ''22=AAKk***{C000ww'',,,r9   )NNrr   rs   rt   ru   rv   rw   )r:   r;   r<   r=   r   rB   rz   rm   r   r   r   r?   r@   s   @r8   rp   rp      s        J.* K $5"5 (L (L (L (L (L (LT	, 	, 	, 	, 	,- - - - - - - - -r9   rp   N)transformersr   r   rB   rp   r   r9   r8   <module>r      s    * ) ) ) ) )=1 =1 =1 =1 =1, =1 =1 =1@n n n n n* n n nbH- H- H- H- H-& H- H- H- H- H-r9   