Files
zk-data-agent/skills/model-iteration/scripts/submit_sft.sh
T
wangsenhao b48032e15c feat: backend gate fallback + metric_diff docs + submit_sft fix
- Auto-inject human-review gate when agent asks question but forgets gate entry
- Add complex_dev/complex_base field docs to program.md metric_diff table
- Fix submit_sft.sh minor issues
- jupyter_runtime improvements

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-26 15:42:02 +08:00

66 lines
2.3 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 用 cml custom_train submit 提交 SFT 训练(**只做这一件事**)。
# 训练完成后请用 scripts/submit_cml_eval.sh 单独起评测,watcher 由 agent 自己挂。
#
# 用法:
# ./submit_sft.sh <SFT_RUNDIC> [PREV_RUNDIC]
#
# 推荐调用方式(runDic 由 resolve_run_ids.sh 决定,不要手敲):
# eval "$(./scripts/resolve_run_ids.sh)"
# ./scripts/submit_sft.sh "$SFT_RUNDIC"
#
# 语义(与 program.md §746 + §5.2 对齐):
# SFT_RUNDIC = R{n-1}.runDicaugment / yaml / 归档全用这个,不 +1)
# PREV_RUNDIC = SFT_RUNDIC - 1(默认;只用作上一轮 sft_output 改名)
set -euo pipefail
SFT_RUNDIC=${1:?usage: $0 <SFT_RUNDIC> [PREV_RUNDIC]}
PREV_RUNDIC=${2:-$((SFT_RUNDIC-1))}
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# chat-isolated 时代 AUTORESEARCH_ROOT == AUTORESEARCH_CHAT_ROOT;优先用 chat
# root,避免 agent 没 export AUTORESEARCH_ROOT 时回退到全局共享路径(已废弃)。
ROOT=${AUTORESEARCH_ROOT:-${AUTORESEARCH_CHAT_ROOT:-$(dirname "$SCRIPT_DIR")}}
TPL=${SFT_TRAIN_JOB_TEMPLATE:-$SCRIPT_DIR/sft_train_job.yaml.tpl}
YAML=/tmp/sft_train_job_r${SFT_RUNDIC}.yaml
if [ -f ~/.cloudml-cli/.profile ]; then
source ~/.cloudml-cli/.profile
else
echo "[sft] ❌ 未找到 ~/.cloudml-cli/.profile,请先安装并初始化 cml" >&2
exit 1
fi
# 1. 渲染 yaml 模板
sed \
-e "s|{RUNDIC}|${SFT_RUNDIC}|g" \
-e "s|{PREV_RUNDIC}|${PREV_RUNDIC}|g" \
-e "s|{AUTORESEARCH_ROOT}|${ROOT}|g" \
"$TPL" > "$YAML"
echo "[sft] yaml: $YAML (SFT_RUNDIC=$SFT_RUNDIC PREV_RUNDIC=$PREV_RUNDIC)"
# 2. 提交训练任务
SUBMIT_OUT=$(cml custom_train submit --filename "$YAML" 2>&1)
echo "$SUBMIT_OUT"
JOB_ID=$(echo "$SUBMIT_OUT" | grep -oE 't-[0-9]+-[a-z0-9]+' | head -1)
if [ -z "$JOB_ID" ]; then
echo "[sft] ❌ 提交失败" >&2
exit 1
fi
echo "[sft] ✅ JobID: $JOB_ID"
cat <<EOF
[sft] 任务提交完成,关键命令:
查看任务状态: cml custom_train describe $JOB_ID
查看实时日志: cml custom_train logs $JOB_ID --follow
停止任务: cml custom_train kill $JOB_ID
训练成功后产物在: $ROOT/sft_output/_SUCCESS
随后用 scripts/submit_cml_eval.sh <EVAL_RUNDIC> 起评测(不要在本脚本里串接,避免跨 step bg 任务)。
JobID: $JOB_ID
SFT_RUNDIC: $SFT_RUNDIC (yaml / sft_output 命名)
EOF