Benjamin-eecs commited on
Commit
9049b5c
·
verified ·
1 Parent(s): 0b7eb60

release v2: add frozen Judge trainer (slime reward, prompts, pool, launch) and heldout_prompts.jsonl

Browse files
adapter/r2e_local/build_prompts.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Build slime prompt JSONL from admitted Harbor task directories.
2
+
3
+ One record per task:
4
+ prompt chat messages (system + user) for --apply-chat-template
5
+ label task id
6
+ metadata {task_dir, repo_key, base_commit, repo, source_files}
7
+
8
+ The user message carries the task's instruction.md and, as context, the
9
+ contents at base_commit of every file the oracle patch touches (oracle file
10
+ retrieval, the SWE-RL convention for single-turn patch generation). Files are
11
+ read from the repository mirror at base_commit; nothing from the oracle patch
12
+ itself is shown. Budgets keep the prompt bounded and deterministic.
13
+
14
+ Usage:
15
+ python -m r2e_local.build_prompts --tasks <dir with task dirs>... --mirrors <repos root> --out train.jsonl
16
+ """
17
+
18
+ from __future__ import annotations
19
+
20
+ import argparse
21
+ import json
22
+ import re
23
+ import subprocess
24
+ import sys
25
+ import tomllib
26
+ from pathlib import Path
27
+
28
+ SYSTEM = (
29
+ "You are an expert Python software engineer. You will be given a bug report for a "
30
+ "repository and the current contents of the relevant source files. Produce a fix as a "
31
+ "single unified diff against the repository root, inside one ```diff fenced block, and "
32
+ "nothing else. Do not modify or add tests."
33
+ )
34
+
35
+ _FILE_RE = re.compile(r"^diff --git a/(\S+) b/(\S+)", re.M)
36
+
37
+
38
+ def oracle_files(patch: str) -> list[str]:
39
+ seen: list[str] = []
40
+ for m in _FILE_RE.finditer(patch):
41
+ p = m.group(2)
42
+ if p not in seen:
43
+ seen.append(p)
44
+ return seen
45
+
46
+
47
+ def git_show(mirror: Path, commit: str, path: str) -> str | None:
48
+ r = subprocess.run(["git", "-C", str(mirror), "show", f"{commit}:{path}"], capture_output=True, text=True, errors="replace")
49
+ return r.stdout if r.returncode == 0 else None
50
+
51
+
52
+ def build_record(task_dir: Path, mirrors: Path, *, per_file: int, total: int) -> dict | None:
53
+ meta = tomllib.loads((task_dir / "task.toml").read_text())
54
+ r2e = meta["metadata"]["repo2env"]
55
+ repo = r2e["repo"]
56
+ key = repo.replace("/", "__")
57
+ base = r2e["commit_runtime"]["parent_sha"]
58
+ patch = (task_dir / "solution" / "patch.diff").read_text()
59
+ files = oracle_files(patch)
60
+ mirror = mirrors / key
61
+ parts = [(task_dir / "instruction.md").read_text().strip(), "", "## Relevant files (at the current commit)", ""]
62
+ used = 0
63
+ for f in files:
64
+ content = git_show(mirror, base, f)
65
+ if content is None:
66
+ continue
67
+ if len(content) > per_file:
68
+ content = content[:per_file] + f"\n... [truncated {len(content) - per_file} chars]\n"
69
+ block = f"### {f}\n```python\n{content}\n```\n"
70
+ if used + len(block) > total:
71
+ break
72
+ parts.append(block)
73
+ used += len(block)
74
+ parts.append("Return the fix as one unified diff in a ```diff block.")
75
+ return {
76
+ "prompt": [{"role": "system", "content": SYSTEM}, {"role": "user", "content": "\n".join(parts)}],
77
+ "label": task_dir.name,
78
+ "metadata": {
79
+ "task_dir": str(task_dir.resolve()),
80
+ "repo_key": key,
81
+ "repo": repo,
82
+ "base_commit": base,
83
+ "source_files": files,
84
+ },
85
+ }
86
+
87
+
88
+ def main(argv: list[str] | None = None) -> int:
89
+ ap = argparse.ArgumentParser()
90
+ ap.add_argument("--tasks", nargs="+", type=Path, required=True, help="directories containing task dirs")
91
+ ap.add_argument("--mirrors", type=Path, required=True)
92
+ ap.add_argument("--out", type=Path, required=True)
93
+ ap.add_argument("--per-file-chars", type=int, default=16000)
94
+ ap.add_argument("--total-chars", type=int, default=48000)
95
+ args = ap.parse_args(argv)
96
+ n = 0
97
+ with args.out.open("w") as fh:
98
+ for root in args.tasks:
99
+ for td in sorted(p for p in root.iterdir() if (p / "task.toml").exists()):
100
+ rec = build_record(td, args.mirrors, per_file=args.per_file_chars, total=args.total_chars)
101
+ if rec is None:
102
+ continue
103
+ fh.write(json.dumps(rec) + "\n")
104
+ n += 1
105
+ print(json.dumps({"records": n, "out": str(args.out)}))
106
+ return 0
107
+
108
+
109
+ if __name__ == "__main__":
110
+ sys.exit(main())
adapter/r2e_local/judge_reward.py ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Frozen Judge reward for slime (`--custom-rm-path r2e_local.judge_reward.reward`).
2
+
3
+ Single-turn patch generation. The sample's response must contain a unified
4
+ diff. The reward applies that diff at the task's base commit inside a pooled
5
+ LocalSandbox checkout and then runs the task's own `tests/test.sh`, the
6
+ verifier Repo2RLEnv emitted with the task (test-patch apply, targeted pytest,
7
+ F2P/P2P grading via tests/verifier.py). Reward is 1.0 when the verifier
8
+ reports resolved, else 0.0. Nothing here is candidate-supplied.
9
+
10
+ Sample.metadata contract (written by build_prompts.py):
11
+ task_dir absolute path of the Harbor task directory
12
+ repo_key owner__name
13
+ base_commit the task's parent_sha
14
+
15
+ Environment:
16
+ R2E_POOL_ROOT root of sandbox pools: <root>/<repo_key>/<i>/ (make_pool.py)
17
+ R2E_REWARD_TIMEOUT seconds per verifier run (default 900)
18
+ """
19
+
20
+ from __future__ import annotations
21
+
22
+ import asyncio
23
+ import json
24
+ import os
25
+ import re
26
+ import shutil
27
+ import tempfile
28
+ from pathlib import Path
29
+
30
+ from .sandbox import LocalSandbox
31
+
32
+ _DIFF_FENCE = re.compile(r"```(?:diff|patch)?\s*\n(.*?)```", re.S)
33
+ _DIFF_START = re.compile(r"^(diff --git |--- (?:a/|/dev/null))", re.M)
34
+
35
+ _pools: dict[str, asyncio.Queue] = {}
36
+ _pools_lock = asyncio.Lock()
37
+
38
+
39
+ def extract_diff(text: str) -> str | None:
40
+ """Return the unified diff in a model response, or None."""
41
+ for m in _DIFF_FENCE.finditer(text):
42
+ body = m.group(1)
43
+ if _DIFF_START.search(body):
44
+ return body if body.endswith("\n") else body + "\n"
45
+ m = _DIFF_START.search(text)
46
+ if m:
47
+ body = text[m.start():]
48
+ return body if body.endswith("\n") else body + "\n"
49
+ return None
50
+
51
+
52
+ async def _pool(repo_key: str) -> asyncio.Queue:
53
+ async with _pools_lock:
54
+ q = _pools.get(repo_key)
55
+ if q is None:
56
+ root = Path(os.environ.get("R2E_POOL_ROOT", "/rsi-data/pool")) / repo_key
57
+ slots = sorted(p for p in root.iterdir() if (p / ".git").exists()) if root.exists() else []
58
+ if not slots:
59
+ raise RuntimeError(f"no sandbox pool for {repo_key} under {root}")
60
+ q = asyncio.Queue()
61
+ for s in slots:
62
+ q.put_nowait(s)
63
+ _pools[repo_key] = q
64
+ return q
65
+
66
+
67
+ def _load_rebuild(repo_key: str) -> list[str]:
68
+ bj = Path(os.environ.get("R2E_BOOTSTRAP_ROOT", "/rsi-data/bootstrap")) / repo_key / "bootstrap.json"
69
+ try:
70
+ return list(json.loads(bj.read_text()).get("rebuild_cmds") or [])
71
+ except OSError:
72
+ return []
73
+
74
+
75
+ def _grade_sync(task_dir: Path, repo_key: str, base_commit: str, diff: str, slot: Path, timeout: int) -> dict:
76
+ sb = LocalSandbox(slot, post_clean_cmds=_load_rebuild(repo_key))
77
+ logs = Path(tempfile.mkdtemp(prefix="r2e-judge-"))
78
+ try:
79
+ prep = sb.exec(
80
+ f"git reset -q --hard {base_commit} && git clean -fdxq -e .venv "
81
+ "-e __pycache__ -e .pytest_cache || true",
82
+ timeout=300,
83
+ )
84
+ if not prep.ok:
85
+ return {"reward": 0.0, "resolved": False, "status": "reset_failed", "stderr": prep.stderr[-500:]}
86
+ # Rebuild after the clean, exactly as validation does (rebuild_cmds).
87
+ if sb.post_clean_cmds:
88
+ sb.exec("(" + " && ".join(sb.post_clean_cmds) + ") >/dev/null 2>&1 || true", timeout=600)
89
+ (logs / "candidate.diff").write_text(diff)
90
+ applied = sb.exec(f"git apply --verbose --reject {logs / 'candidate.diff'}", timeout=120)
91
+ if not applied.ok:
92
+ return {"reward": 0.0, "resolved": False, "status": "patch_apply_failed", "stderr": applied.stderr[-500:]}
93
+ # Run the task's own verifier with /workspace and /logs relocated.
94
+ test_sh = (task_dir / "tests" / "test.sh").read_text()
95
+ test_sh = test_sh.replace("/logs/verifier", str(logs / "verifier")).replace("/logs", str(logs))
96
+ tests_copy = logs / "tests"
97
+ shutil.copytree(task_dir / "tests", tests_copy)
98
+ (tests_copy / "test.sh").write_text(test_sh)
99
+ r = sb.exec(f"bash {tests_copy / 'test.sh'}", timeout=timeout)
100
+ details: dict = {}
101
+ try:
102
+ details = json.loads((logs / "verifier" / "reward-details.json").read_text())
103
+ except (OSError, json.JSONDecodeError):
104
+ pass
105
+ try:
106
+ scalar = float((logs / "verifier" / "reward.txt").read_text().strip())
107
+ except (OSError, ValueError):
108
+ scalar = 0.0
109
+ resolved = bool(details.get("resolved", scalar >= 1.0))
110
+ return {
111
+ "reward": 1.0 if resolved else 0.0,
112
+ "resolved": resolved,
113
+ "verifier_scalar": scalar,
114
+ "status": details.get("parse_status", "graded"),
115
+ "exit_code": r.exit_code,
116
+ }
117
+ finally:
118
+ sb.exec(f"git reset -q --hard {base_commit} && git clean -fdxq -e .venv || true", timeout=300)
119
+ shutil.rmtree(logs, ignore_errors=True)
120
+
121
+
122
+ async def grade(task_dir: Path, repo_key: str, base_commit: str, response: str) -> dict:
123
+ diff = extract_diff(response or "")
124
+ if not diff:
125
+ return {"reward": 0.0, "resolved": False, "status": "no_diff_in_response"}
126
+ timeout = int(os.environ.get("R2E_REWARD_TIMEOUT", "900"))
127
+ q = await _pool(repo_key)
128
+ slot = await q.get()
129
+ try:
130
+ return await asyncio.to_thread(_grade_sync, task_dir, repo_key, base_commit, diff, slot, timeout)
131
+ finally:
132
+ q.put_nowait(slot)
133
+
134
+
135
+ async def reward(args, sample, **kwargs) -> float:
136
+ """slime custom reward entry point."""
137
+ del args, kwargs
138
+ meta = sample.metadata or {}
139
+ task_dir = Path(meta["task_dir"])
140
+ result = await grade(task_dir, meta["repo_key"], meta["base_commit"], sample.response)
141
+ try:
142
+ sample.metadata["judge"] = result
143
+ except Exception:
144
+ pass
145
+ return float(result["reward"])
adapter/r2e_local/make_pool.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Create K sandbox copies per repository for parallel Judge grading.
2
+
3
+ Each copy is `git clone --shared` of the mirror (no object duplication) with
4
+ its own `.venv` installed from the repository's requirements.lock, plus the
5
+ build backends needed for offline editable rebuilds. Layout:
6
+ <pool_root>/<owner__name>/<i>/ i in 0..K-1
7
+
8
+ Usage:
9
+ python -m r2e_local.make_pool --mirrors <repos root> --bootstrap <bootstrap root> \
10
+ --pool <pool root> --copies 2 [--repos owner/name ...] [--python-root <uv python dir>]
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import argparse
16
+ import json
17
+ import os
18
+ import subprocess
19
+ import sys
20
+ from concurrent.futures import ThreadPoolExecutor
21
+ from pathlib import Path
22
+
23
+ BACKENDS = [
24
+ "setuptools", "wheel", "setuptools-scm", "hatchling", "hatch-vcs", "hatch-fancy-pypi-readme",
25
+ "poetry-core", "flit-core", "pdm-backend", "versioningit", "pbr", "editables",
26
+ "hatch-requirements-txt", "setuptools-git-versioning", "poetry-dynamic-versioning",
27
+ ]
28
+
29
+
30
+ def make_one(mirror: Path, boot: dict, lock: Path, dest: Path, env: dict) -> str:
31
+ if (dest / ".venv" / "bin" / "python").exists():
32
+ return f"exists {dest}"
33
+ dest.parent.mkdir(parents=True, exist_ok=True)
34
+ if not (dest / ".git").exists():
35
+ subprocess.run(["git", "clone", "-q", "--shared", "--no-checkout", f"file://{mirror}", str(dest)], check=True)
36
+ subprocess.run(["git", "-C", str(dest), "checkout", "-q", "--detach", boot["ref"]], check=True)
37
+ py = boot.get("extra", {}).get("python_version", "3.12")
38
+ py = ".".join(py.split(".")[:2])
39
+ subprocess.run(["uv", "venv", "-q", "--python", py, ".venv"], cwd=dest, env=env, check=True)
40
+ # The lock is a `uv pip freeze` of the bootstrap venv: drop the editable
41
+ # self-reference (`-e file:///.../sandboxes/<repo>`) and any other local
42
+ # path pins; the copy gets its own editable install via rebuild_cmds below.
43
+ pinned = [
44
+ line for line in lock.read_text().splitlines()
45
+ if line.strip() and not line.startswith(("-e ", "#")) and "file://" not in line
46
+ ]
47
+ lock_copy = dest / ".venv" / "requirements.pool.txt"
48
+ lock_copy.write_text("\n".join(pinned) + "\n")
49
+ subprocess.run(["uv", "pip", "install", "-q", "--python", ".venv/bin/python", "-r", str(lock_copy)], cwd=dest, env=env, check=True)
50
+ subprocess.run(["uv", "pip", "install", "-q", "--python", ".venv/bin/python", *BACKENDS], cwd=dest, env=env, check=False)
51
+ for cmd in boot.get("rebuild_cmds") or []:
52
+ subprocess.run(["bash", "-c", cmd], cwd=dest, env=env, check=False)
53
+ return f"built {dest}"
54
+
55
+
56
+ def main(argv: list[str] | None = None) -> int:
57
+ ap = argparse.ArgumentParser()
58
+ ap.add_argument("--mirrors", type=Path, required=True)
59
+ ap.add_argument("--bootstrap", type=Path, required=True)
60
+ ap.add_argument("--pool", type=Path, required=True)
61
+ ap.add_argument("--copies", type=int, default=2)
62
+ ap.add_argument("--repos", nargs="*", default=None)
63
+ ap.add_argument("--workers", type=int, default=4)
64
+ args = ap.parse_args(argv)
65
+ env = dict(os.environ)
66
+ env.setdefault("UV_LINK_MODE", "hardlink")
67
+ jobs = []
68
+ for bdir in sorted(args.bootstrap.iterdir()):
69
+ bj = bdir / "bootstrap.json"
70
+ if not bj.exists():
71
+ continue
72
+ boot = json.loads(bj.read_text())
73
+ if args.repos and boot["repo"] not in args.repos:
74
+ continue
75
+ if not boot.get("smoke_passed"):
76
+ continue
77
+ key = bdir.name
78
+ for i in range(args.copies):
79
+ jobs.append((args.mirrors / key, boot, bdir / "requirements.lock", args.pool / key / str(i)))
80
+ with ThreadPoolExecutor(max_workers=args.workers) as ex:
81
+ for line in ex.map(lambda j: make_one(*j, env), jobs):
82
+ print(line, flush=True)
83
+ return 0
84
+
85
+
86
+ if __name__ == "__main__":
87
+ sys.exit(main())
adapter/r2e_local/train_judge_slime.sh ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Frozen Judge trainer: slime v0.3.0 (THUDM/slime@bf14dc21), Qwen/Qwen3.5-4B, GRPO,
3
+ # single-turn patch generation graded by r2e_local.judge_reward.reward.
4
+ #
5
+ # Fixed protocol (proposal, Evaluation rows): 50 rollouts x 16 prompts x 8 samples,
6
+ # lr 1e-6, kl 1e-3 (low_var_kl), rollout temperature 1.0, max response 16384, seed 42.
7
+ # Evaluation: the same reward at temperature 0, one sample per held-out task, before
8
+ # training (rollout 0) and after the last rollout.
9
+ #
10
+ # Required env:
11
+ # SLIME_DIR checkout of THUDM/slime at bf14dc21 (inside the image: /root/slime)
12
+ # MODEL_ROOT contains Qwen3.5-4B/ (HF) and Qwen3.5-4B_torch_dist/ (converted)
13
+ # TRAIN_JSONL admitted training tasks (build_prompts.py output)
14
+ # HELDOUT_JSONL held-out evaluation prompts (build_prompts.py output)
15
+ # R2E_POOL_ROOT sandbox pool root (make_pool.py)
16
+ # R2E_BOOTSTRAP_ROOT bootstrap.json root
17
+ # OUTPUT_DIR run directory
18
+ # Optional: NUM_ROLLOUT (50) ROLLOUT_BATCH (16) N_SAMPLES (8) SEED (42)
19
+ set -euo pipefail
20
+
21
+ : "${SLIME_DIR:?}" "${MODEL_ROOT:?}" "${TRAIN_JSONL:?}" "${HELDOUT_JSONL:?}" "${R2E_POOL_ROOT:?}" "${R2E_BOOTSTRAP_ROOT:?}" "${OUTPUT_DIR:?}"
22
+ NUM_ROLLOUT="${NUM_ROLLOUT:-50}"
23
+ ROLLOUT_BATCH="${ROLLOUT_BATCH:-16}"
24
+ N_SAMPLES="${N_SAMPLES:-8}"
25
+ SEED="${SEED:-42}"
26
+ ADAPTER_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # directory containing r2e_local/
27
+ export PYTHONPATH="${ADAPTER_DIR}:${SLIME_DIR}:/root/Megatron-LM:${PYTHONPATH:-}"
28
+ export WANDB_MODE=disabled
29
+ mkdir -p "${OUTPUT_DIR}"
30
+
31
+ # Model configuration shipped with the pinned slime commit.
32
+ source "${SLIME_DIR}/scripts/models/qwen3.5-4B.sh"
33
+
34
+ CKPT_ARGS=(
35
+ --hf-checkpoint "${MODEL_ROOT}/Qwen3.5-4B"
36
+ --ref-load "${MODEL_ROOT}/Qwen3.5-4B_torch_dist"
37
+ --save "${OUTPUT_DIR}/ckpt"
38
+ --save-interval "${NUM_ROLLOUT}"
39
+ )
40
+ DATA_ARGS=(
41
+ --prompt-data "${TRAIN_JSONL}"
42
+ --input-key prompt --label-key label --metadata-key metadata
43
+ --apply-chat-template
44
+ --custom-rm-path r2e_local.judge_reward.reward
45
+ --eval-prompt-data heldout "${HELDOUT_JSONL}"
46
+ --eval-input-key prompt --eval-label-key label
47
+ --eval-interval "${NUM_ROLLOUT}"
48
+ --n-samples-per-eval-prompt 1
49
+ --eval-temperature 0.0
50
+ --eval-max-response-len 16384
51
+ )
52
+ ROLLOUT_ARGS=(
53
+ --num-rollout "${NUM_ROLLOUT}"
54
+ --rollout-batch-size "${ROLLOUT_BATCH}"
55
+ --n-samples-per-prompt "${N_SAMPLES}"
56
+ --rollout-max-response-len 16384
57
+ --rollout-temperature 1.0
58
+ --global-batch-size $((ROLLOUT_BATCH * N_SAMPLES))
59
+ --balance-data
60
+ --rollout-shuffle
61
+ --seed "${SEED}"
62
+ )
63
+ GRPO_ARGS=(
64
+ --advantage-estimator grpo
65
+ --use-kl-loss
66
+ --kl-loss-coef 0.001
67
+ --kl-loss-type low_var_kl
68
+ --entropy-coef 0.0
69
+ --eps-clip 0.2
70
+ --eps-clip-high 0.28
71
+ )
72
+ OPTIMIZER_ARGS=(
73
+ --optimizer adam
74
+ --lr 1e-6
75
+ --lr-decay-style constant
76
+ --weight-decay 0.1
77
+ --adam-beta1 0.9
78
+ --adam-beta2 0.98
79
+ )
80
+ PERF_ARGS=(
81
+ --tensor-model-parallel-size 2
82
+ --sequence-parallel
83
+ --pipeline-model-parallel-size 1
84
+ --context-parallel-size 2
85
+ --use-dynamic-batch-size
86
+ --max-tokens-per-gpu 16384
87
+ --recompute-granularity full
88
+ --recompute-method uniform
89
+ --recompute-num-layers 1
90
+ )
91
+ SGLANG_ARGS=(
92
+ --rollout-num-gpus-per-engine 1
93
+ --sglang-mem-fraction-static 0.7
94
+ )
95
+ MISC_ARGS=(
96
+ --actor-num-nodes 1
97
+ --actor-num-gpus-per-node 8
98
+ --colocate
99
+ --attention-dropout 0.0
100
+ --hidden-dropout 0.0
101
+ --bf16
102
+ --accumulate-allreduce-grads-in-fp32
103
+ --attention-softmax-in-fp32
104
+ --attention-backend flash
105
+ )
106
+
107
+ ray stop --force >/dev/null 2>&1 || true
108
+ ray start --head --num-gpus 8 --disable-usage-stats >/dev/null
109
+ cd "${SLIME_DIR}"
110
+ python train.py \
111
+ "${MODEL_ARGS[@]}" "${CKPT_ARGS[@]}" "${DATA_ARGS[@]}" "${ROLLOUT_ARGS[@]}" \
112
+ "${GRPO_ARGS[@]}" "${OPTIMIZER_ARGS[@]}" "${PERF_ARGS[@]}" "${SGLANG_ARGS[@]}" "${MISC_ARGS[@]}" \
113
+ 2>&1 | tee "${OUTPUT_DIR}/train.log"