
    ois                     t    S SK 7  S SK JrJr  SSKJrJrJrJr   SSKJrJ	r	   " S S\
5      rg!   \r\r	 N= f)	   )*)LlamaRotaryEmbedding!LlamaLinearScalingRotaryEmbedding    )Qwen2AttentionQwen2DecoderLayer
Qwen2ModelQwen2ForCausalLM)Qwen2SdpaAttentionQwen2FlashAttention2c                   N    \ rS rSr\S 5       r\           SS j5       rSrg)FastQwen2Model&   c                     [        S[        [        [        S9u  pU b(  [	        U[        5       5        [        U 5      [        l        [        [        l	        [        [        l	        [        [        l	        [        [        l	        [        [        l	        [!        ["        5      [$        l	        [&        [(        l	        [+        [$        5        SS Kn[        UR.                  R0                  R2                  l        g )Nqwen2)
model_namerope_modulescaled_rope_moduleattention_moduler   )patch_linear_scalingr   r   r   execglobalseval__init__LlamaAttention_fast_forwardforwardr   r   LlamaDecoderLayer_fast_forwardr   LlamaModel_fast_forwardr	   CausalLM_fast_forward!LlamaModel_fast_forward_inferencer
   PeftModel_fast_forwardPeftModelForCausalLM!fix_prepare_inputs_for_generation(transformers.models.qwen2.modeling_qwen2modelsr   modeling_qwen2Qwen2RotaryEmbedding)	init_namefunctiontransformerss      N/home/james-whalen/.local/lib/python3.13/site-packages/unsloth/models/qwen2.py	pre_patchFastQwen2Model.pre_patch'   s    2 .!B-	
	  79%&*9oN#!<%@"'B$$B!4
#8-$
  (>$)*:; 	8 ! 	!!00E 	    Nc                 N    [         R                  " SU UUUUUUU[        U	U
S.UD6$ )N)r   max_seq_lengthdtypeload_in_4bittoken
device_maprope_scalingfix_tokenizermodel_patchertokenizer_nametrust_remote_code )FastLlamaModelfrom_pretrainedr   )r   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   kwargss               r+   r<   FastQwen2Model.from_pretrainedI   sG     -- 
#+'#')*+ 1
 
 	
r.   r:   )zQwen/Qwen2-7Bi   NTN
sequentialNTNNF)__name__
__module____qualname____firstlineno__staticmethodr,   r<   __static_attributes__r:   r.   r+   r   r   &   sJ     B $!!
 
r.   r   N)llamar   r   r$   r   r   r	   r
   r   r   r;   r   r:   r.   r+   <module>rG      sB     *?
^ ?
*')s   / 7