+
    "Ý³j£  ã                   óê   a € R t0 t R t^ RIHt ^ RItRt] ^ k Rt] ^k ^R^R^R^R^R^R^R/t^ tRt	R R lt
R R ltR]P                  /R R	 lltR
 R ltR]P                  /R R lltR R ltR# )aw  Split-plane (planar) bit packing for the GPTQ `gptq_p` checkpoint format.

A logical `b`-bit code is stored as word-aligned bit planes whose widths each
divide 32, so every packed word contains whole fields and no code straddles a
word boundary (unlike the continuous 3-bit layout):

- 2-bit = single 2-bit plane (bit-identical to the continuous 2-bit layout)
- 3-bit = 2-bit low plane + 1-bit high plane
- 4-bit = single 4-bit plane (bit-identical to the continuous 4-bit layout)
- 5-bit = 4-bit low plane + 1-bit high plane
- 6-bit = 4-bit low plane + 2-bit high plane
- 7-bit = 4-bit low plane + 2-bit mid plane + 1-bit top plane
- 8-bit = single 8-bit plane (bit-identical to the continuous 8-bit layout)

For every 32 consecutive logical codes the planes are stored adjacently as
`bits` int32 words: first the low-plane words, then the higher planes. Within a
plane of width `w`, word `i` holds codes `[i*(32//w), (i+1)*(32//w))` at shifts
`w*j`, matching the row-major `[bits, pack_factor]` convention of the 2/4/8-bit
packers. The layout fills exactly `ceil(n * bits / 32)` words, so qweight and
qzeros keep their standard GPTQ shapes.
)ÚTupleNc                ó(   € V ^8„  d   QhR\         RR/# )é   ÚbitsÚreturnN)Úint)Úformats   "Ú_/home/luca/screen-checking/.venv/lib/python3.14/site-packages/gptqmodel/utils/planar_packing.pyÚ__annotate__r
   6   s   € ÷ `ñ `œsð ` tñ `ó    c                 óF   € V \         9  d   \        R \         RV  24      hR# )zplanar packing supports bits z, got bits=N)Ú_PLANESÚ
ValueErrorÚPLANAR_FORMAT_BITS)r   s   &r	   Ú_require_planar_bitsr   6   s,   € Ø”7ÔÜÐ8Ô9KÐ8LÈKÐX\ÐW]Ð^Ó_Ð_ñ r   c                ó<   € V ^8„  d   QhR\         P                  RR/# )r   Ú
pack_dtyper   N)ÚtorchÚdtype)r   s   "r	   r
   r
   ;   s   € ÷ 
ñ 
¤U§[¡[ð 
°Tñ 
r   c                 óN   € V \         P                  8w  d   \        R V  R24      hR# )z;planar packing expects 32-bit packed words, got pack_dtype=Ú.N)r   Úint32ÚNotImplementedError©r   s   &r	   Ú_require_int32_wordsr   ;   s-   € Ø”U—[‘[Ô Ü!ØIÈ*ÈÐUVÐWó
ð 	
ñ !r   r   c                ó„   € V ^8„  d   QhR\         P                  R\        R\         P                  R\         P                  /# ©r   Úvaluesr   r   r   ©r   ÚTensorr   r   )r   s   "r	   r
   r
   B   s=   € ÷ Iñ IœUŸ\™\ð I´ð IÄUÇ[Á[ð IÔch×coÑcoñ Ir   c               ó°  € \        V4       \        V4       V P                  w  r4V\        ,          ^ 8w  d"   \	        R\        V P                  4       24      hV\        ,          pV P                  \        P                  4      P                  V\        V4      p\        P                  ! WQV3\        P                  V P                  R7      p^ p\        V,           FÇ  w  rš\        V	,          pWj,	          ^V	,          ^,
          ,          pVP                  WYW´4      p\        P                  ! V\        P                  V P                  R7      P                  ^^V^4      V	,          pWÞ,          P                  ^\        P                  R7      VRWˆV	,           13&   W‰,          pKÉ  	  V\         ,          P                  WQ,          V4      P                  V4      # )zUPack `[n, cols]` logical codes along dim 0 into `[n * bits // 32, cols]` int32 words.z7planar packing expects rows divisible by 32, got shape ©r   Údevice)Údimr   ºNNN)r   r   ÚshapeÚ
_WORD_BITSr   ÚtupleÚtor   Úint64ÚreshapeÚemptyr"   r   ÚarangeÚviewÚsumÚ_MASK32)r   r   r   ÚnÚcolsÚblocksÚxÚoutÚrowÚwidthÚoffsetÚpack_factorÚplaneÚreshapedÚshiftss   &&$            r	   Úplanar_pack_rowsr<   B   sl  € ä˜ÔÜ˜Ô$Ø�l‰l�G€AØŒ:…~˜ÔÜÐRÔSXÐY_×YeÑYeÓSfÐRgÐhÓiÐià”*�_€FØ�	‰	”%—+‘+Ó×&Ñ& v¬z¸4Ó@€AÜ
�+Š+�v TÐ*´%·+±+ÀfÇmÁmÔ
T€CØ
€CÜ  Ÿ˜‰ˆÜ  EÕ)ˆØ• ! u¥*°Õ!1Õ2ˆØ—=‘= °ÓBˆä�LŠL˜¬E¯K©KÀÇÁÔN×SÑSÐTUÐWXÐZeÐghÓiÐlqÕqð 	ð $,Õ#5×":Ñ":¸qÌÏÉÐ":Ó"TˆˆAˆs˜•;ˆÐÑØ�Šñ 'ð ”7�]×#Ñ# F¥M°4Ó8×<Ñ<¸ZÓHÐHr   c                ód   € V ^8„  d   QhR\         P                  R\        R\         P                  /# ©r   Úpackedr   r   ©r   r   r   )r   s   "r	   r
   r
   Z   s.   € ÷ Eñ EœuŸ|™|ð E´3ð E¼5¿<¹<ñ Er   c           
     óà  € \        V4       \        V P                  4       V P                  w  r#W!,          ^ 8w  d(   \	        RV RV R\        V P                  4       24      hW!,          pV P                  \        P                  4      P                  WAV4      \        ,          p\        P                  ! V\        V3\        P                  V P                  R7      p^ p\        V,           FÆ  w  r‰\        V,          p
\        P                  ! V
\        P                  V P                  R7      P!                  ^^V
^4      V,          pVRWwV,           13,          P#                  ^4      V,	          ^V,          ^,
          ,          pWlP                  V\        V4      V	,          ,          pWx,          pKÈ  	  VP                  V\        ,          V4      P                  \        P$                  4      # )zTUnpack `[n * bits // 32, cols]` int32 words back to `[n, cols]` int32 logical codes.úplanar z'-bit qweight expects rows divisible by ú, got shape r!   r$   )r   r   r   r%   r   r'   r(   r   r)   r*   r/   Úzerosr&   r"   r   r,   r-   Ú	unsqueezer   )r?   r   Úrowsr1   r2   ÚwordsÚresultr5   r6   r7   r8   r;   Úcodess   &&           r	   Úplanar_unpack_rowsrJ   Z   s‚  € ä˜ÔÜ˜Ÿ™Ô&Ø—‘�J€DØ…{�aÔÜØ�d�VÐBÀ4À&ÈÔUZÐ[a×[gÑ[gÓUhÐTiÐjó
ð 	
ð �\€FØ�I‰I”e—k‘kÓ"×*Ñ*¨6¸Ó>ÄÕH€EÜ�[Š[˜&¤*¨dÐ3¼5¿;¹;ÈvÏ}É}Ô]€FØ
€CÜ  Ÿ˜‰ˆÜ  EÕ)ˆä�LŠL˜¬E¯K©KÀÇÁÔN×SÑSÐTUÐWXÐZeÐghÓiÐlqÕqð 	ð �q˜# E�k˜/Ð)Õ*×4Ñ4°QÓ7¸6ÕAÀqÈEÅzÐUVÕFVÕWˆØ—-‘- ¬
°DÓ9¸VÕCÕCˆØ�Šñ 'ð �>‰>˜&¤:Õ-¨tÓ4×7Ñ7¼¿¹ÓDÐDr   c                ó„   € V ^8„  d   QhR\         P                  R\        R\         P                  R\         P                  /# r   r   )r   s   "r	   r
   r
   s   s7   € ÷ /ñ /œUŸ\™\ð /´ð /ÄUÇ[Á[ð /Ôch×coÑcoñ /r   c               óF  € \        V4       \        V4       V P                  w  r4V\        ,          ^ 8w  d"   \	        R\        V P                  4       24      h\        V P                  ^ ^4      P                  4       WR7      pVP                  ^ ^4      P                  4       # )zUPack `[rows, n]` logical codes along dim 1 into `[rows, n * bits // 32]` int32 words.z:planar packing expects columns divisible by 32, got shape r   )	r   r   r%   r&   r   r'   r<   Ú	transposeÚ
contiguous)r   r   r   rF   r0   r?   s   &&$   r	   Úplanar_pack_colsrO   s   sˆ   € ä˜ÔÜ˜Ô$Ø�l‰l�G€DØŒ:…~˜ÔÜÐUÔV[Ð\b×\hÑ\hÓViÐUjÐkÓlÐlÜ˜f×.Ñ.¨q°!Ó4×?Ñ?ÓAÀ4Ô_€FØ×Ñ˜A˜qÓ!×,Ñ,Ó.Ð.r   c                ód   € V ^8„  d   QhR\         P                  R\        R\         P                  /# r>   r@   )r   s   "r	   r
   r
   ~   s)   € ÷ 
1ñ 
1œuŸ|™|ð 
1´3ð 
1¼5¿<¹<ñ 
1r   c           
     óZ  € \        V4       \        V P                  4       V P                  w  r#W1,          ^ 8w  d(   \	        RV RV R\        V P                  4       24      h\        V P                  ^ ^4      P                  4       V4      pVP                  ^ ^4      P                  4       # )zTUnpack `[rows, n * bits // 32]` int32 words back to `[rows, n]` int32 logical codes.rB   z)-bit qzeros expects columns divisible by rC   )	r   r   r   r%   r   r'   rJ   rM   rN   )r?   r   rF   r1   Úunpackeds   &&   r	   Úplanar_unpack_colsrS   ~   s�   € ä˜ÔÜ˜Ÿ™Ô&Ø—‘�J€DØ…{�aÔÜØ�d�VÐDÀTÀFÈ,ÔW\Ð]c×]iÑ]iÓWjÐVkÐló
ð 	
ô " &×"2Ñ"2°1°aÓ"8×"CÑ"CÓ"EÀtÓL€HØ×Ñ˜a Ó#×.Ñ.Ó0Ð0r   c                óœ   € V ^8„  d   Qh/ ^ \         9   d   \        \        R3,          ;R&   ^\         9   d   \        \        R3,          ;R&   # )r   .ÚPLANAR_BITSr   )Ú__conditional_annotations__r   r   )r   s   "r	   r
   r
      s@   € ÷ ñ ÷8 )Ò (ŒU”3˜�8�_Ñ (ñ9÷< <Ò ;”Eœ#˜s˜(•OÑ ;ò=r   )é   é   é   )r   é   é   rW   rX   rY   é   )©r   é    )r]   )é   r   )©r[   r^   )r`   )r_   r[   )r`   ©r   r[   )r`   ra   )r_   rX   ))r\   r^   l   ÿÿ )rV   Ú__doc__Útypingr   r   rU   r   r   r&   r/   r   r   r   r<   rJ   rO   rS   r
   )rV   s   @r	   Ú<module>rd      s    øðöõ, ã ð  )€Ó (à&;Ð Ó ;ð
 €yØÐØ€yØÐØÐØÐØ€yð€ð €
Ø
€õ`õ

ðIÐSX×S^ÑS^÷ Iõ0Eð2/ÐSX×S^ÑS^÷ /÷
1r   