o
    ٷi                     @   s@   d dl mZ g dg dg dg ddZeG dd dZdS )	    )	dataclass)g~V)m*@g聏qg_~K@g>^\̏g尥(?)g      |g     q@g     Fg	@g{Gz)gp=JW4Ag!ge@g[wdgd7?)FluxTransformer2DModelQwenImageTransformer2DModelBagelZImageTransformer2DModelc                   @   sH   e Zd ZU dZdZeed< dZee dB ed< dZ	e
ed< dd	d
ZdS )TeaCacheConfiga  
    Configuration for TeaCache applied to transformer models.

    TeaCache (Timestep Embedding Aware Cache) is an adaptive caching technique that speeds up
    diffusion model inference by reusing transformer block computations when consecutive
    timestep embeddings are similar.

    Args:
        rel_l1_thresh: Threshold for accumulated relative L1 distance. When below threshold,
            cached residual is reused. Values in [0.1, 0.3] work best:
            - 0.2: ~1.5x speedup with minimal quality loss
            - 0.4: ~1.8x speedup with slight quality loss
            - 0.6: ~2.0x speedup with noticeable quality loss
        coefficients: Polynomial coefficients for rescaling L1 distance. If None, uses
            model-specific defaults based on transformer_type.
        transformer_type: Transformer class name (e.g., "QwenImageTransformer2DModel").
            Auto-detected from pipeline.transformer.__class__.__name__ in backend.
            Defaults to "QwenImageTransformer2DModel".
    g?rel_l1_threshNcoefficientsr   transformer_typereturnc                 C   s~   | j dkrtd| j  | jdu r,| jtvr&td| j dtt  t| j | _t| jdkr=tdt| j dS )z&Validate and set default coefficients.r   z$rel_l1_thresh must be positive, got NzCannot find coefficients for z. Supported:    z2coefficients must contain exactly 5 elements, got )	r   
ValueErrorr	   r
   _MODEL_COEFFICIENTSKeyErrorlistkeyslen)self r   ]/home/ubuntu/.local/lib/python3.10/site-packages/vllm_omni/diffusion/cache/teacache/config.py__post_init__E   s   




zTeaCacheConfig.__post_init__)r   N)__name__
__module____qualname____doc__r   float__annotations__r	   r   r
   strr   r   r   r   r   r   +   s   
 r   N)dataclassesr   r   r   r   r   r   r   <module>   s   
	"