o
    پi@                     @   s   d dl Z d dlZd dlmZmZ d dlmZmZmZm	Z	 d dl
Z
d dlmZ d dlmZ eeZG dd dee jZeG dd	 d	ZdS )
    N)	dataclassfield)AnyListOptionalUnion)ModelOptConfig)is_hipc                   @   sT   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdZdS )
LoadFormatautoptsafetensorsnpcachedummysharded_stateggufbitsandbytesmistrallayeredflash_rljaxremoteremote_instancerdmalocal_cachedfastsafetensorsprivateN)__name__
__module____qualname__AUTOPTSAFETENSORSNPCACHEDUMMYSHARDED_STATEGGUFBITSANDBYTESMISTRALLAYEREDFLASH_RLJAXREMOTEREMOTE_INSTANCERDMALOCAL_CACHEDFASTSAFETENSORSPRIVATE r2   r2   R/home/ubuntu/.local/lib/python3.10/site-packages/sglang/srt/configs/load_config.pyr
      s&    r
   c                   @   sd  e Zd ZU dZejZeeef e	d< dZ
ee e	d< eedZeeeef  e	d< dZeeee ef  e	d< dZee e	d< d	Zee	d
< dZee e	d< dZee e	d< dZee e	d< dZeee  e	d< dZee e	d< dZee e	d< dZee e	d< dZee e	d< dZee e	d< dZee e	d< dZ ee e	d< dZ!ee e	d< dd Z"dddZ#dS )
LoadConfiga  
    download_dir: Directory to download and load the weights, default to the
        default cache directory of huggingface.
    load_format: The format of the model weights to load:
        "auto" will try to load the weights in the safetensors format and
            fall back to the pytorch bin format if safetensors format is
            not available.
        "pt" will load the weights in the pytorch bin format.
        "safetensors" will load the weights in the safetensors format.
        "npcache" will load the weights in pytorch format and store
            a numpy cache to speed up the loading.
        "dummy" will initialize the weights with random values, which is
            mainly for profiling.
        "bitsandbytes" will load nf4 type weights.
        "flash_rl" will load weights with support for RL training
            with quantized models, enabling efficient weight reloading.
    ignore_patterns: The list of patterns to ignore when loading the model.
        Default to "original/**/*" to avoid repeated loading of llama's
        checkpoints.
    decryption_key_file: If set, decrypts the output files with a password read
        from this file (after PBKDF2).
    decrypt_max_concurrency: The maximum number of concurrent processes to decrypt the safetensor files. -1 means no limit.

    # ModelOpt-specific loading options
    modelopt_checkpoint_restore_path: Optional[str] = None
    modelopt_checkpoint_save_path: Optional[str] = None
    modelopt_export_path: Optional[str] = None
    load_formatNdownload_dir)default_factorymodel_loader_extra_configignore_patternsdecryption_key_filedecrypt_max_concurrencytp_rank.remote_instance_weight_loader_seed_instance_ip8remote_instance_weight_loader_seed_instance_service_port6remote_instance_weight_loader_send_weights_group_ports%remote_instance_weight_loader_backend-remote_instance_weight_loader_transfer_engine modelopt_checkpoint_restore_pathmodelopt_checkpoint_save_pathmodelopt_export_pathmodelopt_configrl_quant_profiledraft_model_idxc                 C   s   | j pi }t|trt|| _ |   | jd ur(t| jdkr(t	d| j ndg| _| j
d u r>t| j| j| jd| _
d S d S )Nr   z<Ignoring the following patterns when downloading weights: %szoriginal/**/*)checkpoint_restore_pathcheckpoint_save_pathexport_path)r8   
isinstancestrorjsonloads_verify_load_formatr9   lenloggerinforF   r   rC   rD   rE   )selfr8   r2   r2   r3   __post_init__`   s"   


zLoadConfig.__post_init__returnc                    sf   t | jtsd S | j }t|| _g  t r/| v r1 fddtjD }td| d| d S d S )Nc                    s   g | ]}| vr|qS r2   r2   ).0frocm_not_supported_load_formatr2   r3   
<listcomp>   s
    z2LoadConfig._verify_load_format.<locals>.<listcomp>zload format 'z7' is not supported in ROCm. Supported load formats are )rL   r5   rM   lowerr
   r	   __members__
ValueError)rT   r5   rocm_supported_load_formatr2   rY   r3   rP   v   s   


zLoadConfig._verify_load_format)rV   N)$r   r   r   __doc__r
   r    r5   r   rM   __annotations__r6   r   r   dictr8   r9   r   r:   r<   intr=   r>   r?   r@   rA   rB   r   rC   rD   rE   rF   r   rG   rH   rU   rP   r2   r2   r2   r3   r4   $   s.   
 r4   )enumloggingdataclassesr   r   typingr   r   r   r   rN   "sglang.srt.configs.modelopt_configr   sglang.srt.utilsr	   	getLoggerr   rR   rM   Enumr
   r4   r2   r2   r2   r3   <module>   s   
