sanitize swe-rl 4b scripts and document required env overrides

This commit is contained in:
jinxiaolong1129
2026-04-18 19:23:47 +00:00
parent 836e63b3b4
commit 593b44f567
3 changed files with 54 additions and 21 deletions
+18
View File
@@ -12,6 +12,24 @@ Replace placeholders before running:
| `<DATA_DIR>` | Directory containing dataset JSONL files |
| `<REPO_ROOT>` | Path to the repo root |
## PR-safe script overrides (required before run)
The default 4B scripts no longer ship hardcoded private infra values (internal IPs,
proxy endpoints, local SSH key paths, or machine-specific absolute paths). Set
these env vars in your shell or `<ENV_FILE>` before launching:
| Variable | Required | Used by | Example |
| --- | --- | --- | --- |
| `SWE_EXEC_SERVER_URLS` | Yes | train + eval | `http://10.0.0.1:5000,http://10.0.0.2:5000` |
| `HF_CKPT` | Yes (train), recommended (eval) | train + eval | `<REPO_ROOT>/export/hf/swe-rl-4b_iter180` |
| `CES_SSH_USER` | Optional | train + eval | `root` |
| `CES_SSH_KEY` | Optional | train + eval | `<REPO_ROOT>/swe.pem` |
| `HTTP_PROXY` / `HTTPS_PROXY` | Optional | train + eval | `http://<proxy-host>:<port>` |
| `VERIFIED_DATA` | Optional | eval | `<REPO_ROOT>/data/swebench_verified/verified_eval_with_script.jsonl` |
| `SWEGYM_DATA` | Optional | eval | `<REPO_ROOT>/data/swegym_293/train_with_eval_script.parquet` |
| `PROMPT_DATA` | Optional | train | `<REPO_ROOT>/data/swegym_293/train_with_eval_script.parquet` |
| `HF_HOME` | Optional | train + eval | `<ROOT>/systems/huggingface` |
## Eval: SWE-Bench Verified (sample)
```bash
+20 -13
View File
@@ -8,8 +8,9 @@
# * generate_with_swe.{generate,reward_func} (same code as training)
#
# Usage (head node, MLP_ROLE_INDEX=0; worker nodes set MLP_ROLE_INDEX=1..3):
# HF_CKPT=/data_storage/wyj/jxl/OpenClaw-RL/export/hf/swe-rl-4b_iter180 \
# bash swe-rl/scripts/eval_4b_4nodes.sh
# export SWE_EXEC_SERVER_URLS=http://<exec-1>:5000,http://<exec-2>:5000
# export HF_CKPT=<REPO_ROOT>/export/hf/swe-rl-4b_iter180
# bash swe-rl/scripts/eval_4b_4nodes.sh
pkill -9 sglang || true
sleep 3
@@ -66,9 +67,11 @@ if [[ -f "${SWE_RL_DIR}/../.env" ]]; then
fi
# ---- Remote Docker (SWE env pool) ----
# Only server-1/2 have the swebench_verified images; servers 3-6 hold only
# swegym_293. Use the 2 image-complete nodes for eval so both datasets work.
export SWE_EXEC_SERVER_URLS=${SWE_EXEC_SERVER_URLS:-http://192.168.26.236:5000,http://192.168.19.81:5000}
export SWE_EXEC_SERVER_URLS=${SWE_EXEC_SERVER_URLS:-}
if [[ -z "${SWE_EXEC_SERVER_URLS}" ]]; then
echo "SWE_EXEC_SERVER_URLS is required, e.g. http://<exec-1>:5000,http://<exec-2>:5000"
exit 1
fi
export SWE_MAX_CONTAINERS_PER_NODE=${SWE_MAX_CONTAINERS_PER_NODE:-48}
_n_exec_nodes=$(echo "${SWE_EXEC_SERVER_URLS}" | tr ',' '\n' | wc -l)
export SWE_MAX_CONCURRENT=${SWE_MAX_CONCURRENT:-$(( SWE_MAX_CONTAINERS_PER_NODE * _n_exec_nodes ))}
@@ -82,19 +85,19 @@ SWE_ENV_SERVER_PORT=${SWE_ENV_SERVER_PORT:-18090}
SWE_ENV_SERVER_URL=${SWE_ENV_SERVER_URL:-"http://${MASTER_ADDR}:${SWE_ENV_SERVER_PORT}"}
export SWE_ENV_SERVER_URL
CES_SSH_USER=${CES_SSH_USER:-root}
CES_SSH_KEY=${CES_SSH_KEY:-/data_storage/wyj/jxl/OpenClaw-RL/swe.pem}
CES_SSH_KEY=${CES_SSH_KEY:-}
ALL_EXEC_HOSTS="$(echo "${SWE_EXEC_SERVER_URLS}" | tr ',' '\n' | sed -E 's#https?://([^:/]+).*#\1#' | tr '\n' ',' | sed 's/,$//')"
export NO_PROXY="localhost,127.0.0.1,${MASTER_ADDR},${NODE_IP},${ALL_EXEC_HOSTS}"
export no_proxy="${NO_PROXY}"
RAY_NO_PROXY="${NO_PROXY}"
export HTTP_PROXY=${HTTP_PROXY:-http://100.68.168.184:3128}
export HTTPS_PROXY=${HTTPS_PROXY:-http://100.68.168.184:3128}
export HTTP_PROXY=${HTTP_PROXY:-}
export HTTPS_PROXY=${HTTPS_PROXY:-}
export http_proxy="${HTTP_PROXY}"
export https_proxy="${HTTPS_PROXY}"
SWE_DOCKER_REGISTRY=${SWE_DOCKER_REGISTRY:-slime-agent-cn-beijing.cr.volces.com}
SWE_DOCKER_REGISTRY=${SWE_DOCKER_REGISTRY:-docker.io}
SWE_ROLLOUT_TIMEOUT=${SWE_ROLLOUT_TIMEOUT:-1800}
SWE_EVAL_TIMEOUT=${SWE_EVAL_TIMEOUT:-300}
@@ -105,8 +108,8 @@ if [[ ! -d "${HF_CKPT}" ]]; then
fi
# ---- Datasets ----
VERIFIED_DATA=${VERIFIED_DATA:-/data_storage/wyj/jxl/OpenClaw-RL/data/swebench_verified/verified_eval_with_script.jsonl}
SWEGYM_DATA=${SWEGYM_DATA:-/data_storage/wyj/jxl/OpenClaw-RL/data/swegym_293/train_with_eval_script.parquet}
VERIFIED_DATA=${VERIFIED_DATA:-${SWE_RL_DIR}/../data/swebench_verified/verified_eval_with_script.jsonl}
SWEGYM_DATA=${SWEGYM_DATA:-${SWE_RL_DIR}/../data/swegym_293/train_with_eval_script.parquet}
# Batch size: saturate ECS concurrency, but keep moderate so repeated samples
# in the remainder are bounded.
@@ -124,7 +127,11 @@ _cleanup_ecs_containers() {
for url in "${_urls[@]}"; do
host="$(echo "${url}" | sed -E 's#https?://([^:/]+).*#\1#')"
echo "Cleaning Docker on ${host}..."
ssh -i "${CES_SSH_KEY}" -o BatchMode=yes -o StrictHostKeyChecking=no -o ConnectTimeout=5 \
ssh_key_args=()
if [[ -n "${CES_SSH_KEY}" ]]; then
ssh_key_args=(-i "${CES_SSH_KEY}")
fi
ssh "${ssh_key_args[@]}" -o BatchMode=yes -o StrictHostKeyChecking=no -o ConnectTimeout=5 \
"${CES_SSH_USER}@${host}" 'docker ps -aq --filter "name=swe-" | xargs -r docker rm -f' 2>/dev/null || true
done
}
@@ -182,7 +189,7 @@ _build_runtime_env() {
\"https_proxy\": \"${https_proxy}\",
\"NO_PROXY\": \"${NO_PROXY}\",
\"no_proxy\": \"${no_proxy}\",
\"HF_HOME\": \"${HF_HOME:-/data_storage/wyj/systems/huggingface}\"
\"HF_HOME\": \"${HF_HOME:-${HOME}/.cache/huggingface}\"
}
}"
}
@@ -78,7 +78,11 @@ if [[ -f "${SWE_RL_DIR}/../.env" ]]; then
fi
# ---- Remote Docker (SWE env pool) ----
export SWE_EXEC_SERVER_URLS=${SWE_EXEC_SERVER_URLS:-http://192.168.26.236:5000,http://192.168.19.81:5000,http://192.168.16.56:5000,http://192.168.16.57:5000,http://192.168.16.58:5000,http://192.168.16.59:5000}
export SWE_EXEC_SERVER_URLS=${SWE_EXEC_SERVER_URLS:-}
if [[ -z "${SWE_EXEC_SERVER_URLS}" ]]; then
echo "SWE_EXEC_SERVER_URLS is required, e.g. http://<exec-1>:5000,http://<exec-2>:5000"
exit 1
fi
export SWE_MAX_CONTAINERS_PER_NODE=${SWE_MAX_CONTAINERS_PER_NODE:-48}
_n_exec_nodes=$(echo "${SWE_EXEC_SERVER_URLS}" | tr ',' '\n' | wc -l)
export SWE_MAX_CONCURRENT=${SWE_MAX_CONCURRENT:-$(( SWE_MAX_CONTAINERS_PER_NODE * _n_exec_nodes ))}
@@ -92,15 +96,15 @@ SWE_ENV_SERVER_PORT=${SWE_ENV_SERVER_PORT:-18090}
SWE_ENV_SERVER_URL=${SWE_ENV_SERVER_URL:-"http://${MASTER_ADDR}:${SWE_ENV_SERVER_PORT}"}
export SWE_ENV_SERVER_URL
CES_SSH_USER=${CES_SSH_USER:-root}
CES_SSH_KEY=${CES_SSH_KEY:-/data_storage/wyj/jxl/OpenClaw-RL/swe.pem}
CES_SSH_KEY=${CES_SSH_KEY:-}
ALL_EXEC_HOSTS="$(echo "${SWE_EXEC_SERVER_URLS}" | tr ',' '\n' | sed -E 's#https?://([^:/]+).*#\1#' | tr '\n' ',' | sed 's/,$//')"
export NO_PROXY="localhost,127.0.0.1,${MASTER_ADDR},${NODE_IP},${ALL_EXEC_HOSTS}"
export no_proxy="${NO_PROXY}"
# Proxy for external access (grading calls make_test_spec -> git clone github.com)
export HTTP_PROXY=${HTTP_PROXY:-http://100.68.168.184:3128}
export HTTPS_PROXY=${HTTPS_PROXY:-http://100.68.168.184:3128}
export HTTP_PROXY=${HTTP_PROXY:-}
export HTTPS_PROXY=${HTTPS_PROXY:-}
export http_proxy="${HTTP_PROXY}"
export https_proxy="${HTTPS_PROXY}"
@@ -171,7 +175,11 @@ if [[ ${MLP_ROLE_INDEX} -eq 0 ]]; then
fi
# ---- Checkpoint ----
HF_CKPT=${HF_CKPT:-/data_storage/wyj/systems/huggingface/models--Qwen--Qwen3-4B-Instruct-2507/snapshots/cdbee75f17c01a7cc42f958dc650907174af0554}
HF_CKPT=${HF_CKPT:-}
if [[ -z "${HF_CKPT}" ]]; then
echo "HF_CKPT is required (path to model checkpoint/snapshot)."
exit 1
fi
REF_LOAD=${REF_LOAD:-${HF_CKPT}}
CKPT_ARGS=(
--hf-checkpoint "${HF_CKPT}"
@@ -184,10 +192,10 @@ CKPT_ARGS=(
# ---- Dataset ----
DEBUG_MODE=${DEBUG_MODE:-0}
if [[ "${DEBUG_MODE}" == "1" ]]; then
PROMPT_DATA=${PROMPT_DATA:-/data_storage/wyj/swe_gym_subset/train_10.jsonl}
PROMPT_DATA=${PROMPT_DATA:-${SWE_RL_DIR}/../data/swegym_293/train_with_eval_script.parquet}
NUM_ROLLOUT=80
else
PROMPT_DATA=${PROMPT_DATA:-/data_storage/wyj/jxl/OpenClaw-RL/data/swegym_293/train_with_eval_script.parquet}
PROMPT_DATA=${PROMPT_DATA:-${SWE_RL_DIR}/../data/swegym_293/train_with_eval_script.parquet}
NUM_ROLLOUT=500
fi
if [[ ! -f "${PROMPT_DATA}" ]]; then
@@ -347,7 +355,7 @@ RUNTIME_ENV_JSON="{
\"https_proxy\": \"${https_proxy}\",
\"NO_PROXY\": \"${NO_PROXY}\",
\"no_proxy\": \"${no_proxy}\",
\"HF_HOME\": \"${HF_HOME:-/data_storage/wyj/systems/huggingface}\",
\"HF_HOME\": \"${HF_HOME:-${HOME}/.cache/huggingface}\",
\"WANDB_API_KEY\": \"${WANDB_API_KEY:-}\"
}
}"