Run test with specified evaluation configuration.
(config, run_config, worker_id, test_type='infer', eval_config_name='default', eval_subpath=None)
| 110 | |
| 111 | |
| 112 | def 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) |
no test coverage detected