o
    ٷi&                     @   s  U d dl Z d dlZd dlmZmZmZ d dlmZmZ d dl	m
Z
 d dlmZ d dlmZ zd dlmZ W n eyD   d dlmZ Y nw d dlZd dlmZmZmZmZ G d	d
 d
eZG dd deZG dd deZG dd deZeee B eB eB eB Zee d< 	 e
eB eB eB Z!ee d< 				ddee dedB dedB dej"dB de#eef dB defddZ$eG dd dZ%ee%B Z&ee d< dS )    N)asdict	dataclassfield)Any	TypeAlias)
PromptType)SamplingParams)LoRARequest)NotRequired)EmbedsPrompt
TextPromptTokenInputsTokensPromptc                   @   sN   e Zd ZU dZee ed< eej ed< eej ed< ee	ee
f  ed< dS )OmniTextPrompta  Text prompt with optional embeddings and additional information.

    Extends TextPrompt to support prompt embeddings and additional
    information payloads for direct transfer between pipeline stages.

    Attributes:
        prompt_embeds: Optional tensor containing prompt embeddings
        additional_information: Optional dictionary containing additional
            information (tensors or lists) to pass along with the prompt
    negative_promptprompt_embedsnegative_prompt_embedsadditional_informationN)__name__
__module____qualname____doc__r
   str__annotations__torchTensordictr    r   r   I/home/ubuntu/.local/lib/python3.10/site-packages/vllm_omni/inputs/data.pyr      s   
 r   c                   @   sX   e Zd ZU dZee ed< eej ed< ee	ej dB  ed< 	 ee
eef  ed< dS )OmniTokensPrompta  Tokens prompt with optional embeddings and additional information.

    Extends TokensPrompt to support prompt embeddings and additional
    information payloads for direct transfer between pipeline stages.

    Attributes:
        prompt_embeds: Optional tensor containing prompt embeddings
        additional_information: Optional dictionary containing additional
            information (tensors or lists) to pass along with the prompt
    r   r   Nr   r   r   r   r   r   r
   r   r   r   r   listr   r   r   r   r   r   r   (   s   
 r   c                   @   sV   e Zd ZU dZee ed< eej ed< ee	ej dB  ed< ee
eef  ed< dS )OmniTokenInputsa  Token inputs with optional embeddings and additional information.

    Extends TokenInputs to support prompt embeddings and additional
    information payloads for direct transfer between pipeline stages.

    Attributes:
        prompt_embeds: Optional tensor containing prompt embeddings
            aligned with token IDs
        additional_information: Optional dictionary containing additional
            information (tensors or lists) to pass along with the inputs
    r   r   Nr   r   r    r   r   r   r   r"   >   s   
 r"   c                   @   sJ   e Zd ZU dZeej ed< eeej dB  ed< ee	e
ef  ed< dS )OmniEmbedsPrompta  Embeddings prompt with optional additional information.

    Extends EmbedsPrompt to support additional information payloads
    for direct transfer between pipeline stages.

    Attributes:
        prompt_embeds: Optional tensor containing prompt embeddings
        additional_information: Optional dictionary containing additional
            information (tensors or lists) to pass along with the prompt
    r   Nr   r   )r   r   r   r   r
   r   r   r   r!   r   r   r   r   r   r   r   r#   U   s
   
 r#   OmniSingletonPromptOmniPromptTypeprompt_token_idsprompt
cache_saltr   r   returnc                 C   sP   t d| d}|dur||d< |dur||d< |dur||d< |dur&||d< |S )as  Construct token inputs with optional embeddings and metadata.

    Creates an OmniTokenInputs object with token IDs and optional
    embeddings and additional information for pipeline stage transfer.

    Args:
        prompt_token_ids: List of token IDs for the prompt
        prompt: Optional prompt string
        cache_salt: Optional cache salt for prefix caching
        prompt_embeds: Optional tensor containing prompt embeddings
        additional_information: Optional dictionary containing additional
            information (tensors or lists)

    Returns:
        OmniTokenInputs instance with the provided data
    token)typer&   Nr'   r(   r   r   )r"   )r&   r'   r(   r   r   inputsr   r   r   token_inputs_omnis   s   r-   c                   @   s  e Zd ZU dZdZedB ed< dZee	e
f dB ed< dZeed< dZeed< dZedB ed	< dZejeej B dB ed
< dZe	dB 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jdB ed< dZejdB ed< dZejdB ed< dZejdB ed< dZee eB dB ed< dZee eB dB ed< dZ eed< dZ!eed< dZ"edB ed< dZ#edB ed< dZ$edB ed< dZ%eed< dZ&eed< dZ'ejdB ed < dZ(eje)B eB dB ed!< dZ*edB ed"< dZ+e)dB ed#< d$Z,eed%< d&Z-e)ed'< dZ.eed(< dZ/e)dB ed)< d&Z0e)ed*< d&Z1e)ed+< dZ2ee) dB ed,< dZ3e)dB ed-< dZ4edB ed.< e5ed/Z6ee	e
f ed0< dZ7e
dB ed1< dZ8ee	e
f dB ed2< d3Z9eed4< e5ed/Z:ee	e
f ed5< dZ;eed6< dZ<eed7< dZ=eej dB ed8< dZ>ejdB ed9< e5ed/Z?ee	e
f ed:< d3Z@eed;< dZAeed<< dZBeCdB ed=< d>ZDe)ed?< dZEedB ed@< dZFeedA< dZGee dB edB< dZHee dB edC< d&ZIe)edD< dZJeedE< dFZKeedG< dZLeedH< dZMejdB edI< eNdJdK ZOdLdM ZPdQdOdPZQdS )ROmniDiffusionSamplingParamsa  
    The collection of sampling parameters passed to diffusion pipelines.

    This dataclass contains all information needed during the diffusion pipeline
    execution, allowing methods to update specific components without needing
    to manage numerous individual parameters.
    Nmax_sequence_lengthprompt_templateFdo_classifier_free_guidance   num_outputs_per_promptseed	generatorgenerator_device   layerscfg_normalizeuse_en_prompti  
resolutionis_prompt_processedlatentsraw_latent_shape
noise_predimage_latentheight_latentswidth_latents
num_framesnum_frames_round_downheightwidthfpsheight_not_providedwidth_not_provided	timestepstimestep
step_indexboundary_ratio2   num_inference_stepsg        guidance_scaleguidance_scale_providedguidance_scale_2guidance_rescaleetasigmastrue_cfg_scalen_tokens)default_factoryextra_step_kwargspast_key_valueskv_metadataTneed_kv_receivemodulesreturn_trajectory_latentsreturn_trajectory_decodedtrajectory_timestepstrajectory_latents
extra_argssave_outputreturn_frameslora_requestg      ?
lora_scale	STA_paramis_cfg_negativemask_search_final_result_posmask_search_final_result_negVSA_sparsityprofile   num_profiled_timestepsdebugoutputc                 C   s   | j S N)r3   selfr   r   r   
batch_size  s   z&OmniDiffusionSamplingParams.batch_sizec                 C   s   t jt| dddS )N   x   )indentrF   )pprintpformatr   rr   r   r   r   __str__  s   z#OmniDiffusionSamplingParams.__str__r)   c                 C   s
   t | S rq   )copydeepcopyrr   r   r   r   clone  s   
z!OmniDiffusionSamplingParams.clone)r)   r.   )Rr   r   r   r   r/   intr   r0   r   r   r   r1   boolr3   r4   r5   r   	Generatorr!   r6   r8   r9   r:   r;   r<   r=   r   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   floatrL   rM   rO   rP   rQ   rR   rS   rT   rU   rV   rW   r   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   r	   rf   rg   rh   ri   rj   rk   rl   rn   ro   rp   propertyrt   rz   r}   r   r   r   r   r.      s   
 	
r.   OmniSamplingParams)NNNN)'r{   rx   dataclassesr   r   r   typingr   r   vllm.inputsr   vllm.sampling_paramsr   vllm_omni.lora.requestr	   r
   ImportErrortyping_extensionsr   vllm.inputs.datar   r   r   r   r   r   r"   r#   r   r!   r~   r$   r   r%   r   r   r-   r.   r   r   r   r   r   <module>   sT   
  
% 