MCPcopy
hub / github.com/InternLM/lmdeploy / run_eval_test

Function run_eval_test

autotest/evaluate/test_api_evaluate.py:112–186  ·  view source on GitHub ↗

Run test with specified evaluation configuration.

(config, run_config, worker_id, test_type='infer', eval_config_name='default', eval_subpath=None)

Source from the content-addressed store, hash-verified

110
111
112def run_eval_test(config, run_config, worker_id, test_type='infer', eval_config_name='default', eval_subpath=None):
113 """Run test with specified evaluation configuration."""
114 eval_config_name = resolve_eval_config_name(config, run_config, eval_config_name)
115 preset_config = get_eval_preset_config(config, run_config, eval_config_name)
116 eval_path = config.get('eval_path')
117 if eval_subpath:
118 eval_path = os.path.join(eval_path, eval_subpath)
119 os.makedirs(eval_path, exist_ok=True)
120
121 total_gpus = int(os.environ.get('TOTAL_GPU_COUNT', '8'))
122 work_num = int(total_gpus / run_config.get('parallel_config', {}).get('tp', 1))
123
124 extra_config = {'max-num-workers': min(work_num * 16, 64)}
125
126 case_name = get_case_str_by_config(run_config)
127
128 if test_type == 'infer':
129 proxy_pid, proxy_process = start_proxy_server(config.get('server_log_path'), constant.PROXY_PORT,
130 f'{case_name}_infer')
131 run_config_new = run_config.copy()
132 if 'extra_params' not in run_config_new:
133 run_config_new['extra_params'] = {}
134 run_config_new['extra_params']['proxy-url'] = f'http://{constant.DEFAULT_SERVER}:{constant.PROXY_PORT}'
135 run_config_new['extra_params']['server-name'] = constant.DEFAULT_SERVER
136
137 from concurrent.futures import ThreadPoolExecutor
138
139 def run_openai_service_start(i):
140 return start_openai_service(config, run_config_new, f'gw{i}')
141
142 with ThreadPoolExecutor(max_workers=work_num) as executor:
143 futures = [executor.submit(run_openai_service_start, i) for i in range(int(work_num))]
144 results = []
145 for future in futures:
146 pid, content = future.result()
147 results.append((pid, content))
148
149 try:
150 model_path = os.path.join(config.get('model_path'), run_config.get('model'))
151 eval_test(model_path,
152 eval_path,
153 case_name,
154 port=constant.PROXY_PORT,
155 test_type=test_type,
156 extra_config=extra_config,
157 eval_config_name=eval_config_name,
158 **preset_config)
159 finally:
160 for i in range(work_num):
161 terminate_restful_api(f'gw{i}')
162 stop_restful_api(proxy_pid, proxy_process)
163 else: # eval
164 port = constant.PROXY_PORT + get_workerid(worker_id)
165 proxy_pid, proxy_process = start_proxy_server(config.get('server_log_path'), port, f'{case_name}_eval')
166 eval_run_config = build_eval_judge_run_config(
167 config, f'http://{constant.DEFAULT_SERVER}:{port}')
168
169 pid, content = start_openai_service(config, eval_run_config, worker_id)

Calls 14

resolve_eval_config_nameFunction · 0.90
get_eval_preset_configFunction · 0.90
get_case_str_by_configFunction · 0.90
start_proxy_serverFunction · 0.90
eval_testFunction · 0.90
terminate_restful_apiFunction · 0.90
stop_restful_apiFunction · 0.90
get_workeridFunction · 0.90
start_openai_serviceFunction · 0.90
joinMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected