+
    "Ý³jŽ  ã                   ó    € ^ RI t R tR tR tR# )é    Nc                óØ   € V P                  4       pW!,          p. p\        V4       F@  pWQ,          pWa,           pWV p\        P                  ! VRR7      p	VP	                  V	4       KB  	  V# )as  
For each group, compute a permutation that orders the indices in descending order
based on the corresponding diagonal values of H.

Args:
    diag_H (Tensor): 1D tensor representing the diagonal of the Hessian.
    groupsize (int): Number of columns/weights per group.

Returns:
    local_perms (list of Tensors): Each element is a permutation (indices) for that group.
T©Ú
descending)ÚnumelÚrangeÚtorchÚargsortÚappend)
Údiag_HÚ	groupsizeÚnÚ
num_groupsÚlocal_permsÚgÚstartÚendÚsub_diagÚ
local_perms
   &&        Ú_/home/luca/screen-checking/.venv/lib/python3.14/site-packages/gptqmodel/quantization/gar_ref.pyÚcompute_local_perms_originalr      si   € ð 	�‰‹€AØ•€JØ€KÜ�:ÖˆØ•ˆØÕˆØ Ð$ˆä—]’] 8¸Ô=ˆ
Ø×Ñ˜:Ö&ñ ð Ðó    c                óN  € V P                  4       pW!,          p. p\        V4       FB  pWQ,          pWa,           pVP                  WV P                  4       P	                  4       4       KD  	  \
        P                  ! W@P                  R7      p\
        P                  ! VRR7      pV# )a–  
Compute a permutation for the groups themselves. Here we choose the maximum diagonal value
within each group as the group metric and sort the groups in descending order.

Args:
    diag_H (Tensor): 1D tensor representing the diagonal of the Hessian.
    groupsize (int): Number of columns/weights per group.

Returns:
    global_perm (Tensor): 1D tensor of length num_groups with the new order of groups.
)ÚdeviceTr   )	r   r   r
   ÚmaxÚitemr   Útensorr   r	   )	r   r   r   r   Úgroup_metricr   r   r   Úglobal_perms	   &&       r   Úcompute_global_perm_originalr   +   sˆ   € ð 	�‰‹€AØ•€JØ€LÜ�:ÖˆØ•ˆØÕˆØ×Ñ˜F¨Ð-×1Ñ1Ó3×8Ñ8Ó:Ö;ñ ô
 —<’< ·]±]ÔC€LÜ—-’- ¸Ô>€KØÐr   c                ó6  € \        V 4      p. p\        V4       FX  pW,          P                  4       pWb,          pW,          pV F)  p	VP                  V	P                  4       V,           4       K+  	  KZ  	  \        P
                  ! V\        P                  R7      # )a[  
Compose the final overall permutation from the local and global permutations.

Args:
    local_perms (list of Tensors): Local permutation for each group.
    global_perm (Tensor): Global group permutation.
    groupsize (int): Number of indices per group.

Returns:
    final_perm (Tensor): 1D tensor that maps original indices to new positions.
)Údtype)Úlenr   r   r
   r   r   Úlong)
r   r   r   r   Ú
final_permÚ	new_groupÚ
orig_groupÚoffsetr   Úidxs
   &&&       r   Úcompose_final_perm_originalr)   D   s}   € ô �[Ó!€JØ€Jä˜:Ö&ˆ	à Õ+×0Ñ0Ó2ˆ
ØÕ'ˆØ Õ,ˆ
ãˆCØ×Ñ˜cŸh™h›j¨6Õ1Ö2ó ñ 'ô �<Š<˜
¬%¯*©*Ô5Ð5r   )r   r   r   r)   © r   r   Ú<module>r+      s   ðó òò2ô26r   