
    
3j                         S r SSKrSSKrSSKrSSKJr  SSKJr  SSK	J
r
   " S S\5      r\" S5      r " S	 S
\R                  5      r " S S5      r " S S\
5      rg)z
Low VRAM loader nodes for sequential model loading.

These nodes add a 'dependencies' input to control execution order,
ensuring models load one after another instead of simultaneously.
This reduces peak VRAM usage in memory-constrained environments.
    N)AudioVAE)io)LatentUpscaleModelLoaderc                   *    \ rS rSrSrS\S\4S jrSrg)AnyType   z@Custom type that matches any ComfyUI type for dependency inputs._AnyType__valuereturnc                     g)NF )selfr	   s     N/home/wildlama/comfy/ComfyUI/custom_nodes/ComfyUI-LTXVideo/low_vram_loaders.py__ne__AnyType.__ne__   s        r   N)	__name__
__module____qualname____firstlineno____doc__objectboolr   __static_attributes__r   r   r   r   r      s    Jf  r   r   *c                   l   ^  \ rS rSrSr\S\4U 4S jj5       rSrSr	Sr
 SS\S	\S\4U 4S
 jjjrSrU =r$ )LowVRAMCheckpointLoader   zSLoad Checkpoint with dependency input for sequential loading in low VRAM scenarios.r
   c                 B   > [         TU ]  5       nS[        SS040US'   U$ )NdependenciestooltipGConnect any output from a previous loader to ensure sequential loading.optional)superINPUT_TYPESany_type)s
base_types	__class__s     r   r$   #LowVRAMCheckpointLoader.INPUT_TYPES   s:    W(*
h"

: r   LTXV/loaderszLoads a diffusion model checkpoint with dependency support. Connect 'dependencies' to a previous loader's output to ensure sequential loading and reduce peak VRAM usage.load_checkpoint_sequentially	ckpt_namer   c                 "   > [         TU ]  U5      $ N)r#   load_checkpoint)r   r,   r   r(   s      r   r+   4LowVRAMCheckpointLoader.load_checkpoint_sequentially2   s    
 w&y11r   r   r.   )r   r   r   r   r   classmethoddictr$   CATEGORYDESCRIPTIONFUNCTIONstrr   tupler+   r   __classcell__)r(   s   @r   r   r      sc    ]
$ 
 
 H	x  .H
  $22 2 
	2 2r   r   c                   `    \ rS rSrSr\S\4S j5       rSrSr	Sr
SrS	r SS\S\S\4S jjrSrg
)LowVRAMAudioVAELoader:   zWLoad LTXV Audio VAE with dependency input for sequential loading in low VRAM scenarios.r
   c                 T    S[         R                  " S5      SS040S[        SS040S.$ )Nr,   checkpointsr    zAudio VAE checkpoint to load.r   r!   )requiredr"   )folder_pathsget_filename_listr%   )r&   s    r   r$   !LowVRAMAudioVAELoader.INPUT_TYPES=   sO      22=A ?@ !#l!
 	
r   )VAE)	audio_vaer*   zLoads an LTXV Audio VAE checkpoint with dependency support. Connect 'dependencies' to a previous loader's output to ensure sequential loading and reduce peak VRAM usage.load_audio_vae_sequentiallyNr,   r   c                     [         R                  " SU5      n[        R                  R	                  USS9u  pE[        XE5      nU4$ )Nr=   T)return_metadata)r?   get_full_path_or_raisecomfyutilsload_torch_filer   )r   r,   r   	ckpt_pathsdmetadatarC   s          r   rD   1LowVRAMAudioVAELoader.load_audio_vae_sequentiallyY   sC    
 !77yQ	{{229d2SR*	|r   r   r.   )r   r   r   r   r   r1   r2   r$   RETURN_TYPESRETURN_NAMESr3   r4   r5   r6   r   r7   rD   r   r   r   r   r:   r:   :   sl    a
$ 
 
$ L!LH	x  -H
  $  
	 r   r:   c                   X    \ rS rSrSr\S 5       r\SS\R                  4S jj5       r	Sr
g)	LowVRAMLatentUpscaleModelLoaderd   zYLoad latent upsampler with dependency input for sequential loading in low VRAM scenarios.c                 
   [         R                  " SSS[         R                  R                  S[        R
                  " S5      S9[         R                  R                  SSS	S
9/[         R                  R                  5       /S9$ )NrR   z!Low VRAMLoad Latent Upscale Modelr*   
model_namelatent_upscale_models)optionsr   Tr!   )r"   r    )node_iddisplay_namecategoryinputsoutputs)	r   SchemaComboInputr?   r@   r   LatentUpscaleModelOutput)clss    r   define_schema-LowVRAMLatentUpscaleModelLoader.define_schemag   s    yy5<# (::;RS   

  "!e ! 
 %%,,.
 	
r   Nr
   c                 *    [         R                  " US9$ )N)rU   )r   execute)rb   rU   r   s      r   rf   'LowVRAMLatentUpscaleModelLoader.execute}   s    '//:FFr   r   r.   )r   r   r   r   r   r1   rc   r   
NodeOutputrf   r   r   r   r   rR   rR   d   s9    c
 
* Gr}} G Gr   rR   )r   comfy.utilsrH   r?   nodes"comfy.ldm.lightricks.vae.audio_vaer   comfy_api.latestr   comfy_extras.nodes_hunyuanr   r6   r   r%   CheckpointLoaderSimpler   r:   rR   r   r   r   <module>ro      sa       7  ?c  3<2e:: 2>' 'TG&> Gr   