|
|
import lighteval |
|
|
from lighteval.logging.evaluation_tracker import EvaluationTracker |
|
|
from lighteval.models.vllm.vllm_model import VLLMModelConfig |
|
|
from lighteval.pipeline import ParallelismManager, Pipeline, PipelineParameters |
|
|
from lighteval.utils.imports import is_package_available |
|
|
from lighteval.tasks.lighteval_task import LightevalTask |
|
|
import os |
|
|
import torch |
|
|
import warnings |
|
|
|
|
|
def main(): |
|
|
|
|
|
os.environ["CUDA_VISIBLE_DEVICES"] = "0,1" |
|
|
|
|
|
|
|
|
os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn" |
|
|
|
|
|
os.environ["VLLM_USE_RAY_COMPILED_DAG"] = "1" |
|
|
|
|
|
num_gpus = torch.cuda.device_count() |
|
|
print(f"\n{'='*100}") |
|
|
print(f"Detected {num_gpus} GPU(s)") |
|
|
|
|
|
if num_gpus > 0: |
|
|
for i in range(num_gpus): |
|
|
print(f" GPU {i}: {torch.cuda.get_device_name(i)}") |
|
|
print(f"{'='*100}\n") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
evaluation_tracker = EvaluationTracker( |
|
|
output_dir="./results", |
|
|
save_details=True, |
|
|
push_to_hub=False, |
|
|
) |
|
|
|
|
|
pipeline_params = PipelineParameters( |
|
|
launcher_type=ParallelismManager.ACCELERATE, |
|
|
custom_tasks_directory=None, |
|
|
max_samples=500 |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model_config = VLLMModelConfig( |
|
|
|
|
|
|
|
|
|
|
|
model_name="/public/home/lshi/yoAI/projects/Online_CL/LUFFY/data/save_model/Qwen2.5-1.5B", |
|
|
|
|
|
|
|
|
|
|
|
dtype="bfloat16", |
|
|
max_model_length=4096, |
|
|
trust_remote_code=True, |
|
|
tensor_parallel_size=num_gpus, |
|
|
gpu_memory_utilization=0.90, |
|
|
) |
|
|
task = "lighteval|math_500|0" |
|
|
|
|
|
print(f"Using {num_gpus} GPU(s) with tensor parallelism\n") |
|
|
|
|
|
pipeline = Pipeline( |
|
|
tasks=task, |
|
|
pipeline_parameters=pipeline_params, |
|
|
evaluation_tracker=evaluation_tracker, |
|
|
model_config=model_config, |
|
|
) |
|
|
|
|
|
|
|
|
for task_name, task_obj in pipeline.tasks_dict.items(): |
|
|
for doc in task_obj._docs: |
|
|
doc.generation_size = 2048 |
|
|
try: |
|
|
pipeline.evaluate() |
|
|
|
|
|
pipeline.show_results() |
|
|
finally: |
|
|
|
|
|
if torch.distributed.is_initialized(): |
|
|
torch.distributed.destroy_process_group() |
|
|
|
|
|
if __name__ == "__main__": |
|
|
main() |