commit 0fc02e3b4f8c8904def2ce1a550520968deb7226 Author: zhousha <736730048@qq.com> Date: Wed Jun 10 21:42:41 2026 +0800 Initial commit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0950a05 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM modelhubxc-4pd.tencentcloudcr.com/xc_agent_platform/python:3.11-slim + +ENV PYTHONUNBUFFERED=1 + +WORKDIR /app + +COPY requirements.txt . +RUN pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt + +COPY . . + +EXPOSE 8080 + +CMD ["python", "main.py"] \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..48f5f14 --- /dev/null +++ b/main.py @@ -0,0 +1,155 @@ +import requests +import json +from typing import List, Tuple + +# ========== 全局配置 ========== +BASE_URL = "https://modelhub.org.cn" +LOGIN_ENDPOINT = "/adminApi/user/login" +SUBMIT_TEST_TASK_ENDPOINT = "/adminApi/async/task/create-contest-task" + +USER_ACCOUNT = "zhoushasha@4paradigm.com" +USER_PASSWORD = "4pdpassword" + + +CONTEST_API_TOKEN = "ef1ef82f3c9efee413d602345fbe224d" + + +CONTRIBUTORS = "zhoushasha" + + +GPU_TYPE = "Cambricon_mlu-370-x8" + +TASK_TYPE = "text-generation" + +HEADERS = {"Content-Type": "application/json"} + +# ======== 模型列表(保持不变)======== +ALL_MODEL_IDS = [ + + "AI-ModelScope/gemma-2b", + "AI-ModelScope/falcon-mamba-7b", + "katanemo/deepseek-2", + "OpenBMB/MiniCPM4-0.5B", + "NousResearch/Meta-Llama-3-8B-Instruct", + "MediaTek-Research/Breeze-7B-Instruct-v1_0", + "QLUNLP/BianCang-Qwen2.5-7B-Instruct", + "OpenBMB/MiniCPM4-Survey", + "OpenBMB/MiniCPM4-8B", + "PaddlePaddle/ERNIE-4.5-0.3B-PT", + "LLM-Research/Llama-Guard-3-8B", + "OpenBMB/MiniCPM-2B-dpo-fp16", + "OpenBMB/MiniCPM4.1-8B", + "Cylingo/Xinyuan-LLM-14B-0428", + "Fengshenbang/Ziya-LLaMA-13B-v1", + "baichuan-inc/Baichuan2-13B-Chat", + "LLM-Research/gemma-2-9b-it", + "Qwen/CodeQwen1.5-7B-Chat", + "OpenBMB/cpm-bee-10b", + "OpenBMB/MiniCPM3-4B", + + +] + +# === 登录获取 token === +def login(): + payload = {"userAccount": USER_ACCOUNT, "userPassword": USER_PASSWORD} + print("🔑 正在登录...") + resp = requests.post(BASE_URL + LOGIN_ENDPOINT, headers=HEADERS, json=payload) + if resp.status_code != 200: + raise Exception(f"HTTP 登录失败: {resp.text}") + data = resp.json() + if data.get("code") != 0: + raise Exception(f"业务登录失败: {data.get('message')}") + token = data["data"]["token"] + print("✅ 登录成功!") + return token + +# === 提交单个模型的测试任务(vLLM + kunlunxin_p-800)=== +def submit_test_task(token: str, model_id: str) -> Tuple[str, str]: + auth_headers = {**HEADERS, "Authorization": f"Bearer {token}"} + config_content = f"""docker_image: harbor.4pd.io/hardcore-tech/cambricon-mlu370-pytorch:v25.01-torch2.5.0-torchmlu1.24.1-ubuntu22.04-py310 +nv_docker_image: harbor.4pd.io/dooke/vllm/vllm/vllm-openai:v0.11.0 +framework: vllm +storage: gpfs +modelhub_options: + srcRelativePath: leaderboard/modelHubXC/{model_id} + mountPoint: /model +sut_config: + values: + gpu_num: 1 + env: + - name: MAX_MODEL_LEN + value: 8192 + command: ["vllm", "serve", "/model", "--port", "8000", "--served-model-name", "llm", "--max-model-len", "8192", "--trust-remote-code", "--dtype", "float16"] +ref_config: + values: + cpu_num: 2 + gpu_num: 1 + env: + - name: MAX_MODEL_LEN + value: 8192 + command: ["vllm", "serve", "/model", "--port", "80", "--served-model-name", "llm", "--max-model-len", "8192", "--trust-remote-code", "--dtype", "float16"] +""" + task_data = { + "contestApiToken": CONTEST_API_TOKEN, + "contributors": CONTRIBUTORS, + "gpuTypes": [GPU_TYPE], + "taskType": TASK_TYPE, + "modelId": model_id, + "framework": "vllm", + "submissionConfig": [{ + "config": config_content, + "gpuType": GPU_TYPE, + "taskType": TASK_TYPE + }] + } + print(f"📤 提交验证任务: {model_id} (GPU: {GPU_TYPE})") + try: + resp = requests.post(BASE_URL + SUBMIT_TEST_TASK_ENDPOINT, json=task_data, headers=auth_headers, timeout=15) + if resp.status_code == 200: + result = resp.json() + if result.get("code") == 0: + task_id = result.get("data", {}).get("id") + print(f"✅ 验证任务提交成功! Task ID: {task_id}") + return task_id, model_id + else: + print(f"❌ 验证任务业务错误 ({model_id}): {result.get('message')}") + return None, model_id + else: + print(f"❌ 验证任务 HTTP 错误 ({model_id}): {resp.status_code} - {resp.text}") + return None, model_id + except Exception as e: + print(f"💥 提交验证任务异常 ({model_id}): {e}") + return None, model_id + +# === 主函数:仅提交验证任务 === +def main(): + if not ALL_MODEL_IDS: + print("❌ 模型列表为空,请在 ALL_MODEL_IDS 中填入模型ID") + return + + token = login() + total_count = len(ALL_MODEL_IDS) + print(f"📊 共 {total_count} 个模型待提交验证任务") + + successful_tasks: List[Tuple[str, str]] = [] # (task_id, model_id) + + for model_id in ALL_MODEL_IDS: + task_id, mid = submit_test_task(token, model_id) + if task_id: + successful_tasks.append((task_id, mid)) + + # 写入成功提交的 task_id 和 model_id 到文件 + with open("submitted_validation_tasks.txt", "w", encoding="utf-8") as f: + for tid, mid in successful_tasks: + f.write(f"{tid}\t{mid}\n") + + # 最终统计 + print("\n" + "=" * 60) + print(f"🎉 全部完成!") + print(f"✅ 成功提交验证任务: {len(successful_tasks)}") + print(f"📄 详情已写入: submitted_validation_tasks.txt") + print(f"📊 总计尝试: {total_count}") + +if __name__ == "__main__": + main() \ No newline at end of file