Ë
    ÜÓ^jP"  ã                   ó
  — d Z ddlmZ ddlmZ ddlmZmZ  e«       rddlm	Z	m
Z
mZmZmZmZmZmZ dZn0ddlmZ ed	   Z	ed
   Z
ed   Zed   Zed   Zed   Zdededefd„ZdZ ed¬«      e G d„ de«      «       «       ZdgZy)zxLSTM configuration.é    )Ústricté   )ÚPreTrainedConfig)Úauto_docstringÚis_xlstm_available)ÚBackendModeTypeÚChunkwiseKernelTypeÚ	DtypeTypeÚSequenceKernelTypeÚStepKernelTypeÚWeightModeTypeÚround_up_to_next_multiple_ofÚxLSTMLargeConfigT)ÚLiteral)ÚtrainÚtrain_with_paddingÚ	inference)úchunkwise--native_autogradzparallel--native_autograd)Úfloat32Úbfloat16Úfloat16Únative_sequence__nativeÚnative)ÚsingleÚfusedÚxÚmultiple_ofÚreturnc                 ó0   — t        | |z   dz
  |z  |z  «      S )z0Rounds up x to the next multiple of multiple_of.é   )Úint)r   r   s     úx/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/xlstm/configuration_xlstm.pyr   r   1   s    € ä�Q˜‘_ qÑ(¨[Ñ8¸KÑGÓHÐHó    FzNX-AI/xLSTM-7b)Ú
checkpointc                   óX  ‡ — e Zd ZU dZdZdZeed<   dZeed<   dZ	edz  ed<   d	Z
eed
<   dZedz  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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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ed0<   d1Z(e)ed2<   dZ*eed3<   d4Z+edz  ed5<   d6Z,edz  ed7<   d8Z-ee.e   z  dz  ed9<   d:Z/eed;<   ˆ fd<„Z0e1d=„ «       Z2e1d>„ «       Z3e1d?„ «       Z4e1d@„ «       Z5dA„ Z6ˆ xZ7S )BÚxLSTMConfigaN  
    num_blocks (int, optional, *optional*, defaults to 32):
        Number of blocks of the xLSTM model, use num_hidden_layers if None.
    num_heads (int, optional, *optional*, defaults to 8):
        Number of heads for the xLSTM Layer/Cell.
    use_bias (bool, optional, *optional*, defaults to `False`):
        Whether to use biases in the xLSTM model.
    norm_reduction_force_float32 (bool, optional, *optional*, defaults to `True`):
        Whether to force the float32 norm reduction op to be done in fp32 precision.
    add_out_norm (bool, optional, *optional*, defaults to `True`):
        Whether to add an output norm after the blocks before the LMHead.
    qk_dim_factor (float, optional, *optional*, defaults to 0.5):
        Scale factor for the query and key dimension.
    v_dim_factor (float, optional, *optional*, defaults to 1.0):
        Scale factor for the value dimension.
    chunkwise_kernel (ChunkwiseKernelType, optional, *optional*, defaults to `"chunkwise--native_autograd"`):
        Kernel type for chunkwise processing mode.
    sequence_kernel (SequenceKernelType, optional, *optional*, defaults to `"native_sequence__native"`):
        Kernel type for sequence processing mode.
    step_kernel (StepKernelType, optional, *optional*, defaults to `"native"`):
        Kernel type for step processing mode.
    mode (BackendModeType, optional, *optional*, defaults to `"inference"`):
        Operation mode (inference is needed for generation).
    chunk_size (int, optional, *optional*, defaults to 64):
        Internal chunk size.
    return_last_states (bool, optional, *optional*, defaults to `True`):
        If to return the last states / cache internally. Needed as True for generation.
    autocast_kernel_dtype (DtypeType, optional, *optional*, defaults to `"bfloat16"`):
        Kernel dtype for the states.
    inference_state_dtype (DtypeType, optional, *optional*, defaults to `"float32"`):
        Kernel dtype for states in inference.
    ffn_proj_factor (float, optional, *optional*, defaults to 2.667):
        Size factor of the post-up projection gated Feed Forward network.
    ffn_round_up_to_multiple_of (int, optional, *optional*, defaults to 64):
        Size factor round value of the post-up projection gated Feed Forward network.
    gate_soft_cap (float, optional, *optional*, defaults to 15.0):
        Gate soft cap scale.
    output_logit_soft_cap (float, optional, *optional*, defaults to 30.0):
        Output logit soft cap scale.
    weight_mode (`Literal`, *optional*, defaults to `"single"`):
        Whether parallel linear layers are separated or fused (single).
    max_inference_chunksize (int, optional, *optional*, defaults to 16384):
        Limit the chunk size for inference to save memory.

    Example:

    ```python
    >>> from transformers import xLSTMConfig, xLSTMModel

    >>> # Initializing a xLSTM configuration
    >>> configuration = xLSTMConfig()

    >>> # Initializing a model (with random weights) from the configuration
    >>> model = xLSTMModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Úxlstmi€Ä  Ú
vocab_sizei   Úhidden_sizeNÚembedding_dimé    Únum_hidden_layersÚ
num_blocksé   Ú	num_headsFÚuse_biasTÚnorm_reduction_force_float32Útie_word_embeddingsÚadd_out_normg�íµ ÷Æ°>Únorm_epsg      à?Úqk_dim_factorg      ð?Úv_dim_factorr   Úchunkwise_kernelr   Úsequence_kernelr   Ústep_kernelr   Úmodeé@   Ú
chunk_sizeÚreturn_last_statesr   Úautocast_kernel_dtypeÚepsr   Úinference_state_dtypeg¼t“V@Úffn_proj_factorÚffn_round_up_to_multiple_ofg      .@Úgate_soft_capg      >@Úoutput_logit_soft_capr   Úweight_modeÚ	use_cacher    Úpad_token_idr   Úbos_token_idé   Úeos_token_idi @  Úmax_inference_chunksizec                 ól  •— | j                   �| j                   n| j                  | _         | j                  �| j                  n| j                   | _        | j                  �| j                  n| j                  | _        | j                  �| j                  n| j                  | _        t	        ‰| �  di |¤Ž y )N© )r)   r*   r,   r-   ÚsuperÚ__post_init__)ÚselfÚkwargsÚ	__class__s     €r"   rO   zxLSTMConfig.__post_init__™   s•   ø€ Ø/3×/?Ñ/?Ð/K˜4×+Ò+ÐQU×QcÑQcˆÔØ37×3EÑ3EÐ3Q˜T×/Ò/ÐW[×WgÑWgˆÔØ;?×;QÑ;QÐ;] ×!7Ò!7Ðcg×crÑcrˆÔØ-1¯_©_Ð-H˜$Ÿ/š/Èd×NdÑNdˆŒÜ‰ÑÑ' Ó'r#   c                 óJ   — t        | j                  | j                  z  d¬«      S ©Nr;   )r   )r   r)   r5   ©rP   s    r"   Úqk_dimzxLSTMConfig.qk_dim    s&   € ä+Ø×Ñ˜t×1Ñ1Ñ1Øô
ð 	
r#   c                 óJ   — t        | j                  | j                  z  d¬«      S rT   )r   r)   r6   rU   s    r"   Úv_dimzxLSTMConfig.v_dim§   s&   € ä+Ø×Ñ˜t×0Ñ0Ñ0Øô
ð 	
r#   c                 ó4   — | j                   | j                  z  S ©N)rV   r/   rU   s    r"   Úqk_head_dimzxLSTMConfig.qk_head_dim®   s   € à�{‰{˜dŸn™nÑ,Ð,r#   c                 ó4   — | j                   | j                  z  S rZ   )rX   r/   rU   s    r"   Ú
v_head_dimzxLSTMConfig.v_head_dim²   s   € à�z‰z˜TŸ^™^Ñ+Ð+r#   c                 ó–  — t         �rAt        di d| j                  “d| j                  “d| j                  “d| j
                  “d| j                  “d| j                  “d| j                  “d| j                  “d	| j                  “d
| j                  “d| j                  “d| j                  “d| j                  “d| j                  “d| j                   “d| j"                  “d| j$                  “d| j&                  “d| j(                  “d| j*                  “d| j,                  “d| j.                  “d| j0                  “d| j2                  “ŽS | S )Nr(   r*   r-   r/   r0   r3   r4   r1   r5   r6   r7   r8   r9   r:   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rM   )Úexternal_xlstmr   r(   r)   r,   r/   r0   r3   r4   r1   r5   r6   r7   r8   r9   r:   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rU   s    r"   Úto_xlstm_block_configz!xLSTMConfig.to_xlstm_block_config¶   s‡  € ÞÜ#ò ØŸ?š?ðà"×.Ò.ðð  ×1Ò1ðð Ÿ.š.ð	ð
 Ÿšðð "×.Ò.ðð Ÿšðð .2×-NÒ-Nðð #×0Ò0ðð "×.Ò.ðð "&×!6Ò!6ðð !%× 4Ò 4ðð !×,Ò,ðð  —Y’Yð!ð"  Ÿ?š?ð#ð$ $(×#:Ò#:ð%ð& '+×&@Ò&@ð'ð( —H’Hð)ð* '+×&@Ò&@ð+ð. !%× 4Ò 4ð/ð0 -1×,LÒ,Lð1ð4 #×0Ò0ð5ð6 '+×&@Ò&@ð7ð8 !×,Ò,ð9ð ð> ˆKr#   )8Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typer(   r!   Ú__annotations__r)   r*   r,   r-   r/   r0   Úboolr1   r2   r3   r4   Úfloatr5   r6   r7   r	   r8   r   r9   r   r:   r   r<   r=   r>   r
   r?   r@   rA   rB   rC   rD   rE   r   rF   rG   rH   rJ   ÚlistrK   rO   ÚpropertyrV   rX   r[   r]   r`   Ú__classcell__)rR   s   @r"   r&   r&   8   sÓ  ø… ñ9ðv €Jà€J�ÓØ€K�ÓØ $€M�3˜‘:Ó$ØÐ�sÓØ!€J��d‘
Ó!Ø€IˆsÓØ€HˆdÓØ)-Ð  $Ó-Ø %Ð˜Ó%Ø€L�$ÓØ€HˆeÓØ€M�5ÓØ€L�%ÓØ,HÐÐ)ÓHØ*C€OÐ'ÓCØ"*€K�Ó*Ø'€Dˆ/Ó'Ø€J�ÓØ#Ð˜Ó#Ø'1Ð˜9Ó1Ø€CˆÓØ'0Ð˜9Ó0Ø"€O�UÓ"Ø')Ð Ó)Ø€M�5ÓØ#'Ð˜5Ó'Ø"*€K�Ó*Ø€IˆtÓØ €L�#˜‘*Ó Ø €L�#˜‘*Ó Ø+,€L�#˜˜S™	‘/ DÑ(Ó,Ø#(Ð˜SÓ(ô(ð ñ
ó ð
ð ñ
ó ð
ð ñ-ó ð-ð ñ,ó ð,ö!r#   r&   N)rd   Úhuggingface_hub.dataclassesr   Úconfiguration_utilsr   Úutilsr   r   Úxlstm.xlstm_large.modelr   r	   r
   r   r   r   r   r   r_   Útypingr   r!   r&   Ú__all__rM   r#   r"   ú<module>rr      sÙ   ðñ å .å 3ß 7ñ Ô÷	÷ 	ó 	ð �NåàÐHÑI€OØ!ð	%ñÐð Ð8Ñ9€IØ Ð!:Ñ;ÐØ˜XÑ&€NØÐ.Ñ/€NðI¨ð I¸#ð IÀ#ó Ið €Nñ Ð+Ô,Øô]Ð"ó ]ó ó -ð]ð@ ˆ/�r#   