o
    پiy                     @   s`   d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
mZmZ G dd deZdS )	    N)ABC)SimpleNamespace)kill_process_tree)run_eval)!DEFAULT_TIMEOUT_FOR_SERVER_LAUNCHDEFAULT_URL_FOR_TESTpopen_launch_serverc                   @   sD   e Zd ZdZdZeZg dZdZe	dd Z
e	dd Zd	d
 ZdS )GSM8KAscendMixin g        )z--trust-remote-codez--mem-fraction-staticz0.8z--attention-backendascendz--disable-cuda-graph   c                 C   s   t | _dtjd< dtjd< dtjd< dtjd< d	tjd
< dtjd< dtjd< d	tjd< dtjd< dtjd< tj }t| j| j| j| j|d| _	d S )Nzexpandable_segments:TruePYTORCH_NPU_ALLOC_CONFztcp://127.0.0.1:24666ASCEND_MF_STORE_URL200HCCL_BUFFSIZE24.SGLANG_DEEPEP_NUM_MAX_DISPATCH_TOKENS_PER_RANK1USE_VLLM_CUSTOM_ALLREDUCEHCCL_EXEC_TIMEOUT32STREAMS_PER_DEVICESGLANG_ENBLE_TORCH_COMILE0AUTO_USE_UC_MEMORY20P2P_HCCL_BUFFSIZE)timeout
other_argsenv)
r   base_urlosenvironcopyr   modeltimeout_for_server_launchr   process)clsr    r(   Y/home/ubuntu/.local/lib/python3.10/site-packages/sglang/test/ascend/gsm8k_ascend_mixin.py
setUpClass   s&   










zGSM8KAscendMixin.setUpClassc                 C   s   t | jj d S )N)r   r&   pid)r'   r(   r(   r)   tearDownClass3   s   zGSM8KAscendMixin.tearDownClassc                 C   sf   t | jd ddddt| jdd d}t|}| |d | jd	| j d
t	|d  d| j  d S )N   i      zhttp://127.0.0.1:)	num_shots	data_pathnum_questionsmax_new_tokensparallelhostportaccuracyzAccuracy of z is z, is lower than )
r   gsm8k_num_shotsintr    splitr   assertGreaterEqualr8   r$   str)selfargsmetricsr(   r(   r)   
test_gsm8k7   s   	 zGSM8KAscendMixin.test_gsm8kN)__name__
__module____qualname__r$   r8   r   r%   r   r9   classmethodr*   r,   rA   r(   r(   r(   r)   r	      s    

r	   )r!   abcr   typesr   sglang.srt.utilsr   sglang.test.few_shot_gsm8kr   sglang.test.test_utilsr   r   r   r	   r(   r(   r(   r)   <module>   s    