o
    پi                     @   s|   d dl Z d dlZd dlmZmZ d dlmZ d dlZd dlmZm	Z	 d dl
mZ eG dd deZeG dd	 d	e	ZdS )
    N)	dataclassfield)Any)
ArchConfigModelConfig)StoreBooleanc                   @   s8   e Zd ZU dZeejB ed< dZe	ed< dZ
e	ed< dS )VAEArchConfigr   scaling_factor   temporal_compression_ratio   spatial_compression_ratioN)__name__
__module____qualname__r	   floattorchTensor__annotations__r   intr    r   r   b/home/ubuntu/.local/lib/python3.10/site-packages/sglang/multimodal_gen/configs/models/vaes/base.pyr      s   
 r   c                   @   s  e Zd ZU eedZeed< dZeed< dZ	eed< dZ
eed< dZeed< d	Zeed
< dZeed< dZeed< dZeed< dZeed< dZeed< dZeed< dZeed< dZeed< dd Zdd Zed(dededefddZd d! Zd"d# Zed$ej dd fd%d&Z!d'S ))	VAEConfig)default_factoryarch_configTload_encoderload_decoder   tile_sample_min_heighttile_sample_min_width   tile_sample_min_num_frames   tile_sample_stride_heighttile_sample_stride_width   tile_sample_stride_num_framesr   blend_num_frames
use_tilinguse_temporal_tilinguse_parallel_tilinguse_temporal_scaling_framesc                 C   s   | j | j | _d S N)r!   r&   r'   selfr   r   r   __post_init__-   s   
zVAEConfig.__post_init__c                 C   s   d S r,   r   r-   r   r   r   	post_init2      zVAEConfig.post_init
vae-configparserprefixreturnc                 C   s  | j d| dt|dd dtjdd | j d| dt|dd d	tjd
d | j d| dt|dd dtjdd | j d| dt|dd dtjdd | j d| dt|dd dtj	dd | j d| dt|dd dtj
dd | j d| dt|dd dtjdd | j d| dt|dd dtjdd | j d| dt|dd dtjd d | j d| d!t|dd d"tjd#d | j d| d$t|dd d%tjd&d | j d| d't|dd d(tjd)d | S )*z&Add CLI arguments for VAEConfig fieldsz--z.load-encoder-_z.load_encoderzWhether to load the VAE encoder)actiondestdefaulthelpz.load-decoderz.load_decoderzWhether to load the VAE decoderz.tile-sample-min-heightz.tile_sample_min_heightz$Minimum height for VAE tile sampling)typer9   r:   r;   z.tile-sample-min-widthz.tile_sample_min_widthz#Minimum width for VAE tile samplingz.tile-sample-min-num-framesz.tile_sample_min_num_framesz.Minimum number of frames for VAE tile samplingz.tile-sample-stride-heightz.tile_sample_stride_heightz#Stride height for VAE tile samplingz.tile-sample-stride-widthz.tile_sample_stride_widthz"Stride width for VAE tile samplingz.tile-sample-stride-num-framesz.tile_sample_stride_num_framesz-Stride number of frames for VAE tile samplingz.blend-num-framesz.blend_num_framesz/Number of frames to blend for VAE tile samplingz.use-tilingz.use_tilingzWhether to use tiling for VAEz.use-temporal-tilingz.use_temporal_tilingz&Whether to use temporal tiling for VAEz.use-parallel-tilingz.use_parallel_tilingz&Whether to use parallel tiling for VAE)add_argumentr   replacer   r   r   r   r   r   r!   r#   r$   r&   r'   r(   r)   r*   )r3   r4   r   r   r   add_cli_args5   s   











zVAEConfig.add_cli_argsc                 C   s   dt | jjd  S )N      )lenr   block_out_channelsr-   r   r   r   get_vae_scale_factor   s   zVAEConfig.get_vae_scale_factorc                 C   s   dS )Nargmaxr   r-   r   r   r   encode_sample_mode   r1   zVAEConfig.encode_sample_modeargsc                 C   sB   i }t | D ]}t||jd }|d ur|||j< q| di |S )Nr   )dataclassesfieldsgetattrname)clsrG   kwargsattrvaluer   r   r   from_cli_args   s   
zVAEConfig.from_cli_argsN)r2   )"r   r   r   r   r   r   r   r   boolr   r   r   r   r!   r#   r$   r&   r'   r(   r)   r*   r+   r/   r0   staticmethodr   strr?   rD   rF   classmethodargparse	NamespacerP   r   r   r   r   r      s.   
 Yr   )rU   rH   r   r   typingr   r   )sglang.multimodal_gen.configs.models.baser   r   sglang.multimodal_gen.utilsr   r   r   r   r   r   r   <module>   s   