+
    "Ý³jª  ã                  óz   € ^ RI Ht ^ RIHtHt ^ RIt^ RIHt ^ RIHt ^RI	H
t
Ht R tR tR	 R
 ltRR R lltR# )é    )Úannotations)ÚOptionalÚUnionN)ÚDevice)Únn)ÚCPUÚCUDA_0c                 ój   € \        \        4      p V P                  4       R ,          R ,          R ,          # ©i   )r   r	   Úmemory_used©Úsmis    ÚW/home/luca/screen-checking/.venv/lib/python3.14/site-packages/gptqmodel/utils/device.pyÚget_gpu_usage_memoryr      s'   € Ü
”‹.€CØ�?‰?Ó˜tÕ# dÕ*¨TÕ1Ð1ó    c                 ój   € \        \        4      p V P                  4       R ,          R ,          R ,          # r   )r   r   r   r   s    r   Úget_cpu_usage_memoryr      s'   € Ü
”‹+€CØ�?‰?Ó˜tÕ# dÕ*¨TÕ1Ð1r   c               ó    € V ^8„  d   QhRRRR/# )é   Úobjútorch.Tensor | nn.ModuleÚreturnútorch.device© )Úformats   "r   Ú__annotate__r      s   € ÷ ñ Ð,ð °ñ r   c                óV  € \        V \        P                  4      '       d   V P                  # \	        V P                  4       4      p\	        V P                  4       4      p\        V4      ^ 8”  d   V^ ,          P                  # \        V4      ^ 8”  d   V^ ,          P                  # \        # )r   )	Ú
isinstanceÚtorchÚTensorÚdeviceÚlistÚ
parametersÚbuffersÚlenr   )r   Úparamsr$   s   &  r   Ú
get_devicer'      sz   € Ü�#”u—|‘|×$Ò$Ø�z‰zÐä�#—.‘.Ó"Ó#€FÜ�3—;‘;“=Ó!€GÜ
ˆ6ƒ{�Q„Ø�a�y×ÑÐÜ	ˆW‹˜Ô	Ø�q�z× Ñ Ð äˆ
r   c               ó0   € V ^8„  d   QhRRRRRRRRRRR	R
/# )r   r   r   Ú	recursiveÚboolÚassert_modeÚexpectedú"Optional[Union[str, torch.device]]Úcheck_indexr   r   r   )r   s   "r   r   r   '   sL   € ÷ Zñ ZØ	!ðZàðZð ðZð 1ð	Zð
 ðZð ñZr   c           
     ó>  a€ R R lp\        V \        P                  4      '       d   V P                  .pM¿\        V \        P
                  4      '       d‰   \        V P                  VR7      4      p\        V P                  VR7      4      p. pV'       d   VP                  R V 4       4       V'       d   VP                  R V 4       4       V'       g   \        .pM\        R\        V 4       24      hV^ ,          p	V'       Edƒ   V! V4      w  r«R V3R llpV
eÀ   V Uu. uF3  pVP                  V
8w  g   S'       g   K  VP                  V8w  g   K1  VNK5  	  ppV'       dv   R	P                  VR
,           Uu0 uF  qÝP                   RVP                   2kK  	  up4      pT
 S'       d   RV 2MR,           p\        RV RV R\!        V4       R24      h V	# V Uu0 uF
  qÜ! V4      kK  	  pp\!        V4      ^8”  d‡   R	P                  \#        R V 4       4      4      pR	P                  VR,           Uu0 uF  qÝP                   RVP                   2kK  	  up4      pRV RV R2pS'       g
   VR,          p\        V4      hV	# u upi u upi u upi u upi )aï  
Return a representative device for a Tensor/Module and optionally assert uniformity.

Args:
    obj: Tensor or nn.Module.
    recursive: If obj is an nn.Module, traverse submodules (parameters/buffers)
               recursively (like module.parameters(recurse=True)).
    assert_mode: If True, perform assertions about device placement:
        - If `expected` is provided: assert that ALL params/buffers live on a device
          whose .type matches `expected`'s .type (and, if check_index, the same index).
        - If `expected` is None: assert that ALL params/buffers share a single uniform
          device type (and, if check_index, the same index).
    expected: A target device or device string (e.g., "cpu", "cuda", "cuda:1").
    check_index: If True, also require the same device index (e.g., all on cuda:0).

Returns:
    torch.device: A representative device. Priority order:
        - Tensor: its own device
        - Module: the first parameter device, else first buffer device, else CPU
c               ó   € V ^8„  d   QhRR/# )r   Úexpr-   r   )r   s   "r   r   Ú$get_device_new.<locals>.__annotate__C   s   € ÷ #ñ #Ð!Cñ #r   c                óš   € V f   R# \        V \        4      '       d   \        P                  ! V 4      MT pVP                  VP
                  3# )N)NN)r   Ústrr   r!   ÚtypeÚindex)r1   Údevs   & r   Ú_normalize_expectedÚ+get_device_new.<locals>._normalize_expectedC   s<   € ØŠ;ØÐÜ#-¨c´3×#7Ò#7Œe�lŠl˜3Ô¸SˆØ�x‰x˜Ÿ™Ð"Ð"r   )Úrecursec              3  ó8   "  € T F  qP                   x € K  	  R # 5i©N©r!   )Ú.0Úps   & r   Ú	<genexpr>Ú!get_device_new.<locals>.<genexpr>R   s   é € Ð4©V¨Ÿ8ž8«Vùó   ‚c              3  ó8   "  € T F  qP                   x € K  	  R # 5ir<   r=   )r>   Úbs   & r   r@   rA   T   s   é € Ð3©U¨Ÿ8ž8«UùrB   z.get_device() expects Tensor or nn.Module, got c               ó   € V ^8„  d   QhRR/# )r   Údr   r   )r   s   "r   r   r2   a   s   € ÷ 	>ñ 	>�Lñ 	>r   c                óJ   <€ V P                   S'       d   V P                  3# R 3# r<   )r5   r6   )rF   r.   s   &€r   Ú_keyÚget_device_new.<locals>._keya   s    ø€ Ø—F‘F§{˜AŸG™GÐ=Ð=¸Ð=Ð=r   z, :Né   NÚ:Ú z1Device assertion failed: expected all tensors on z, but found mismatches (e.g., z). Total tensors checked: Ú.c              3  ó4   "  € T F  w  rV R V 2x € K  	  R# 5i)rK   Nr   )r>   ÚtÚis   &  r   r@   rA   w   s   é € Ð*KÁF¹&¸1¨a¨S°°!°­:ÃFùs   ‚:Né   NzADevice assertion failed: tensors are on multiple devices. Found {z}. Examples: z? (Tip: set check_index=True to also require same device index.))r   r   r    r!   r   ÚModuler"   r#   r$   Úextendr   Ú	TypeErrorr5   r6   ÚjoinÚAssertionErrorr%   Úsorted)r   r)   r+   r,   r.   r8   Údevicesr&   ÚbuffsÚ
rep_deviceÚexp_typeÚ	exp_indexrH   rF   Ú
mismatchesÚsampleÚtargetÚuniqueÚsummaryÚdetailÚmsgs   &&&&f                r   Úget_device_newrd   '   sz  ø€ õ8#ô �#”u—|‘|×$Ò$Ø—:‘:�,‰Ü	�CœŸ™×	#Ò	#ä�c—n‘n¨Y�nÓ7Ó8ˆÜ�S—[‘[¨�[Ó3Ó4ˆØˆßØ�N‰NÑ4©VÓ4Ô4ßØ�N‰NÑ3©UÓ3Ô3ßÜ�eˆGøäÐHÌÈcËÈÐTÓUÐUð ˜•€J÷ €{Ù1°(Ó;Ñˆ÷	>ð 	>ð Òñ #óÙ"�aØ—6‘6˜XÔ%¬+ô Ø:;¿'¹'ÀYÑ:N÷ �™7ð ð ÷ àŸ™À:ÈbÆ>Ó#RÁ>¸a§v¡v h¨a°·±¨yÓ$9Á>Ñ#RÓS�Ø$˜:¿[¨A¨i¨[©/ÈbÕQ�Ü$ØGÈÀxð P3Ø39°(Ð:TÔUXÐY`ÓUaÐTbÐbcðeóð ð	 ð. Ðñ )0Ó1© 1�t˜A–w©ˆFÐ1Ü�6‹{˜QŒàŸ)™)¤FÑ*KÁFÓ*KÓ$KÓL�ØŸ™À7È2Æ;Ó#OÁ;¸a§v¡v h¨a°·±¨yÓ$9Á;Ñ#OÓP�ðØ&˜i ~°f°X¸Qð@ð ÷ #ØÐ\Õ\�CÜ$ SÓ)Ð)àÐùò7ùò $Sùò 2ùò $Ps$   Ä"JÅJÅJÅ;#JÇ!JÈ:#J)FFNF)Ú
__future__r   Útypingr   r   r   Ú
device_smir   r   Úmodels._constr   r	   r   r   r'   rd   r   r   r   Ú<module>ri      s4   ðõ
 #ç "ã Ý Ý ç 'ò2ò
2õ÷Zñ Zr   