+
    „°ñj‘  ã                   óæ   € R t ^ RIt^ RIHt ^ RIt^ RIt^ RIt^ RIH	t	H
t
  ! R R]
P                  4      t ! R R]
P                  4      t ! R R	]
P                  4      t ! R
 R]	4      tR R ltR# )aM  
ComfyUI nodes for autoregressive video generation (Causal Forcing, Self-Forcing, etc.).
  - EmptyARVideoLatent: create 5D [B, C, T, H, W] video latent tensors
  - SamplerARVideo: SAMPLER for the block-by-block autoregressive denoising loop
  - ARVideoI2V: image-to-video conditioning for AR models (seeds KV cache with start image)
N)Úoverride)ÚComfyExtensionÚioc                   óL   a € ] tR t^t o ]R 4       t]V 3R lR l4       tRtV tR# )ÚEmptyARVideoLatentc                óŠ  € \         P                  ! R R\         P                  P                  RR^R^R7      \         P                  P                  RR^R^R7      \         P                  P                  R^Q^R	^R7      \         P                  P                  R
^^^@R7      .\         P                  P                  RR7      .R7      # )r   zmodel/latent/autoregressiveÚwidthé@  é    ©ÚdefaultÚminÚmaxÚstepÚheightéà  Úlengthé   Ú
batch_size©r   r   r   ÚLATENT©Údisplay_name©Únode_idÚcategoryÚinputsÚoutputs)r   ÚSchemaÚIntÚInputÚLatentÚOutput©Úclss   &Ú?C:\Ai_Coding\apps\studio\ComfyUI\comfy_extras\nodes_ar_video.pyÚdefine_schemaÚ EmptyARVideoLatent.define_schema   s    € ä�yŠyØ(Ø2ä—‘—‘˜W¨c°r¸tÈ"�ÓMÜ—‘—‘˜X¨s¸ÀÈ2�ÓNÜ—‘—‘˜X¨r°q¸dÈ�ÓKÜ—‘—‘˜\°1¸!À�ÓDð	ô —	‘	× Ñ ¨hÐ Ó7ðô
ð 	
ó    c                ó4   <€ V ^8„  d   QhRS[ P                  /# ©é   Úreturn©r   Ú
NodeOutput)ÚformatÚ__classdict__s   "€r%   Ú__annotate__ÚEmptyARVideoLatent.__annotate__#   s   ø€ ÷ 2ñ 2¹2¿=¹=ñ 2r(   c                óì   € V^,
          ^,          ^,           p\         P                  ! V^WR^,          V^,          .\        P                  P	                  4       R7      p\
        P                  ! RV/4      # )é   ©ÚdeviceÚsamples)ÚtorchÚzerosÚcomfyÚmodel_managementÚintermediate_devicer   r.   )r$   r   r   r   r   Úlat_tÚlatents   &&&&&  r%   ÚexecuteÚEmptyARVideoLatent.execute"   s_   € à˜1•* Õ" aÕ'ˆÜ—’Ø˜˜U¨a¥K°¸!µÐ<Ü×)Ñ)×=Ñ=Ó?ô
ˆô �}Š}˜i¨Ð0Ó1Ð1r(   © N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Úclassmethodr&   r?   Ú__static_attributes__Ú__classdictcell__©r0   s   @r%   r   r      s+   ø‡ € Øñ
ó ð
ð ÷2ó ö2r(   r   c                   óP   a € ] tR t^,t o Rt]R 4       t]V 3R lR l4       tRtV t	R# )ÚSamplerARVideozÏSampler for autoregressive video models (Causal Forcing, Self-Forcing).

All AR-loop parameters are owned by this node so they live in the workflow.
Add new widgets here as the AR sampler grows new options.
c                ó¸   € \         P                  ! R RR\         P                  P                  R^^^@RR7      .\         P                  P                  4       .R7      # )rK   zSampler AR Videozmodel/sampling/samplersÚnum_frame_per_blockziFrames per autoregressive block. 1 = framewise, 3 = chunkwise. Must match the checkpoint's training mode.)r   r   r   Útooltip)r   r   r   r   r   )r   r   r   r    ÚSamplerr"   r#   s   &r%   r&   ÚSamplerARVideo.define_schema3   s[   € ä�yŠyØ$Ø+Ø.ä—‘—‘Ø)Ø 1¨"ðXð ó ðô —Z‘Z×&Ñ&Ó(Ð)ô
ð 	
r(   c                ó4   <€ V ^8„  d   QhRS[ P                  /# r*   r-   )r/   r0   s   "€r%   r1   ÚSamplerARVideo.__annotate__E   s   ø€ ÷ Qñ Q©R¯]©]ñ Qr(   c                ór   € R V/p\         P                  ! \        P                  P	                  RV4      4      # )rM   Úar_video)r   r.   r:   ÚsamplersÚksampler)r$   rM   Úextra_optionss   && r%   r?   ÚSamplerARVideo.executeD   s3   € ð "Ð#6ð
ˆô �}Š}œUŸ^™^×4Ñ4°ZÀÓOÓPÐPr(   rA   N©
rB   rC   rD   rE   Ú__doc__rF   r&   r?   rG   rH   rI   s   @r%   rK   rK   ,   s4   ø‡ € ñð ñ
ó ð
ð  ÷Qó öQr(   rK   c                   óP   a € ] tR t^Lt o Rt]R 4       t]V 3R lR l4       tRtV t	R# )Ú
ARVideoI2Va"  Image-to-video setup for AR video models (Causal Forcing, Self-Forcing).

VAE-encodes the start image and stores it in the model's transformer_options
so that sample_ar_video can seed the KV cache before denoising.
Uses the same T2V model checkpoint -- no separate I2V architecture needed.
c                ó|  € \         P                  ! R R\         P                  P                  R4      \         P                  P                  R4      \         P
                  P                  R4      \         P                  P                  RR^R^R7      \         P                  P                  R	R
^R^R7      \         P                  P                  R^Q^R^R7      \         P                  P                  R^^^@R7      .\         P                  P                  RR7      \         P                  P                  RR7      .R7      # )r\   z!model/conditioning/autoregressiveÚmodelÚvaeÚstart_imager   r	   r
   r   r   r   r   r   r   r   ÚMODELr   r   r   )	r   r   ÚModelr    ÚVaeÚImager   r"   r!   r#   s   &r%   r&   ÚARVideoI2V.define_schemaT   sâ   € ä�yŠyØ Ø8ä—‘—‘˜wÓ'Ü—‘—‘˜UÓ#Ü—‘—‘˜}Ó-Ü—‘—‘˜W¨c°r¸tÈ"�ÓMÜ—‘—‘˜X¨s¸ÀÈ2�ÓNÜ—‘—‘˜X¨r°q¸dÈ�ÓKÜ—‘—‘˜\°1¸!À�ÓDðô —‘—‘¨W�Ó5Ü—	‘	× Ñ ¨hÐ Ó7ðô
ð 	
r(   c                ó4   <€ V ^8„  d   QhRS[ P                  /# r*   r-   )r/   r0   s   "€r%   r1   ÚARVideoI2V.__annotate__i   s   ø€ ÷ 5ñ 5ÑTV×TaÑTañ 5r(   c                ó4  € \         P                  P                  VR ,          P                  R^4      WERR4      P                  ^R4      pVP	                  VR	,          4      pVP                  4       p	V	P                  P                  R/ 4      p
V
P                  R/ 4      pW‹R&   V^,
          ^,          ^,           p\        P                  ! V^WÅ^,          V^,          .\         P                  P                  4       R7      p\        P                  ! V	RV/4      # )
:Nr4   NÚbilinearÚcenterÚtransformer_optionsÚ	ar_configÚinitial_latentr5   r7   éÿÿÿÿ)ºNNNro   ro   :Né   N)r:   ÚutilsÚcommon_upscaleÚmovedimÚencodeÚcloneÚmodel_optionsÚ
setdefaultr8   r9   r;   r<   r   r.   )r$   r^   r_   r`   r   r   r   r   rm   ÚmÚtoÚar_cfgr=   r>   s   &&&&&&&&      r%   r?   ÚARVideoI2V.executeh   sí   € ä—k‘k×0Ñ0Ø˜�O×#Ñ# B¨Ó*¨E¸:Àxó
ç
‰'�!�R‹.ð 	ð Ÿ™ K°Õ$<Ó=ˆà�K‰K‹MˆØ�_‰_×'Ñ'Ð(=¸rÓBˆØ—‘˜{¨BÓ/ˆØ#1ÐÑ à˜1•* Õ" aÕ'ˆÜ—’Ø˜˜U¨a¥K°¸!µÐ<Ü×)Ñ)×=Ñ=Ó?ô
ˆô �}Š}˜Q ¨FÐ 3Ó4Ð4r(   rA   NrY   rI   s   @r%   r\   r\   L   s2   ø‡ € ñð ñ
ó ð
ð& ÷5ó ö5r(   r\   c                   ó<   a € ] tR t^}t o ]V 3R lR l4       tRtV tR# )ÚARVideoExtensionc                óT   <€ V ^8„  d   QhRS[ S[S[P                  ,          ,          /# r*   )ÚlistÚtyper   Ú	ComfyNode)r/   r0   s   "€r%   r1   ÚARVideoExtension.__annotate__   s"   ø€ ÷ 
ñ 
¡T©$©r¯|©|Õ*<Õ%=ñ 
r(   c              ƒ  ó,   "  € \         \        \        .# 5i©N)r   rK   r\   )Úselfs   &r%   Úget_node_listÚARVideoExtension.get_node_list~   s   é € ô ÜÜð
ð 	
ùs   ‚rA   N)rB   rC   rD   rE   r   r†   rG   rH   rI   s   @r%   r}   r}   }   s   ø‡ € Ø÷
ó ö
r(   r}   c                ó$   € V ^8„  d   QhR\         /# r*   ©r}   )r/   s   "r%   r1   r1   ‡   s   € ÷ ñ Ô 0ñ r(   c               ƒ   ó   "  € \        4       # 5ir„   r‰   rA   r(   r%   Úcomfy_entrypointr‹   ‡   s   é € ÜÓÐùs   ‚)rZ   r8   Útyping_extensionsr   Úcomfy.model_managementr:   Úcomfy.samplersÚcomfy.utilsÚcomfy_api.latestr   r   r�   r   rK   r\   r}   r‹   rA   r(   r%   Ú<module>r‘      sc   ðñó Ý &ã Û Û ß /ô2˜Ÿ™ô 2ô6Q�R—\‘\ô Qô@.5�—‘ô .5ôb
�~ô 
÷r(   