o
    
Û¾iZ  ã                   @   s2   d dl mZ d dlmZ G dd„ deƒZdgZdS )é    )ÚAny)ÚPretrainedConfigc                2       sÒ   e Zd ZdZdZdgZ								
																	d/dedededededededededee	e
f dB ded ed!ed"ed#ed$ed%ed&ed'ed(ed)ed*ed+ed,ee	 dB f0‡ fd-d.„Z‡  ZS )0ÚLfm2MoeConfiga  
    This is the configuration class to store the configuration of a [`Lfm2MoeModel`]. It is used to instantiate a LFM2 Moe
    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 LFM2-8B-A1B model.
    e.g. [LiquidAI/LFM2-8B-A1B](https://huggingface.co/LiquidAI/LFM2-8B-A1B)

    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 65536):
            Vocabulary size of the LLaMA model. Defines the number of different tokens that can be represented by the
            `inputs_ids` passed when calling [`Lfm2Model`]
        hidden_size (`int`, *optional*, defaults to 2048):
            Dimension of the hidden representations.
        intermediate_size (`int`, *optional*, defaults to 7168):
            Dimension of the MLP representations.
        moe_intermediate_size (`int`, *optional*, defaults to 1792):
            Intermediate size of the routed expert.
        num_hidden_layers (`int`, *optional*, defaults to 32):
            Number of hidden layers in the Transformer decoder.
        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.
        tie_word_embeddings (`bool`, *optional*, defaults to `True`):
            Whether to tie weight embeddings
        rope_parameters (`dict`, *optional*):
            The parameters of the RoPE embeddings.
        max_position_embeddings (`int`, *optional*, defaults to 128000):
            The maximum sequence length that this model might ever be used with.
        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`.
        norm_eps (`float`, *optional*, defaults to 1e-05):
            The epsilon used by the rms normalization layers.
        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*, defaults to 8):
            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, check out [this
            paper](https://huggingface.co/papers/2305.13245). If it is not specified, will default to
            `num_attention_heads`.
        conv_bias (`bool`, *optional*, defaults to `False`):
            Whether to use bias in the conv layers.
        conv_L_cache (`int`, *optional*, defaults to 3):
            L_cache dim in the conv layers.
        num_dense_layers (`int`, *optional*, defaults to 2):
            Number of dense Lfm2MoeMLP layers in shallow layers(embed->dense->dense->...->dense->moe->moe...->lm_head).
        num_experts_per_tok (`int`, *optional*, defaults to 4):
            Number of selected experts.
        num_experts (`int`, *optional*, defaults to 32):
            Number of routed experts.
        use_expert_bias (`bool`, *optional*, defaults to `True`):
            Whether to use the expert bias on the routing weights.
        routed_scaling_factor (`float`, *optional*, defaults to 1.0):
            Scaling factor for routed experts in MoE models.
        norm_topk_prob (`bool`, *optional*, defaults to `True`):
            Whether to normalize the topk probabilities.
        layer_types (`Optional`, *optional*):
            Type of each layers.

    ```python
    >>> from transformers import Lfm2MoeModel, Lfm2MoeConfig

    >>> # Initializing a LFM2 Moe model
    >>> configuration = Lfm2MoeConfig()

    >>> # Initializing a model from the LFM2-8B-A1B style configuration
    >>> model = Lfm2MoeModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Úlfm2_moeÚpast_key_valuesé   é   é   é   é    r   é   é   TNé ô çñhãˆµøä>é   Fé   é   ç      ð?Ú
vocab_sizeÚhidden_sizeÚintermediate_sizeÚmoe_intermediate_sizeÚnum_hidden_layersÚpad_token_idÚbos_token_idÚeos_token_idÚtie_word_embeddingsÚrope_parametersÚmax_position_embeddingsÚ	use_cacheÚnorm_epsÚnum_attention_headsÚnum_key_value_headsÚ	conv_biasÚconv_L_cacheÚnum_dense_layersÚnum_experts_per_tokÚnum_expertsÚuse_expert_biasÚrouted_scaling_factorÚnorm_topk_probÚlayer_typesc                    sÂ   || _ || _|| _|| _| dd¡}|
d u rd|dœ}
|
| _|| _|| _|| _|| _	|| _
|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _| d|	¡}	tƒ jd||||	dœ|¤Ž d S )NÚ
rope_thetag    €„.AÚdefault)Ú	rope_typer,   Útie_embedding)r   r   r   r   © )r   r   r   r   Úpopr   r   r   r    r!   r"   r#   r$   r%   r   r&   r'   r(   r)   r*   r+   ÚgetÚsuperÚ__init__)Úselfr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   Úkwargsr,   ©Ú	__class__r0   ú\/home/ubuntu/.local/lib/python3.10/site-packages/vllm/transformers_utils/configs/lfm2_moe.pyr4   ]   sD   
ÿü
ûzLfm2MoeConfig.__init__)r   r   r	   r
   r   r   r   r   TNr   Tr   r   r   Fr   r   r   r   Tr   TN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typeÚkeys_to_ignore_at_inferenceÚintÚboolÚdictÚstrr   ÚfloatÚlistr4   Ú__classcell__r0   r0   r7   r9   r      sš    Qçþýüûúùø	÷
öõôóòñðïîíìëêéè
çr   N)Útypingr   Ú transformers.configuration_utilsr   r   Ú__all__r0   r0   r0   r9   Ú<module>   s
    
