Compare commits
125
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d9ca92551 | ||
|
|
ea2f390045 | ||
|
|
44dcc5ab40 | ||
|
|
271801bd4d | ||
|
|
851233e5de | ||
|
|
7f7ce8a0f4 | ||
|
|
09e2977437 | ||
|
|
fa191e589b | ||
|
|
d718fddaa4 | ||
|
|
1f26eeeb52 | ||
|
|
90e9ae98bf | ||
|
|
67cdc55521 | ||
|
|
d3e478d732 | ||
|
|
d8698f4e53 | ||
|
|
845eb6e6f2 | ||
|
|
eaf95997f7 | ||
|
|
09e11c7527 | ||
|
|
03f7feff14 | ||
|
|
87ab84b666 | ||
|
|
0b37bc923e | ||
|
|
6591943919 | ||
|
|
4748472b9f | ||
|
|
8106bf0a02 | ||
|
|
46653c1d70 | ||
|
|
c5fb9591b2 | ||
|
|
b22e768fc4 | ||
|
|
ef8f459ca0 | ||
|
|
c3c6b70f11 | ||
|
|
f18297fd7d | ||
|
|
6d80c412b6 | ||
|
|
a166a8b8df | ||
|
|
66ff00d117 | ||
|
|
ae610d9dd8 | ||
|
|
c935497d71 | ||
|
|
cd2f3daeb2 | ||
|
|
897b935cae | ||
|
|
81f9e9512b | ||
|
|
d4385029c8 | ||
|
|
c654dc1d4d | ||
|
|
6ba37c2c21 | ||
|
|
458b16ef47 | ||
|
|
b5f196a9c5 | ||
|
|
6dda4a1466 | ||
|
|
fa55779272 | ||
|
|
b2ba40b5eb | ||
|
|
e4330c2d2c | ||
|
|
4a6b45487f | ||
|
|
024abb2043 | ||
|
|
5b11b8de33 | ||
|
|
7c434ec267 | ||
|
|
469a4e6714 | ||
|
|
319af10769 | ||
|
|
d11fc90469 | ||
|
|
c9a4b3b199 | ||
|
|
a252057978 | ||
|
|
429c1bb5e5 | ||
|
|
efb874b734 | ||
|
|
2171368063 | ||
|
|
7b7bde1fa0 | ||
|
|
0fe673c23c | ||
|
|
84ccb9507d | ||
|
|
09e403b4a4 | ||
|
|
7da26cd651 | ||
|
|
5f2c004184 | ||
|
|
c0d896f3f8 | ||
|
|
bb522cce53 | ||
|
|
95af0118db | ||
|
|
d7b3ae203c | ||
|
|
229391fa27 | ||
|
|
1e9a3e9196 | ||
|
|
3b01ce9d48 | ||
|
|
38b524925d | ||
|
|
d62c7539e4 | ||
|
|
edf41113fe | ||
|
|
bcac552c3f | ||
|
|
f7a27f69dd | ||
|
|
31591b7fe8 | ||
|
|
0deb4abaa9 | ||
|
|
4be61bbd68 | ||
|
|
0660a9b3cb | ||
|
|
2ff21d97e7 | ||
|
|
5e6f7ebae8 | ||
|
|
7d7bd92333 | ||
|
|
d8d214cbab | ||
|
|
a50b4079de | ||
|
|
0403c097a2 | ||
|
|
0b8c35e9b3 | ||
|
|
ca5e02c24c | ||
|
|
c37e2ca71b | ||
|
|
b1e9c7bdd2 | ||
|
|
af17a555fe | ||
|
|
a87badd65f | ||
|
|
5061b8d88e | ||
|
|
a8575d6f1c | ||
|
|
e75d8ca47f | ||
|
|
daedc1dbc6 | ||
|
|
3719abcfbb | ||
|
|
93cbc75b81 | ||
|
|
4e4390be87 | ||
|
|
8457b601d6 | ||
|
|
273524e2fc | ||
|
|
d2f36c9f65 | ||
|
|
2566de0bd5 | ||
|
|
0fca0d15c5 | ||
|
|
24a2af0054 | ||
|
|
8342ccd0c8 | ||
|
|
20454ecd7b | ||
|
|
4a42aa039e | ||
|
|
b0a7cad8a8 | ||
|
|
f1bbdf924e | ||
|
|
9bbed30eba | ||
|
|
a6a6441a3b | ||
|
|
e8abfa264b | ||
|
|
c3a24c35e2 | ||
|
|
d2718f5f65 | ||
|
|
d49f3939e7 | ||
|
|
9eeffdb6fb | ||
|
|
03689b8ac0 | ||
|
|
f29e947585 | ||
|
|
bb7449c829 | ||
|
|
82fa41f4f2 | ||
|
|
1ade129004 | ||
|
|
26ea8df85e | ||
|
|
d4bddbaed7 | ||
|
|
6bf14b80f8 |
@@ -14,7 +14,11 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
submodules: false
|
||||
- name: Init public submodules
|
||||
run: |
|
||||
git config --global url."https://github.com/".insteadOf "git@github.com:"
|
||||
git submodule update --init --recursive -- deps/verifiers deps/renderers deps/research-environments deps/pydantic-config
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
@@ -38,3 +42,59 @@ jobs:
|
||||
run: PYTEST_OUTPUT_DIR=/tmp/outputs uv run pytest tests/unit -m "not gpu"
|
||||
- name: Cleanup output_dir
|
||||
run: rm -rf /tmp/outputs
|
||||
|
||||
slim-configs-install:
|
||||
name: Slim install (prime-rl-configs only)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: "uv.lock"
|
||||
- name: Build the slim wheel
|
||||
run: uv build --wheel ./packages/prime-rl-configs --out-dir /tmp/slim-wheel
|
||||
- name: Install slim wheel from a directory with no workspace context
|
||||
# Build the wheel and install it from /tmp so uv can't discover the
|
||||
# repo's root pyproject.toml [tool.uv.sources] and silently apply
|
||||
# them. This mirrors what an external pip-only user gets.
|
||||
run: |
|
||||
uv venv --python 3.12 /tmp/slim
|
||||
cd /tmp && uv pip install --python /tmp/slim/bin/python /tmp/slim-wheel/*.whl
|
||||
- name: Verify configs import without heavy deps
|
||||
run: |
|
||||
/tmp/slim/bin/python - <<'PY'
|
||||
import sys
|
||||
|
||||
from prime_rl.configs.rl import RLConfig
|
||||
from prime_rl.configs.sft import SFTConfig
|
||||
from prime_rl.configs.inference import InferenceConfig
|
||||
from prime_rl.configs.orchestrator import OrchestratorConfig
|
||||
from prime_rl.configs.trainer import TrainerConfig
|
||||
from prime_rl.configs.env_server import EnvServerConfig
|
||||
from prime_rl.utils.config import BaseConfig, find_package_resource, rgetattr, rsetattr
|
||||
from prime_rl.utils.validation import validate_shared_ckpt_config
|
||||
|
||||
forbidden = ["torch", "transformers", "vllm", "wandb", "ring_flash_attn",
|
||||
"verifiers", "prime", "datasets", "liger_kernel", "loguru"]
|
||||
leaked = [m for m in forbidden if m in sys.modules]
|
||||
if leaked:
|
||||
raise SystemExit(f"slim install leaked heavy deps into sys.modules: {leaked}")
|
||||
|
||||
# Slim wheel does not ship the templates/ data dir; resolver returns None.
|
||||
assert find_package_resource("templates") is None, "templates should not be in slim wheel"
|
||||
print("slim install OK — configs import with no heavy deps loaded")
|
||||
PY
|
||||
- name: Verify a real config (with [slurm]) parses on slim install
|
||||
run: |
|
||||
/tmp/slim/bin/python - <<'PY'
|
||||
from pydantic_config import cli
|
||||
from prime_rl.configs.rl import RLConfig
|
||||
rl = cli(RLConfig, args=["@", "examples/Intellect-3.1/rl.toml"])
|
||||
assert rl.slurm is not None, "expected [slurm] in example config"
|
||||
# On slim, template_path can't be auto-resolved (heavy wheel absent) — must stay None.
|
||||
assert rl.slurm.template_path is None, f"unexpected template_path on slim: {rl.slurm.template_path}"
|
||||
print("slim parse OK")
|
||||
PY
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
name: Release
|
||||
name: Docker Push
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -24,6 +24,12 @@ jobs:
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: false
|
||||
- name: Init public submodules
|
||||
run: |
|
||||
git config --global url."https://github.com/".insteadOf "git@github.com:"
|
||||
git submodule update --init --recursive -- deps/verifiers deps/renderers deps/research-environments deps/pydantic-config
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: crazy-max/ghaction-docker-meta@v2
|
||||
@@ -28,23 +28,20 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
submodules: false
|
||||
- name: Init public submodules
|
||||
run: |
|
||||
git config --global url."https://github.com/".insteadOf "git@github.com:"
|
||||
git submodule update --init --recursive -- deps/verifiers deps/renderers deps/research-environments deps/pydantic-config
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: "uv.lock"
|
||||
- name: Install dependencies
|
||||
run: uv sync --all-extras --locked
|
||||
- name: Run unit tests
|
||||
env:
|
||||
USERNAME_CI: CI_RUNNER
|
||||
WANDB_API_KEY: ${{ secrets.WANDB_API_KEY }}
|
||||
# Set WANDB_MODE to online only if WANDB_API_KEY is available, otherwise set to offline
|
||||
# This is to allow running tests on forks without WANDB_API_KEY
|
||||
WANDB_MODE: ${{ secrets.WANDB_API_KEY && 'online' || 'offline' }}
|
||||
WANDB_MODE: offline
|
||||
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
PRIME_API_KEY: ${{ secrets.PRIME_API_KEY }}
|
||||
GITHUB_REF_NAME: ${{ github.ref_name }}
|
||||
GITHUB_HEAD_REF: ${{ github.head_ref }}
|
||||
@@ -63,21 +60,36 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- test: base
|
||||
- test: reverse_text_sft
|
||||
runner: vm
|
||||
pytest_args: "tests/integration -m gpu --ignore=tests/integration/test_rl_lora.py --ignore=tests/integration/test_rl_multi_run_lora.py --ignore=tests/integration/test_benchmark_regression.py --ignore=tests/integration/test_alphabet_sort.py"
|
||||
- test: rl_lora
|
||||
pytest_args: "tests/integration/test_reverse_text_sft.py"
|
||||
- test: reverse_text_sft_lora
|
||||
runner: vm
|
||||
pytest_args: "tests/integration/test_rl_lora.py -m gpu"
|
||||
pytest_args: "tests/integration/test_reverse_text_sft_lora.py"
|
||||
- test: reverse_text
|
||||
runner: vm
|
||||
pytest_args: "tests/integration/test_reverse_text.py"
|
||||
- test: reverse_text_rl_opd
|
||||
runner: vm
|
||||
pytest_args: "tests/integration/test_reverse_text_rl_opd.py"
|
||||
- test: reverse_text_rl_sft
|
||||
runner: vm
|
||||
pytest_args: "tests/integration/test_reverse_text_rl_sft.py"
|
||||
- test: alphabet_sort
|
||||
runner: vm
|
||||
pytest_args: "tests/integration/test_alphabet_sort.py -m gpu"
|
||||
- test: rl_multi_run
|
||||
pytest_args: "tests/integration/test_alphabet_sort.py"
|
||||
- test: reverse_text_lora
|
||||
runner: vm
|
||||
pytest_args: "tests/integration/test_reverse_text_lora.py"
|
||||
- test: reverse_text_moe
|
||||
runner: vm
|
||||
pytest_args: "tests/integration/test_reverse_text_moe.py"
|
||||
- test: reverse_text_multi_run
|
||||
runner: 4xa6000
|
||||
pytest_args: "tests/integration/test_rl_multi_run_lora.py -m gpu"
|
||||
pytest_args: "tests/integration/test_reverse_text_multi_run.py"
|
||||
- test: benchmark_regression
|
||||
runner: 4xa6000
|
||||
pytest_args: "tests/integration/test_benchmark_regression.py -m gpu"
|
||||
pytest_args: "tests/integration/test_benchmark_regression.py"
|
||||
steps:
|
||||
- name: Install Git
|
||||
run: |
|
||||
@@ -87,23 +99,20 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
submodules: false
|
||||
- name: Init public submodules
|
||||
run: |
|
||||
git config --global url."https://github.com/".insteadOf "git@github.com:"
|
||||
git submodule update --init --recursive -- deps/verifiers deps/renderers deps/research-environments deps/pydantic-config
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: "uv.lock"
|
||||
- name: Install dependencies
|
||||
run: uv sync --all-extras --locked
|
||||
- name: Run integration tests
|
||||
env:
|
||||
USERNAME_CI: CI_RUNNER
|
||||
WANDB_API_KEY: ${{ secrets.WANDB_API_KEY }}
|
||||
# Set WANDB_MODE to online only if WANDB_API_KEY is available, otherwise set to offline
|
||||
# This is to allow running tests on forks without WANDB_API_KEY
|
||||
WANDB_MODE: ${{ secrets.WANDB_API_KEY && 'online' || 'offline' }}
|
||||
WANDB_MODE: offline
|
||||
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
PRIME_API_KEY: ${{ secrets.PRIME_API_KEY }}
|
||||
PRIME_BASE_URL: ${{ secrets.PRIME_BASE_URL }}
|
||||
PRIME_TEAM_ID: ${{ secrets.PRIME_TEAM_ID }}
|
||||
@@ -111,4 +120,4 @@ jobs:
|
||||
GITHUB_HEAD_REF: ${{ github.head_ref }}
|
||||
PYTEST_OUTPUT_DIR: /tmp/outputs
|
||||
VLLM_WORKER_MULTIPROC_METHOD: spawn
|
||||
run: uv run pytest ${{ matrix.pytest_args }}
|
||||
run: uv run pytest -vvs ${{ matrix.pytest_args }}
|
||||
|
||||
@@ -25,7 +25,7 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
submodules: false
|
||||
|
||||
- name: Build matrix from nightly test files
|
||||
id: build-matrix
|
||||
@@ -57,7 +57,10 @@ jobs:
|
||||
runs-on: research-cluster
|
||||
container:
|
||||
image: pytorch/pytorch:2.10.0-cuda13.0-cudnn9-devel
|
||||
options: --gpus all
|
||||
# --shm-size: vLLM V1's DP engine/API-server IPC uses POSIX shm-backed
|
||||
# MessageQueue (~160MB per queue); Docker's default 64MB /dev/shm triggers
|
||||
# SIGBUS in DP engine cores on VLM runs (mm data overflows tmpfs).
|
||||
options: --gpus all --shm-size=16g
|
||||
timeout-minutes: 1440 # 24 hours
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -72,7 +75,11 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
submodules: false
|
||||
- name: Init public submodules
|
||||
run: |
|
||||
git config --global url."https://github.com/".insteadOf "git@github.com:"
|
||||
git submodule update --init --recursive -- deps/verifiers deps/renderers deps/research-environments deps/pydantic-config
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
|
||||
@@ -16,8 +16,9 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
# Submodules are excluded from ruff via pyproject.toml; no need to fetch them.
|
||||
with:
|
||||
submodules: true
|
||||
submodules: false
|
||||
- name: Run ruff
|
||||
uses: astral-sh/ruff-action@v3
|
||||
with:
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
name: Tag and Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
# Stable release tags only. `.dev` tags are created by `devx_tag.yaml`
|
||||
# via GITHUB_TOKEN (which does not retrigger workflows), so they would
|
||||
# not arrive here anyway — this exclusion is defensive for manual pushes.
|
||||
- 'v*'
|
||||
- '!v*dev*'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Existing tag to release (e.g. v0.6.0)'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
auto-tag-on-main:
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
outputs:
|
||||
created: ${{ steps.tag.outputs.created }}
|
||||
tag: ${{ steps.tag.outputs.tag }}
|
||||
version: ${{ steps.tag.outputs.version }}
|
||||
steps:
|
||||
- name: Checkout main
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Detect version bump and create tag
|
||||
id: tag
|
||||
env:
|
||||
BEFORE_SHA: ${{ github.event.before }}
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
echo "created=false" >> "$GITHUB_OUTPUT"
|
||||
|
||||
if [ "$BEFORE_SHA" = "0000000000000000000000000000000000000000" ]; then
|
||||
echo "No valid base commit available; skipping auto-tag."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
OLD_VERSION=$(git show "$BEFORE_SHA:pyproject.toml" | sed -n 's/^version = "\([^"]*\)"$/\1/p' | head -n1)
|
||||
if [ -z "$OLD_VERSION" ]; then
|
||||
echo "Could not find version in previous pyproject.toml" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NEW_VERSION=$(python - <<'PY'
|
||||
from pathlib import Path
|
||||
import re
|
||||
import sys
|
||||
|
||||
match = re.search(r'(?m)^version\s*=\s*"([^"]+)"', Path("pyproject.toml").read_text())
|
||||
if not match:
|
||||
sys.exit("Could not find version in current pyproject.toml")
|
||||
print(match.group(1))
|
||||
PY
|
||||
)
|
||||
|
||||
if [ "$OLD_VERSION" = "$NEW_VERSION" ]; then
|
||||
echo "No version change detected in pyproject.toml; skipping auto-tag."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
TAG="v${NEW_VERSION}"
|
||||
|
||||
# A draft GitHub Release must already exist for this tag before we
|
||||
# bump the version on main. The release skill creates it via
|
||||
# `gh release create --draft` ahead of the PR merge.
|
||||
STATE=$(gh release view "$TAG" --repo "$GITHUB_REPOSITORY" --json isDraft --jq '.isDraft' 2>/dev/null || echo "missing")
|
||||
if [ "$STATE" = "missing" ]; then
|
||||
echo "No GitHub Release found for $TAG." >&2
|
||||
echo "Create a draft release first: gh release create --draft $TAG --title $TAG --notes-file <notes>.md" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ "$STATE" = "false" ]; then
|
||||
echo "Release $TAG is already published; skipping auto-tag."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
TAG_EXISTS_LOCAL=false
|
||||
TAG_EXISTS_REMOTE=false
|
||||
if git rev-parse -q --verify "refs/tags/${TAG}" >/dev/null; then
|
||||
TAG_EXISTS_LOCAL=true
|
||||
fi
|
||||
if git ls-remote --exit-code --tags origin "refs/tags/${TAG}" >/dev/null 2>&1; then
|
||||
TAG_EXISTS_REMOTE=true
|
||||
fi
|
||||
|
||||
if [ "$TAG_EXISTS_LOCAL" = "true" ] || [ "$TAG_EXISTS_REMOTE" = "true" ]; then
|
||||
# Tag exists but draft hasn't been published — proceed to publish
|
||||
# (covers retries after the release-from-auto-tag step failed).
|
||||
echo "Tag ${TAG} already exists with a draft release; will publish."
|
||||
echo "created=true" >> "$GITHUB_OUTPUT"
|
||||
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
|
||||
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git tag -a "$TAG" -m "Release $TAG"
|
||||
git push origin "$TAG"
|
||||
|
||||
echo "created=true" >> "$GITHUB_OUTPUT"
|
||||
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
|
||||
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
release-from-auto-tag:
|
||||
needs: auto-tag-on-main
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.auto-tag-on-main.outputs.created == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Publish draft release
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
TAG: ${{ needs.auto-tag-on-main.outputs.tag }}
|
||||
run: |
|
||||
gh release edit "$TAG" --repo "$GITHUB_REPOSITORY" --draft=false --latest
|
||||
|
||||
tag-and-release:
|
||||
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v')
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout tagged release (dispatch)
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: refs/tags/${{ inputs.tag }}
|
||||
|
||||
- name: Checkout tagged release (push)
|
||||
if: github.event_name != 'workflow_dispatch'
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Resolve release version
|
||||
id: release
|
||||
env:
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
PUSHED_REF: ${{ github.ref_name }}
|
||||
INPUT_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || '' }}
|
||||
run: |
|
||||
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
|
||||
TAG="$INPUT_TAG"
|
||||
else
|
||||
TAG="$PUSHED_REF"
|
||||
fi
|
||||
|
||||
if [ -z "$TAG" ]; then
|
||||
echo "Unable to determine release tag" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$TAG" in
|
||||
v*)
|
||||
;;
|
||||
*)
|
||||
echo "Release tags must be prefixed with 'v' (received '$TAG')" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
VERSION="${TAG#v}"
|
||||
FILE_VERSION=$(python - <<'PY'
|
||||
from pathlib import Path
|
||||
import re
|
||||
import sys
|
||||
|
||||
match = re.search(r'(?m)^version\s*=\s*"([^"]+)"', Path("pyproject.toml").read_text())
|
||||
if not match:
|
||||
sys.exit("Could not find version in pyproject.toml")
|
||||
print(match.group(1))
|
||||
PY
|
||||
)
|
||||
|
||||
if [ "$FILE_VERSION" != "$VERSION" ]; then
|
||||
echo "Version mismatch: tag requests '$VERSION' but pyproject.toml defines '$FILE_VERSION'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Publish draft release
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
TAG: ${{ steps.release.outputs.tag }}
|
||||
run: |
|
||||
STATE=$(gh release view "$TAG" --repo "$GITHUB_REPOSITORY" --json isDraft --jq '.isDraft' 2>/dev/null || echo "missing")
|
||||
if [ "$STATE" = "missing" ]; then
|
||||
echo "No GitHub Release found for $TAG." >&2
|
||||
echo "Create a draft release first: gh release create --draft $TAG --title $TAG --notes-file <notes>.md" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ "$STATE" = "false" ]; then
|
||||
echo "Release $TAG is already published; nothing to do."
|
||||
exit 0
|
||||
fi
|
||||
gh release edit "$TAG" --repo "$GITHUB_REPOSITORY" --draft=false --latest
|
||||
@@ -1,4 +1,5 @@
|
||||
.vscode/*
|
||||
.claude/scheduled_tasks.lock
|
||||
*.ipynb
|
||||
*.jsonl
|
||||
configs/endpoints.py
|
||||
@@ -199,3 +200,5 @@ debug_I2_zero_band
|
||||
.idea
|
||||
|
||||
outputs/
|
||||
|
||||
third_party/
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
[submodule "verifiers"]
|
||||
path = deps/verifiers
|
||||
url = git@github.com:PrimeIntellect-ai/verifiers.git
|
||||
[submodule "renderers"]
|
||||
path = deps/renderers
|
||||
url = git@github.com:PrimeIntellect-ai/renderers.git
|
||||
[submodule "research-environments"]
|
||||
path = deps/research-environments
|
||||
url = git@github.com:PrimeIntellect-ai/research-environments.git
|
||||
[submodule "configs/private"]
|
||||
path = configs/private
|
||||
url = git@github.com:PrimeIntellect-ai/research-configs.git
|
||||
[submodule "pydantic-config"]
|
||||
path = deps/pydantic-config
|
||||
url = https://github.com/PrimeIntellect-ai/pydantic-config
|
||||
@@ -3,6 +3,7 @@
|
||||
## Writing code
|
||||
|
||||
- **Minimal try/except**: let errors propagate — silent failures hide bugs. Only catch exceptions for intentional fault tolerance (retries, robustness).
|
||||
- **Don't touch `optimization_dtype` / `reduce_dtype`**: never change these model config fields (or their defaults in `trainer.py`) unless the user explicitly asks. They're load-bearing numerical knobs — flipping bfloat16/float32 silently changes training dynamics.
|
||||
- **Targeted comments**: don't explain your work process or reference old code. Use targeted comments sparingly to clarify ambiguous logic.
|
||||
- **Zen of Python**: remember the Zen of Python when writing code.
|
||||
```
|
||||
@@ -32,6 +33,7 @@ Namespaces are one honking great idea -- let's do more of those!
|
||||
- **Always use uv**: run code with `uv run` or `uv run <command>`, never raw `python`.
|
||||
- **Adding dependencies**: add to `pyproject.toml` and run `uv sync --all-extras` to install and lock them.
|
||||
- **Git dependency pins**: when pinning git dependencies in `pyproject.toml`, always use a small (7-char) commit hash for the `rev` field.
|
||||
- **Never edit `.venv/`**: the local virtual env is read-only. Edits there are silently overwritten by the next `uv sync` and don't propagate to teammates or CI. Reading files under `.venv/` to understand library behavior is fine; writing is not. To fix a dependency issue, update `pyproject.toml` (pin a fork via 7-char commit hash if needed), vendor the code into `src/`, or patch upstream.
|
||||
|
||||
## Skills
|
||||
|
||||
@@ -43,6 +45,9 @@ You are responsible for maintaining the skills folder. When a workflow fails and
|
||||
|
||||
Write tests as plain functions with pytest fixtures. Don't use class-based tests.
|
||||
|
||||
- **Conservative test additions**: don't add new tests unless the user explicitly asks for them or it's clearly necessary. Editing existing tests is fine, but adding new test files or test functions should be the exception, not the default.
|
||||
- **Test what matters**: only test code with clear, isolated logic — pure functions, abstract base classes, data transformations, well-defined algorithms. Don't test runtime-level code, framework glue, or anything that requires extensive mocking/patching just to get a test to pass. If you need to patch everything out to make it testable, it's probably not worth testing.
|
||||
|
||||
## Git
|
||||
|
||||
- **Branch prefixes**: use the following prefixes for branches: `feat/`, `fix/`, `chore/`
|
||||
@@ -51,4 +56,5 @@ Write tests as plain functions with pytest fixtures. Don't use class-based tests
|
||||
|
||||
- **Draft PRs**: always create PRs as drafts (`gh pr create --draft`) to avoid triggering CI unnecessarily.
|
||||
- **Pull requests**: do not include a "test plan" section in PR descriptions unless you actually ran tests to verify the changes or the user explicitly asked for one.
|
||||
- **Keep PR descriptions in sync**: every time you push commits to a PR, also update the PR description (`gh pr edit <num> --body-file ...`) so it reflects the current state of the branch — not just what was true when the PR was opened. Preserve any auto-generated blocks (e.g. `<!-- CURSOR_SUMMARY -->`).
|
||||
|
||||
|
||||
@@ -2,6 +2,19 @@
|
||||
|
||||
Documenting **breaking** configuration changes — renamed, removed, or moved fields that require users to update existing configs.
|
||||
|
||||
- **`[model.vlm]` requires `orchestrator.use_renderer = true`**: VLMs must go through the renderer path; the `vlm_requires_renderer` validator rejects `use_renderer = false` when `[model.vlm]` is set. The renderer owns the HF processor per-slot and ships generic `mm_kwargs` keyed by the model's forward signature. Since `use_renderer` already defaults to `true`, most VLM configs need no change. (2026-05-19)
|
||||
- **First-class `training_mode` + batch-driven loss dispatch** (collection of removals/renames). Loss selection is now driven by `TrainingSample.training_mode` (`rl` / `opd` / `sft`), set under `[orchestrator]`. The trainer is mode-agnostic and dispatches per batch.
|
||||
- **`orchestrator.use_sft_loss` removed**: replaced by `[orchestrator] training_mode = "sft"`. The orchestrator stamps each sample's `training_mode` and the trainer dispatches to `sft_loss_fn` per batch.
|
||||
- **`orchestrator.teacher_rollout_model` removed (no alias)**: configs must rename to `[orchestrator.teacher]` (`teacher_model` is also accepted as a back-compat alias for `teacher`). Used in both opd and sft modes; the role is determined by `training_mode`.
|
||||
- **`orchestrator.model` → `orchestrator.student`**: renamed for symmetry with `orchestrator.teacher`. Legacy `[orchestrator.model]` and a flat `[orchestrator.model.lora]`-style layout are aliased via a back-compat shim, so most existing configs still parse. New code should use `[orchestrator.student.*]`.
|
||||
- **`trainer.loss.type = "sft"` removed (`SFTLossConfig` deleted)**: zero-field discriminator that is now implied by `training_mode = "sft"`. `trainer.loss` collapsed to a `DefaultLossConfig | CustomLossConfig` union. Existing configs setting `[trainer.loss] type = "sft"` must remove that line; the orchestrator-level `training_mode = "sft"` is enough.
|
||||
- **`trainer.loss.teacher_tau` removed from `DefaultLossConfig`**: the teacher-KL term is now exclusive to `opd_loss_fn` (which inlines `teacher_tau = 1.0`). `default_loss_fn` only handles reward-driven RL and no longer accepts a `teacher_tau`. Configs that set `teacher_tau` on `[trainer.loss]` will fail validation — switch to `[orchestrator] training_mode = "opd"` (which uses `opd_loss_fn` with the value baked in).
|
||||
- **`trainer.loss` only applies to rl-mode batches**: opd and sft don't read `trainer.loss`. `opd_loss_fn`'s knobs (dppo_mask_*, kl_tau) are inlined as literals; tweak them by editing the function. `CustomLossConfig` overrides the rl-mode loss only — opd and sft always use their dedicated fns. (2026-05-19)
|
||||
- **`orchestrator.use_token_client` removed**: The server-tokenized TITO path has been deprecated end-to-end. The orchestrator-side config flag (`use_token_client`), the verifiers client_type (`openai_chat_completions_token`), and the inference server's `/v1/chat/completions/tokens` route (along with the `OpenAIServingChatWithTokens` wrapper) are all gone. The orchestrator now picks between renderer-backed TITO (`use_renderer = true`, default) and MITO (`use_renderer = false`, fallback). Existing configs with `use_token_client = true` must migrate to `use_renderer = true` (or `use_renderer = false` for MITO); configs with `use_token_client = false` can simply drop the field. (2026-05-19)
|
||||
- **`orchestrator.advantage.length_penalty` → discriminated sub-config**: The scalar `length_penalty: Literal["tokens","turns"] | None` is replaced by a `LengthPenaltyConfig | None` discriminated on `type`. Token shaping now takes weighted completion + tool-response token costs. Migration: `length_penalty = "tokens"` becomes `[orchestrator.advantage.length_penalty]\ntype = "tokens"` (default weights `completion_weight = 1.0`, `tool_response_weight = 1.0` — total context). `length_penalty = "turns"` becomes `[orchestrator.advantage.length_penalty]\ntype = "turns"`. (2026-05-06)
|
||||
- **`orchestrator.advantage.length_shaping` → `orchestrator.advantage.length_penalty`**: The boolean `length_shaping` flag has been replaced by `length_penalty: Literal["tokens", "turns"] | None` (default: `None`). `length_shaping = true` becomes `length_penalty = "tokens"`; `length_shaping = false` becomes `length_penalty = None`. The new `"turns"` option applies the same correctness-gated efficiency shaping using trajectory turn count instead of completion-token count. (2026-05-01)
|
||||
- **`AdvantageInputs` API**: Replaced the `rewards`/`completion_lengths`/`num_turns` tensor fields with a single `rollouts: list[list[vf.RolloutOutput]]` (grouped by problem). Custom advantage functions can now access any rollout metadata. Existing custom advantages must update their signatures and extract per-rollout fields directly (e.g. `torch.tensor([[r["reward"] for r in g] for g in inputs.rollouts])`). (2026-05-01)
|
||||
- **`orchestrator.teacher_rollout_model` now requires `orchestrator.use_sft_loss = true`**: External teacher rollout configs no longer rely on `trainer.loss.type = "sft"` to select SFT loss. Existing hard-distill configs must set `orchestrator.use_sft_loss = true` alongside `orchestrator.teacher_rollout_model`; the orchestrator validates the pair and stamps training samples with the per-batch SFT loss bool. (2026-04-26)
|
||||
- **`model.attn = "eager"` (NEW option)**: Added `eager` as a valid value for the `model.attn` field. Required for GPT-OSS models on non-Hopper GPUs, since the only flash attention kernel GPT-OSS supports (`kernels-community/vllm-flash-attn3`) is Hopper-only. A clear error message is raised at model load time if GPT-OSS is used without `eager` on unsupported hardware. Also added `kernels` as a core dependency. (2026-04-05)
|
||||
- **`[[orchestrator.env]]` → `[[orchestrator.train.env]]`**: Training environments and sampling are now configured under `[orchestrator.train]`. The old `[[orchestrator.env]]` and `[orchestrator.sampling]` paths are auto-translated with a deprecation warning and will be removed in a future release. (2026-04-09)
|
||||
- **Per-env sampling overrides (NEW)**: Both `TrainEnvConfig` and `EvalEnvConfig` now accept a `[sampling]` section for per-env overrides. Unset fields inherit from the group-level sampling config (`[orchestrator.train.sampling]` or `[orchestrator.eval.sampling]`). (2026-04-09)
|
||||
|
||||
+3
-7
@@ -12,7 +12,7 @@ RUN echo "LC_ALL=en_US.UTF-8" >> /etc/environment
|
||||
ENV CUDA_HOME=/usr/local/cuda
|
||||
ENV PATH=$PATH:/usr/local/cuda/bin
|
||||
|
||||
# Install packages (including Python 3.12 and ninja for fast CUDA kernel compilation)
|
||||
# Install build tooling.
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV TZ=Etc/UTC
|
||||
@@ -22,12 +22,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends --force-yes \
|
||||
sudo \
|
||||
git \
|
||||
ninja-build \
|
||||
software-properties-common \
|
||||
&& add-apt-repository ppa:deadsnakes/ppa \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends python3.12 python3.12-dev python3.12-venv \
|
||||
&& ln -sf /usr/bin/python3.12 /usr/bin/python3 \
|
||||
&& ln -sf /usr/bin/python3.12 /usr/bin/python \
|
||||
&& apt-get clean autoclean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
# Download the latest installer
|
||||
@@ -48,6 +42,8 @@ COPY pyproject.toml /app/pyproject.toml
|
||||
COPY uv.lock /app/uv.lock
|
||||
COPY README.md /app/README.md
|
||||
COPY src/ /app/src/
|
||||
COPY packages/ /app/packages/
|
||||
COPY deps/ /app/deps/
|
||||
COPY configs /app/configs
|
||||
COPY examples /app/examples
|
||||
COPY benchmarks/scripts /app/benchmarks/scripts
|
||||
|
||||
@@ -53,6 +53,7 @@ With `[model] impl = "auto"` (the default), the trainer selects that custom stac
|
||||
| Qwen3 MoE (`qwen3_moe`) | `Qwen/Qwen3-30B-A3B`, … | yes | ✅ | ✅ |
|
||||
| Qwen3.5 MoE (`qwen3_5_moe`) | `Qwen/Qwen3.5-35B-A3B`, … | yes | ✅ | ✅ |
|
||||
| Qwen3 / Qwen3.5 VLMs | [multimodal.md](docs/multimodal.md) (`qwen3_vl`, `qwen3_5`, `qwen3_5_moe`) | MoE only on MoE VLMs | MoE only | ✅ |
|
||||
| Poolside Laguna (`laguna`) | `poolside/Laguna-XS.2` | yes | ✅ | ✅ |
|
||||
| MiniMax M2 (`minimax_m2`) | `MiniMax/MiniMax-M2` | yes | ✅ | ✅ |
|
||||
| Nemotron H (`nemotron_h`) | `nvidia/Nemotron-3-Nano-30B-A3B`, `nvidia/Nemotron-3-Super-120B-A12B`, … | yes | ✅ | ❌ |
|
||||
| Trinity (`afmoe`) | `arcee-ai/Trinity-Mini`, … | yes | ✅ | ✅ |
|
||||
@@ -90,14 +91,20 @@ git clone https://github.com/PrimeIntellect-ai/prime-rl.git
|
||||
cd prime-rl
|
||||
```
|
||||
|
||||
2. Install [uv](https://docs.astral.sh/uv/)
|
||||
2. Initialize submodules
|
||||
|
||||
```bash
|
||||
git submodule update --init -- deps/verifiers deps/renderers deps/research-environments deps/pydantic-config
|
||||
```
|
||||
|
||||
3. Install [uv](https://docs.astral.sh/uv/)
|
||||
|
||||
```bash
|
||||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
source $HOME/.local/bin/env
|
||||
```
|
||||
|
||||
3. Install dependencies from the lock file
|
||||
4. Install dependencies from the lock file
|
||||
|
||||
```bash
|
||||
uv sync --all-extras
|
||||
|
||||
+16
-16
@@ -15,34 +15,34 @@
|
||||
"cp": 1,
|
||||
"docker_image": null,
|
||||
"device_name": "NVIDIA RTX A6000",
|
||||
"commit_sha": "83c21ddac",
|
||||
"timestamp": "2026-02-26T02:07:06+00:00",
|
||||
"commit_sha": "0b37bc923",
|
||||
"timestamp": "2026-05-19T01:28:25+00:00",
|
||||
"success": true,
|
||||
"error_reason": null,
|
||||
"time_taken": 276.12556480802596
|
||||
},
|
||||
"metrics": {
|
||||
"mfu": {
|
||||
"mean": 16.41977165630161,
|
||||
"std": 0.010586646038388221,
|
||||
"min": 16.407648988464405,
|
||||
"max": 16.42719598975201
|
||||
"mean": 22.77046832707997,
|
||||
"std": 0.03172890658906481,
|
||||
"min": 22.750797215697055,
|
||||
"max": 22.80707156937409
|
||||
},
|
||||
"throughput": {
|
||||
"mean": 1960.9836648020673,
|
||||
"std": 1.2643440104327244,
|
||||
"min": 1959.5358764831926,
|
||||
"max": 1961.8703395331793
|
||||
"mean": 2719.4358949662887,
|
||||
"std": 3.7893259921987053,
|
||||
"min": 2717.086609671837,
|
||||
"max": 2723.8073540657224
|
||||
},
|
||||
"step_time": {
|
||||
"mean": 65.87,
|
||||
"std": 0.13,
|
||||
"min": 65.74,
|
||||
"max": 66.0
|
||||
"mean": 48.285218452724315,
|
||||
"std": 0.06726350421944344,
|
||||
"min": 48.207625919021666,
|
||||
"max": 48.327002701349556
|
||||
},
|
||||
"peak_memory": {
|
||||
"gib": 31.806640625,
|
||||
"pct": 67.03
|
||||
"gib": 24.248046875,
|
||||
"pct": 51.15428047554115
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
-17
@@ -15,34 +15,34 @@
|
||||
"cp": 1,
|
||||
"docker_image": null,
|
||||
"device_name": "NVIDIA RTX A6000",
|
||||
"commit_sha": "83c21ddac",
|
||||
"timestamp": "2026-02-26T02:07:06+00:00",
|
||||
"commit_sha": "0b37bc923",
|
||||
"timestamp": "2026-05-19T01:32:27+00:00",
|
||||
"success": true,
|
||||
"error_reason": null,
|
||||
"time_taken": 291.91085167229176
|
||||
},
|
||||
"metrics": {
|
||||
"mfu": {
|
||||
"mean": 15.634260517326164,
|
||||
"std": 0.009817863071768202,
|
||||
"min": 15.622927380137481,
|
||||
"max": 15.640172924064188
|
||||
"mean": 21.824271379711288,
|
||||
"std": 0.07444985226850119,
|
||||
"min": 21.739369034306105,
|
||||
"max": 21.878404774433935
|
||||
},
|
||||
"throughput": {
|
||||
"mean": 7468.685954343421,
|
||||
"std": 4.690118598479809,
|
||||
"min": 7463.271969943842,
|
||||
"max": 7471.510386564679
|
||||
"mean": 10425.733211800512,
|
||||
"std": 35.565645418564436,
|
||||
"min": 10385.174276894972,
|
||||
"max": 10451.593425935866
|
||||
},
|
||||
"step_time": {
|
||||
"mean": 68.34095695288852,
|
||||
"std": 0.16054587555887065,
|
||||
"min": 68.16114284005016,
|
||||
"max": 68.46991707291454
|
||||
"mean": 50.39627862814814,
|
||||
"std": 0.1756523472528039,
|
||||
"min": 50.26670710090548,
|
||||
"max": 50.59620195720345
|
||||
},
|
||||
"peak_memory": {
|
||||
"gib": 23.25390625,
|
||||
"pct": 49.05701678145735
|
||||
"gib": 17.490234375,
|
||||
"pct": 36.897831788841806
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,11 @@ name = "stage1"
|
||||
batch_size = 1024
|
||||
rollouts_per_example = 8
|
||||
|
||||
[orchestrator.sampling]
|
||||
[orchestrator.train.sampling]
|
||||
temperature = 0.6
|
||||
max_tokens = 8192
|
||||
max_completion_tokens = 8192
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env"
|
||||
args = { dataset_name = "nvidia/AceReason-Math", dataset_subset = "default", question_key = "problem", math_verify_max_workers = 128, math_verify_timeout = 60 }
|
||||
|
||||
@@ -45,4 +45,9 @@ rollouts_per_example = 32
|
||||
[trainer.model.ac]
|
||||
|
||||
[inference.parallel]
|
||||
dp = 6
|
||||
dp = 6
|
||||
|
||||
# Model not in MODEL_RENDERER_MAP — opt into DefaultRenderer (apply_chat_template).
|
||||
[orchestrator.renderer]
|
||||
name = "default"
|
||||
reasoning_parser = "think"
|
||||
|
||||
@@ -20,11 +20,11 @@ name = "stage2"
|
||||
batch_size = 2048
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.sampling]
|
||||
[orchestrator.train.sampling]
|
||||
temperature = 0.6
|
||||
max_tokens = 16384
|
||||
max_completion_tokens = 16384
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env"
|
||||
args = { dataset_name = "nvidia/AceReason-Math", dataset_subset = "default", question_key = "problem", math_verify_max_workers = 128, math_verify_timeout = 60 }
|
||||
|
||||
@@ -46,4 +46,9 @@ rollouts_per_example = 32
|
||||
[trainer.model.ac]
|
||||
|
||||
[inference.parallel]
|
||||
dp = 6
|
||||
dp = 6
|
||||
|
||||
# Model not in MODEL_RENDERER_MAP — opt into DefaultRenderer (apply_chat_template).
|
||||
[orchestrator.renderer]
|
||||
name = "default"
|
||||
reasoning_parser = "think"
|
||||
|
||||
@@ -13,10 +13,10 @@ name = "Qwen/Qwen3-4B-Instruct-2507"
|
||||
batch_size = 512
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 512
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 512
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "alphabet-sort"
|
||||
name = "alphabet-sort"
|
||||
args = { min_turns = 2, max_turns = 2 }
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
max_steps = 5
|
||||
seq_len = 2048
|
||||
|
||||
[ckpt]
|
||||
|
||||
[model]
|
||||
name = "Qwen/Qwen3-0.6B"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 1e-5
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 128
|
||||
rollouts_per_example = 8
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 384
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
id = "alphabet-sort"
|
||||
name = "alphabet-sort"
|
||||
args = { min_turns = 2, max_turns = 2, min_names_per_turn = 1, max_names_per_turn = 3, similarity_power = 4, power_per_turn = false }
|
||||
|
||||
[inference]
|
||||
|
||||
# Mirror of Qwen/Qwen3-0.6B; PI's template patch always re-emits prior
|
||||
# <think> blocks. Match that with the qwen3 renderer's preserve_all_thinking.
|
||||
[orchestrator.renderer]
|
||||
preserve_all_thinking = true
|
||||
@@ -1,24 +0,0 @@
|
||||
max_steps = 10
|
||||
seq_len = 2048
|
||||
|
||||
[ckpt]
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 1e-5
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 128
|
||||
rollouts_per_example = 8
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 384
|
||||
|
||||
[[orchestrator.env]]
|
||||
id = "alphabet-sort"
|
||||
name = "alphabet-sort"
|
||||
args = { min_turns = 2, max_turns = 2, min_names_per_turn = 1, max_names_per_turn = 3, similarity_power = 4, power_per_turn = false }
|
||||
|
||||
[inference]
|
||||
@@ -1,29 +0,0 @@
|
||||
max_steps = 10
|
||||
seq_len = 2048
|
||||
|
||||
[deployment]
|
||||
type = "single_node"
|
||||
num_infer_gpus = 1
|
||||
num_train_gpus = 1
|
||||
|
||||
[ckpt]
|
||||
|
||||
[model]
|
||||
name = "Qwen/Qwen3-0.6B"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 1e-5
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 128
|
||||
rollouts_per_example = 8
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 1024
|
||||
|
||||
[[orchestrator.env]]
|
||||
id = "primeintellect/alphabet-sort"
|
||||
name = "alphabet-sort"
|
||||
args = { min_turns = 2, max_turns = 2, min_names_per_turn = 1, max_names_per_turn = 3, similarity_power = 4, power_per_turn = false }
|
||||
|
||||
[inference]
|
||||
@@ -0,0 +1,27 @@
|
||||
max_steps = 20
|
||||
seq_len = 2048
|
||||
|
||||
[ckpt]
|
||||
resume_step = 15
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 128
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[inference]
|
||||
|
||||
# Model not in MODEL_RENDERER_MAP — opt into DefaultRenderer (apply_chat_template).
|
||||
[orchestrator.renderer]
|
||||
name = "default"
|
||||
@@ -0,0 +1,26 @@
|
||||
max_steps = 15
|
||||
seq_len = 2048
|
||||
|
||||
[ckpt]
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 128
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[inference]
|
||||
|
||||
# Model not in MODEL_RENDERER_MAP — opt into DefaultRenderer (apply_chat_template).
|
||||
[orchestrator.renderer]
|
||||
name = "default"
|
||||
+9
-4
@@ -2,6 +2,7 @@ max_steps = 20
|
||||
seq_len = 2048
|
||||
|
||||
[ckpt]
|
||||
resume_step = 15
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
@@ -22,12 +23,16 @@ rollouts_per_example = 16
|
||||
[orchestrator.model.lora]
|
||||
name = "r8-1e-4"
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 128
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[inference]
|
||||
enable_lora = true
|
||||
gpu_memory_utilization = 0.7
|
||||
gpu_memory_utilization = 0.7
|
||||
|
||||
# Model not in MODEL_RENDERER_MAP — opt into DefaultRenderer (apply_chat_template).
|
||||
[orchestrator.renderer]
|
||||
name = "default"
|
||||
+9
-6
@@ -1,8 +1,7 @@
|
||||
max_steps = 25
|
||||
max_steps = 15
|
||||
seq_len = 2048
|
||||
|
||||
[ckpt]
|
||||
resume_step = 20
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
@@ -23,12 +22,16 @@ rollouts_per_example = 16
|
||||
[orchestrator.model.lora]
|
||||
name = "r8-1e-4"
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 128
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[inference]
|
||||
enable_lora = true
|
||||
gpu_memory_utilization = 0.7
|
||||
gpu_memory_utilization = 0.7
|
||||
|
||||
# Model not in MODEL_RENDERER_MAP — opt into DefaultRenderer (apply_chat_template).
|
||||
[orchestrator.renderer]
|
||||
name = "default"
|
||||
+10
-3
@@ -9,14 +9,17 @@ name = "samsja/mini-glm-moe"
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
[trainer.model]
|
||||
impl = "custom"
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 128
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 128
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[inference]
|
||||
@@ -24,3 +27,7 @@ gpu_memory_utilization = 0.7
|
||||
|
||||
[inference.model]
|
||||
max_model_len = 2048
|
||||
|
||||
# Model not in MODEL_RENDERER_MAP — opt into DefaultRenderer (apply_chat_template).
|
||||
[orchestrator.renderer]
|
||||
name = "default"
|
||||
+7
-3
@@ -11,12 +11,16 @@ name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
[optim]
|
||||
lr = 3e-5
|
||||
|
||||
[sampling]
|
||||
max_tokens = 128
|
||||
[train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[env]]
|
||||
[[train.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[ckpt]
|
||||
interval = 10
|
||||
resume_step = -1
|
||||
|
||||
# Model not in MODEL_RENDERER_MAP — opt into DefaultRenderer (apply_chat_template).
|
||||
[renderer]
|
||||
name = "default"
|
||||
@@ -0,0 +1,51 @@
|
||||
# Smoke test for the RL-entrypoint OPD (on-policy distillation) training mode.
|
||||
# The student inference deployment is launched by the rl entrypoint on GPU 0;
|
||||
# the teacher inference server is started externally by the test fixture (see
|
||||
# tests/integration/test_reverse_text_rl_opd.py) on the same GPU. Trainer
|
||||
# takes GPU 1. Training config mirrors `reverse_text/start.toml`.
|
||||
|
||||
max_steps = 5
|
||||
seq_len = 2048
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
project = "reverse-text-ci"
|
||||
name = "ci-rl-opd"
|
||||
|
||||
[orchestrator]
|
||||
training_mode = "opd"
|
||||
batch_size = 128
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.renderer]
|
||||
name = "qwen3"
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 1
|
||||
num_examples = 16
|
||||
|
||||
[orchestrator.eval.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.teacher.model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL"
|
||||
|
||||
[orchestrator.teacher.client]
|
||||
base_url = ["http://localhost:8001/v1"]
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
[inference]
|
||||
gpu_memory_utilization = 0.4
|
||||
@@ -0,0 +1,48 @@
|
||||
# Smoke test for the RL-entrypoint SFT (on-policy hard distillation) training
|
||||
# mode. The student inference deployment is launched by the rl entrypoint on
|
||||
# GPU 0; the teacher inference server is started externally by the test
|
||||
# fixture (see tests/integration/test_reverse_text_rl_sft.py) on the same GPU.
|
||||
# Trainer takes GPU 1. Training config mirrors `reverse_text/start.toml`.
|
||||
|
||||
max_steps = 5
|
||||
seq_len = 2048
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
project = "reverse-text-ci"
|
||||
name = "ci-rl-sft"
|
||||
|
||||
[orchestrator]
|
||||
training_mode = "sft"
|
||||
batch_size = 128
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 1
|
||||
num_examples = 16
|
||||
|
||||
[orchestrator.eval.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.teacher.model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL"
|
||||
|
||||
[orchestrator.teacher.client]
|
||||
base_url = ["http://localhost:8001/v1"]
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
[inference]
|
||||
gpu_memory_utilization = 0.4
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
max_steps = 10
|
||||
|
||||
[ckpt]
|
||||
resume_step = 5
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B"
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
max_steps = 20
|
||||
max_steps = 5
|
||||
|
||||
[ckpt]
|
||||
resume_step = 10
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B"
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
max_steps = 20
|
||||
max_steps = 10
|
||||
|
||||
[ckpt]
|
||||
resume_step = 10
|
||||
resume_step = 5
|
||||
|
||||
[ckpt.weights]
|
||||
save_adapter_separately = true
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
max_steps = 10
|
||||
max_steps = 5
|
||||
|
||||
[ckpt]
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
max_steps = 25
|
||||
seq_len = 2048
|
||||
|
||||
[ckpt]
|
||||
resume_step = 20
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 128
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 128
|
||||
|
||||
[[orchestrator.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[inference]
|
||||
@@ -1,22 +0,0 @@
|
||||
max_steps = 20
|
||||
seq_len = 2048
|
||||
|
||||
[ckpt]
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 128
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 128
|
||||
|
||||
[[orchestrator.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[inference]
|
||||
@@ -17,15 +17,20 @@ name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B"
|
||||
batch_size = 1024
|
||||
rollouts_per_example = 8
|
||||
|
||||
[orchestrator.sampling]
|
||||
[orchestrator.train.sampling]
|
||||
temperature = 0.6
|
||||
max_tokens = 8192
|
||||
max_completion_tokens = 8192
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env"
|
||||
name = "acereason-math"
|
||||
args = { dataset_name = "nvidia/AceReason-Math", dataset_subset = "default", question_key = "problem", math_verify_max_workers = 128, math_verify_timeout = 60 }
|
||||
|
||||
[trainer]
|
||||
|
||||
[inference]
|
||||
[inference]
|
||||
|
||||
# Model not in MODEL_RENDERER_MAP — opt into DefaultRenderer (apply_chat_template).
|
||||
[orchestrator.renderer]
|
||||
name = "default"
|
||||
reasoning_parser = "think"
|
||||
|
||||
@@ -17,10 +17,10 @@ language_model_attr = "model.language_model"
|
||||
batch_size = 256
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 64
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 64
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "color-codeword"
|
||||
args = { images_per_turn = 1, max_turns = 3, num_examples = 1000, seed = 42 }
|
||||
|
||||
|
||||
@@ -2,6 +2,6 @@ max_steps = 5
|
||||
max_async_level = 5
|
||||
batch_size = 16
|
||||
|
||||
[sampling]
|
||||
max_tokens = 16
|
||||
[train.sampling]
|
||||
max_completion_tokens = 16
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# Training Mode — Debug Configs
|
||||
|
||||
Minimal end-to-end configs for the three training modes (`rl` / `opd` / `sft`) against the `reverse-text` env, using `PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT` as the student.
|
||||
|
||||
| Config | Mode | Teacher | Notes |
|
||||
|---|---|---|---|
|
||||
| `rl.toml` | `rl` | none | |
|
||||
| `opd.toml` | `opd` | local vLLM (`Qwen3-0.6B-Reverse-Text-RL`) | |
|
||||
| `opd_lora.toml` | `opd` | local vLLM (`Qwen3-0.6B-Reverse-Text-RL`) | trains a LoRA adapter (rank 8) |
|
||||
| `sft.toml` | `sft` | local vLLM (`Qwen3-0.6B-Reverse-Text-RL`) | |
|
||||
| `sft_lora.toml` | `sft` | local vLLM (`Qwen3-0.6B-Reverse-Text-RL`) | trains a LoRA adapter (rank 8) |
|
||||
| `sft_external.toml` | `sft` | PI inference (`openai/gpt-5-mini`) | external OAI endpoint; no local teacher |
|
||||
|
||||
The student inference server is auto-launched on GPU 0 at `http://localhost:8000/v1` with `gpu_memory_utilization=0.5`. The local teacher (used by everything except `rl.toml` and `sft_external.toml`) is **not** auto-launched — start it manually on GPU 1.
|
||||
|
||||
## Start the local teacher
|
||||
|
||||
Needed for `opd*.toml` and `sft.toml` / `sft_lora.toml`:
|
||||
|
||||
```bash
|
||||
CUDA_VISIBLE_DEVICES=1 uv run inference \
|
||||
--model.name PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL \
|
||||
--server.port 8001 \
|
||||
--gpu-memory-utilization 0.5 \
|
||||
--model.enforce-eager
|
||||
```
|
||||
|
||||
## Run the debug configs
|
||||
|
||||
```bash
|
||||
# RL (no teacher)
|
||||
uv run rl @ configs/debug/training_modes/rl.toml
|
||||
|
||||
# OPD (needs teacher on port 8001)
|
||||
uv run rl @ configs/debug/training_modes/opd.toml
|
||||
uv run rl @ configs/debug/training_modes/opd_lora.toml
|
||||
|
||||
# SFT hard distill (needs teacher on port 8001)
|
||||
uv run rl @ configs/debug/training_modes/sft.toml
|
||||
uv run rl @ configs/debug/training_modes/sft_lora.toml
|
||||
|
||||
# SFT hard distill from openai/gpt-5-mini via PI inference
|
||||
# (requires PRIME_API_KEY + PRIME_TEAM_ID in env; no local teacher needed)
|
||||
uv run rl @ configs/debug/training_modes/sft_external.toml
|
||||
```
|
||||
|
||||
See [docs/training_modes.md](../../docs/training_modes.md) for what each mode does.
|
||||
@@ -0,0 +1,54 @@
|
||||
# Start the teacher inference server first (on a separate GPU):
|
||||
# CUDA_VISIBLE_DEVICES=1 uv run inference \
|
||||
# --model.name PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL \
|
||||
# --server.port 8001 --gpu-memory-utilization 0.5 --model.enforce-eager
|
||||
# Then:
|
||||
# uv run rl @ configs/debug/training_modes/opd.toml
|
||||
|
||||
max_steps = 20
|
||||
seq_len = 2048
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
project = "reverse-text-debug"
|
||||
name = "debug-opd"
|
||||
|
||||
[orchestrator]
|
||||
training_mode = "opd"
|
||||
batch_size = 128
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.renderer]
|
||||
name = "qwen3"
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 1
|
||||
num_examples = 128
|
||||
|
||||
[orchestrator.eval.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.teacher.model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL"
|
||||
|
||||
[orchestrator.teacher.client]
|
||||
base_url = ["http://localhost:8001/v1"]
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
[ckpt]
|
||||
|
||||
[inference]
|
||||
gpu_memory_utilization = 0.5
|
||||
@@ -0,0 +1,60 @@
|
||||
# Start the teacher inference server first (on a separate GPU):
|
||||
# CUDA_VISIBLE_DEVICES=1 uv run inference \
|
||||
# --model.name PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL \
|
||||
# --server.port 8001 --gpu-memory-utilization 0.5 --model.enforce-eager
|
||||
# Then:
|
||||
# uv run rl @ configs/debug/training_modes/opd_lora.toml
|
||||
|
||||
max_steps = 20
|
||||
seq_len = 2048
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
project = "reverse-text-debug"
|
||||
name = "debug-opd-lora"
|
||||
|
||||
[orchestrator]
|
||||
training_mode = "opd"
|
||||
batch_size = 128
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.renderer]
|
||||
name = "qwen3"
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 1
|
||||
num_examples = 128
|
||||
|
||||
[orchestrator.eval.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.teacher.model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL"
|
||||
|
||||
[orchestrator.teacher.client]
|
||||
base_url = ["http://localhost:8001/v1"]
|
||||
|
||||
[trainer.optim]
|
||||
lr = 1e-4
|
||||
|
||||
[trainer.model.lora]
|
||||
rank = 8
|
||||
|
||||
[trainer.ckpt.weights]
|
||||
save_adapter_separately = true
|
||||
|
||||
[ckpt]
|
||||
|
||||
[inference]
|
||||
gpu_memory_utilization = 0.5
|
||||
@@ -0,0 +1,41 @@
|
||||
max_steps = 20
|
||||
seq_len = 2048
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
project = "reverse-text-debug"
|
||||
name = "debug-rl"
|
||||
|
||||
[orchestrator]
|
||||
training_mode = "rl"
|
||||
batch_size = 128
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.renderer]
|
||||
name = "qwen3"
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 1
|
||||
num_examples = 128
|
||||
|
||||
[orchestrator.eval.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
[ckpt]
|
||||
|
||||
[inference]
|
||||
gpu_memory_utilization = 0.5
|
||||
@@ -0,0 +1,51 @@
|
||||
# Start the teacher inference server first (on a separate GPU):
|
||||
# CUDA_VISIBLE_DEVICES=1 uv run inference \
|
||||
# --model.name PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL \
|
||||
# --server.port 8001 --gpu-memory-utilization 0.5 --model.enforce-eager
|
||||
# Then:
|
||||
# uv run rl @ configs/debug/training_modes/sft.toml
|
||||
|
||||
max_steps = 20
|
||||
seq_len = 2048
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
project = "reverse-text-debug"
|
||||
name = "debug-sft"
|
||||
|
||||
[orchestrator]
|
||||
training_mode = "sft"
|
||||
batch_size = 128
|
||||
rollouts_per_example = 4
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 1
|
||||
num_examples = 128
|
||||
|
||||
[orchestrator.eval.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.teacher.model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL"
|
||||
|
||||
[orchestrator.teacher.client]
|
||||
base_url = ["http://localhost:8001/v1"]
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
[ckpt]
|
||||
|
||||
[inference]
|
||||
gpu_memory_utilization = 0.5
|
||||
@@ -0,0 +1,55 @@
|
||||
# SFT from openai/gpt-5-mini via PI inference.
|
||||
# Requires PRIME_API_KEY + PRIME_TEAM_ID in the environment.
|
||||
#
|
||||
# Run with:
|
||||
# uv run rl @ configs/debug/training_modes/sft_external.toml
|
||||
|
||||
max_steps = 20
|
||||
seq_len = 2048
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
project = "reverse-text-debug"
|
||||
name = "debug-sft-external"
|
||||
|
||||
[orchestrator]
|
||||
training_mode = "sft"
|
||||
batch_size = 128
|
||||
rollouts_per_example = 4
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 2048
|
||||
extra_body = { reasoning_effort = "minimal" }
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 1
|
||||
num_examples = 128
|
||||
|
||||
[orchestrator.eval.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.teacher.model]
|
||||
name = "openai/gpt-5-mini"
|
||||
|
||||
[orchestrator.teacher.client]
|
||||
base_url = ["https://api.pinference.ai/api/v1"]
|
||||
api_key_var = "PRIME_API_KEY"
|
||||
|
||||
[orchestrator.teacher.client.headers_from_env]
|
||||
X-Prime-Team-ID = "PRIME_TEAM_ID"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
[ckpt]
|
||||
|
||||
[inference]
|
||||
gpu_memory_utilization = 0.5
|
||||
@@ -0,0 +1,57 @@
|
||||
# Start the teacher inference server first (on a separate GPU):
|
||||
# CUDA_VISIBLE_DEVICES=1 uv run inference \
|
||||
# --model.name PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL \
|
||||
# --server.port 8001 --gpu-memory-utilization 0.5 --model.enforce-eager
|
||||
# Then:
|
||||
# uv run rl @ configs/debug/training_modes/sft_lora.toml
|
||||
|
||||
max_steps = 20
|
||||
seq_len = 2048
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
project = "reverse-text-debug"
|
||||
name = "debug-sft-lora"
|
||||
|
||||
[orchestrator]
|
||||
training_mode = "sft"
|
||||
batch_size = 128
|
||||
rollouts_per_example = 4
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 1
|
||||
num_examples = 128
|
||||
|
||||
[orchestrator.eval.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.teacher.model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL"
|
||||
|
||||
[orchestrator.teacher.client]
|
||||
base_url = ["http://localhost:8001/v1"]
|
||||
|
||||
[trainer.optim]
|
||||
lr = 1e-4
|
||||
|
||||
[trainer.model.lora]
|
||||
rank = 8
|
||||
|
||||
[trainer.ckpt.weights]
|
||||
save_adapter_separately = true
|
||||
|
||||
[ckpt]
|
||||
|
||||
[inference]
|
||||
gpu_memory_utilization = 0.5
|
||||
@@ -19,11 +19,11 @@ interval = 100
|
||||
batch_size = 1024
|
||||
rollouts_per_example = 8
|
||||
|
||||
[orchestrator.sampling]
|
||||
[orchestrator.train.sampling]
|
||||
temperature = 0.6
|
||||
max_tokens = 8192
|
||||
max_completion_tokens = 8192
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env"
|
||||
name = "deepscaler"
|
||||
args = { dataset_name= "agentica-org/DeepScaleR-Preview-Dataset", dataset_subset = "default", question_key = "problem", answer_key = "solution", math_verify_max_workers = 128, math_verify_timeout = 60 }
|
||||
@@ -31,4 +31,9 @@ args = { dataset_name= "agentica-org/DeepScaleR-Preview-Dataset", dataset_subset
|
||||
[trainer.model.ac]
|
||||
|
||||
[inference.parallel]
|
||||
dp = 6
|
||||
dp = 6
|
||||
|
||||
# Model not in MODEL_RENDERER_MAP — opt into DefaultRenderer (apply_chat_template).
|
||||
[orchestrator.renderer]
|
||||
name = "default"
|
||||
reasoning_parser = "think"
|
||||
|
||||
@@ -20,11 +20,11 @@ resume_step = 500
|
||||
batch_size = 1024
|
||||
rollouts_per_example = 8
|
||||
|
||||
[orchestrator.sampling]
|
||||
[orchestrator.train.sampling]
|
||||
temperature = 0.6
|
||||
max_tokens = 16384
|
||||
max_completion_tokens = 16384
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env"
|
||||
name = "deepscaler"
|
||||
args = { dataset_name= "agentica-org/DeepScaleR-Preview-Dataset", dataset_subset = "default", question_key = "problem", answer_key = "solution", math_verify_max_workers = 128, math_verify_timeout = 60 }
|
||||
@@ -32,4 +32,9 @@ args = { dataset_name= "agentica-org/DeepScaleR-Preview-Dataset", dataset_subset
|
||||
[trainer.model.ac]
|
||||
|
||||
[inference.parallel]
|
||||
dp = 6
|
||||
dp = 6
|
||||
|
||||
# Model not in MODEL_RENDERER_MAP — opt into DefaultRenderer (apply_chat_template).
|
||||
[orchestrator.renderer]
|
||||
name = "default"
|
||||
reasoning_parser = "think"
|
||||
|
||||
@@ -20,11 +20,11 @@ resume_step = 1000
|
||||
batch_size = 1024
|
||||
rollouts_per_example = 8
|
||||
|
||||
[orchestrator.sampling]
|
||||
[orchestrator.train.sampling]
|
||||
temperature = 0.6
|
||||
max_tokens = 24576
|
||||
max_completion_tokens = 24576
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env"
|
||||
name = "deepscaler"
|
||||
args = { dataset_name= "agentica-org/DeepScaleR-Preview-Dataset", dataset_subset = "default", question_key = "problem", answer_key = "solution", math_verify_max_workers = 128, math_verify_timeout = 60 }
|
||||
@@ -32,4 +32,9 @@ args = { dataset_name= "agentica-org/DeepScaleR-Preview-Dataset", dataset_subset
|
||||
[trainer.model.ac]
|
||||
|
||||
[inference.parallel]
|
||||
dp = 6
|
||||
dp = 6
|
||||
|
||||
# Model not in MODEL_RENDERER_MAP — opt into DefaultRenderer (apply_chat_template).
|
||||
[orchestrator.renderer]
|
||||
name = "default"
|
||||
reasoning_parser = "think"
|
||||
|
||||
@@ -32,15 +32,15 @@ lr = 1e-5
|
||||
batch_size = 512
|
||||
rollouts_per_example = 8
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 768
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 768
|
||||
|
||||
[orchestrator.client.elastic]
|
||||
hostname = "localhost"
|
||||
port = 8000
|
||||
sync_interval = 5.0
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "alphabet-sort"
|
||||
name = "alphabet-sort"
|
||||
args = { min_turns = 3, max_turns = 5, power_per_turn = false }
|
||||
@@ -16,27 +16,27 @@ name = "Qwen/Qwen3-4B-Instruct-2507"
|
||||
batch_size = 512
|
||||
rollouts_per_example = 16
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env"
|
||||
name = "math"
|
||||
args = { min_avg_reward = 0.1, rubric_max_workers = 128 }
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "code-env"
|
||||
name = "code"
|
||||
args = { min_avg_reward = 0.1 }
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "science-env"
|
||||
name = "science"
|
||||
args = { min_avg_reward = 0.1, pool_size = 128, rubric_max_workers = 128 }
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "logic-env"
|
||||
name = "logic"
|
||||
args = { min_avg_reward = 0.1 }
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env"
|
||||
name = "math-python"
|
||||
args = { min_avg_reward = 0.1, sandbox_client_max_workers = 128, sandbox_timeout_minutes = 10, sandbox_memory_gb = 1, sandbox_disk_size_gb = 1, pip_install_packages = "numpy sympy", python_tool = true, rubric_max_workers = 128 }
|
||||
|
||||
+10
-5
@@ -6,20 +6,25 @@ project = "gsm8k-debug"
|
||||
name = "gsm8k"
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B"
|
||||
name = "Qwen/Qwen3-0.6B"
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 512
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 2048
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 2048
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env"
|
||||
name = "gsm8k"
|
||||
args = { dataset_name = "openai/gsm8k", dataset_subset = "main", math_verify_max_workers = 128, math_verify_timeout = 60 }
|
||||
|
||||
[trainer] # Default trainer config
|
||||
|
||||
[inference] # Default inference config
|
||||
[inference] # Default inference config
|
||||
|
||||
# Mirror of Qwen/Qwen3-0.6B; PI's template patch always re-emits prior
|
||||
# <think> blocks. Match that with the qwen3 renderer's preserve_all_thinking.
|
||||
[orchestrator.renderer]
|
||||
preserve_all_thinking = true
|
||||
|
||||
@@ -12,10 +12,10 @@ name = "Qwen/Qwen3-4B-Instruct-2507"
|
||||
batch_size = 512
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 2048
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 2048
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env"
|
||||
name = "hendrycks-math"
|
||||
args = { dataset_name = "PrimeIntellect/Hendrycks-Math", dataset_subset = "default", math_verify_max_workers = 128, math_verify_timeout = 60 }
|
||||
@@ -28,7 +28,7 @@ hard_threshold = 0.0
|
||||
interval = 10
|
||||
|
||||
[orchestrator.eval.sampling]
|
||||
max_tokens = 2048
|
||||
max_completion_tokens = 2048
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
id = "math500"
|
||||
|
||||
@@ -12,7 +12,7 @@ name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B"
|
||||
batch_size = 512
|
||||
rollouts_per_example = 8
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env"
|
||||
args = { dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B", dataset_subset = "default" }
|
||||
name = "hendrycks-math"
|
||||
@@ -25,9 +25,6 @@ id = "aime2024"
|
||||
name = "aime2024"
|
||||
rollouts_per_example = 16
|
||||
|
||||
[trainer.model]
|
||||
name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B"
|
||||
|
||||
[trainer.model.ac]
|
||||
|
||||
[trainer.model.compile]
|
||||
@@ -36,4 +33,9 @@ name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B"
|
||||
max_model_len = 8192
|
||||
|
||||
[log]
|
||||
level = "debug"
|
||||
level = "debug"
|
||||
|
||||
# Model not in MODEL_RENDERER_MAP — opt into DefaultRenderer (apply_chat_template).
|
||||
[orchestrator.renderer]
|
||||
name = "default"
|
||||
reasoning_parser = "think"
|
||||
|
||||
@@ -11,13 +11,13 @@ name = "Qwen/Qwen3-4B-Instruct-2507"
|
||||
batch_size = 256
|
||||
rollouts_per_example = 8
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env"
|
||||
name = "hendrycks-math"
|
||||
args = { dataset_name = "PrimeIntellect/Hendrycks-Math", dataset_subset = "default" }
|
||||
ratio = 0.5
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env"
|
||||
name = "acereason-math"
|
||||
args = { dataset_name = "nvidia/AceReason-Math", dataset_subset = "default", question_key = "problem" }
|
||||
|
||||
@@ -12,10 +12,10 @@ name = "Qwen/Qwen3-4B-Instruct-2507"
|
||||
batch_size = 512
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 512
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 512
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-python"
|
||||
args = { sandbox_client_max_workers = 128, sandbox_timeout_minutes = 10, sandbox_memory_gb = 1, sandbox_disk_size_gb = 1, pip_install_packages = "numpy sympy" }
|
||||
|
||||
|
||||
@@ -52,4 +52,8 @@ temperature = 0.5
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
[inference] # Default inference config
|
||||
[inference] # Default inference config
|
||||
|
||||
# Model not in MODEL_RENDERER_MAP — opt into DefaultRenderer (apply_chat_template).
|
||||
[orchestrator.renderer]
|
||||
name = "default"
|
||||
|
||||
@@ -12,11 +12,10 @@ language_model_attr = "model.language_model"
|
||||
batch_size = 256
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 64
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 64
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "color-codeword"
|
||||
args = { images_per_turn = 1, max_turns = 3, num_examples = 1000, seed = 42 }
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
# 20-step Qwen3-VL-4B RL run on color-codeword using the renderer multimodal path.
|
||||
#
|
||||
# Pair with rl_color_codeword_main_mito.toml for an A/B comparison: same env,
|
||||
# same hyperparameters, same step count — only difference is the inference
|
||||
# client. The feat-branch run uses the new RendererClient + Qwen3VLRenderer
|
||||
# (renderers package with multimodal support); the main-branch baseline uses
|
||||
# the existing TITO chat-completions path through the inference server.
|
||||
#
|
||||
# Compare in W&B project ``multimodal-renderer``:
|
||||
# - ``kl/sampler_vs_trainer`` should be ~0 on this branch (the renderer
|
||||
# produces byte-identical tokens to what the trainer re-tokenizes) and
|
||||
# can spike on main when BPE drifts mid-rollout.
|
||||
# - ``reward`` and ``loss`` should track within noise — same model, same
|
||||
# env, same hyperparameters.
|
||||
# - ``bridge_break_rate`` is renderer-only; surfaces multi-turn extension
|
||||
# failures.
|
||||
|
||||
max_steps = 20
|
||||
seq_len = 4096
|
||||
output_dir = "outputs/rl_color_codeword_feat_renderer"
|
||||
clean_output_dir = true
|
||||
# Pure on-policy: inference can't run ahead of training, so every rollout
|
||||
# is generated from the latest policy weights. Removes async/off-policy
|
||||
# drift as a confound for the sampler-vs-trainer KL.
|
||||
max_async_level = 0
|
||||
|
||||
[model]
|
||||
name = "Qwen/Qwen3-VL-4B-Instruct"
|
||||
|
||||
[model.vlm]
|
||||
vision_encoder_attr = "model.visual"
|
||||
language_model_attr = "model.language_model"
|
||||
|
||||
[deployment]
|
||||
num_train_gpus = 1
|
||||
num_infer_gpus = 1
|
||||
gpus_per_node = 2
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 16
|
||||
rollouts_per_example = 8
|
||||
use_renderer = true
|
||||
|
||||
# Track zero-advantage groups but don't drop them — we're validating the
|
||||
# multimodal renderer path on 20 steps, not optimizing training efficiency.
|
||||
# Step 0 on Qwen3-VL-4B vs color-codeword is likely uniform (all-correct or
|
||||
# all-wrong) so enforce=True would crash before any training happens.
|
||||
[[orchestrator.filters]]
|
||||
type = "gibberish"
|
||||
|
||||
[[orchestrator.filters]]
|
||||
type = "repetition"
|
||||
|
||||
[[orchestrator.filters]]
|
||||
type = "zero_advantage"
|
||||
enforce = false
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 64
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
id = "color-codeword"
|
||||
args = { images_per_turn = 2, max_turns = 2, num_examples = 100, seed = 42 }
|
||||
|
||||
[orchestrator.renderer]
|
||||
name = "auto"
|
||||
# 64 concurrent rollouts (batch_size=16 × rollouts_per_example=4) want
|
||||
# more than one tokenizer slot to avoid serialization queueing. The
|
||||
# image processor (CPU-bound) dominates for VLMs so returns diminish
|
||||
# past 4; bump to 4 as the default for multimodal runs.
|
||||
pool_size = 4
|
||||
|
||||
[trainer]
|
||||
|
||||
[trainer.model]
|
||||
optimization_dtype = "bfloat16"
|
||||
reduce_dtype = "bfloat16"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
[inference]
|
||||
|
||||
[inference.model]
|
||||
# Workaround for vLLM 0.20.1 Qwen3-VL deepstack buffer bug: when num_scheduled_tokens
|
||||
# (188) gets padded up to the next cudagraph_capture_size (192), the model's
|
||||
# _set_deepstack_input_embeds sizes the buffer to 188 but forward() runs with 192,
|
||||
# triggering "Requested more deepstack tokens than available in buffer". Eager mode
|
||||
# skips the padding so num_input_tokens == num_scheduled_tokens.
|
||||
enforce_eager = true
|
||||
|
||||
[inference.parallel]
|
||||
dp = 1
|
||||
tp = 1
|
||||
|
||||
[wandb]
|
||||
project = "multimodal-renderer"
|
||||
name = "feat-renderer-20step-r8-i2-t2-onpolicy"
|
||||
tags = ["qwen3vl-4b", "color-codeword", "renderer", "feat-branch", "mm-kwargs-generic", "on-policy"]
|
||||
@@ -13,10 +13,10 @@ language_model_attr = "model.language_model"
|
||||
batch_size = 16
|
||||
rollouts_per_example = 2
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 32
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 32
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "color-codeword"
|
||||
args = { images_per_turn = 1, max_turns = 2, num_examples = 100, seed = 42 }
|
||||
|
||||
|
||||
@@ -48,10 +48,10 @@ max_inflight_activations = 5
|
||||
batch_size = 128
|
||||
rollouts_per_example = 8
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 2048
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 2048
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env"
|
||||
name = "hendrycks-math"
|
||||
args = { dataset_name = "PrimeIntellect/Hendrycks-Math", dataset_subset = "default", math_verify_max_workers = 128, math_verify_timeout = 60 }
|
||||
@@ -64,7 +64,7 @@ hard_threshold = 0.0
|
||||
interval = 10
|
||||
|
||||
[orchestrator.eval.sampling]
|
||||
max_tokens = 2048
|
||||
max_completion_tokens = 2048
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
id = "math500"
|
||||
|
||||
@@ -47,10 +47,10 @@ freq = 1
|
||||
batch_size = 512
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 4096
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 4096
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env"
|
||||
name = "hendrycks-math"
|
||||
args = { dataset_name = "PrimeIntellect/Hendrycks-Math", dataset_subset = "default", math_verify_max_workers = 128, math_verify_timeout = 60 }
|
||||
@@ -63,7 +63,7 @@ hard_threshold = 0.0
|
||||
interval = 10
|
||||
|
||||
[orchestrator.eval.sampling]
|
||||
max_tokens = 4096
|
||||
max_completion_tokens = 4096
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
id = "math500"
|
||||
|
||||
Submodule
+1
Submodule configs/private added at 74c1330008
@@ -30,13 +30,13 @@ batch_size = 512
|
||||
rollouts_per_example = 16
|
||||
oversampling_factor = 2.0
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 512
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 512
|
||||
|
||||
[orchestrator.buffer]
|
||||
online_difficulty_filtering = true
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "wiki-search"
|
||||
|
||||
[inference.model]
|
||||
|
||||
+1
Submodule deps/pydantic-config added at 94d71ecdec
+1
Submodule deps/renderers added at 8704f9d502
+1
Submodule deps/research-environments added at d141472268
+1
Submodule deps/verifiers added at 58b119fa1b
@@ -86,10 +86,12 @@ def my_custom_advantage(inputs: AdvantageInputs, **kwargs) -> AdvantageOutputs:
|
||||
```python
|
||||
@dataclass
|
||||
class AdvantageInputs:
|
||||
rewards: Float[Tensor, "num_examples rollouts_per_example"]
|
||||
completion_lengths: Int[Tensor, "num_examples rollouts_per_example"]
|
||||
# Rollouts grouped by problem: rollouts[i][j] is the j-th rollout for problem i.
|
||||
rollouts: list[list[vf.RolloutOutput]]
|
||||
```
|
||||
|
||||
Each `vf.RolloutOutput` carries the full rollout (`reward`, `trajectory`, etc.), so custom advantages can read any metadata they need (e.g. completion-token counts, turn counts, tool calls).
|
||||
|
||||
#### AdvantageOutputs
|
||||
|
||||
```python
|
||||
@@ -106,9 +108,10 @@ from prime_rl.orchestrator.advantage import AdvantageInputs, AdvantageOutputs
|
||||
|
||||
def normalized_advantage(inputs: AdvantageInputs, eps: float = 1e-8) -> AdvantageOutputs:
|
||||
"""Normalize advantages to zero mean and unit variance per example."""
|
||||
mean = inputs.rewards.mean(dim=1, keepdim=True)
|
||||
std = inputs.rewards.std(dim=1, keepdim=True)
|
||||
advantages = (inputs.rewards - mean) / (std + eps)
|
||||
rewards = torch.tensor([[r["reward"] for r in group] for group in inputs.rollouts])
|
||||
mean = rewards.mean(dim=1, keepdim=True)
|
||||
std = rewards.std(dim=1, keepdim=True)
|
||||
advantages = (rewards - mean) / (std + eps)
|
||||
return AdvantageOutputs(advantages=advantages)
|
||||
```
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ Checkpointing is non-standard due to trainer/orchestrator separation and natural
|
||||
|
||||
The default checkpoint directory is `checkpoints` and each checkpoint step will live in a step subdirectory, i.e. `checkpoints/step_{step}`.
|
||||
|
||||
Checkpointing is configured with the config key `--ckpt`. One can specify the interval (`--ckpt.interval`), whether to save checkpoints asynchronoously (`--ckpt.save-async`), how many recent step checkpoints to keep on disk (`--ckpt.keep-last`), and keep checkpoints at every N steps permanently (`--ckpt.keep-interval`). By default, we do not checkpoint to save disk space.
|
||||
Checkpointing is configured with the config key `--ckpt`. One can specify the interval (`--ckpt.interval`), whether to save checkpoints asynchronously (`--ckpt.save-async`), how many recent step checkpoints to keep on disk (`--ckpt.keep-last`), and keep checkpoints at every N steps permanently (`--ckpt.keep-interval`). By default, we do not checkpoint to save disk space.
|
||||
|
||||
## SFT
|
||||
|
||||
@@ -54,4 +54,4 @@ uv run rl \
|
||||
--orchestrator @ path/to/orch.toml \
|
||||
--max-steps 20 \
|
||||
--ckpt.resume-step 10
|
||||
```
|
||||
```
|
||||
|
||||
+1
-1
@@ -30,4 +30,4 @@ name = "Qwen/Qwen-14B"
|
||||
PRIME_MODEL__NAME=Qwen/Qwen3-4B uv run ... @ qwen8b.toml @ qwen14b.toml --model.name Qwen/Qwen3-32B
|
||||
```
|
||||
|
||||
In this example, the CLI argument `--model.name Qwen/Qwen3-32B` will take precedence and the script will use `Qwen/Qwen3-32B` as the model name. If the CLI argument wasn't set, then the second config file would take precedence and the script would use `Qwen/Qwen-14B` as the model name. If the second config file wasn't set, then the first config file would take precedence and the script would use `Qwen/Qwen3-8B` as the model name. Finally, if the first config file wasn't set, then the environment variable would take precedence and the script would use `Qwen/Qwen-4B` as the model name. If the environment variable wasn't set, then the default value would be used and the script would use `Qwen/Qwen3-0.6B` as the model name.
|
||||
In this example, the CLI argument `--model.name Qwen/Qwen3-32B` will take precedence and the script will use `Qwen/Qwen3-32B` as the model name. If the CLI argument wasn't set, then the second config file would take precedence and the script would use `Qwen/Qwen-14B` as the model name. If the second config file wasn't set, then the first config file would take precedence and the script would use `Qwen/Qwen3-8B` as the model name. Finally, if the first config file wasn't set, then the environment variable would take precedence and the script would use `Qwen/Qwen3-4B` as the model name. If the environment variable wasn't set, then the default value would be used and the script would use `Qwen/Qwen3-0.6B` as the model name.
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ For more details on multi-node deployment options, see the [deployment](deployme
|
||||
|
||||
## SFT
|
||||
|
||||
We provide a fairly straight-forward SFT trainer which is capable of fine-tuning any conversational model on multi-turn conversation with tool calling. It shares a lot of components with the RL trainer, such as the modeling code, parallelism techniques, checkpoint format, logger, etc. which ensures a seemless post-training workflow.
|
||||
We provide a fairly straight-forward SFT trainer which is capable of fine-tuning any conversational model on multi-turn conversation with tool calling. It shares a lot of components with the RL trainer, such as the modeling code, parallelism techniques, checkpoint format, logger, etc. which ensures a seamless post-training workflow.
|
||||
|
||||
To start an SFT training, you need to prepare a conversational dataset in either [prompt-completion format](https://huggingface.co/docs/trl/en/dataset_formats#prompt-completion) or raw `messages` format. If `messages` is provided, the trainer interprets the full conversation as a single sample with an empty prompt and applies role-based loss masking across the whole chat. If both `messages` and `prompt` / `completion` are present, `messages` takes precedence. Single-turn fine-tuning should be compatible with the chat templates of most models. However, to properly handle loss masking, we require that the tokenizer's chat template satisfies a prefix property: the tokenization of any conversation prefix must be a prefix of the tokenization of the full conversation. For instance, tokenizing message 1 should yield a token sequence that forms a prefix of tokenizing messages 1 and 2, which in turn should be a prefix of tokenizing messages 1, 2, 3, and so forth. An example of a chat template that *does not* satisfy this property is Qwen3's chat template, as it strips away past think sections.
|
||||
|
||||
|
||||
+3
-1
@@ -7,6 +7,7 @@
|
||||
"index",
|
||||
"entrypoints",
|
||||
"configs",
|
||||
"training_modes",
|
||||
"environments",
|
||||
"async",
|
||||
"logging",
|
||||
@@ -15,8 +16,9 @@
|
||||
"benchmarking",
|
||||
"deployment",
|
||||
"kubernetes",
|
||||
"testing-moe-at-small-scale",
|
||||
"troubleshooting"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ The eviction takes effect through two mechanisms:
|
||||
- The orchestrator checks for `evicted.txt` at the start of each iteration in its main loop
|
||||
- If found, it raises a `RuntimeError` with the eviction reason, causing the orchestrator to exit
|
||||
- This surfaces the eviction reason to the user
|
||||
- The orchestrator also self-evicts by writing `evicted.txt` if a training batch has no learning signal (all rollouts filtered out) on `MAX_EMPTY_BATCH_ATTEMPTS` (3) consecutive attempts
|
||||
|
||||
## LoRA Module Registration
|
||||
|
||||
|
||||
+4
-6
@@ -47,13 +47,11 @@ To add permanent support for a new model family, add an entry to `VLM_REGISTRY`
|
||||
|
||||
## How Multi-Turn VLM RL Training Works
|
||||
|
||||
VLM training uses the same `interleave_rollout` path as text-only models. Multi-turn trajectory steps are merged into a single training sample wherever the extension property holds.
|
||||
VLM rollouts go through the renderer-backed TITO client (`orchestrator.use_renderer = true`, the default and required for VLMs). The renderer owns the HuggingFace processor per-slot and emits multimodal tensors alongside tokens.
|
||||
|
||||
Images are handled via a `VLMImageCache` built once per batch:
|
||||
|
||||
1. **Extract**: Base64 images are decoded from trajectory step prompts into PIL images.
|
||||
2. **Preprocess**: Images are processed through the HuggingFace image processor, producing `pixel_values` and `image_grid_thw`.
|
||||
3. **Attach**: Each training sample receives the cumulative `pixel_values` up to its last merged step.
|
||||
1. **Render**: For each trajectory step, the renderer tokenizes messages and emits per-image multimodal tensors (e.g. `pixel_values`, `image_grid_thw` for Qwen3-VL) as `multi_modal_data`.
|
||||
2. **Pack**: `interleave_rollout` concatenates the per-image tensors emitted across a sample's merged step range into a single `mm_kwargs` dict on the `TrainingSample`. Per-token `mm_token_type_ids` (0=text, 1=image, 2=video) come from `renderer.mm_token_type_id_map`.
|
||||
3. **Forward**: The trainer `**`-unpacks `mm_kwargs` into the model's `forward` signature, so any VLM whose HF processor and forward agree on kwarg names works without touching the transport.
|
||||
|
||||
Each multimodal sample becomes its own micro-batch during training (no packing) since image tensor sizes vary.
|
||||
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
# On-Policy Distillation
|
||||
|
||||
On-policy distillation uses a teacher model to provide dense token-level feedback during RL training. The student generates rollouts, and the teacher's logprobs guide the student to stay close to stronger behavior while still learning from rewards.
|
||||
|
||||
For more details, see [On-Policy Distillation](https://thinkingmachines.ai/blog/on-policy-distillation/) by Thinking Machines.
|
||||
|
||||
## Quick Start
|
||||
|
||||
Add `num_teacher_gpus` to `[deployment]` and set `teacher_tau > 0`:
|
||||
|
||||
```toml
|
||||
[deployment]
|
||||
num_teacher_gpus = 2
|
||||
|
||||
[trainer.loss]
|
||||
teacher_tau = 0.5
|
||||
```
|
||||
|
||||
This automatically starts a teacher inference server using the same model as inference. To use a different teacher model:
|
||||
|
||||
```toml
|
||||
[deployment]
|
||||
num_teacher_gpus = 2
|
||||
|
||||
[teacher_inference.model]
|
||||
name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B"
|
||||
|
||||
[trainer.loss]
|
||||
teacher_tau = 0.5
|
||||
```
|
||||
|
||||
## Using an External Teacher Server
|
||||
|
||||
If the teacher is already running elsewhere:
|
||||
|
||||
```toml
|
||||
[trainer.loss]
|
||||
teacher_tau = 0.5
|
||||
|
||||
[orchestrator.teacher_model.client]
|
||||
base_url = ["http://teacher-server:8000/v1"]
|
||||
|
||||
[orchestrator.teacher_model.model]
|
||||
name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B"
|
||||
```
|
||||
|
||||
## Pure Distillation (No Verification)
|
||||
|
||||
For agentic environments where verification is expensive (code execution, tool use, multi-turn interactions), you can skip verification entirely and use only the teacher signal:
|
||||
|
||||
```toml
|
||||
[deployment]
|
||||
num_teacher_gpus = 2
|
||||
|
||||
[trainer.loss]
|
||||
teacher_tau = 1.0
|
||||
adv_tau = 0.0 # Disable reward-based learning
|
||||
|
||||
[orchestrator.verification]
|
||||
enabled = false # Skip expensive verification
|
||||
```
|
||||
|
||||
This runs pure on-policy distillation: the student learns to match the teacher without needing any reward signal.
|
||||
|
||||
## SFT Distillation ("Hard Distillation") From Teacher Rollouts
|
||||
|
||||
Use this mode when you want to train from teacher-generated completions directly (hard distillation), without teacher token-level logprobs.
|
||||
|
||||
```toml
|
||||
[trainer.loss]
|
||||
type = "sft"
|
||||
|
||||
[orchestrator]
|
||||
use_token_client = false
|
||||
|
||||
[orchestrator.teacher_rollout_model.client]
|
||||
base_url = ["https://your-openai-compatible-endpoint/v1"]
|
||||
skip_model_check = true
|
||||
|
||||
[orchestrator.teacher_rollout_model.model]
|
||||
name = "teacher-model-name"
|
||||
```
|
||||
|
||||
In this mode:
|
||||
- Rollouts are generated from `orchestrator.teacher_rollout_model`
|
||||
- The orchestrator uses text-level reconstruction with the student tokenizer
|
||||
- The RL trainer optimizes masked NLL (`trainer.loss.type = "sft"`)
|
||||
- Omit `[inference]` (no local inference server required)
|
||||
|
||||
### Image Input (VLM) Support
|
||||
|
||||
Yes, image input is supported in SFT/hard-distillation mode when the student model is multimodal (VLM).
|
||||
|
||||
- Prompts can include OpenAI-style image items in `message.content`, e.g. `{"type": "image_url", "image_url": {"url": "data:image/..."}}`
|
||||
- The orchestrator extracts and preprocesses images from trajectory prompts and attaches `pixel_values`/`image_grid_thw` to training samples
|
||||
- No teacher token IDs/logprobs are required; reconstruction still happens from messages
|
||||
|
||||
Notes:
|
||||
- This path currently expects `data:image/...` payloads in message content
|
||||
- The teacher rollout endpoint still needs to be able to handle the same multimodal prompts during generation
|
||||
|
||||
Reference configs:
|
||||
- `configs/alphabet_sort/sft_distill_hard_qwen4b_lora_prime_teacher.toml`
|
||||
- `examples/alphabet_sort/sft_distill_hard.toml`
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Default | Description |
|
||||
|-----------|---------|-------------|
|
||||
| `deployment.num_teacher_gpus` | `None` | Number of GPUs for teacher server. Auto-starts server when set. |
|
||||
| `trainer.loss.teacher_tau` | `0.0` | Distillation strength. Set `> 0` to enable. |
|
||||
| `trainer.loss.adv_tau` | `1.0` | Weight for RL advantage signal. Set `0` for pure distillation. |
|
||||
| `orchestrator.verification.enabled` | `true` | Enable/disable verification. Set to `false` for pure distillation with `adv_tau = 0`. |
|
||||
|
||||
## Monitoring
|
||||
|
||||
The `teacher_kl` metric shows the KL divergence from teacher to student. Lower values mean the student is closer to the teacher.
|
||||
@@ -0,0 +1,39 @@
|
||||
# Training Modes
|
||||
|
||||
PRIME-RL supports three training modes through our RL trainer, selected via `training_mode`:
|
||||
|
||||
- **`rl`** — reinforcement learning: student generates rollouts, no teacher
|
||||
- **`opd`** — [on-policy distillation](https://thinkingmachines.ai/blog/on-policy-distillation/): students generates rollouts, train to minimize the KL divergence between the student and teacher's logprobs for each token in the rollout
|
||||
- **`sft`** — supervised fine-tuning on teacher-generated rollouts
|
||||
|
||||
> Note: PRIME-RL also has a dedicated `sft` entrypoint for more traditional supervised fine-tuning from a HF dataset. When using the `sft` training mode on the orchestrator, teacher rollouts are generated on-the-fly and used for training.
|
||||
|
||||
The mode determines who generates rollouts, what role the teacher plays, and what must be configured.
|
||||
|
||||
| Mode | Student | Teacher |
|
||||
|---|---|---|
|
||||
| `rl` | required | forbidden |
|
||||
| `opd` | required | required (local vLLM) |
|
||||
| `sft` | required | required (any OAI-compatible endpoint) |
|
||||
|
||||
**SFT vs OPD teachers** differ in what the orchestrator asks of them. SFT only calls `/v1/chat/completions` to generate rollouts — any OpenAI-compatible endpoint works (PI inference, OpenAI, Anthropic, a local vLLM). OPD additionally needs token-level logprobs scored over the student's tokens, which today only vLLM's `/inference/v1/generate` with `prompt_logprobs` exposes — so the OPD teacher must be a vLLM server.
|
||||
|
||||
### Reference configs
|
||||
|
||||
Debug-scale configs for all three modes (and LoRA variants) live in [`configs/debug/training_modes/`](../configs/debug/training_modes/):
|
||||
|
||||
- `rl.toml` / `opd.toml` / `opd_lora.toml`
|
||||
- `sft.toml` / `sft_lora.toml` (local vLLM teacher)
|
||||
- `sft_external.toml` (PI inference teacher)
|
||||
|
||||
See [`configs/debug/training_modes/README.md`](../configs/debug/training_modes/README.md) for run commands.
|
||||
|
||||
## Parameter reference
|
||||
|
||||
| Parameter | Default | Description |
|
||||
|-----------|---------|-------------|
|
||||
| `training_mode` | `"rl"` | One of `rl`, `opd`, `sft`. Propagates to `orchestrator.training_mode` and (for sft) `trainer.loss.type`. |
|
||||
| `deployment.num_teacher_gpus` | `None` | Number of GPUs for the teacher vLLM server. Auto-starts when set. OPD only. |
|
||||
| `trainer.loss.teacher_tau` | `0.0` | Distillation strength. Must be `> 0` in OPD. |
|
||||
| `trainer.loss.adv_tau` | `1.0` | Weight for the RL advantage signal. Set `0` for pure distillation. |
|
||||
| `orchestrator.verification.enabled` | `true` | Enable/disable verification. Set to `false` for pure distillation with `adv_tau = 0`. |
|
||||
@@ -39,7 +39,7 @@ Interleaving enforces a strict invariant:
|
||||
|
||||
> The prompt at turn $t$ must be the exact concatenation of prior messages exactly as the LLM originally generated them
|
||||
|
||||
We call this the "exact prefix" invariant. For example, at turn 2, the LLM should see U1,A1,U2 as the prompt, where U1 exactly matches the user message in turn 1 and A1 exactly matches the produced assistant message in turn 1. Any violation to this invariant will result in downstream problems when computing the importance sampling ratio during training.
|
||||
We call this the "exact prefix" invariant. For example, at turn 2, the LLM should see U1,A1,U2 as the prompt, where U1 exactly matches the user message in turn 1 and A1 exactly matches the produced assistant message in turn 1. Any violation of this invariant will result in downstream problems when computing the importance sampling ratio during training.
|
||||
|
||||
For example, assume that at turn 2 the prompt is U1,A1',U2 where A1' varies from A1. In this scenario it is not clear whether to add A1 or A1' to the interleaved rollout:
|
||||
- If we add A1', the logprobs from turn 1 might be off because the inference LLM produced A1 but the trainer LLM is computing logprobs for A1'
|
||||
|
||||
@@ -12,7 +12,7 @@ ulimit -n 32000
|
||||
|
||||
Assuming this is happening on the RL or SFT trainer, you can try the following:
|
||||
- Use full activation checkpointing (`--model.ac`)
|
||||
- Reduce the the micro batch size (`--data.micro-batch-size`) and sequence length (`--data.seq-len`)
|
||||
- Reduce the micro batch size (`--data.micro-batch-size`) and sequence length (`--data.seq-len`)
|
||||
- (*Experimental*) Use context parallelism with `--model.cp`
|
||||
|
||||
> I cannot pass my TOML config file
|
||||
|
||||
@@ -47,31 +47,31 @@ weight_decay = 0.01
|
||||
batch_size = 2048
|
||||
oversampling_factor = 2
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "mini-swe-agent-plus"
|
||||
name = "swe"
|
||||
ratio = 0.3
|
||||
args = { max_turns = 200, cpu_cores = 2, memory_gb = 4, disk_size_gb = 4, labels = ["mini-swe-agent-plus"], total_timeout_minutes = 720, sandbox_client_max_workers = 256, max_command_timeouts = 3, sandbox_command_timeout = 30}
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "deepdive"
|
||||
name = "deepdive"
|
||||
ratio = 0.2
|
||||
args = { finish_with_tool = true, open_max_workers = 128, cache_dir = "/tmp/i3_deepdive_cache_train" }
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env"
|
||||
name = "math"
|
||||
ratio = 0.3
|
||||
args = { min_avg_reward = 0.0, max_avg_reward = 0.874}
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "logic-env"
|
||||
name = "logic"
|
||||
ratio = 0.2
|
||||
args = { min_avg_reward = 0.0, max_avg_reward = 0.874 }
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "code-env"
|
||||
name = "code"
|
||||
ratio = 0.2
|
||||
@@ -94,4 +94,8 @@ args = { dataset_name="PrimeIntellect/SWE-Bench-Verified-Quick", max_turns = 200
|
||||
id = "aime2025"
|
||||
|
||||
[inference.parallel]
|
||||
tp = 8
|
||||
tp = 8
|
||||
|
||||
# Model not in MODEL_RENDERER_MAP — opt into DefaultRenderer (apply_chat_template).
|
||||
[orchestrator.renderer]
|
||||
name = "default"
|
||||
|
||||
@@ -28,10 +28,10 @@ lr = 1e-5
|
||||
batch_size = 512
|
||||
rollouts_per_example = 8
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 768
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 768
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "primeintellect/alphabet-sort"
|
||||
name = "alphabet-sort"
|
||||
args = { min_turns = 3, max_turns = 5, power_per_turn = false }
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
max_steps = 24
|
||||
seq_len = 2048
|
||||
|
||||
[deployment]
|
||||
type = "single_node"
|
||||
gpus_per_node = 2
|
||||
num_train_gpus = 2
|
||||
num_infer_gpus = 0
|
||||
|
||||
[model]
|
||||
name = "Qwen/Qwen3-4B-Instruct-2507"
|
||||
|
||||
[wandb]
|
||||
project = "alphabet-sort-sft-distill"
|
||||
name = "qwen3-4b-hard-distill"
|
||||
|
||||
[ckpt]
|
||||
|
||||
[trainer.optim]
|
||||
lr = 1e-5
|
||||
|
||||
[trainer.loss]
|
||||
type = "sft"
|
||||
|
||||
[trainer.model.lora]
|
||||
rank = 16
|
||||
alpha = 32
|
||||
|
||||
[trainer.ckpt.weights]
|
||||
save_adapter_separately = true
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 256
|
||||
rollouts_per_example = 4
|
||||
use_token_client = false
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 512
|
||||
temperature = 0.7
|
||||
|
||||
[orchestrator.teacher_rollout_model.client]
|
||||
base_url = ["https://api.pinference.ai/api/v1"]
|
||||
api_key_var = "PRIME_API_KEY"
|
||||
|
||||
[orchestrator.teacher_rollout_model.model]
|
||||
name = "qwen/qwen3-235b-a22b-instruct-2507"
|
||||
|
||||
[[orchestrator.env]]
|
||||
id = "primeintellect/alphabet-sort"
|
||||
name = "alphabet-sort"
|
||||
args = { min_turns = 2, max_turns = 2, min_names_per_turn = 1, max_names_per_turn = 3, similarity_power = 4, power_per_turn = false }
|
||||
@@ -6,9 +6,6 @@ level = "debug"
|
||||
[wandb]
|
||||
project = "glm5-pd-disag"
|
||||
|
||||
[model]
|
||||
name = "zai-org/GLM-5"
|
||||
|
||||
[weight_broadcast]
|
||||
type = "nccl"
|
||||
port = 29502
|
||||
@@ -38,6 +35,7 @@ interval = 100
|
||||
dist_timeout_seconds = 7200
|
||||
|
||||
[trainer.model]
|
||||
name = "zai-org/GLM-5"
|
||||
impl = "custom"
|
||||
attn = "flash_attention_2" # dsa is skipping flash attn anyway
|
||||
fused_lm_head_token_chunk_size = 2048
|
||||
@@ -68,6 +66,9 @@ rollouts_per_example = 16
|
||||
oversampling_factor = 3
|
||||
max_off_policy_steps = 16
|
||||
|
||||
[orchestrator.student.model]
|
||||
name = "zai-org/GLM-5-FP8"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 20
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
max_steps = 5000
|
||||
seq_len = 8192
|
||||
|
||||
[wandb]
|
||||
project = "hendrycks-sanity"
|
||||
@@ -15,8 +14,9 @@ name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B"
|
||||
[orchestrator]
|
||||
batch_size = 512
|
||||
rollouts_per_example = 8
|
||||
seq_len = 8192
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env" # included in lock file
|
||||
args = { dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B", dataset_subset = "default" }
|
||||
name = "hendrycks-math"
|
||||
@@ -30,8 +30,12 @@ name = "aime2024"
|
||||
rollouts_per_example = 32
|
||||
|
||||
[trainer.model]
|
||||
name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B"
|
||||
seq_len = 16384
|
||||
|
||||
[inference.model]
|
||||
max_model_len = 8192
|
||||
max_model_len = 8192
|
||||
|
||||
# Model not in MODEL_RENDERER_MAP — opt into DefaultRenderer (apply_chat_template).
|
||||
[orchestrator.renderer]
|
||||
name = "default"
|
||||
reasoning_parser = "think"
|
||||
|
||||
@@ -49,7 +49,7 @@ oversampling_factor = 2
|
||||
max_off_policy_steps = 16
|
||||
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "mini-swe-agent-plus"
|
||||
name = "swe"
|
||||
args = { max_turns = 200, cpu_cores = 2, memory_gb = 4, disk_size_gb = 4, labels = ["mini-swe-agent-plus"], total_timeout_minutes = 720, sandbox_client_max_workers = 256, max_command_timeouts = 3, sandbox_command_timeout = 30}
|
||||
@@ -68,4 +68,8 @@ hard_threshold = 0.0
|
||||
seed = 42
|
||||
|
||||
[inference.parallel]
|
||||
tp = 8
|
||||
tp = 8
|
||||
|
||||
# PrimeIntellect/MiniMax-M2.5-bf16 — template-identical to MiniMaxAI/MiniMax-M2.5 (mapped).
|
||||
[orchestrator.renderer]
|
||||
name = "minimax-m2"
|
||||
|
||||
@@ -38,10 +38,10 @@ freq = 1
|
||||
batch_size = 512
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 2048
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 2048
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env"
|
||||
name = "hendrycks-math"
|
||||
args = { dataset_name = "PrimeIntellect/Hendrycks-Math", dataset_subset = "default", math_verify_max_workers = 128, math_verify_timeout = 60 }
|
||||
|
||||
@@ -45,10 +45,10 @@ batch_size = 512
|
||||
oversampling_factor = 2
|
||||
max_off_policy_steps = 8
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 32768
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 32768
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env"
|
||||
name = "math"
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ batch_size = 512
|
||||
oversampling_factor = 2
|
||||
max_off_policy_steps = 16
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "mini-swe-agent-plus"
|
||||
name = "swe"
|
||||
args = { max_turns = 200, cpu_cores = 2, memory_gb = 4, disk_size_gb = 4, labels = ["mini-swe-agent-plus"], total_timeout_minutes = 720, sandbox_client_max_workers = 256, max_command_timeouts = 3, sandbox_command_timeout = 30}
|
||||
|
||||
@@ -12,10 +12,10 @@ name = "reverse-text"
|
||||
batch_size = 128
|
||||
rollouts_per_example = 16
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 128
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "reverse-text"
|
||||
|
||||
[trainer.optim]
|
||||
@@ -23,4 +23,8 @@ lr = 3e-6
|
||||
|
||||
[ckpt] # Checkpoint at the end of training
|
||||
|
||||
[inference]
|
||||
[inference]
|
||||
|
||||
# Model not in MODEL_RENDERER_MAP — opt into DefaultRenderer (apply_chat_template).
|
||||
[orchestrator.renderer]
|
||||
name = "default"
|
||||
|
||||
@@ -37,13 +37,13 @@ oversampling_factor = 2.0
|
||||
[orchestrator.model.lora]
|
||||
name = "qwen3-4b-wiki-search"
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 512
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 512
|
||||
|
||||
[orchestrator.buffer]
|
||||
online_difficulty_filtering = true
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "primeintellect/wiki-search"
|
||||
|
||||
[ckpt] # Checkpoint at the end of training
|
||||
|
||||
+10
-3
@@ -18,14 +18,21 @@ name = "PrimeIntellect/Qwen3-1.7B-Wordle-SFT"
|
||||
batch_size = 1024
|
||||
rollouts_per_example = 16
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "primeintellect/wordle"
|
||||
name = "wordle"
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 1024
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 1024
|
||||
|
||||
[trainer] # Default trainer config
|
||||
|
||||
[inference.parallel]
|
||||
dp = 6
|
||||
|
||||
# Qwen3 finetune with the standard PI template patch (byte-identical to
|
||||
# PrimeIntellect/Qwen3-0.6B base); always re-emits prior <think> blocks.
|
||||
# Match that with the qwen3 renderer's preserve_all_thinking.
|
||||
[orchestrator.renderer]
|
||||
name = "qwen3"
|
||||
preserve_all_thinking = true
|
||||
|
||||
@@ -9,7 +9,7 @@ name = "PrimeIntellect/Qwen3-1.7B"
|
||||
name = "willcb/V3-wordle"
|
||||
seq_len = 1024
|
||||
batch_size = 64
|
||||
micro-batch-size = 1
|
||||
micro_batch_size = 1
|
||||
|
||||
[optim]
|
||||
lr = 1e-5
|
||||
@@ -207,7 +207,7 @@ spec:
|
||||
timeoutSeconds: {{ .Values.inference.probes.startup.timeoutSeconds }}
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
path: /liveness
|
||||
port: {{ .Values.inference.service.port }}
|
||||
periodSeconds: {{ .Values.inference.probes.liveness.periodSeconds }}
|
||||
failureThreshold: {{ .Values.inference.probes.liveness.failureThreshold }}
|
||||
|
||||
@@ -75,7 +75,7 @@ inference:
|
||||
|
||||
runtimeClassName: nvidia
|
||||
|
||||
# Health probes for inference server (requires /health endpoint)
|
||||
# Health probes for inference server (/health for startup/readiness, /liveness for engine liveness)
|
||||
probes:
|
||||
enabled: false
|
||||
# Startup probe: allows long model loading time (up to 45 min by default)
|
||||
@@ -86,7 +86,7 @@ inference:
|
||||
liveness:
|
||||
periodSeconds: 10
|
||||
failureThreshold: 3
|
||||
timeoutSeconds: 60
|
||||
timeoutSeconds: 10
|
||||
readiness:
|
||||
periodSeconds: 5
|
||||
failureThreshold: 2
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# prime-rl-configs
|
||||
|
||||
Slim config schema for [`prime-rl`](https://github.com/PrimeIntellect-ai/prime-rl), with no GPU or ML deps.
|
||||
|
||||
`pip install prime-rl-configs` gives you `prime_rl.configs.*` (RL/SFT/inference/orchestrator/trainer/env-server schemas) without pulling in `torch`, `vllm`, `transformers`, `wandb`, etc. The full training stack lives in `prime-rl`, which depends on this package.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
pip install git+https://github.com/PrimeIntellect-ai/prime-rl.git#subdirectory=packages/prime-rl-configs
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
The pip *distribution name* (`prime-rl-configs`) and the *import path* (`prime_rl.configs.*`) are different on purpose: this package contributes submodules to the shared `prime_rl` namespace.
|
||||
|
||||
```python
|
||||
from pydantic_config import cli
|
||||
from prime_rl.configs.rl import RLConfig
|
||||
|
||||
config = cli(RLConfig, args=["@", "path/to/rl.toml"])
|
||||
```
|
||||
|
||||
Other config classes live alongside `RLConfig` under `prime_rl.configs.*` (`sft`, `inference`, `orchestrator`, `trainer`, `env_server`).
|
||||
|
||||
`import prime_rl` on its own succeeds but is empty — it's a [PEP 420](https://peps.python.org/pep-0420/) namespace package with no top-level attributes. Always import a submodule.
|
||||
@@ -0,0 +1,28 @@
|
||||
[project]
|
||||
name = "prime-rl-configs"
|
||||
version = "0.4.0"
|
||||
description = "Slim config schema for prime-rl (no GPU/ML deps)."
|
||||
readme = "README.md"
|
||||
requires-python = "~=3.12.0"
|
||||
dependencies = [
|
||||
"pydantic>=1.10.13",
|
||||
"prime-pydantic-config>=0.3.0.dev82",
|
||||
# OrchestratorConfig validates renderer.name='auto' against
|
||||
# renderers.base.MODEL_RENDERER_MAP. Renderers itself is light; its only
|
||||
# weighty transitive (transformers) is lazy-imported via the validator,
|
||||
# so plain `from prime_rl.configs.orchestrator import OrchestratorConfig`
|
||||
# still doesn't pull it into sys.modules.
|
||||
"renderers>=0.1.8.dev4",
|
||||
"tomli>=2.2.1",
|
||||
"tomli-w>=1.2.0",
|
||||
]
|
||||
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["src/prime_rl"]
|
||||
|
||||
[tool.hatch.metadata]
|
||||
allow-direct-references = true
|
||||
@@ -0,0 +1,25 @@
|
||||
from pathlib import Path
|
||||
|
||||
from pydantic import model_validator
|
||||
|
||||
from prime_rl.configs.orchestrator import EnvConfig
|
||||
from prime_rl.configs.shared import LogConfig
|
||||
from prime_rl.utils.config import BaseConfig
|
||||
|
||||
|
||||
class EnvServerConfig(BaseConfig):
|
||||
env: EnvConfig = EnvConfig()
|
||||
|
||||
log: LogConfig = LogConfig()
|
||||
|
||||
env_install_prerelease: bool = False
|
||||
"""Allow pre-release versions when installing environments. Passes ``--prerelease`` to ``prime env install``."""
|
||||
|
||||
output_dir: Path = Path("outputs")
|
||||
"""Directory to write outputs to — logs and any generated artifacts are written as subdirectories."""
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_num_workers(self):
|
||||
if self.env.num_workers == "auto":
|
||||
self.env.num_workers = 1
|
||||
return self
|
||||
@@ -0,0 +1,457 @@
|
||||
from argparse import Namespace
|
||||
from pathlib import Path
|
||||
from typing import Annotated, Any, Literal, TypeAlias
|
||||
|
||||
from pydantic import Field, model_validator
|
||||
from pydantic_config import BaseConfig
|
||||
|
||||
from prime_rl.configs.shared import BaseModelConfig, SlurmConfig
|
||||
from prime_rl.utils.config import find_package_resource, rgetattr, rsetattr
|
||||
from prime_rl.utils.parsers import resolve_reasoning_parser, resolve_tool_call_parser
|
||||
|
||||
# TODO: Set thinking/ solution budget
|
||||
|
||||
|
||||
class ServerConfig(BaseConfig):
|
||||
host: str | None = None
|
||||
"""Host to bind to."""
|
||||
|
||||
port: int = 8000
|
||||
"""Port to bind to."""
|
||||
|
||||
liveness_timeout_seconds: float = Field(30.0, gt=0)
|
||||
"""Timeout in seconds for the ``/liveness`` endpoint's internal vLLM worker RPC. With Kubernetes liveness probes, keep the probe ``timeoutSeconds`` at least this high."""
|
||||
|
||||
|
||||
class ParallelConfig(BaseConfig):
|
||||
tp: int = 1
|
||||
"""Tensor parallel size. Forwarded to vLLM as ``--tensor-parallel-size``."""
|
||||
|
||||
dp: int = Field(1, ge=1)
|
||||
"""Data parallel size. Forwarded to vLLM as ``--data-parallel-size``."""
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"tp={self.tp} dp={self.dp}"
|
||||
|
||||
|
||||
class ModelConfig(BaseModelConfig):
|
||||
"""Configures the inference model. Most arguments are passed directly to the vLLM LLM class (https://docs.vllm.ai/en/latest/api/vllm.LLM.html).
|
||||
|
||||
Parser fields (``tool_call_parser``, ``reasoning_parser``) default to ``"auto"``,
|
||||
which resolves to a concrete parser name at validation time from the model name.
|
||||
Set to ``None`` to disable.
|
||||
"""
|
||||
|
||||
dtype: Literal["auto", "float16", "bfloat16", "float32"] = "auto"
|
||||
"""dtype for model weights and activations. ``auto`` uses FP16 for FP32/FP16 models and BF16 for BF16 models. Forwarded as ``--dtype``."""
|
||||
|
||||
max_model_len: int | None = None
|
||||
"""Maximum model context length. If None, uses the model config's value. Forwarded as ``--max-model-len``."""
|
||||
|
||||
enforce_eager: bool = False
|
||||
"""Enforce eager mode. When False, PyTorch eager and cuda graphs run hybrid for maximum performance. Forwarded as ``--enforce-eager``."""
|
||||
|
||||
trust_remote_code: bool = False
|
||||
"""Trust remote code. Forwarded to vLLM engine init."""
|
||||
|
||||
chat_template: str | None = None
|
||||
"""Chat template — a Jinja2 template string or path to a template file. Forwarded as ``--chat-template``. If None, uses the model's default."""
|
||||
|
||||
tool_call_parser: str | None = "auto"
|
||||
"""Tool-call parser. Forwarded as ``--tool-call-parser``. Set to ``"auto"`` (default) to detect from the model name, or ``None`` to disable."""
|
||||
|
||||
reasoning_parser: str | None = "auto"
|
||||
"""Parser for extracting reasoning content from model outputs. Forwarded as ``--reasoning-parser``. Set to ``"auto"`` (default) to detect from the model name, or ``None`` to disable."""
|
||||
|
||||
rope_scaling: dict[str, Any] | str | None = None
|
||||
"""RoPE scaling configuration as a dict (e.g. ``{rope_type="yarn", factor=4.0, original_max_position_embeddings=32768}``). Forwarded as ``--rope-scaling``."""
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_resolve_parsers(self):
|
||||
"""Resolve ``"auto"`` parser values to concrete parser names from the model name.
|
||||
|
||||
Runs after ``RLConfig.auto_setup_shared_configs`` (mode=before) has
|
||||
propagated the shared ``[model] name`` into ``inference.model``, so the
|
||||
name is set even when only the shared block specifies it.
|
||||
"""
|
||||
if self.tool_call_parser == "auto":
|
||||
self.tool_call_parser = resolve_tool_call_parser(self.name)
|
||||
if self.reasoning_parser == "auto":
|
||||
self.reasoning_parser = resolve_reasoning_parser(self.name)
|
||||
return self
|
||||
|
||||
|
||||
class WeightBroadcastConfig(BaseConfig):
|
||||
type: Literal["nccl", "filesystem"] = "filesystem"
|
||||
"""Weight broadcast transport."""
|
||||
|
||||
|
||||
class KVCacheOffloadConfig(BaseConfig):
|
||||
cpu_bytes: int = Field(1_000_000_000, gt=0)
|
||||
"""CPU bytes available for KV cache offloading per worker."""
|
||||
|
||||
|
||||
# Valid vLLM max_lora_rank values (from vllm/config/lora.py)
|
||||
# TODO: on newer vLLM, can import via `get_args(vllm.config.lora.MaxLoRARanks)`
|
||||
VALID_VLLM_LORA_RANKS = (8, 16, 32, 64, 128, 256, 320, 512)
|
||||
|
||||
# vLLM all2all backend options for expert-parallel deployments.
|
||||
All2AllBackend = Literal[
|
||||
"allgather_reducescatter",
|
||||
"deepep_high_throughput",
|
||||
"deepep_low_latency",
|
||||
"flashinfer_nvlink_one_sided",
|
||||
"flashinfer_nvlink_two_sided",
|
||||
]
|
||||
|
||||
|
||||
class BaseInferenceDeploymentConfig(BaseConfig):
|
||||
gpus_per_node: int = 8
|
||||
"""GPUs per node."""
|
||||
|
||||
|
||||
class SingleNodeInferenceDeploymentConfig(BaseInferenceDeploymentConfig):
|
||||
type: Literal["single_node"] = "single_node"
|
||||
|
||||
|
||||
# Multi-node inference: each node runs an independent vLLM replica.
|
||||
class MultiNodeInferenceDeploymentConfig(BaseInferenceDeploymentConfig):
|
||||
type: Literal["multi_node"] = "multi_node"
|
||||
|
||||
num_nodes: int = Field(2, ge=1)
|
||||
"""Inference nodes."""
|
||||
|
||||
router_port: int = 8000
|
||||
"""Port for the vllm-router."""
|
||||
|
||||
backend_port: int = 8100
|
||||
"""Port for vLLM backend instances."""
|
||||
|
||||
router_policy: str = "consistent_hash"
|
||||
"""vllm-router routing policy (e.g. ``consistent_hash``, ``round_robin``)."""
|
||||
|
||||
|
||||
# Disaggregated prefill/decode inference. Each replica is split into separate
|
||||
# prefill and decode node groups. Requires NIXL for KV transfer and a vllm-router
|
||||
# for request routing. Multi-replica: set ``num_prefill_replicas`` /
|
||||
# ``num_decode_replicas`` to run multiple independent vLLM instances within the
|
||||
# prefill / decode node groups. E.g. ``num_prefill_nodes=4, num_prefill_replicas=2``
|
||||
# creates two prefill vLLM instances each spanning 2 nodes (EP16 with 8 GPUs/node).
|
||||
class DisaggregatedInferenceDeploymentConfig(BaseInferenceDeploymentConfig):
|
||||
type: Literal["disaggregated"] = "disaggregated"
|
||||
|
||||
num_prefill_nodes: int = Field(1, ge=1)
|
||||
"""Total prefill nodes."""
|
||||
|
||||
num_decode_nodes: int = Field(1, ge=1)
|
||||
"""Total decode nodes."""
|
||||
|
||||
num_prefill_replicas: int = Field(1, ge=1)
|
||||
"""Independent prefill vLLM instances. Must evenly divide ``num_prefill_nodes``."""
|
||||
|
||||
num_decode_replicas: int = Field(1, ge=1)
|
||||
"""Independent decode vLLM instances. Must evenly divide ``num_decode_nodes``."""
|
||||
|
||||
router_port: int = 8000
|
||||
"""Port for the vllm-router on each replica."""
|
||||
|
||||
prefill_port: int = 8100
|
||||
"""Port for prefill vLLM instances."""
|
||||
|
||||
decode_port: int = 8200
|
||||
"""Port for decode vLLM instances."""
|
||||
|
||||
router_policy: str = "consistent_hash"
|
||||
"""vllm-router routing policy (e.g. ``consistent_hash``, ``round_robin``)."""
|
||||
|
||||
prefill_env_overrides: dict[str, str] = {}
|
||||
"""Extra environment variables exported only on prefill nodes."""
|
||||
|
||||
decode_env_overrides: dict[str, str] = {}
|
||||
"""Extra environment variables exported only on decode nodes."""
|
||||
|
||||
@property
|
||||
def num_nodes(self) -> int:
|
||||
return self.num_prefill_nodes + self.num_decode_nodes
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_replicas_divide_nodes(self):
|
||||
if self.num_prefill_nodes % self.num_prefill_replicas != 0:
|
||||
raise ValueError(
|
||||
f"num_prefill_replicas ({self.num_prefill_replicas}) must evenly divide "
|
||||
f"num_prefill_nodes ({self.num_prefill_nodes})"
|
||||
)
|
||||
if self.num_decode_nodes % self.num_decode_replicas != 0:
|
||||
raise ValueError(
|
||||
f"num_decode_replicas ({self.num_decode_replicas}) must evenly divide "
|
||||
f"num_decode_nodes ({self.num_decode_nodes})"
|
||||
)
|
||||
return self
|
||||
|
||||
|
||||
InferenceDeploymentConfig: TypeAlias = Annotated[
|
||||
SingleNodeInferenceDeploymentConfig | MultiNodeInferenceDeploymentConfig | DisaggregatedInferenceDeploymentConfig,
|
||||
Field(discriminator="type"),
|
||||
]
|
||||
|
||||
|
||||
class InferenceExperimentalConfig(BaseConfig):
|
||||
pass
|
||||
|
||||
|
||||
class InferenceConfig(BaseConfig):
|
||||
server: ServerConfig = ServerConfig()
|
||||
|
||||
model: ModelConfig = Field(default_factory=ModelConfig)
|
||||
|
||||
parallel: ParallelConfig = ParallelConfig()
|
||||
"""Multi-node and multi-GPU parallelism (TP, DP, PP)."""
|
||||
|
||||
enable_lora: bool = False
|
||||
"""Enable LoRA. Forwarded as ``--enable-lora``."""
|
||||
|
||||
max_loras: int = 8
|
||||
"""Maximum number of LoRAs. Forwarded as ``--max-loras``."""
|
||||
|
||||
# TODO: The default value is very high because our areal impl for lora isn't ideal
|
||||
# We add a lora with the same name instead of changing weights inplace
|
||||
# Because we dont cancel requests that are past max_async, these requests could be using a LoRA that gets unloaded which will crash the inference server
|
||||
max_cpu_loras: int = 100
|
||||
"""Maximum number of LoRAs on CPU. Forwarded as ``--max-cpu-loras``."""
|
||||
|
||||
max_lora_rank: int | None = None
|
||||
"""Maximum LoRA rank. Forwarded as ``--max-lora-rank``."""
|
||||
|
||||
lora_target_modules: list[str] | None = None
|
||||
"""LoRA target modules. Forwarded as ``--lora-target-modules``."""
|
||||
|
||||
enable_prefix_caching: bool | None = None
|
||||
"""Enable prefix caching. Forwarded as ``--enable-prefix-caching``."""
|
||||
|
||||
gpu_memory_utilization: float = 0.9
|
||||
"""GPU memory utilization. Forwarded as ``--gpu-memory-utilization``."""
|
||||
|
||||
api_server_count: int = Field(1, ge=0)
|
||||
"""API servers to run. Forwarded as ``--api-server-count``. Set to 0 for headless mode."""
|
||||
|
||||
data_parallel_size_local: int | None = Field(None, ge=1)
|
||||
"""Data parallel replicas to run on this node. Forwarded as ``--data-parallel-size-local``."""
|
||||
|
||||
data_parallel_rpc_port: int = Field(13345, ge=1, le=65535)
|
||||
"""RPC port for data parallel communication. Forwarded as ``--data-parallel-rpc-port``."""
|
||||
|
||||
seed: int = 0
|
||||
"""Seed the inference components. Forwarded as ``--seed``."""
|
||||
|
||||
enable_expert_parallel: bool = False
|
||||
"""Enable expert parallelism for MoE models. Forwarded as ``--enable-expert-parallel``."""
|
||||
|
||||
all2all_backend: All2AllBackend = "allgather_reducescatter"
|
||||
"""All-to-all backend for expert-parallel communication. Forwarded as ``--all2all-backend``."""
|
||||
|
||||
enable_eplb: bool = False
|
||||
"""Enable expert parallel load balancer (EPLB). Forwarded as ``--enable-eplb``."""
|
||||
|
||||
enable_dbo: bool = False
|
||||
"""Enable dual batch overlap (DBO). Forwarded as ``--enable-dbo``."""
|
||||
|
||||
use_deep_gemm: bool = False
|
||||
"""Force DeepGEMM FP8 kernels via ``VLLM_USE_DEEP_GEMM=1``. Only works with per-tensor FP8 quantization (e.g. GLM-5-FP8)."""
|
||||
|
||||
weight_broadcast: WeightBroadcastConfig = WeightBroadcastConfig()
|
||||
|
||||
kv_cache_offload: KVCacheOffloadConfig | None = None
|
||||
"""CPU KV cache offload for inference workers. Standard inference uses vLLM's ``OffloadingConnector``. Disaggregated P/D deployments combine it with NIXL through ``MultiConnector`` in the SLURM launcher."""
|
||||
|
||||
enable_return_routed_experts: bool = False
|
||||
"""Return routed experts in responses. Forwarded as ``--enable-return-routed-experts``."""
|
||||
|
||||
enable_fp32_lm_head: bool = False
|
||||
"""Run the lm_head projection in fp32 via a native bf16×bf16 → fp32 GEMM (``torch.mm`` with ``out_dtype=torch.float32``). Stabilizes logprob precision under FP8/bf16 inference, matching SGLang's ``--enable-fp32-lm-head``. Implemented as a monkey-patch over vLLM's LogitsProcessor, activated by setting ``additional_config["fp32_lm_head"] = True`` on the vLLM config."""
|
||||
|
||||
vllm_extra: dict[str, Any] = {}
|
||||
"""Extra arguments forwarded to vLLM. Applied as attributes on the vLLM namespace after config translation."""
|
||||
|
||||
# Launcher-only fields
|
||||
|
||||
deployment: InferenceDeploymentConfig = SingleNodeInferenceDeploymentConfig()
|
||||
|
||||
slurm: SlurmConfig | None = None
|
||||
"""SLURM configuration. When set, the run is submitted as a SLURM job instead of running locally."""
|
||||
|
||||
output_dir: Path = Path("outputs")
|
||||
"""Directory for SLURM logs and generated scripts."""
|
||||
|
||||
dry_run: bool = False
|
||||
"""Only validate and dump resolved configs, then exit early."""
|
||||
|
||||
experimental: InferenceExperimentalConfig = InferenceExperimentalConfig()
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_multi_node_requires_slurm(self):
|
||||
if self.deployment.type == "multi_node" and self.slurm is None:
|
||||
raise ValueError("Must use SLURM for multi-node deployment.")
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_kv_cache_offload(self):
|
||||
if self.kv_cache_offload is not None:
|
||||
if self.enable_prefix_caching is False:
|
||||
raise ValueError("KV cache offloading requires inference.enable_prefix_caching to be true.")
|
||||
if "enable_prefix_caching" not in self.model_fields_set:
|
||||
self.enable_prefix_caching = True
|
||||
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_disaggregated(self):
|
||||
"""Auto-configure inference for disaggregated P/D: enable EP and compute DP."""
|
||||
if self.deployment.type == "disaggregated":
|
||||
if "enable_expert_parallel" not in self.model_fields_set:
|
||||
self.enable_expert_parallel = True
|
||||
if "enable_eplb" not in self.model_fields_set:
|
||||
self.enable_eplb = False
|
||||
gpus_per_node = self.deployment.gpus_per_node
|
||||
tp = self.parallel.tp
|
||||
dp_per_node = gpus_per_node // tp
|
||||
if self.data_parallel_size_local is None:
|
||||
self.data_parallel_size_local = dp_per_node
|
||||
if self.parallel.dp == 1:
|
||||
self.parallel.dp = dp_per_node
|
||||
if self.api_server_count == 1:
|
||||
self.api_server_count = dp_per_node
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_slurm_template(self):
|
||||
if self.slurm is not None and self.slurm.template_path is None:
|
||||
templates_dir = find_package_resource("templates")
|
||||
if templates_dir is not None:
|
||||
self.slurm.template_path = templates_dir / "inference.sbatch.j2"
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_max_lora_rank(self):
|
||||
"""Auto-setup max_lora_rank by rounding up to the nearest valid vLLM value.
|
||||
|
||||
vLLM only accepts specific values for max_lora_rank: (1, 8, 16, 32, 64, 128, 256, 320, 512).
|
||||
This validator ensures that any configured rank is rounded up to the minimum valid value
|
||||
that can serve adapters of the requested rank.
|
||||
"""
|
||||
if self.max_lora_rank is not None:
|
||||
original_rank = self.max_lora_rank
|
||||
for valid_rank in VALID_VLLM_LORA_RANKS:
|
||||
if valid_rank >= self.max_lora_rank:
|
||||
self.max_lora_rank = valid_rank
|
||||
break
|
||||
else:
|
||||
raise ValueError(f"max_lora_rank={original_rank} exceeds vLLM maximum of {VALID_VLLM_LORA_RANKS[-1]}")
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_api_server_count(self):
|
||||
"""
|
||||
Ensures that we have at least as many API servers as data parallel
|
||||
size. Unless LoRA is enabled, in which case only one API server is
|
||||
supported (vLLM limitation).
|
||||
"""
|
||||
if self.vllm_extra.get("headless", False):
|
||||
self.api_server_count = 0
|
||||
return self
|
||||
|
||||
if "api_server_count" not in self.model_fields_set:
|
||||
min_api_server_count = self.data_parallel_size_local or self.parallel.dp
|
||||
if self.api_server_count < min_api_server_count:
|
||||
self.api_server_count = min_api_server_count
|
||||
|
||||
if self.enable_lora:
|
||||
self.api_server_count = 1 # LoRA requires only one API server
|
||||
return self
|
||||
|
||||
def to_vllm(self) -> Namespace:
|
||||
"""Convert InferenceConfig to vLLM-compatible Namespace."""
|
||||
namespace = Namespace()
|
||||
to_vllm = {
|
||||
"server.host": "host",
|
||||
"server.port": "port",
|
||||
"server.liveness_timeout_seconds": "liveness_timeout_seconds",
|
||||
"model.name": "model",
|
||||
"model.dtype": "dtype",
|
||||
"model.max_model_len": "max_model_len",
|
||||
"model.enforce_eager": "enforce_eager",
|
||||
"model.trust_remote_code": "trust_remote_code",
|
||||
"model.chat_template": "chat_template",
|
||||
"model.tool_call_parser": "tool_call_parser",
|
||||
"model.reasoning_parser": "reasoning_parser",
|
||||
"model.rope_scaling": "rope_scaling",
|
||||
"parallel.tp": "tensor_parallel_size",
|
||||
"parallel.dp": "data_parallel_size",
|
||||
"data_parallel_size_local": "data_parallel_size_local",
|
||||
"data_parallel_rpc_port": "data_parallel_rpc_port",
|
||||
"enable_lora": "enable_lora",
|
||||
"enable_prefix_caching": "enable_prefix_caching",
|
||||
"max_loras": "max_loras",
|
||||
"max_cpu_loras": "max_cpu_loras",
|
||||
"max_lora_rank": "max_lora_rank",
|
||||
"lora_target_modules": "lora_target_modules",
|
||||
"gpu_memory_utilization": "gpu_memory_utilization",
|
||||
"api_server_count": "api_server_count",
|
||||
"enable_return_routed_experts": "enable_return_routed_experts",
|
||||
"enable_expert_parallel": "enable_expert_parallel",
|
||||
"all2all_backend": "all2all_backend",
|
||||
"enable_eplb": "enable_eplb",
|
||||
"enable_dbo": "enable_dbo",
|
||||
"seed": "seed",
|
||||
}
|
||||
|
||||
for config_key, vllm_key in to_vllm.items():
|
||||
value = rgetattr(self, config_key.replace("-", "_"))
|
||||
rsetattr(namespace, vllm_key, value)
|
||||
|
||||
# Set `logprobs_mode` to `processed_logprobs` by default
|
||||
rsetattr(namespace, "logprobs_mode", "processed_logprobs")
|
||||
|
||||
if self.kv_cache_offload is not None:
|
||||
rsetattr(
|
||||
namespace,
|
||||
"kv_transfer_config",
|
||||
{
|
||||
"kv_connector": "OffloadingConnector",
|
||||
"kv_role": "kv_both",
|
||||
"kv_connector_extra_config": {
|
||||
"cpu_bytes_to_use": int(self.kv_cache_offload.cpu_bytes),
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
# Pass prime-rl-specific flags through vLLM's additional_config dict;
|
||||
# workers read these via get_current_vllm_config().additional_config.
|
||||
if self.enable_fp32_lm_head:
|
||||
existing = getattr(namespace, "additional_config", None) or {}
|
||||
existing["fp32_lm_head"] = True
|
||||
rsetattr(namespace, "additional_config", existing)
|
||||
|
||||
# Remove chat_template if not set (vLLM doesn't accept None)
|
||||
if namespace.chat_template is None:
|
||||
delattr(namespace, "chat_template")
|
||||
|
||||
# Remove tool_call_parser if not set (vLLM doesn't accept None) and gate
|
||||
# `enable_auto_tool_choice` on its presence.
|
||||
if namespace.tool_call_parser is None:
|
||||
delattr(namespace, "tool_call_parser")
|
||||
namespace.enable_auto_tool_choice = hasattr(namespace, "tool_call_parser")
|
||||
|
||||
# Remove reasoning_parser if not set (vLLM doesn't accept None)
|
||||
if namespace.reasoning_parser is None:
|
||||
delattr(namespace, "reasoning_parser")
|
||||
|
||||
# Remove lora_target_modules if not set (vLLM doesn't accept None)
|
||||
if hasattr(namespace, "lora_target_modules") and namespace.lora_target_modules is None:
|
||||
delattr(namespace, "lora_target_modules")
|
||||
|
||||
# Remove rope_scaling if not set (vLLM doesn't accept None)
|
||||
if hasattr(namespace, "rope_scaling"):
|
||||
if namespace.rope_scaling is None:
|
||||
delattr(namespace, "rope_scaling")
|
||||
|
||||
return namespace
|
||||
@@ -0,0 +1,948 @@
|
||||
import math
|
||||
import warnings
|
||||
from pathlib import Path
|
||||
from typing import Annotated, Any, Literal, TypeAlias
|
||||
|
||||
from pydantic import AliasChoices, Field, model_validator
|
||||
|
||||
from prime_rl.configs.shared import (
|
||||
BaseModelConfig,
|
||||
ClientConfig,
|
||||
FileSystemTransportConfig,
|
||||
HeartbeatConfig,
|
||||
LogConfig,
|
||||
PrimeMonitorConfig,
|
||||
RendererConfig,
|
||||
TransportConfig,
|
||||
WandbWithExtrasConfig,
|
||||
)
|
||||
from prime_rl.configs.trainer import TokenizerConfig
|
||||
from prime_rl.utils.config import BaseConfig
|
||||
|
||||
|
||||
class OptimizerConfig(BaseConfig):
|
||||
lr: float = Field(1e-4, ge=0)
|
||||
"""Learning rate for this run (per-run override for multi-run training)."""
|
||||
|
||||
|
||||
class LoRAConfig(BaseConfig):
|
||||
name: str | None = None
|
||||
"""LoRA adapter name. If None, auto-generated from rank and alpha."""
|
||||
|
||||
rank: int | None = Field(None, ge=1)
|
||||
"""LoRA rank for this run. Must be ≤ trainer's max rank. If None, uses the trainer's rank."""
|
||||
|
||||
alpha: float | None = Field(None, ge=0)
|
||||
"""LoRA alpha for this run. If None, uses the trainer's alpha."""
|
||||
|
||||
|
||||
class ModelConfig(BaseModelConfig):
|
||||
lora: LoRAConfig | None = None
|
||||
"""Per-run LoRA configuration. If None, LoRA is disabled."""
|
||||
|
||||
|
||||
class TrainSamplingConfig(BaseConfig):
|
||||
temperature: float = Field(1.0, ge=0)
|
||||
"""Sampling temperature."""
|
||||
|
||||
repetition_penalty: float = Field(1.0, ge=0)
|
||||
"""Repetition penalty. Values > 1.0 discourage repetition, < 1.0 encourage it, 1.0 disables."""
|
||||
|
||||
max_completion_tokens: int | None = Field(
|
||||
None, validation_alias=AliasChoices("max_completion_tokens", "max_tokens")
|
||||
)
|
||||
"""Maximum output tokens per turn. If None, generates until max context length or EOS."""
|
||||
|
||||
min_tokens: int = Field(0, ge=0)
|
||||
"""Minimum output tokens per sequence."""
|
||||
|
||||
seed: int | None = None
|
||||
"""Random seed for sampling. If None, no seeding is used."""
|
||||
|
||||
# Strictly speaking, extra_body is not a sampling parameter, but it is the
|
||||
# easiest way to pass arbitrary extra parameters to the server via verifiers
|
||||
extra_body: dict[str, Any] = {}
|
||||
"""Extra body forwarded with each request to the inference server."""
|
||||
|
||||
def to_sampling_args(self) -> dict[str, Any]:
|
||||
"""Convert to OAI-compatible sampling args dict, omitting None values."""
|
||||
# Top-level OAI params
|
||||
args: dict[str, Any] = {
|
||||
"temperature": self.temperature,
|
||||
"top_p": 1.0,
|
||||
"logprobs": True,
|
||||
}
|
||||
if self.max_completion_tokens is not None:
|
||||
args["max_completion_tokens"] = self.max_completion_tokens
|
||||
if self.seed is not None:
|
||||
args["seed"] = self.seed
|
||||
|
||||
# vLLM extra_body params
|
||||
extra_body = dict(self.extra_body)
|
||||
if self.min_tokens > 0:
|
||||
extra_body["min_tokens"] = self.min_tokens
|
||||
if self.repetition_penalty != 1.0:
|
||||
extra_body["repetition_penalty"] = self.repetition_penalty
|
||||
if extra_body:
|
||||
args["extra_body"] = extra_body
|
||||
|
||||
return args
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def _deprecate_max_tokens(cls, data: Any) -> Any:
|
||||
if isinstance(data, dict) and "max_tokens" in data and "max_completion_tokens" not in data:
|
||||
warnings.warn(
|
||||
"'max_tokens' is deprecated, use 'max_completion_tokens' instead. "
|
||||
"Auto-translating for now, but this will be removed in a future release.",
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return data
|
||||
|
||||
|
||||
class EvalSamplingConfig(BaseConfig):
|
||||
temperature: float | None = Field(None, ge=0)
|
||||
"""Sampling temperature. None defers to the inference server default."""
|
||||
|
||||
repetition_penalty: float | None = Field(None, ge=0)
|
||||
"""Repetition penalty. None defers to the inference server default."""
|
||||
|
||||
top_p: float | None = None
|
||||
"""Nucleus sampling threshold. None defers to the inference server default."""
|
||||
|
||||
top_k: int | None = None
|
||||
"""Top-k sampling. None defers to the inference server default."""
|
||||
|
||||
min_p: float | None = Field(None, ge=0)
|
||||
"""Min-p sampling threshold. None defers to the inference server default."""
|
||||
|
||||
max_completion_tokens: int | None = Field(
|
||||
None, validation_alias=AliasChoices("max_completion_tokens", "max_tokens")
|
||||
)
|
||||
"""Maximum output tokens per turn. None defers to the inference server default."""
|
||||
|
||||
min_tokens: int | None = Field(None, ge=0)
|
||||
"""Minimum output tokens per sequence. None defers to the inference server default."""
|
||||
|
||||
reasoning_effort: Literal["minimal", "low", "medium", "high"] | None = None
|
||||
"""Reasoning effort constraint for reasoning models."""
|
||||
|
||||
seed: int | None = None
|
||||
"""Random seed for sampling. None means no seeding."""
|
||||
|
||||
extra_body: dict[str, Any] = {}
|
||||
"""Extra body parameters forwarded to the inference server."""
|
||||
|
||||
def to_sampling_args(self) -> dict[str, Any]:
|
||||
"""Convert to OAI-compatible sampling args dict. Only includes non-None fields."""
|
||||
args: dict[str, Any] = {}
|
||||
if self.temperature is not None:
|
||||
args["temperature"] = self.temperature
|
||||
if self.top_p is not None:
|
||||
args["top_p"] = self.top_p
|
||||
if self.max_completion_tokens is not None:
|
||||
args["max_completion_tokens"] = self.max_completion_tokens
|
||||
if self.reasoning_effort is not None:
|
||||
args["reasoning_effort"] = self.reasoning_effort
|
||||
if self.seed is not None:
|
||||
args["seed"] = self.seed
|
||||
|
||||
extra_body = dict(self.extra_body)
|
||||
if self.top_k is not None:
|
||||
extra_body["top_k"] = self.top_k
|
||||
if self.min_p is not None:
|
||||
extra_body["min_p"] = self.min_p
|
||||
if self.min_tokens is not None:
|
||||
extra_body["min_tokens"] = self.min_tokens
|
||||
if self.repetition_penalty is not None:
|
||||
extra_body["repetition_penalty"] = self.repetition_penalty
|
||||
if extra_body:
|
||||
args["extra_body"] = extra_body
|
||||
|
||||
return args
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def _deprecate_max_tokens(cls, data: Any) -> Any:
|
||||
if isinstance(data, dict) and "max_tokens" in data and "max_completion_tokens" not in data:
|
||||
warnings.warn(
|
||||
"'max_tokens' is deprecated, use 'max_completion_tokens' instead. "
|
||||
"Auto-translating for now, but this will be removed in a future release.",
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return data
|
||||
|
||||
|
||||
class EnvConfig(BaseConfig):
|
||||
id: str = "reverse-text"
|
||||
"""Registered verifiers environment ID (e.g. ``math-env``, ``primeintellect/math-env``). May include an ``@version`` suffix for installation."""
|
||||
|
||||
name: str | None = None
|
||||
"""Display name for this environment in logs, metrics, and buffer keys. Defaults to the ``id`` without ``@version``. Must be unique across all envs in the same group."""
|
||||
|
||||
args: dict = {}
|
||||
"""Keyword arguments forwarded to ``vf.load_environment``. See the environment's docstring for accepted args."""
|
||||
|
||||
extra_env_kwargs: dict[str, Any] = {}
|
||||
"""Extra kwargs passed to the env (e.g. ``seq_len``, ``max_total_completion_tokens``). Auto-populated by the orchestrator; user overrides are generally discouraged. The main use case is matching ``extra_env_kwargs`` when running an env in an isolated environment server."""
|
||||
|
||||
address: str | None = None
|
||||
"""ZMQ address of an external env server (e.g. ``tcp://host:5000``). When set, the orchestrator connects to this server instead of spawning one; when None, a subprocess env server is spawned automatically."""
|
||||
|
||||
num_workers: int | Literal["auto"] = "auto"
|
||||
"""Worker processes for the spawned env server. ``auto`` scales to 1 worker per 256 concurrent rollouts. Ignored when ``address`` is set."""
|
||||
|
||||
ratio: float | None = Field(None, gt=0)
|
||||
"""Sampling weight for this environment in the buffer. When None for all envs, samples uniformly across all available problems. When set, must be set on all envs — values are relative weights normalized to probabilities (e.g. [1, 1] and [0.5, 0.5] are equivalent)."""
|
||||
|
||||
max_retries: int = Field(0, ge=0)
|
||||
"""Times the env server retries a failed rollout before returning an error."""
|
||||
|
||||
max_total_completion_tokens: int = -1
|
||||
"""Maximum total completion tokens across all turns in a multi-turn rollout. ``-1`` disables. Auto-populated into ``extra_env_kwargs``."""
|
||||
|
||||
timeout: float | None = Field(None, validation_alias=AliasChoices("timeout", "timeout_seconds"))
|
||||
"""Per-rollout wall-clock timeout in seconds. None disables."""
|
||||
|
||||
@property
|
||||
def stripped_id(self) -> str:
|
||||
"""Environment ID without the @version suffix."""
|
||||
return self.id.split("@")[0]
|
||||
|
||||
@property
|
||||
def resolved_name(self) -> str:
|
||||
return self.name or self.stripped_id
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_env_name(self):
|
||||
if self.resolved_name == "all":
|
||||
raise ValueError(
|
||||
'Environment name "all" is reserved for global metric aggregation. Use a different name or id.'
|
||||
)
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def resolve_max_total_completion_tokens(self):
|
||||
self.extra_env_kwargs["max_total_completion_tokens"] = self.max_total_completion_tokens
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def resolve_timeout(self):
|
||||
if self.timeout is not None:
|
||||
self.extra_env_kwargs["timeout_seconds"] = self.timeout
|
||||
return self
|
||||
|
||||
|
||||
class TrainEnvConfig(EnvConfig):
|
||||
sampling: TrainSamplingConfig = TrainSamplingConfig()
|
||||
"""Per-env sampling overrides. Unset fields inherit from the group-level train sampling config."""
|
||||
|
||||
|
||||
class EvalEnvConfig(EnvConfig):
|
||||
sampling: EvalSamplingConfig = EvalSamplingConfig()
|
||||
"""Per-env sampling overrides. Unset fields inherit from the group-level eval sampling config."""
|
||||
|
||||
num_examples: int = -1
|
||||
"""Eval examples to sample from the dataset. ``-1`` uses all available examples."""
|
||||
|
||||
rollouts_per_example: int = Field(1, ge=1)
|
||||
"""Rollouts generated per example. Used for pass@k estimation (e.g. ``rollouts_per_example=8`` enables pass@1 through pass@8)."""
|
||||
|
||||
interval: int = Field(100, ge=1)
|
||||
"""Per-env eval interval. If unset, inherits from the group-level eval interval."""
|
||||
|
||||
|
||||
class TrainConfig(BaseConfig):
|
||||
env: list[TrainEnvConfig] = [TrainEnvConfig()]
|
||||
"""Training environments."""
|
||||
|
||||
sampling: TrainSamplingConfig = TrainSamplingConfig()
|
||||
"""Shared training sampling configuration."""
|
||||
|
||||
num_workers: int | Literal["auto"] = "auto"
|
||||
"""Default worker processes for env servers. Can be overridden per env."""
|
||||
|
||||
max_retries: int = Field(0, ge=0)
|
||||
"""Default retries for failed rollouts. Can be overridden per env."""
|
||||
|
||||
@model_validator(mode="after")
|
||||
def resolve_env_defaults(self):
|
||||
"""Resolve per-env overrides: inherit group-level sampling, num_workers, and max_retries."""
|
||||
group_sampling = self.sampling.model_dump()
|
||||
for env in self.env:
|
||||
if "sampling" not in env.model_fields_set:
|
||||
env.sampling = TrainSamplingConfig(**group_sampling)
|
||||
else:
|
||||
merged = group_sampling | env.sampling.model_dump(exclude_unset=True)
|
||||
env.sampling = TrainSamplingConfig(**merged)
|
||||
if "num_workers" not in env.model_fields_set:
|
||||
env.num_workers = self.num_workers
|
||||
if "max_retries" not in env.model_fields_set:
|
||||
env.max_retries = self.max_retries
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_unique_env_names(self):
|
||||
env_names = [env.resolved_name for env in self.env]
|
||||
duplicates = [n for n in env_names if env_names.count(n) > 1]
|
||||
if duplicates:
|
||||
raise ValueError(
|
||||
f"Duplicate training environment names: {set(duplicates)}. Each env must have a unique name."
|
||||
)
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_env_ratios(self):
|
||||
ratios = [env.ratio for env in self.env]
|
||||
if all(r is None for r in ratios):
|
||||
return self
|
||||
if any(r is None for r in ratios):
|
||||
raise ValueError("Either all envs must have a ratio or none of them. Got a mix of set and unset ratios.")
|
||||
return self
|
||||
|
||||
|
||||
class EvalConfig(BaseConfig):
|
||||
env: list[EvalEnvConfig] = [EvalEnvConfig()]
|
||||
"""Evaluation environments."""
|
||||
|
||||
sampling: EvalSamplingConfig = Field(default_factory=EvalSamplingConfig)
|
||||
"""Shared eval sampling configuration; can differ from training sampling."""
|
||||
|
||||
num_examples: int = -1
|
||||
"""Default eval examples per environment. ``-1`` uses all. Can be overridden per env."""
|
||||
|
||||
rollouts_per_example: int = Field(1, ge=1)
|
||||
"""Default rollouts per example. Can be overridden per env."""
|
||||
|
||||
num_workers: int | Literal["auto"] = "auto"
|
||||
"""Default worker processes for env servers. Can be overridden per env."""
|
||||
|
||||
max_retries: int = Field(0, ge=0)
|
||||
"""Default retries for failed rollouts. Can be overridden per env."""
|
||||
|
||||
interval: int = Field(100, ge=1)
|
||||
"""Step interval at which to evaluate the model."""
|
||||
|
||||
@model_validator(mode="after")
|
||||
def resolve_env_defaults(self):
|
||||
"""Resolve per-env overrides: inherit group-level sampling, num_workers, max_retries, num_examples, rollouts_per_example, and interval. Then resolve auto num_workers."""
|
||||
group_sampling = self.sampling.model_dump()
|
||||
for env in self.env:
|
||||
if "sampling" not in env.model_fields_set:
|
||||
env.sampling = EvalSamplingConfig(**group_sampling)
|
||||
else:
|
||||
merged = group_sampling | env.sampling.model_dump(exclude_unset=True)
|
||||
env.sampling = EvalSamplingConfig(**merged)
|
||||
if "num_examples" not in env.model_fields_set:
|
||||
env.num_examples = self.num_examples
|
||||
if "rollouts_per_example" not in env.model_fields_set:
|
||||
env.rollouts_per_example = self.rollouts_per_example
|
||||
if "interval" not in env.model_fields_set:
|
||||
env.interval = self.interval
|
||||
if "num_workers" not in env.model_fields_set:
|
||||
env.num_workers = self.num_workers
|
||||
if "max_retries" not in env.model_fields_set:
|
||||
env.max_retries = self.max_retries
|
||||
# Resolve auto num_workers now that num_examples and rollouts_per_example are set
|
||||
if env.num_workers == "auto":
|
||||
if env.num_examples == -1:
|
||||
env.num_workers = 4
|
||||
else:
|
||||
max_concurrent = env.num_examples * env.rollouts_per_example
|
||||
env.num_workers = max(1, math.ceil(max_concurrent / 256))
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_unique_env_names(self):
|
||||
env_names = [env.resolved_name for env in self.env]
|
||||
duplicates = [n for n in env_names if env_names.count(n) > 1]
|
||||
if duplicates:
|
||||
raise ValueError(
|
||||
f"Duplicate evaluation environment names: {set(duplicates)}. Each env must have a unique name."
|
||||
)
|
||||
return self
|
||||
|
||||
eval_base_model: bool = True
|
||||
"""Evaluate the base model we are training on."""
|
||||
|
||||
skip_eval_on_resume: bool = Field(
|
||||
True, validation_alias=AliasChoices("skip_eval_on_resume", "skip_eval_on_restart")
|
||||
)
|
||||
"""When resuming the orchestrator from a checkpoint, skip the (potentially redundant) online eval that would otherwise run immediately at the resumed step."""
|
||||
|
||||
cancel_inflight_rollouts_on_eval: bool = False
|
||||
"""Cancel in-flight training rollouts before starting online evals. Avoids congestion (no training + eval rollouts at the same time) at the cost of slower training steps as the pipeline has to refill after each eval."""
|
||||
|
||||
|
||||
class CheckpointConfig(BaseConfig):
|
||||
interval: int | None = Field(None, ge=1)
|
||||
"""Step interval at which to save the orchestrator checkpoint."""
|
||||
|
||||
resume_step: int | None = Field(None, ge=-1)
|
||||
"""Step to resume the orchestrator from. None starts from scratch; ``-1`` resumes from the latest checkpoint available."""
|
||||
|
||||
wait_for_weights_timeout: int | None = Field(None, ge=1)
|
||||
"""When resuming, wait up to this many seconds for the weight directory to appear. Useful when the orchestrator restarts while the trainer is still saving weights. If None, fail immediately when weights are not found."""
|
||||
|
||||
keep_last: int | None = Field(None, ge=1)
|
||||
"""Keep at most this many recent step checkpoints on disk. If None, never clean old checkpoints based on recency."""
|
||||
|
||||
keep_interval: int | None = Field(None, ge=1)
|
||||
"""Keep checkpoints at every N steps permanently (e.g. ``keep_interval=100`` keeps step 100, 200, ...). If None, no interval-based keeping."""
|
||||
|
||||
skip_progress: bool = False
|
||||
"""Skip loading the progress from checkpoint."""
|
||||
|
||||
skip_buffer: bool = False
|
||||
"""Skip loading the buffer from checkpoint."""
|
||||
|
||||
|
||||
class BufferConfig(BaseConfig):
|
||||
seed: int | None = None
|
||||
"""Random seed for the buffer. When set, sampling from the buffer is deterministic."""
|
||||
|
||||
easy_threshold: float | None = None
|
||||
"""Average-reward threshold above which a problem is classified ``easy``."""
|
||||
|
||||
hard_threshold: float | None = None
|
||||
"""Average-reward threshold below which a problem is classified ``hard``."""
|
||||
|
||||
easy_fraction: float = Field(0.0, ge=0, le=1)
|
||||
"""Fraction of easy problems to convert to ``normal`` when resuming or starting training. Only problems with difficulty ``normal`` are sampled."""
|
||||
|
||||
hard_fraction: float = Field(0.0, ge=0, le=1)
|
||||
"""Fraction of hard problems to convert to ``normal`` when resuming or starting training. Only problems with difficulty ``normal`` are sampled."""
|
||||
|
||||
online_difficulty_filtering: bool = False
|
||||
"""Filter rollouts based on difficulty. When True, rollouts with average reward 0.0 or 1.0 are not added to the buffer."""
|
||||
|
||||
hash_keys: list[str] = Field(["env_name", "prompt"], min_length=1)
|
||||
"""Keys used to compute example hashes. Used to match examples from buffer checkpoints and determine buffer resume behavior."""
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_thresholds(self):
|
||||
if self.easy_threshold is not None and self.hard_threshold is not None:
|
||||
assert self.easy_threshold > self.hard_threshold, "easy_threshold must be greater than hard_threshold."
|
||||
return self
|
||||
|
||||
|
||||
class TokensLengthPenaltyConfig(BaseConfig):
|
||||
type: Literal["tokens"] = "tokens"
|
||||
|
||||
completion_weight: float = Field(1.0, ge=0, allow_inf_nan=False)
|
||||
"""Weight on model completion tokens. Finite and non-negative."""
|
||||
|
||||
tool_response_weight: float = Field(1.0, ge=0, allow_inf_nan=False)
|
||||
"""Weight on tool-response tokens (read from the rollout's ``*_total_tool_response_tokens`` harness metric; 0 if absent). Finite and non-negative."""
|
||||
|
||||
|
||||
class TurnsLengthPenaltyConfig(BaseConfig):
|
||||
type: Literal["turns"] = "turns"
|
||||
|
||||
|
||||
LengthPenaltyConfig: TypeAlias = Annotated[
|
||||
TokensLengthPenaltyConfig | TurnsLengthPenaltyConfig,
|
||||
Field(discriminator="type"),
|
||||
]
|
||||
|
||||
|
||||
class DefaultAdvantageConfig(BaseConfig):
|
||||
type: Literal["default"] = "default"
|
||||
|
||||
length_penalty: LengthPenaltyConfig | None = None
|
||||
"""Correctness-gated length penalty. ``tokens`` shapes by weighted token cost; ``turns`` shapes by trajectory turn count; None disables shaping. In mixed groups, lower-cost correct rollouts get amplified advantage (up to 2x), higher-cost correct rollouts are unchanged, incorrect untouched. In all-correct groups, below-average-cost rollouts get advantage in [0, 1], others get 0."""
|
||||
|
||||
|
||||
class CustomAdvantageConfig(BaseConfig):
|
||||
type: Literal["custom"] = "custom"
|
||||
|
||||
import_path: str
|
||||
"""Import path to the advantage function (e.g. ``my_module.my_advantage``)."""
|
||||
|
||||
kwargs: dict[str, Any] = Field(default_factory=dict)
|
||||
"""Kwargs forwarded to the advantage function."""
|
||||
|
||||
|
||||
AdvantageConfig: TypeAlias = Annotated[
|
||||
DefaultAdvantageConfig | CustomAdvantageConfig,
|
||||
Field(discriminator="type"),
|
||||
]
|
||||
|
||||
|
||||
# Flags rare tokens generated at high entropy (Section 5.2, https://arxiv.org/abs/2510.02387).
|
||||
class GibberishFilterConfig(BaseConfig):
|
||||
type: Literal["gibberish"] = "gibberish"
|
||||
|
||||
enforce: bool = False
|
||||
"""When True, skip detected rollouts entirely so they are not sent to the trainer. When False, only track detection metrics."""
|
||||
|
||||
token_id_threshold: int = 100_000
|
||||
"""Token IDs above this are candidates for gibberish. BPE tokens are sorted by merge order."""
|
||||
|
||||
logprob_offset: float = 2.0
|
||||
"""Offset from uniform-distribution logprob. Threshold = ``-log(vocab_size) - logprob_offset``."""
|
||||
|
||||
|
||||
# Flags rollouts stuck in a repetition loop: emits high-confidence tokens for an extended stretch.
|
||||
# Flagged when `window` consecutive tokens are each sampled with probability above `prob_threshold`.
|
||||
# (Section 3.2, https://arxiv.org/abs/2506.13585)
|
||||
class RepetitionFilterConfig(BaseConfig):
|
||||
type: Literal["repetition"] = "repetition"
|
||||
|
||||
enforce: bool = False
|
||||
"""When True, skip detected rollouts entirely so they are not sent to the trainer. When False, only track detection metrics."""
|
||||
|
||||
window: int = Field(3_000, ge=1)
|
||||
"""Consecutive high-probability steps required to flag the rollout."""
|
||||
|
||||
prob_threshold: float = Field(0.99, gt=0, le=1)
|
||||
"""Tokens sampled with probability above this are considered repetitive. Consecutive such tokens count toward the window."""
|
||||
|
||||
|
||||
# Flags rollouts with zero advantage.
|
||||
class ZeroAdvantageFilterConfig(BaseConfig):
|
||||
type: Literal["zero_advantage"] = "zero_advantage"
|
||||
|
||||
enforce: bool = True
|
||||
"""When True, skip detected rollouts entirely so they are not sent to the trainer. When False, only track detection metrics."""
|
||||
|
||||
|
||||
FilterConfig: TypeAlias = Annotated[
|
||||
GibberishFilterConfig | RepetitionFilterConfig | ZeroAdvantageFilterConfig,
|
||||
Field(discriminator="type"),
|
||||
]
|
||||
|
||||
|
||||
class FileSystemWeightBroadcastConfig(BaseConfig):
|
||||
type: Literal["filesystem"] = "filesystem"
|
||||
|
||||
|
||||
class NCCLWeightBroadcastConfig(BaseConfig):
|
||||
type: Literal["nccl"] = "nccl"
|
||||
|
||||
host: str = "localhost"
|
||||
"""Host for the NCCL broadcast rendezvous."""
|
||||
|
||||
port: int = 29501
|
||||
"""Port for the NCCL broadcast rendezvous."""
|
||||
|
||||
timeout: int = 1200
|
||||
"""Timeout in seconds for the NCCL broadcast."""
|
||||
|
||||
quantize_in_weight_transfer: bool = False
|
||||
"""Use kernel-format FP8 quantized NCCL transfer for weight updates."""
|
||||
|
||||
inference_world_size: int = Field(1, ge=1)
|
||||
"""Total inference GPUs across all servers. Used by ``init_nccl_broadcast`` to compute per-server rank offsets."""
|
||||
|
||||
|
||||
WeightBroadcastConfig: TypeAlias = Annotated[
|
||||
FileSystemWeightBroadcastConfig | NCCLWeightBroadcastConfig, Field(discriminator="type")
|
||||
]
|
||||
|
||||
|
||||
class OrchestratorExperimentalConfig(BaseConfig):
|
||||
pass
|
||||
|
||||
|
||||
class RolloutModelConfig(BaseConfig):
|
||||
model: ModelConfig = ModelConfig()
|
||||
|
||||
client: ClientConfig = ClientConfig()
|
||||
|
||||
|
||||
class OrchestratorConfig(BaseConfig):
|
||||
training_mode: Literal["rl", "opd", "sft"] = "rl"
|
||||
"""Training mode. ``rl``: student generates rollouts, no teacher. ``opd``: student generates rollouts, teacher computes logprobs (teacher_tau > 0). ``sft``: teacher generates rollouts, student inference pool used for evals and weight sync."""
|
||||
|
||||
student: RolloutModelConfig = Field(RolloutModelConfig(), validation_alias=AliasChoices("student", "model"))
|
||||
"""Student rollout participant (model + client) — the model being trained."""
|
||||
|
||||
teacher: RolloutModelConfig | None = Field(None, validation_alias=AliasChoices("teacher", "teacher_model"))
|
||||
"""Teacher rollout participant (model + client). Role depends on ``training_mode``: ``opd`` — teacher computes logprobs; ``sft`` — teacher generates rollouts."""
|
||||
|
||||
train: TrainConfig = TrainConfig()
|
||||
|
||||
tokenizer: TokenizerConfig = TokenizerConfig()
|
||||
|
||||
renderer: RendererConfig = RendererConfig()
|
||||
"""Client-side renderer configuration. Only consumed when ``use_renderer=true``."""
|
||||
|
||||
optim: OptimizerConfig = OptimizerConfig()
|
||||
"""Per-run optimizer configuration for multi-run training."""
|
||||
|
||||
eval: EvalConfig | None = None
|
||||
"""Evaluation configuration."""
|
||||
|
||||
buffer: BufferConfig = BufferConfig()
|
||||
|
||||
advantage: AdvantageConfig | None = DefaultAdvantageConfig()
|
||||
|
||||
filters: list[FilterConfig] = [GibberishFilterConfig(), RepetitionFilterConfig(), ZeroAdvantageFilterConfig()]
|
||||
"""Rollout filters. Each filter can ``monitor`` (default) or ``enforce`` (skip rollouts)."""
|
||||
|
||||
log: LogConfig = LogConfig()
|
||||
|
||||
wandb: WandbWithExtrasConfig | None = None
|
||||
|
||||
prime_monitor: PrimeMonitorConfig | None = None
|
||||
|
||||
collect_inference_metrics: bool = True
|
||||
"""Collect inference-server metrics (requires wandb)."""
|
||||
|
||||
ckpt: CheckpointConfig | None = None
|
||||
"""Checkpoint configuration."""
|
||||
|
||||
weight_broadcast: WeightBroadcastConfig = FileSystemWeightBroadcastConfig()
|
||||
"""Transport used to receive updated weights from the trainer."""
|
||||
|
||||
rollout_transport: TransportConfig = FileSystemTransportConfig()
|
||||
"""Transport used to ship rollouts from orchestrator to trainer."""
|
||||
|
||||
output_dir: Path = Path("outputs/run_default")
|
||||
"""Directory to write outputs to — checkpoints, weights, rollouts, and logs are written as subdirectories. Should be a persistent directory with enough disk space and unique per experiment running on a single node."""
|
||||
|
||||
tasks_per_minute: int | None = Field(None, ge=1)
|
||||
"""Rate limit per environment worker, in tasks per minute. Recommended for sandbox-backed environments to prevent sandbox-not-ready errors during autoscaling. With multiple workers, the effective total rate is ``workers × this value``. None disables rate limiting."""
|
||||
|
||||
batch_size: int | None = Field(None, ge=1)
|
||||
"""Samples to train on per step (rollout-based batching). Set this OR ``token_batch_size``."""
|
||||
|
||||
token_batch_size: int | None = Field(None, ge=1)
|
||||
"""Tokens to train on per step (token-based batching). Set this OR ``batch_size``."""
|
||||
|
||||
oversampling_factor: float | None = Field(None, gt=0)
|
||||
"""Rollout-mode batching only. Multiplier used to derive ``max_inflight_rollouts`` from ``batch_size`` when ``max_inflight_rollouts`` is unset. Values below 1.0 intentionally cap in-flight rollout capacity below ``batch_size``."""
|
||||
|
||||
max_inflight_rollouts: int | None = Field(None, ge=1)
|
||||
"""Maximum number of rollouts kept in-flight. Required for token-based batching. With ``batch_size`` set, defaults to ``batch_size * oversampling_factor`` (or ``batch_size`` when ``oversampling_factor`` is unset)."""
|
||||
|
||||
rollouts_per_example: int = Field(1, ge=1)
|
||||
"""Output sequences returned per example during training."""
|
||||
|
||||
seq_len: int = 2048
|
||||
"""Training sequence length. Shorter samples are padded; longer samples are truncated."""
|
||||
|
||||
# TODO(Mika): This should be automatic from the number of ZMQ connections
|
||||
num_train_workers: int = Field(1, ge=1)
|
||||
"""Training workers to use."""
|
||||
|
||||
max_steps: int | None = None
|
||||
"""Maximum training steps. If None, runs indefinitely."""
|
||||
|
||||
max_off_policy_steps: int = Field(8, ge=0)
|
||||
"""Maximum policies allowed to generate a single rollout. Rollouts generated more than ``max_off_policy_steps`` ahead of training are discarded. Higher values yield better throughput at the cost of off-policy noise."""
|
||||
|
||||
max_error_reschedule_attempts: int | None = Field(3, ge=1)
|
||||
"""The group is dropped from the current step's batch once this many of its dispatch rounds have returned errored or empty rollouts (the trainer proceeds with the rollouts from other groups). Counts rounds, not individual rollouts: a non-group-scoring env that dispatches ``rollouts_per_example`` rollouts at once still only counts one round per failed batch. None retries indefinitely. Useful for unblocking single-example hangs in agent envs."""
|
||||
|
||||
max_async_level: int = Field(1, ge=0)
|
||||
"""Maximum steps inference can be ahead of training. ``0`` degenerates to synchronous on-policy RL; ``≥1`` overlaps training and inference."""
|
||||
|
||||
strict_async_level: bool = False
|
||||
"""Strictly enforce ``max_async_level``. When True, the rollout policy is always exactly ``max_async_level`` steps ahead of training. When False, any policy within ``max_async_level`` steps is allowed (always uses the latest available policy)."""
|
||||
|
||||
bench: bool = False
|
||||
"""Benchmark mode. Sets ``max_steps`` to 5, ``max_async_level`` to ~∞, and disables W&B."""
|
||||
|
||||
seed: int | None = 42
|
||||
"""Random seed for the orchestrator."""
|
||||
|
||||
heartbeat: HeartbeatConfig | None = None
|
||||
"""BetterStack heartbeat configuration for monitoring training progress."""
|
||||
|
||||
use_renderer: bool = True
|
||||
"""Use the renderer-backed TITO client (client-side tokenization via the ``renderers`` package, served by ``/v1/generate``). When True, the ``[orchestrator.renderer]`` block (name / tool_parser / reasoning_parser / pool_size) applies. Default for both text-only and VLM rollouts; VLMs require it. False falls back to MITO (``openai_chat_completions``)."""
|
||||
|
||||
env_install_prerelease: bool = False
|
||||
"""Allow pre-release versions when installing environments (e.g. ``verifiers>=0.1.12.dev5``). Passes ``--prerelease`` to ``prime env install``."""
|
||||
|
||||
experimental: OrchestratorExperimentalConfig = OrchestratorExperimentalConfig()
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def fold_student_shortcuts(cls, data: Any) -> Any:
|
||||
"""Accept top-level ``[orchestrator.model]`` / ``[orchestrator.client]``
|
||||
as shorthand for the student sub-config. Useful for ergonomic rl configs
|
||||
where ``[orchestrator.student.*]`` is overkill, and required for
|
||||
pre-refactor configs that used the flat layout to keep parsing:
|
||||
|
||||
- [orchestrator.client.*] -> [orchestrator.student.client.*]
|
||||
- [orchestrator.model.<k>] -> [orchestrator.student.model.<k>]
|
||||
(where <k> is any ModelConfig field)
|
||||
|
||||
Teacher must always be configured under [orchestrator.teacher.*]
|
||||
(no equivalent shortcut), because rl mode forbids a teacher and we
|
||||
don't want the same shortcut to silently route to two different roles.
|
||||
"""
|
||||
if not isinstance(data, dict):
|
||||
return data
|
||||
|
||||
# 1. Re-nest top-level [orchestrator.client] under student.client.
|
||||
if "client" in data:
|
||||
student = data.setdefault("student", {})
|
||||
if isinstance(student, dict) and "client" not in student:
|
||||
student["client"] = data.pop("client")
|
||||
|
||||
# 2. Consolidate the legacy `model` alias into `student` so the
|
||||
# flat-layout fix-up below sees a single target.
|
||||
legacy_model = data.pop("model", None)
|
||||
if legacy_model is not None:
|
||||
existing = data.get("student")
|
||||
if existing is None:
|
||||
data["student"] = legacy_model
|
||||
elif isinstance(existing, dict) and isinstance(legacy_model, dict):
|
||||
for k, v in legacy_model.items():
|
||||
existing.setdefault(k, v)
|
||||
else:
|
||||
# Mismatched types - put it back and let pydantic surface the error.
|
||||
data["model"] = legacy_model
|
||||
|
||||
# 3. Re-nest flat ModelConfig keys under student.model.
|
||||
model_only_keys = set(ModelConfig.model_fields)
|
||||
student = data.get("student")
|
||||
if isinstance(student, dict):
|
||||
flat = {k: student.pop(k) for k in list(student) if k in model_only_keys}
|
||||
if flat:
|
||||
student.setdefault("model", {}).update(flat)
|
||||
|
||||
return data
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def _env_to_train(cls, data: Any) -> Any:
|
||||
"""Allow [[env]] and [sampling] as shorthand for [train] with [[train.env]] and [train.sampling]."""
|
||||
if not isinstance(data, dict):
|
||||
return data
|
||||
if "env" in data or "sampling" in data:
|
||||
train = data.setdefault("train", {})
|
||||
if isinstance(train, dict):
|
||||
if "env" in data:
|
||||
warnings.warn(
|
||||
"'[[orchestrator.env]]' is deprecated, use '[[orchestrator.train.env]]' instead. "
|
||||
"Auto-translating for now, but this will be removed in a future release.",
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
train.setdefault("env", data.pop("env"))
|
||||
if "sampling" in data:
|
||||
warnings.warn(
|
||||
"'[orchestrator.sampling]' is deprecated, use '[orchestrator.train.sampling]' instead. "
|
||||
"Auto-translating for now, but this will be removed in a future release.",
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
train.setdefault("sampling", data.pop("sampling"))
|
||||
return data
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_tokenizer(self):
|
||||
if self.tokenizer.name is None:
|
||||
self.tokenizer.name = self.student.model.name
|
||||
if self.tokenizer.trust_remote_code is None:
|
||||
self.tokenizer.trust_remote_code = self.student.model.trust_remote_code
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_session_headers(self):
|
||||
"""Ensure X-Session-ID header is always set for sticky DP-aware routing at the inference router."""
|
||||
self.student.client.extra_headers_from_state.setdefault("X-Session-ID", "example_id")
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_prime_monitor_run_name(self):
|
||||
"""Default ``prime_monitor.run_name`` to the W&B run name when monitoring
|
||||
is enabled and the user hasn't named the prime-monitor run explicitly."""
|
||||
if self.prime_monitor is None or self.prime_monitor.run_name is not None:
|
||||
return self
|
||||
if self.wandb is not None and self.wandb.name:
|
||||
self.prime_monitor.run_name = self.wandb.name
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_unique_filter_types(self):
|
||||
types = [f.type for f in self.filters]
|
||||
if len(types) != len(set(types)):
|
||||
raise ValueError(f"Duplicate filter types: {types}. Each filter type may only appear once.")
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def _force_no_renderer_for_sft(self):
|
||||
"""SFT rolls out via the teacher's plain chat-completions endpoint; the
|
||||
renderer client doesn't apply. Force use_renderer=False so the user
|
||||
doesn't have to remember to set it. Declared before the renderer
|
||||
validators below so they see the corrected value."""
|
||||
if self.training_mode == "sft":
|
||||
self.use_renderer = False
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_training_mode(self):
|
||||
"""Enforce training mode invariants that involve only orchestrator fields."""
|
||||
has_teacher = self.teacher is not None
|
||||
if self.training_mode == "rl" and has_teacher:
|
||||
raise ValueError("orchestrator.teacher must not be set when training_mode = 'rl'.")
|
||||
if self.training_mode in ("opd", "sft") and not has_teacher:
|
||||
raise ValueError(f"orchestrator.teacher must be configured when training_mode = '{self.training_mode}'.")
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_renderer_args(self):
|
||||
"""``[orchestrator.renderer]`` knobs are only meaningful when
|
||||
``use_renderer=True``. Reject otherwise so callers don't silently
|
||||
pass them and wonder why they're ignored."""
|
||||
if self.use_renderer:
|
||||
return self
|
||||
|
||||
renderer_args_set = []
|
||||
if self.renderer.name != "auto":
|
||||
renderer_args_set.append(f"renderer.name={self.renderer.name!r}")
|
||||
if self.renderer.tool_parser is not None:
|
||||
renderer_args_set.append(f"renderer.tool_parser={self.renderer.tool_parser!r}")
|
||||
if self.renderer.reasoning_parser is not None:
|
||||
renderer_args_set.append(f"renderer.reasoning_parser={self.renderer.reasoning_parser!r}")
|
||||
if self.renderer.pool_size is not None:
|
||||
renderer_args_set.append(f"renderer.pool_size={self.renderer.pool_size!r}")
|
||||
if self.renderer.preserve_all_thinking:
|
||||
renderer_args_set.append(f"renderer.preserve_all_thinking={self.renderer.preserve_all_thinking!r}")
|
||||
if self.renderer.preserve_thinking_between_tool_calls:
|
||||
renderer_args_set.append(
|
||||
f"renderer.preserve_thinking_between_tool_calls={self.renderer.preserve_thinking_between_tool_calls!r}"
|
||||
)
|
||||
|
||||
if renderer_args_set:
|
||||
raise ValueError(
|
||||
"Renderer-specific args set without orchestrator.use_renderer=True: "
|
||||
f"{', '.join(renderer_args_set)}. Either enable the renderer client or remove these knobs."
|
||||
)
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def vlm_requires_renderer(self):
|
||||
"""VLMs (``[model.vlm]`` block set) must go through the renderer.
|
||||
|
||||
The renderer owns the processor per-slot, produces byte-identical
|
||||
tokens, and ships generic ``mm_kwargs`` keyed by whatever the
|
||||
model's forward signature expects.
|
||||
"""
|
||||
if self.student.model.vlm is not None and not self.use_renderer:
|
||||
raise ValueError(
|
||||
"orchestrator.use_renderer must be true when model.vlm is set. "
|
||||
"VLMs must go through a renderer (e.g. Qwen3VLRenderer) that owns the processor."
|
||||
)
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_renderer_auto_resolves(self):
|
||||
"""Reject the silent DefaultRenderer fallback at config time.
|
||||
|
||||
When ``use_renderer=True`` with ``renderer.name='auto'`` and the
|
||||
model isn't in ``MODEL_RENDERER_MAP``, ``create_renderer`` would
|
||||
fall back to ``DefaultRenderer``. That fallback doesn't fix the
|
||||
position-dependent chat-template bug the renderer client exists to
|
||||
solve, and rejects envs that pass tools (the rollout dies with
|
||||
"RendererPool does not support tools") unless
|
||||
``renderer.tool_parser`` is configured. Surface at config time so
|
||||
``--dry-run`` reports the error.
|
||||
"""
|
||||
if not self.use_renderer or self.renderer.name != "auto":
|
||||
return self
|
||||
from renderers.base import MODEL_RENDERER_MAP
|
||||
|
||||
model_id = self.tokenizer.name or self.student.model.name
|
||||
if model_id in MODEL_RENDERER_MAP:
|
||||
return self
|
||||
raise ValueError(
|
||||
f"orchestrator.use_renderer=True with renderer.name='auto' but "
|
||||
f"{model_id!r} is not in renderers.base.MODEL_RENDERER_MAP, so it "
|
||||
f"would silently fall back to DefaultRenderer. Pick one: "
|
||||
f"(a) [orchestrator.renderer] name='default' — for fine-tunes / "
|
||||
f"vendored mirrors with custom chat templates (DefaultRenderer "
|
||||
f"calls apply_chat_template); pair with tool_parser=<name> if "
|
||||
f"the env uses tools. "
|
||||
f"(b) [orchestrator.renderer] name=<model-specific renderer> — "
|
||||
f"if {model_id!r} is template-identical to a mapped family "
|
||||
f"(and ideally also add it upstream to "
|
||||
f"renderers.base.MODEL_RENDERER_MAP). "
|
||||
f"(c) orchestrator.use_renderer=false — opt out of the renderer "
|
||||
f"client entirely."
|
||||
)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def nccl_max_async_level(self):
|
||||
if self.weight_broadcast.type == "nccl":
|
||||
if not self.max_async_level == 1:
|
||||
raise ValueError("max_async_level must be 1 for NCCL broadcast")
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def resolve_batching(self):
|
||||
has_rollout_batch = self.batch_size is not None
|
||||
has_token_batch = self.token_batch_size is not None
|
||||
|
||||
if has_rollout_batch and has_token_batch:
|
||||
raise ValueError("Set exactly one of batch_size or token_batch_size")
|
||||
|
||||
if not has_rollout_batch and not has_token_batch:
|
||||
self.batch_size = 128
|
||||
|
||||
if has_token_batch:
|
||||
if self.oversampling_factor is not None:
|
||||
raise ValueError("oversampling_factor can only be set when batch_size is set")
|
||||
if self.max_inflight_rollouts is None:
|
||||
raise ValueError("max_inflight_rollouts must be set when token_batch_size is set")
|
||||
else:
|
||||
assert self.batch_size is not None
|
||||
if self.batch_size % self.rollouts_per_example != 0:
|
||||
raise ValueError("Batch size must be divisible by the number of samples per problem")
|
||||
oversampling_factor = self.oversampling_factor if self.oversampling_factor is not None else 1.0
|
||||
resolved_max_inflight_rollouts = max(
|
||||
self.rollouts_per_example,
|
||||
int(self.batch_size * oversampling_factor),
|
||||
)
|
||||
if self.max_inflight_rollouts is not None and self.oversampling_factor is not None:
|
||||
expected_max_inflight_rollouts = resolved_max_inflight_rollouts
|
||||
if self.max_inflight_rollouts != expected_max_inflight_rollouts:
|
||||
raise ValueError("max_inflight_rollouts conflicts with oversampling_factor * batch_size")
|
||||
if self.max_inflight_rollouts is None:
|
||||
self.max_inflight_rollouts = resolved_max_inflight_rollouts
|
||||
|
||||
if self.max_inflight_rollouts is not None and self.max_inflight_rollouts < self.rollouts_per_example:
|
||||
raise ValueError("max_inflight_rollouts must be at least the number of rollouts per example")
|
||||
|
||||
# Resolve train env num_workers from max_inflight_rollouts
|
||||
for env_cfg in self.train.env:
|
||||
if env_cfg.num_workers == "auto":
|
||||
assert self.max_inflight_rollouts is not None
|
||||
env_cfg.num_workers = max(1, math.ceil(self.max_inflight_rollouts / 256))
|
||||
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_bench(self):
|
||||
if self.bench:
|
||||
self.max_steps = 4 # Run for 1 warmup step + 3 evaluation steps
|
||||
self.max_async_level = int(1e9) # Never wait for RL weight checkpoints
|
||||
|
||||
# Disable evaluation
|
||||
self.eval = None
|
||||
if self.wandb:
|
||||
self.wandb.log_extras = None
|
||||
if self.prime_monitor:
|
||||
self.prime_monitor.log_extras = None
|
||||
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def resolve_env_config(self):
|
||||
"""Populate extra_env_kwargs and vLLM sampling defaults from top-level fields."""
|
||||
is_vllm = self.training_mode != "sft"
|
||||
for env in self.train.env:
|
||||
env.extra_env_kwargs.update(max_seq_len=self.seq_len)
|
||||
if is_vllm:
|
||||
env.sampling.extra_body.setdefault("top_k", -1)
|
||||
env.sampling.extra_body.setdefault("min_p", 0.0)
|
||||
env.sampling.extra_body.setdefault("return_token_ids", True)
|
||||
return self
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user