Ë
    ÜÓ^j”  ã                   ó¦  — d dl Z d dlmZ d dl mZ ddlmZ ddlmZ ddl	m
Z
mZ dd	lmZ dd
lmZ ddlmZmZmZmZmZmZ ddlmZ  ej2                  e«      Z e
d¬«      e G d„ de«      «       «       Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z  G d„ de«      Z! G d„ dee«      Z" G d„ de«      Z# G d„ d e«      Z$g d!¢Z%y)"é    N)Ústrict)Únné   )Úinitialization)ÚPreTrainedModel)Úauto_docstringÚloggingé   )ÚDeepseekV3Config)ÚDeepseekV3Attention)ÚLlamaDecoderLayerÚLlamaForCausalLMÚ
LlamaModelÚLlamaPreTrainedModelÚLlamaRMSNormÚLlamaRotaryEmbedding)ÚQwen3MLPztencent/Youtu-LLM-2B)Ú
checkpointc                   ó²  ‡ — e Zd ZU dZdZddddœZi ZdZee	d<   dZ
ee	d	<   d
Zee	d<   dZee	d<   dZee	d<   dZee	d<   dZee	d<   dZedz  e	d<   dZedz  e	d<   dZedz  e	d<   dZedz  e	d<   dZeee   z  dz  e	d<   dZee	d<    e«       Z e«       Z e«       Z e«       Z e«       Z e«       Z e«       Z  e«       Z! e«       Z" e«       Z# e«       Z$ˆ fd„Z%ˆ xZ&S )ÚYoutuConfiga   
    rope_interleave (`bool`, *optional*, defaults to `True`):
        Whether to interleave the rotary position embeddings.
    embedding_initializer_range (`float`, *optional*):
        The standard deviation of the truncated_normal_initializer for initializing all embedding matrices.

    ```python
    >>> from transformers import YoutuModel, YoutuConfig
    >>> # Initializing a Youtu-LLM-2B style configuration
    >>> configuration = YoutuConfig()
    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```ÚyoutuÚcolwiseÚrowwise)zlayers.*.mlp.gate_projzlayers.*.mlp.up_projzlayers.*.mlp.down_proji õ Ú
vocab_sizei   Úhidden_sizei   Úintermediate_sizeé    Únum_hidden_layersé   Únum_attention_headsÚnum_key_value_headsi   Úmax_position_embeddingsNÚinitializer_rangeÚembedding_initializer_rangeÚpad_token_idi ô Úbos_token_idiô Úeos_token_idTÚtie_word_embeddingsc                 óâ   •— | j                   €1| j                  dk7  rdd| j                  z  dz  z  | _         nd| _         | j                  xs d| j                   z  | _        t        ‰| �  di |¤Ž y )Nr   g       @g      @g      à?ç{®Gáz”?© )r#   r   r$   ÚsuperÚ__post_init__)ÚselfÚkwargsÚ	__class__s     €úr/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/youtu/modular_youtu.pyr-   zYoutuConfig.__post_init__`   sq   ø€ Ø×!Ñ!Ð)Ø×Ñ 1Ò$Ø),°°d×6FÑ6FÑ0FÈ3Ñ/NÑ)N�Õ&à)-�Ô&à+/×+KÑ+KÒ+kÈsÐUY×UkÑUkÑOkˆÔ(Ü‰ÑÑ' Ó'ó    )'Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typeÚbase_model_tp_planÚattribute_mapr   ÚintÚ__annotations__r   r   r   r    r!   r"   r#   Úfloatr$   r%   r&   r'   Úlistr(   ÚboolÚAttributeErrorÚn_shared_expertsÚn_routed_expertsÚrouted_scaling_factorÚn_groupÚ
topk_groupÚnum_experts_per_tokÚfirst_k_dense_replaceÚnorm_topk_probÚpretraining_tpÚmoe_intermediate_sizeÚnum_mtp_layersr-   Ú__classcell__)r0   s   @r1   r   r   ,   s8  ø… ñð €Jà"+Ø )Ø"+ñÐð
 €Mà€J�ÓØ€K�ÓØ!Ð�sÓ!ØÐ�sÓØ!Ð˜Ó!Ø!Ð˜Ó!Ø#)Ð˜SÓ)Ø&*Ð�u˜t‘|Ó*Ø04Ð ¨¡Ó4Ø#€L�#˜‘*Ó#Ø%€L�#˜‘*Ó%Ø+1€L�#˜˜S™	‘/ DÑ(Ó1Ø $Ð˜Ó$ñ &Ó'ÐÙ%Ó'ÐÙ*Ó,ÐÙÓ€GÙÓ!€JÙ(Ó*ÐÙ*Ó,ÐÙ#Ó%€NÙ#Ó%€NÙ*Ó,ÐÙ#Ó%€N÷(ð (r2   r   c                   ó   — e Zd Zy)ÚYoutuRMSNormN©r3   r4   r5   r+   r2   r1   rM   rM   k   ó   „ Ør2   rM   c                   ó   — e Zd Zy)ÚYoutuRotaryEmbeddingNrN   r+   r2   r1   rQ   rQ   o   rO   r2   rQ   c                   ó   — e Zd Zy)ÚYoutuMLPNrN   r+   r2   r1   rS   rS   s   rO   r2   rS   c                   ó   — e Zd Zy)ÚYoutuAttentionNrN   r+   r2   r1   rU   rU   w   rO   r2   rU   c                   ó   — e Zd Zy)ÚYoutuDecoderLayerNrN   r+   r2   r1   rW   rW   {   rO   r2   rW   c                   ó:   — e Zd Z ej                  «       d„ «       Zy)ÚYoutuPreTrainedModelc                 ó’  — t        j                  | |«       t        | j                  dd«      }t        | j                  dd|z  «      }t	        |t
        j                  «      rft        j                  |j                  d|¬«       |j                  �7t        j                  |j                  j                  |j                     «       y y y )Nr#   r*   r$   r
   g        )ÚmeanÚstd)r   Ú_init_weightsÚgetattrÚconfigÚ
isinstancer   Ú	EmbeddingÚinitÚnormal_ÚweightÚpadding_idxÚzeros_Údata)r.   Úmoduler\   Ú	embed_stds       r1   r]   z"YoutuPreTrainedModel._init_weights€   s•   € ä×%Ñ% d¨FÔ3Ü�d—k‘kÐ#6¸Ó=ˆÜ˜DŸK™KÐ)FÈÈCÉÓPˆ	Ü�fœbŸl™lÔ+Ü�L‰L˜Ÿ™¨S°iÕ@Ø×!Ñ!Ð-Ü—‘˜FŸM™M×.Ñ.¨v×/AÑ/AÑBÕCð .ð ,r2   N)r3   r4   r5   ÚtorchÚno_gradr]   r+   r2   r1   rY   rY      s   „ Ø€U‡]�]ƒ_ñDó ñDr2   rY   c                   ó   — e Zd Zy)Ú
YoutuModelNrN   r+   r2   r1   rm   rm   ‹   rO   r2   rm   c                   ó   — e Zd Zy)ÚYoutuForCausalLMNrN   r+   r2   r1   ro   ro   �   rO   r2   ro   )r   rY   rm   ro   )&rj   Úhuggingface_hub.dataclassesr   r   Ú r   rb   Úmodeling_utilsr   Úutilsr   r	   Ú%deepseek_v3.configuration_deepseek_v3r   Ú deepseek_v3.modeling_deepseek_v3r   Úllama.modeling_llamar   r   r   r   r   r   Úqwen3.modeling_qwen3r   Ú
get_loggerr3   Úloggerr   rM   rQ   rS   rU   rW   rY   rm   ro   Ú__all__r+   r2   r1   ú<module>r{      sÝ   ðó* Ý .Ý å &Ý -ß ,Ý DÝ B÷÷ õ ,ð 
ˆ×	Ñ	˜HÓ	%€ñ Ð1Ô2Øô:(Ð"ó :(ó ó 3ð:(ôz	�<ô 	ô	Ð/ô 	ô	ˆxô 	ô	Ð(ô 	ô	Ð)ô 	ô	DÐ/°ô 	Dô	�ô 	ô	Ð'ô 	ò�r2   