12 Commits

Author SHA1 Message Date
4e603b9fb0 update 2026-07-14 19:06:47 +08:00
5fe8bf27e5 update main.py
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 18:41:06 +08:00
d6b0e416db update ppu 2026-07-13 19:43:35 +08:00
4dcfed6b6d update ppu 2026-07-13 18:38:55 +08:00
1e8cfacd8e uodate 2026-06-22 19:00:46 +08:00
d6cca90496 update main.py 2026-06-22 18:44:42 +08:00
031e0dc7a8 update main.py 2026-06-19 01:48:50 +08:00
af6f501a5a update main.py 2026-06-18 15:22:29 +08:00
94da35d152 clean up Dockerfile 2026-06-14 23:55:41 +08:00
5b92f129d2 clean up Dockerfile 2026-06-14 23:54:02 +08:00
87d4ae1c18 fix: add env vars to Dockerfile 2026-06-12 21:02:56 +08:00
6f599a8a23 fix: add env vars to Dockerfile 2026-06-12 14:51:50 +08:00
4 changed files with 300 additions and 63 deletions

View File

@@ -1,6 +1,7 @@
FROM modelhubxc-4pd.tencentcloudcr.com/xc_agent_platform/python:3.11-slim
ENV PYTHONUNBUFFERED=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app

View File

@@ -1,5 +1,29 @@
# xc_validation_strategy
信创自动化模型适配平台 — 验证策略服务
批量向 ModelHub XC 平台提交模型验证任务的策略服务,之后保持 HTTP 服务存活供平台探活。
从 HuggingFace 周期性抓取新模型,自动完成同步、下载、提交验证任务的全流程,常驻运行在 xc_agent_platform 上。
## 功能
- 自动登录 ModelHub 获取 Token
- 批量提交模型验证任务vLLM 框架Cambricon MLU-370-x8
- 提交结果写入 `submitted_validation_tasks.txt`
- 暴露 `/health``/status` 接口满足平台运行时契约
## 项目结构
```
.
├── main.py # 主入口HTTP 服务 + 提交逻辑
├── Dockerfile # 平台镜像构建配置
├── requirements.txt # Python 依赖
└── submitted_validation_tasks.txt # 运行后自动生成,记录提交结果
```
## 平台契约说明
本项目满足平台对策略镜像的全部必要约束:
- Dockerfile 位于仓库根目录,基于官方轻量基础镜像
- 暴露 8080 端口并实现 `GET /health`
- 通过环境变量 `STRATEGY_ID` 获取策略 ID
- 正确处理 `SIGTERM` 信号,支持优雅停机

Binary file not shown.

332
main.py
View File

@@ -9,7 +9,6 @@ import json
import os
import signal
import threading
import traceback
from datetime import datetime
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from typing import List, Tuple
@@ -20,16 +19,15 @@ import requests
# 配置(全部从环境变量读取,不硬编码敏感信息)
# ══════════════════════════════════════════════════════════
BASE_URL = os.environ.get("BASE_URL", "https://modelhub.org.cn")
LOGIN_ENDPOINT = "/adminApi/user/login"
SUBMIT_ENDPOINT = "/adminApi/async/task/create-contest-task"
USER_ACCOUNT = os.environ["USER_ACCOUNT"] # 必填
USER_PASSWORD = os.environ["USER_PASSWORD"] # 必填
CONTEST_API_TOKEN = os.environ["CONTEST_API_TOKEN"] # 必填
STRATEGY_ID = os.environ.get("STRATEGY_ID", "") # 平台注入
CONTRIBUTORS = os.environ.get("CONTRIBUTORS", USER_ACCOUNT)
GPU_TYPE = os.environ.get("GPU_TYPE", "Cambricon_mlu-370-x8")
TASK_TYPE = os.environ.get("TASK_TYPE", "text-generation")
# 通过 curl -X POST https://modelhub.org.cn/adminApi/user/login 获取后填入
AUTH_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyQWNjb3VudCI6Inpob3VzaGFzaGEiLCJpZCI6MTQsInVzZXJSb2xlIjoibGVhZGVyYm9hcmQiLCJleHAiOjE3ODQ1NDc1NDYsImlhdCI6MTc4Mzk0Mjc0Nn0.ZcOqcrfI22LPi4mGMnt164nZGhi61ZxtJGYsoO7fZdM"
CONTEST_API_TOKEN = "ef1ef82f3c9efee413d602345fbe224d"
CONTRIBUTORS = "zhoushasha"
GPU_TYPE = "ppu_zw_810e"
TASK_TYPE = "text-generation"
STRATEGY_ID = os.environ.get("STRATEGY_ID", "") # 平台自动注入,无需修改
HTTP_HOST = "0.0.0.0"
HTTP_PORT = 8080
@@ -38,26 +36,231 @@ HTTP_PORT = 8080
# 模型列表
# ══════════════════════════════════════════════════════════
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",
"Alienpenguin10/M3PO-bahdanau-trial1-seed123",
"sujalrajpoot/TrueSyncAI-Aurion",
"prithivMLmods/Tureis-Qwen3_QWQ-4B-Exp",
"standrey/listing-parser-llama31-8b-ft-v1-full",
"zarakiquemparte/zarablend-l2-7b",
"linzju/Bio-Medical-Llama-3-8B_EnchTable_FFN",
"leonMW/Qwen3-4B-Thinking-2507-GSPO-Easy",
"longvideoagent/longvideoagent-qwen3-4b",
"ishikaa/acquisition_qwen3b_alpaca_proximity",
"01ai/Yi-9B-200K",
"Gille/StrangeMerges_33-7B-slerp",
"sstoica12/acquisition_llama-3_2-3b_bins_medmcqa_gradient",
"speechlessai/speechless-coding-7b-16k-tora",
"unsloth/Qwen2.5-Math-1.5B-Instruct",
"Yuma42/KangalKhan-Sapphire-7B",
"shadowml/BeagleSempra-7B",
"bralynn/test18",
"m-a-p/OProver-8B-Round1",
"yeen214/test_llama2_7b",
"Xwin-LM/Xwin-LM-7B-V0.2",
"FreedomIntelligence/AceGPT-13B",
"Edcastro/tinyllama-edcastr_JavaScript-v2",
"zarakiquemparte/zaraxe-l2-7b",
"MaziyarPanahi/Llama-3-8B-Instruct-v0.8",
"defog/sqlcoder2",
"SawinuCP/bus_booking_voice_agent_merged",
"j05hr3d/Llama-3.2-3B-Instruct-C_M_T-DOLLY-SEED999",
"Changgil/K2S3-SOLAR-11b-v1.0",
"agentica-org/DeepCoder-1.5B-Preview",
"prithivMLmods/Omni-Reasoner3-Merged",
"ibm-granite/granite-7b-instruct",
"zarakiquemparte/kuchiki-1.1-l2-7b",
"MaziyarPanahi/Llama-3-8B-Instruct-v0.1",
"Magpie-Align/Llama-3.1-8B-Magpie-Align-v0.1",
"prithivMLmods/Neumind-Math-7B-Instruct",
"dphn/dolphin-2.9.3-qwen2-1.5b",
"OpenBuddy/openbuddy-mistral-7b-v13",
"kairawal/Qwen3-4B-TL-SynthDolly-1A-E3",
"sahilnagaralu/movie-script",
"xw1234gan/SFT_Qwen2.5-1.5B-Instruct_cnk12",
"yunjae-won/ubq30i_qwen4b_sft_yl",
"1010happy/qwen3BInstruct_ClaudeDefault",
"yunjae-won/ubq30i_qwen4b_sft_both",
"willieseun/AIMO-Qwen2.5-Math-1.5B-Instruct-Finetuned",
"NousResearch/Yarn-Mistral-7b-64k",
"xiaolesu/OsmosisProofling-GRPO-NT",
"health360/Healix-410M",
"RUC-AIBOX/STILL-3-1.5B-preview",
"cjvt/GaMS-1B",
"Lansechen/Qwen2.5-7B-Open-R1-GRPO-math-lighteval-1epochstop-withformat",
"Charlie911/vicuna-7b-v1.5-general-temporal-merged",
"Kyleyee/cDPO_hh-seed5",
"prithivMLmods/Llama-3.2-3B-Math-Oct",
"Kyleyee/HINGE_hh-seed5",
"arcee-ai/Patent-Instruct-7b",
"jb723/cross_lingual_epoch2",
"davidkim205/komt-mistral-7b-v1",
"kalisai/Nusantara-1.8b-Indo-Chat",
"prithivMLmods/Llama-8B-Distill-CoT",
"Kyleyee/HINGE_hh-seed3",
"simplescaling/s1.1-1.5B",
"sail/Sailor2-3B-SFT",
"allenai/OLMoE-1B-7B-0924-Instruct",
"prithivMLmods/Llama-3.2-6B-AlgoCode",
"CloneBO/OracleLM",
"NousResearch/Yarn-Solar-10b-32k",
"m-a-p/OProver-8B-Base",
"HuggingFaceH4/mistral-7b-sft-alpha",
"Hyeongwon/P2-split2_prob_Qwen3-4B-Base_0312-01",
"martyn/mixtral-megamerge-dare-8x7b-v1",
"Kyleyee/rDPO_hh-seed4",
"jingyeom/seal3.1.6n_7b",
"sonthenguyen/OpenHermes-2.5-Mistral-7B-mt-bench-DPO-reversed_corrupted",
"shibing624/ziya-llama-13b-medical-merged",
"datajuicer/LLaMA-1B-dj-refine-150B",
"ajibawa-2023/Uncensored-Jordan-7B",
"nlpguy/AlloyIngot",
"HuggingFaceTB/SmolLM3-3B",
"allenai/codetulu-2-7b",
"vihangd/dopeyshearedplats-2.7b-v1",
"uukuguy/speechless-code-mistral-7b-v2.0",
"j05hr3d/Llama-3.2-3B-Instruct-C_M_T-ALPACA",
"cognitivetech/Mistral-7B-Inst-0.2-Bulleted-Notes",
"sail/Qwen2.5-Math-1.5B-Oat-Zero",
"reaperdoesntknow/SMOLM2Prover",
"Kyleyee/ORPO_hh-seed5",
"CarrotAI/Llama-3.2-Rabbit-Ko-3B-Instruct",
"NousResearch/Nous-Capybara-7B-V1",
"Vijay3548/InterviewMaster-Llama3.1",
"ReviewHub/qwen3-4b-it-2507-sft-2018-2022-rl-step-20",
"Nos-PT/Llama-Carvalho-PT",
"Gille/StrangeMerges_49-7B-dare_ties",
"Kyleyee/CPO_hh-seed2",
"Kyleyee/cDPO_hh-seed3",
"Kyleyee/DrDPO_hh-seed2",
"sthenno-com/miscii-14b-0218",
"mtgv/MobileLLaMA-2.7B-Chat",
"Novaciano/Alice_In_The_Dark_2-Slerp-RP-3.2-1B",
"Himitsui/KuroMitsu-11B",
"owlninjam/nytheria-3b",
"Kyleyee/DrDPO_hh-seed4",
"Kyleyee/DrDPO_hh-seed5",
"shahzebnaveed/NeuralHermes-2.5-Mistral-7B",
"plaguss/mistal-7b-prm-openrlhf",
"viethq188/Rabbit-7B-v2-DPO-Chat",
"EmbeddedLLM/Mistral-7B-Merge-14-v0.3-ft-step-9984",
"dbpedia/nspm-starcoder-1b",
"psh3333/llama-3.2-3b-grpo-merged",
"saarvajanik/facebook-opt-6.7b-qcqa-ub-16-best-for-KV-cache",
"EmbeddedLLM/Mistral-7B-Merge-14-v0.3",
"xformAI/facebook-opt-125m-qcqa-ub-6-best-for-KV-cache",
"Rev124/llama-3-pruned",
"RatanRohith/NeuralPizza-7B-V0.3",
"mncai/DPO_BC_partial_epoch6",
"zeemen2723/museai-lyrics-gen",
"automerger/OgnoExperiment27-7B",
"sohamb37lexsi/qwen25-3b-legal-correction",
"swift/Meta-Llama-3-8B",
"m-a-p/MuPT-v0-8192-190M",
"Kquant03/Samlagast-7B-laser-bf16",
"VTSNLP/Llama3-ViettelSolutions-8B",
"vihangd/dopeyshearedplats-1.3b-v1",
"HCY123902/qwen25_7b_base_hc_tsss_n32_r1_dpo",
"coder3101/gemma-3-1b-it-heretic",
"Hemkant04/qwen05-resume-job-match-evaluator",
"yekon9/Qwen3-4B-Instruct-2507-heretic",
"uukuguy/Orca-2-13b-f16",
"Kquant03/NeuralTrix-7B-dpo-relaser",
"sambanovasystems/SambaLingo-Russian-Base",
"bineric/NorskGPT-Mistral-7b",
"ReviewHub/qwen3-4b-it-2507-sft-2018-2022-rl-step-10",
"beyoru/EvolLLM",
"driaforall/Dria-Agent-a-3B",
"tlphams/zoyllm-7b-slimorca",
"QuixiAI/WizardLM-33B-V1.0-Uncensored",
"bilalRahib/TinyLLama-NSFW-Chatbot",
"Ahatsham/Llama-3-8B-Instruct_Planning_Feedback_oldaug_v2",
"unsloth/Qwen2.5-Math-1.5B",
"wang7776/Llama-2-7b-chat-hf-30-sparsity",
"hector-gr/RLCR-v4-ks-uniqueness-buf5k-hotpot",
"m-a-p/neo_7b_instruct_v0.1",
"p208p2002/llama-traditional-chinese-120M",
"tartuNLP/Llammas-base",
"riotu-lab/ArabianGPT-01B",
"openaccess-ai-collective/DPOpenHermes-7B",
"Enxin/MovieChat-vicuna",
"Skywork/Skywork-OR1-Math-7B",
"Lugha-Llama/Lugha-Llama-8B-wura_edu",
"laion/allenai-sera-unified-316__Qwen3-8B",
"T1anyu/DeepInnovator",
"mideind/icelandic-gpt-sw3-6.7b-gec",
"Rayeeennnnnnnn/legalmind-chatbot",
"Wanfq/FuseLLM-7B",
"mrvinph/Qwen2.5-0.5B-Instruct-Gensyn-Swarm-placid_wily_woodpecker",
"shivanikerai/Llama-2-7b-chat-hf-title-ner-and-title-suggestions-v2.0",
"Invalid-Null/PeiYangMe-0.7",
"open-unlearning/unlearn_tofu_Llama-3.2-1B-Instruct_forget10_GradDiff_lr1e-05_alpha5_epoch5",
"Tesslate/Tessa-T1-3B",
"LorenaYannnnn/unsafe_compliance-Qwen3-0.6B-OURS_self-seed_1",
"HiTZ/latxa-7b-v1",
"huggyllama/llama-7b",
"FlyPig23/Llama3.2-3B_Paper_Impact_media_SFT_1ep",
"hongzhouyu/FineMedLM-o1",
"shisa-ai/shisa-v1-llama3-8b.lr-5e6",
"senseable/Westlake-7B",
"simplescaling/s1.1-3B",
"Borjan/finki-gpt-140M",
"TinyLlama/TinyLlama_v1.1_chinese",
"Manirajan/interview_tiny",
"ajibawa-2023/Young-Children-Storyteller-Mistral-7B",
"TinyLlama/TinyLlama_v1.1_math_code",
"manotham/Thai-dialogue-transalate_sft_80K",
"nassimjp/Maral-7B-alpha-1",
"MSL7/INEX16-7b",
"Rayeeennnnnnnn/mizan-legal-tunisian",
"maheshrawat18/Qwen3-4B-2507-sft1",
"prithivMLmods/Theta-Crucis-0.6B-Turbo1",
"mlabonne/llama-2-7b-miniguanaco",
"FreekCoolAI/privacy-gemma-qlora",
"lex-hue/Delexa-V0.1-7b",
"goldfish-models/tur_latn_100mb",
"shisa-ai/ablation-18-rafbestseq-shisa-v2-llama-3.1-8b-lr8e6",
"yash-lulla/Legal_AI_Assistant",
"prithivMLmods/Deepthink-Llama-3-8B-Preview",
"prithivMLmods/QwQ-R1-Distill-7B-CoT",
"sstoica12/acquisition_metamath_llama_instruct-3_1-8b-math_format_500_combined_openr1math",
"goldfish-models/rus_cyrl_1000mb",
"goldfish-models/ukr_cyrl_1000mb",
"eren23/dpo-binarized-NeutrixOmnibe-7B",
"RAANA-IA/Gheya-med",
"mesolitica/malaysian-tinyllama-1.1b-16k-instructions-v2",
"bue0912/ToolOmni-Qwen3-4B",
"BRlkl/distill-sft-qwen3-4b-full",
"prithivMLmods/PocketThinker-QwQ-3B-Instruct",
"prithivMLmods/Megatron-Bots-1.7B-Reasoning",
"kumarprince070107/geobot",
"ClaudioSavelli/FAME_GA_llama32-1b-instruct-qa",
"kairawal/Qwen3-0.6B-EL-SynthDolly-1A-E8",
"prithivMLmods/Poseidon-Reasoning-1.7B",
"PKU-Alignment/ProgressGym-HistLlama3-8B-C014-instruct-v0.2",
"unsloth/Qwen2-7B",
"prithivMLmods/Open-Xi-Math-Preview",
"MiniLLM/teacher-gpt2-1.5B",
"Rakancorle1/qwen2.5-7b_Instruct_policy_traj_30k_full",
"prithivMLmods/Lang-Exster-0.5B-Instruct",
"prithivMLmods/Nenque-MoT-0.6B-Elite14",
"posicube/Llama2-chat-AYT-13B",
"lomahony/pythia-70m-helpful-sft",
"kyubeen/code-grpo-checkpoint-950",
"nicholasKluge/TeenyTinyLlama-160m",
"allenai/Llama-3.1-Tulu-3-8B",
"BarraHome/Mistroll-7B-v2.2",
"posicube/Llama-chat-AY-13B",
"hongli-zhan/MINT-empathy-Qwen3-4B",
"jhhj25/qwen3-moe-neuron_structure_drop-p50-s1k-128samples-sft",
"Ikonz-Studios/seva-sarathi-intent-qwen3-1.7b",
"NECOUDBFM/Jellyfish-8B",
"gradients-io-tournaments/augmented-1db17e1d682d23fd",
"Locutusque/LocutusqueXFelladrin-TinyMistral248M-Instruct",
"ChuGyouk/R16",
"oveja1122/toolcalling-merged-demo",
"kmseong/llama3_2_3b-instruct-math-safedelta-scale0.8",
"EleutherAI/SmolLM2-1.7B-magpie-ultra-v1.0-math-431k-s",
"paulml/NeuralOmniBeagleMBX-v3-7B",
"skemessage/Qwen2.5-7B-Instruct-neuron",
]
# ══════════════════════════════════════════════════════════
@@ -110,30 +313,15 @@ def _run_http():
# ══════════════════════════════════════════════════════════
# 业务逻辑
# ══════════════════════════════════════════════════════════
def _login() -> str:
headers = {"Content-Type": "application/json"}
resp = requests.post(
BASE_URL + LOGIN_ENDPOINT,
headers=headers,
json={"userAccount": USER_ACCOUNT, "userPassword": USER_PASSWORD},
timeout=30,
)
data = resp.json()
if data.get("code") != 0:
raise RuntimeError(f"登录失败: {data.get('message')}")
print("[worker] 登录成功", flush=True)
return data["data"]["token"]
def _submit_task(token: str, model_id: str) -> Tuple[bool, str]:
headers = {
"Content-Type": "application/json",
"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
config_content = f"""gpu_type: ppu_zw_810e
framework: vllm
storage: gpfs
docker_image: harbor.4pd.io/hardcore-tech/asllm:1.10.1-pytorch2.10.0-ubuntu24.04-sail2.1.0-cuda13.0-sglang0.5.10-vllm0.19.0-py312
nv_docker_image: harbor-contest.4pd.io/sunruoxi/vllm-openai-fix-tokenizer:v0.11.0
modelhub_options:
srcRelativePath: leaderboard/modelHubXC/{model_id}
mountPoint: /model
@@ -141,17 +329,44 @@ 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"]
- name: test
value: fp16
command:
- bash
- /opt/t-head/entrypoint.sh
- python3
- -m
- asllm.entrypoints.api_server
- --model
- /model
- --port
- '30000'
- --host
- 0.0.0.0
- --served-model-name
- llm
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"]
- name: test
value: fp16
command:
- vllm
- serve
- /model
- --port
- '80'
- --served-model-name
- llm
- --max-model-len
- '2048'
- --gpu-memory-utilization
- '0.9'
- --enforce-eager
- --trust-remote-code
- -tp
- '1'
"""
payload = {
"contestApiToken": CONTEST_API_TOKEN,
@@ -167,6 +382,7 @@ ref_config:
"taskType": TASK_TYPE,
}],
}
print(f"[payload] {json.dumps(payload, indent=2, ensure_ascii=False)}", flush=True)
try:
resp = requests.post(
BASE_URL + SUBMIT_ENDPOINT,
@@ -192,12 +408,8 @@ def _run_worker():
_state["phase"] = "submitting"
successful: List[Tuple[str, str]] = []
try:
token = _login()
except Exception:
traceback.print_exc()
_state["phase"] = "error"
return
token = AUTH_TOKEN
print("[worker] 使用预设 Token跳过登录", flush=True)
for model_id in ALL_MODEL_IDS:
if _shutdown.is_set():