+
    –°³jò9  ã                  óê   € ^ RI Ht ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RI	t	^ RI
HtHtHtHt R.t^ tR^ R^/tR	t]P*                  R
 R l4       tR R ltR R ltR R ltR R lt ! R R4      tR# )é    )ÚannotationsN)ÚAny)Ú
deprecated)Ú_check_cuda_bindingsÚ_cuda_bindings_driverÚ_cuda_bindings_runtimeÚ_HAS_CUDA_BINDINGSÚGreenContextÚ
device_ctxÚbalancedzª`GreenContext.set_context` and `GreenContext.pop_context` are deprecated. Please create a stream with `GreenContext.Stream()` and use `torch.cuda.stream(stream)` instead.c               ó   € V ^8„  d   QhRR/# )é   ÚreturnÚint© )Úformats   "ÚZ/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/cuda/green_contexts.pyÚ__annotate__r   '   s   € ÷ ñ ˜Sñ ó    c                 ó¦   €  \        \        P                  ! 4       4      #   \         d&   p \        P
                  ! R T  24       Ru Rp ? # Rp ? ii ; i)z*Error while querying CUDA driver version: Néÿÿÿÿ)r   Ú_drvÚcuDriverGetVersionÚRuntimeErrorÚwarningsÚwarn)Úes    r   Ú_get_driver_versionr   &   sD   € ðä#¤D×$;Ò$;Ó$=Ó>Ð>øÜô Ü�ŠÐBÀ1À#ÐFÔGØ�	ûðús   ‚   A«AÁAÁAc               ó$   € V ^8„  d   QhRRRRRR/# )r   Úversionr   ÚmessageÚstrr   ÚNoner   )r   s   "r   r   r   0   s!   € ÷ $ñ $ Cð $°#ð $¸$ñ $r   c                óJ   € \        4       pV^ 8  g   W 8  d   \        V4      hR# )r   N)r   r   )r    r!   Údrv_versions   && r   Ú_ensure_driver_versionr&   0   s&   € Ü%Ó'€KØ�Q„˜+Ô/Ü˜7Ó#Ð#ñ 0r   c               ó   € V ^8„  d   QhRR/# ©r   r   r#   r   )r   s   "r   r   r   6   s   € ÷ Sñ S˜4ñ Sr   c                 ó  € \         P                  P                  e   \         P                  P                  e   \	        R4      h\
        P                  R8X  d   \	        R4      h\        '       g   \	        R4      h\        RR4       R # )Nz.Green Context is only supported on Nvidia CUDAÚwin32z)Green Context is not supported on Windowsz/GreenContext requires the cuda.bindings packagei0/  z-Green Context requires user mode driver 12.8+)	Útorchr    ÚcudaÚhipr   ÚsysÚplatformr	   r&   r   r   r   Ú_ensure_supportedr0   6   sb   € Ü‡}�}×ÑÒ!¤U§]¡]×%6Ñ%6Ò%BÜÐKÓLÐLÜ
‡|�|�wÔÜÐFÓGÐGßÓÜÐLÓMÐMÜ˜5Ð"QÖRr   c               ó   € V ^8„  d   QhRR/# r(   r   )r   s   "r   r   r   @   s   € ÷ ñ  Tñ r   c                 ó   € \        R R4       R# )iÒ2  z=CUDA user mode driver too old to use workqueue configuration!N)r&   r   r   r   Ú_ensure_workqueue_supportedr3   @   s   € ÜØÐNör   c               ó    € V ^8„  d   QhRRRR/# )r   Úworkqueue_scopeú
str | Noner   ú
int | Noner   )r   s   "r   r   r   F   s   € ÷ 4ñ 4¨Jð 4¸:ñ 4r   c                ó\   € V f   R # V \         9  d   \        RV  R24      h\         V ,          # )Nz9workqueue_scope must be 'device_ctx' or 'balanced', got 'Ú')Ú_WORKQUEUE_SCOPE_VALUESÚ
ValueError)r5   s   &r   Ú_parse_workqueue_scoper<   F   s@   € ØÒÙØÔ5Ô5ÜðØ#Ð$ Að'ó
ð 	
ô # ?Õ3Ð3r   c            	      óú   € ] tR t^QtRtRRRRRRRR/R R lltR	 R
 ltR R lt]RRRRRRRR/R R ll4       t	]RR R ll4       t
R R lt]! ]]R7      R R l4       t]! ]]R7      R R l4       tR R ltRtR# )r
   a,  Wrapper around a CUDA green context.

.. warning::
   This API is in beta and may change in future releases.

CUDA work should be placed on streams created from the green context:

.. code-block:: python

    ctx = GreenContext(...)
    stream = ctx.Stream()
    with torch.cuda.stream(stream):
        # torch operations here are using resources from `ctx`
        pass

Green-context streams are custom CUDA streams. Synchronization with other
streams is the user's responsibility and should be handled with CUDA events,
as with any other custom stream.
Únum_smsNr5   Úworkqueue_concurrency_limitÚ	device_idc          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r   r>   r7   r5   r6   r?   r@   r   r#   r   )r   s   "r   r   ÚGreenContext.__annotate__f   sL   € ÷ xDñ xDð ðxDð $ð	xDð
 &0ðxDð ðxDð 
ñxDr   c               óV  € RV n         RV n        RV n        \        4        \	        V4      pVe   \        4        Vf   Vf   \        R4      hVe   Vf   \        R4      hVf   \        P                  P                  4       p\        \        P                  ! 4       4      p\        V4      ^ 8X  d8   \        P                  ! R^R7       \        \         P"                  ! ^ 4      4       \        \        P$                  ! V4      4      p. pVeÏ   \        \        P&                  ! V\        P(                  P*                  4      4      p	V^ 8:  g   WP,                  P.                  8”  d'   \        RV RV	P,                  P.                   R24      h\        \        P0                  ! ^V	^ V4      4      w  r«pV^8w  d   \        R	4      hVP3                  V
^ ,          4       Ven   \        \        P&                  ! V\        P(                  P4                  4      4      pW]P6                  n        Ve   W=P6                  n        VP3                  V4       \        \        P<                  ! V\?        V4      4      4      p\        \        P@                  ! VV\        PB                  PD                  4      4      p \        \        PF                  ! V4      4      p\        V4      ^ 8X  d   \        R
4      h T PM                  YOT4       R#   \H         d"    \        \        PJ                  ! T4      4       h i ; i)a¢  Create a CUDA green context.

At least one of ``num_sms`` or ``workqueue_scope`` must be specified.
Both can be combined to partition SMs and configure workqueues in the
same green context.

Arguments:
    num_sms (int, optional): The number of SMs to use in the green
        context. When ``None``, SMs are not partitioned.
    workqueue_scope (str, optional): Workqueue sharing scope. One of
        ``"device_ctx"`` (shared across all contexts, default driver
        behavior) or ``"balanced"`` (non-overlapping workqueues with
        other balanced green contexts). When ``None``, no workqueue
        configuration is applied.
    workqueue_concurrency_limit (int, optional): Maximum number of
        concurrent stream-ordered workloads for the workqueue. Requires
        ``workqueue_scope`` to be set.
    device_id (int, optional): The device index of green context.
        When ``None``, the current device is used.
Nz<At least one of num_sms or workqueue_scope must be specifiedz>workqueue_concurrency_limit requires workqueue_scope to be setzcAttempted to create a green context but there was no primary context! Creating a primary context...)Ú
stacklevelz3Invalid number of SMs requested for green context: z (device has z SMs)z)Failed to create single SM resource groupz+Green ctx conversion to regular ctx failed!)'Ú
_device_idÚ
_green_ctxÚ_contextr0   r<   r3   r   r+   r,   Úcurrent_devicer   r   ÚcuCtxGetCurrentr   r   r   Ú_rtÚcudaFreeÚcuDeviceGetÚcuDeviceGetDevResourceÚCUdevResourceTypeÚCU_DEV_RESOURCE_TYPE_SMÚsmÚsmCountÚcuDevSmResourceSplitByCountÚappendÚ%CU_DEV_RESOURCE_TYPE_WORKQUEUE_CONFIGÚwqConfigÚsharingScopeÚwqConcurrencyLimitÚcuDevResourceGenerateDescÚlenÚcuGreenCtxCreateÚCUgreenCtxCreate_flagsÚCU_GREEN_CTX_DEFAULT_STREAMÚcuCtxFromGreenCtxÚ	ExceptionÚcuGreenCtxDestroyÚ_init_from_cuda_objects)Úselfr>   r5   r?   r@   Úscope_valueÚcurrent_ctxÚdeviceÚ	resourcesÚsm_resourceÚsplit_resultÚ	nb_groupsÚ
_remainingÚwq_resourceÚdescÚ	green_ctxÚcontexts   &$$$$            r   Ú__init__ÚGreenContext.__init__f   sÎ  € ð8 ˆŒØˆŒØˆŒÜÔä,¨_Ó=ˆØÒ"Ü'Ô)àŠ?˜{Ò2ÜØNóð ð 'Ò2°{Ò7JÜØPóð ð ÒÜŸ
™
×1Ñ1Ó3ˆIô +¬4×+?Ò+?Ó+AÓBˆäˆ{Ó˜qÔ Ü�MŠMð9àõô !¤§¢¨a£Ô1ô &¤d×&6Ò&6°yÓ&AÓBˆØˆ	àÒÜ.Ü×+Ò+ØÜ×*Ñ*×BÑBóóˆKð ˜!Œ|˜w¯©×)?Ñ)?Ô?Ü"ØIØ�i˜}¨[¯^©^×-CÑ-CÐ,DÀEðKóð ô 3GÜ×0Ò0Ø�{ A wóó3Ñ/ˆL Zð
 ˜AŒ~Ü"Ð#NÓOÐOØ×Ñ˜\¨!�_Ô-àÒ"Ü.Ü×+Ò+ØÜ×*Ñ*×PÑPóóˆKð 1<× Ñ Ô-Ø*Ò6Ø:U×$Ñ$Ô7Ø×Ñ˜[Ô)ä#Ü×*Ò*Øœ3˜y›>óó
ˆô
 )Ü×!Ò!ØØÜ×+Ñ+×GÑGóó
ˆ	ð	ä*¬4×+AÒ+AÀ)Ó+LÓMˆGÜ�7‹|˜qÔ Ü"Ð#PÓQÐQð !ð 	×$Ñ$ Y¸7ÖCøô ô 	ä ¤×!7Ò!7¸	Ó!BÔCØð	ús   Ê-:K< Ë<,L(c               ó   € V ^8„  d   QhRR/# r(   r   )r   s   "r   r   rB   à   s   € ÷ Tñ T˜ñ Tr   c           
     	ó.  € \        V R R4      pVf   R# \        \        V P                  ^,           4      p\	        \        V4      4       F4  p \        \        P                  ! V P                  V,          4      4       K6  	  RV n         \        \        P                  ! V4      4       R#   \         d+   p\        P                  ! RT RT RT 24        Rp?K‘  Rp?ii ; i  \         d(   p\        P                  ! RT RT 24        Rp?R# Rp?ii ; i)rF   Nz3Error while destroying green context stream at idx z for green context z: z%Error while destroying green context )ÚgetattrÚminÚ_STREAMS_PER_GREEN_CONTEXT_POOLÚ_curr_stream_idxÚreversedÚranger   r   ÚcuStreamDestroyÚ_green_ctx_streamsr   r   r   rF   r_   )ra   rl   ÚendÚidxr   s   &    r   Ú__del__ÚGreenContext.__del__à   sü   € Ü˜D ,°Ó5ˆ	ØÒÙô Ô1°4×3HÑ3HÈ1Õ3LÓMˆÜœE #›JÖ'ˆCðä$¤T×%9Ò%9¸$×:QÑ:QÐRUÕ:VÓ%WÖXñ (ð ˆŒð	Tä ¤×!7Ò!7¸	Ó!BÖCøô  ô Ü—’ØIÈ#Èð O)Ø)2¨°2°a°Sð:÷ò ûðûô ô 	TÜ�MŠMÐAÀ)ÀÈBÈqÈcÐR×SÒSûð	Tús0   Á0B*Â	C" Â*CÂ5CÃCÃ"DÃ-DÄDc               ó    € V ^8„  d   QhRRRR/# )r   r@   r   r   r#   r   )r   s   "r   r   rB   ø   s   € ÷ #ñ #°ð #ÈTñ #r   c                	ól   € Wn         W n        W0n        R V n        R .\        ,          V n        RV n        R # )Nr   )rE   rF   rG   Ú_parent_streamrt   ry   ru   )ra   r@   rl   rm   s   &&&&r   r`   Ú$GreenContext._init_from_cuda_objectsø   s8   € Ø#ŒØ#ŒØŒØ8<ˆÔàð5
ä+õ5,ˆÔð !#ˆÖr   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r   r>   r7   r5   r6   r?   r@   r   r
   r   )r   s   "r   r   rB     s<   € ÷ 
ñ 
àð
ð $ð
ð &0ð	
ð
 ð
ð 
ñ
r   c                ó    € \        V VVVR7      # )zVCreate a CUDA green context.

Kept for compatibility, see `GreenContext` constructor.
©r>   r5   r?   r@   )r
   r„   s   $$$$r   ÚcreateÚGreenContext.create  s   € ô ØØ+Ø(CØô	
ð 	
r   c               ó    € V ^8„  d   QhRRRR/# )r   r@   r7   r   r   r   )r   s   "r   r   rB     s   € ÷ 7ñ 7¨Zð 7À3ñ 7r   c                óH  € \        4        \        4        V f   \        P                  P	                  4       p \        \        P                  ! V 4      4      p\        \        P                  ! V\        P                  P                  4      4      pVP                  P                  # )a?  Return the maximum workqueue concurrency limit for the device.

This queries the device for the default number of concurrent
stream-ordered workloads supported by workqueue configuration
resources.

Arguments:
    device_id (int, optional): The device index to query. When
        ``None``, the current device is used.
)r0   r3   r+   r,   rH   r   r   rL   rM   rN   rT   rU   rW   )r@   rd   rj   s   &  r   Úmax_workqueue_concurrencyÚ&GreenContext.max_workqueue_concurrency  s}   € ô 	ÔÜ#Ô%ØÒÜŸ
™
×1Ñ1Ó3ˆIô &¤d×&6Ò&6°yÓ&AÓBˆÜ*Ü×'Ò'ØÜ×&Ñ&×LÑLóó
ˆð ×#Ñ#×6Ñ6Ð6r   c               ó   € V ^8„  d   QhRR/# r(   r   )r   s   "r   r   rB   0  s   € ÷ Bñ B˜tñ Br   c                	óT   € V P                   e   V P                  f   \        R4      hR # )NzGreenContext has been destroyed)rF   rG   r   )ra   s   &r   Ú_ensure_aliveÚGreenContext._ensure_alive0  s&   € Ø�?‰?Ò" d§m¡mÒ&;ÜÐ@ÓAÐAñ '<r   )Úcategoryc               ó   € V ^8„  d   QhRR/# r(   r   )r   s   "r   r   rB   5  s   € ÷ 0ñ 0˜Tñ 0r   c                ó²  € V P                  4        V P                  e   \        R4      h\        P                  P                  4       pWn        \        P                  P                  4       pVP                  V4       \        \        P                  ! 4       4      p\        V4      ^ 8X  d+   \        \        P                  ! V P                  4      4       M)\        \        P                  ! V P                  4      4       \        P                  P                  V P                   4      pVP#                  V4       \        P                  P%                  V4       R# )z‡Make the green context the current context.

Deprecated. Create streams with :meth:`Stream` and use
:func:`torch.cuda.stream` instead.
Nz+set_context called twice before pop_context)r�   r€   r   r+   r,   Úcurrent_streamÚEventÚrecordr   r   rI   r   ÚcuCtxSetCurrentrG   ÚcuCtxPushCurrentÚdefault_streamrE   ÚwaitÚ
set_stream)ra   r’   Úeventrc   Úgreen_ctx_streams   &    r   Úset_contextÚGreenContext.set_context4  sé   € ð 	×ÑÔØ×ÑÒ*ÜÐLÓMÐMÜŸ™×2Ñ2Ó4ˆØ,Ôä—
‘
× Ñ Ó"ˆØ�‰�^Ô$ô +¬4×+?Ò+?Ó+AÓBˆÜˆ{Ó˜qÔ ä ¤×!5Ò!5°d·m±mÓ!DÕEô !¤×!6Ò!6°t·}±}Ó!EÔFä Ÿ:™:×4Ñ4°T·_±_ÓEÐØ�
‰
Ð#Ô$Ü�
‰
×ÑÐ.Ö/r   c               ó   € V ^8„  d   QhRR/# r(   r   )r   s   "r   r   rB   R  s   € ÷ 'ñ '˜Tñ 'r   c                ó6  €  V P                  4        V P                  f   \        R4      h\        P                  P                  4       pVP                  \        P                  P                  4       4       \        \        P                  ! 4       4      p\        V4      \        V P                  4      8w  d   \        R4      hVP                  V P                  4       \        P                  P                  V P                  4       RV n        R#   RT n        i ; i)zÎAssuming the green context is the current context, pop it from the
context stack and restore the previous context.

Deprecated. Create streams with :meth:`Stream` and use
:func:`torch.cuda.stream` instead.
Nz/pop_context called without matching set_contextz-expected popped context to be the current ctx)r�   r€   r   r+   r,   r“   r”   r’   r   r   ÚcuCtxPopCurrentr   rG   r˜   r™   )ra   rš   Úpoppeds   &  r   Úpop_contextÚGreenContext.pop_contextQ  sÇ   € ð	'Ø×ÑÔ Ø×"Ñ"Ò*Ü"Ð#TÓUÐUä—J‘J×$Ñ$Ó&ˆEØ�L‰LœŸ™×2Ñ2Ó4Ô5ô *¬$×*>Ò*>Ó*@ÓAˆFä�6‹{œc $§-¡-Ó0Ô0Ü"Ð#RÓSÐSà�J‰J�t×*Ñ*Ô+Ü�J‰J×!Ñ! $×"5Ñ"5Ô6à"&ˆDÖø $ˆDÕús   ‚DD Ä	Dc               ó   € V ^8„  d   QhRR/# )r   r   ztorch.cuda.Streamr   )r   s   "r   r   rB   l  s   € ÷ Qñ QÐ)ñ Qr   c                ó´  € V P                  4        V P                  ^,           pV\        ,          pV\        8  dS   \        \        P
                  ! V P                  \        P                  P                  ^ 4      4      pW0P                  V&   MV P                  V,          pWn        \        P                  P                  \        V4      V P                  4      # )zùReturn a CUDA stream associated with this green context.

Use the returned stream with :func:`torch.cuda.stream` to run work on
the green context. Synchronization with other streams is not automatic;
use CUDA events as with any other custom stream.
)r�   ru   rt   r   r   ÚcuGreenCtxStreamCreaterF   ÚCUstream_flagsÚCU_STREAM_NON_BLOCKINGry   r+   r,   ÚExternalStreamr   rE   )ra   Úcurr_idxr{   r›   s   &   r   ÚStreamÚGreenContext.Streaml  s®   € ð 	×ÑÔØ×(Ñ(¨1Õ,ˆØÔ8Õ8ˆØÔ5Ô5Ü3Ü×+Ò+Ø—O‘OÜ×'Ñ'×>Ñ>Øóó Ðð ,<×#Ñ# CÒ(à#×6Ñ6°sÕ;ÐØ (Ôä�z‰z×(Ñ(¬Ð-=Ó)>ÀÇÁÓPÐPr   )rG   ru   rE   rF   ry   r€   )N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rn   r|   r`   Ústaticmethodr…   r‰   r�   r   Ú_CONTEXT_STACK_DEPRECATIONÚFutureWarningrœ   r¢   r«   Ú__static_attributes__r   r   r   r
   r
   Q   sä   † ñð(xDð #ðxDð '+ð	xDð
 37ðxDð !%÷xDõtTõ0#ð ð
à"ð
ð '+ð
ð 37ð	
ð
 !%ö
ó ð
ð$ ö7ó ð7õ4Bñ Ð*°]ÔCô0ó Dð0ñ8 Ð*°]ÔCô'ó Dð'÷4Qñ Qr   )Ú
__future__r   Ú	functoolsr.   r   Útypingr   Útyping_extensionsr   r+   Útorch.cuda._utilsr   r   r   r   rJ   r	   Ú__all__rt   r:   r³   Úcacher   r&   r0   r3   r<   r
   r   r   r   Ú<module>r½      s‘   ðÝ "ã Û 
Û Ý Ý (ã ÷ó ð ð€ð #%Ð ð �!Ø�ðÐ ð+ð ð ‡�ôó ðõ$õSõõ4÷rQó rQr   