Compare commits
45
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2a25f0622 | ||
|
|
bc9e186963 | ||
|
|
bfb0fe346e | ||
|
|
2acb19eccd | ||
|
|
69308b88cb | ||
|
|
0630b7bff7 | ||
|
|
5ed05cf6ac | ||
|
|
1c0720d975 | ||
|
|
61f2448d1d | ||
|
|
c7a6573de5 | ||
|
|
8b2819b4c7 | ||
|
|
1fd4fefd4a | ||
|
|
15d6c81974 | ||
|
|
4f5d943a15 | ||
|
|
572cc82e76 | ||
|
|
d8f3d01016 | ||
|
|
7b97965bb3 | ||
|
|
b8d9553c0f | ||
|
|
9975d8868d | ||
|
|
de626e934e | ||
|
|
e56a8df198 | ||
|
|
68e0c50f6c | ||
|
|
e26b505039 | ||
|
|
70caa7c61f | ||
|
|
5a005de2d6 | ||
|
|
756afd40eb | ||
|
|
c1674ac93c | ||
|
|
b1d4f2fa6c | ||
|
|
d43e0f329b | ||
|
|
8c1f196dd3 | ||
|
|
753a3fec0a | ||
|
|
3ad13dd0bc | ||
|
|
ee06d333e4 | ||
|
|
91d4b92597 | ||
|
|
82acb12ed7 | ||
|
|
124f9694a6 | ||
|
|
4308fe3aba | ||
|
|
da53d4c064 | ||
|
|
efe8e7fda8 | ||
|
|
bb23623d6e | ||
|
|
03f12efbaf | ||
|
|
f2ead102d1 | ||
|
|
c698bdeb2a | ||
|
|
6e33f3f82f | ||
|
|
c282262e6e |
@@ -0,0 +1,11 @@
|
||||
# .git stays: docker-editable-pretend-versions.sh reads .git/modules via the bind mount.
|
||||
outputs
|
||||
**/.venv
|
||||
**/__pycache__
|
||||
**/*.py[cod]
|
||||
**/.pytest_cache
|
||||
**/.ruff_cache
|
||||
**/.mypy_cache
|
||||
.claude
|
||||
.vscode
|
||||
*.ipynb
|
||||
@@ -146,7 +146,7 @@ jobs:
|
||||
id: artifact
|
||||
run: echo "name=benchmark-${{ matrix.runner }}-$(echo '${{ matrix.model }}' | sed 's/\//--/')-${{ matrix.type }}-${{ matrix.lora_rank || 'full' }}-${{ matrix.num_gpus }}gpu-${{ matrix.ac }}-${{ matrix.attention }}-${{ matrix.seq_len }}-cp${{ matrix.cp }}-ep${{ matrix.ep }}" >> "$GITHUB_OUTPUT"
|
||||
- name: Upload benchmark result
|
||||
uses: actions/upload-artifact@v5
|
||||
uses: actions/upload-artifact@v7
|
||||
if: always()
|
||||
with:
|
||||
name: ${{ steps.artifact.outputs.name }}
|
||||
@@ -163,16 +163,16 @@ jobs:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout repository # We can't use the image because then no git
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v7
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v7
|
||||
uses: astral-sh/setup-uv@v10.0.1
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: "uv.lock"
|
||||
- name: Install dependencies
|
||||
run: uv sync
|
||||
- name: Download all benchmark artifacts
|
||||
uses: actions/download-artifact@v6
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
path: /tmp/benchmark_artifacts
|
||||
pattern: benchmark-*
|
||||
|
||||
@@ -103,7 +103,7 @@ jobs:
|
||||
esac
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
ref: ${{ env.BUILD_REF }}
|
||||
fetch-depth: 0
|
||||
@@ -161,10 +161,16 @@ jobs:
|
||||
steps:
|
||||
- name: Remove unnecessary packages
|
||||
run: |
|
||||
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
|
||||
# Deleting the preinstalled toolchains costs ~70s; skip unless disk is tight.
|
||||
avail_gb=$(df -BG --output=avail / | tail -1 | tr -dc '0-9')
|
||||
if [ "${avail_gb:-0}" -lt 80 ]; then
|
||||
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
|
||||
else
|
||||
echo "Skipping cleanup: ${avail_gb}G available on /"
|
||||
fi
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
ref: ${{ needs.prepare.outputs.ref }}
|
||||
fetch-depth: 0
|
||||
@@ -174,7 +180,7 @@ jobs:
|
||||
run: |
|
||||
if [ -f .gitmodules ]; then
|
||||
git config --global url."https://github.com/".insteadOf "git@github.com:"
|
||||
git submodule update --init --recursive -- deps/pydantic-config deps/verifiers deps/renderers deps/research-environments
|
||||
git submodule update --init --recursive -- deps/pydantic-config deps/verifiers deps/renderers deps/prime-envs
|
||||
fi
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
@@ -198,6 +204,10 @@ jobs:
|
||||
# rather than needlessly recompressed. Pulling zstd layers needs containerd >= 1.5
|
||||
# or Docker >= 23.
|
||||
outputs: type=image,push=true,compression=zstd,compression-level=3
|
||||
# The per-job builder is ephemeral; mode=max caches builder-stage
|
||||
# layers so warm builds skip the dependency sync.
|
||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.suffix }}
|
||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.suffix }},mode=max,image-manifest=true,oci-mediatypes=true,compression=zstd,compression-level=3
|
||||
platforms: ${{ matrix.platform }}
|
||||
tags: |
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.prepare.outputs.tag }}-${{ matrix.suffix }}
|
||||
|
||||
@@ -12,15 +12,15 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v7
|
||||
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
|
||||
git submodule update --init --recursive -- deps/verifiers deps/renderers deps/prime-envs deps/pydantic-config
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v7
|
||||
uses: astral-sh/setup-uv@v10.0.1
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: "uv.lock"
|
||||
@@ -48,9 +48,9 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v7
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v7
|
||||
uses: astral-sh/setup-uv@v10.0.1
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: "uv.lock"
|
||||
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Create next .dev tag from latest release
|
||||
uses: actions/github-script@v8
|
||||
uses: actions/github-script@v9
|
||||
with:
|
||||
script: |
|
||||
const { owner, repo } = context.repo;
|
||||
|
||||
@@ -26,15 +26,15 @@ jobs:
|
||||
apt-get install -y git
|
||||
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v7
|
||||
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
|
||||
git submodule update --init --recursive -- deps/verifiers deps/renderers deps/prime-envs deps/pydantic-config
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v7
|
||||
uses: astral-sh/setup-uv@v10.0.1
|
||||
- name: Install dependencies
|
||||
run: uv sync --all-extras --all-packages --locked
|
||||
- name: Run unit tests
|
||||
@@ -94,15 +94,15 @@ jobs:
|
||||
apt-get install -y git
|
||||
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v7
|
||||
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
|
||||
git submodule update --init --recursive -- deps/verifiers deps/renderers deps/prime-envs deps/pydantic-config
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v7
|
||||
uses: astral-sh/setup-uv@v10.0.1
|
||||
- name: Install dependencies
|
||||
run: uv sync --all-extras --all-packages --locked
|
||||
- name: Run integration tests
|
||||
@@ -120,7 +120,7 @@ jobs:
|
||||
run: uv run pytest -vvs ${{ matrix.pytest_args }}
|
||||
- name: Upload run logs on failure
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: ${{ matrix.test }}-logs
|
||||
path: /tmp/outputs/**/*.log
|
||||
|
||||
@@ -31,7 +31,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
submodules: false
|
||||
|
||||
@@ -70,7 +70,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
submodules: false
|
||||
|
||||
@@ -159,7 +159,7 @@ jobs:
|
||||
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v7
|
||||
uses: astral-sh/setup-uv@v10.0.1
|
||||
|
||||
- name: Install prime CLI (latest)
|
||||
run: uv tool install prime
|
||||
|
||||
@@ -23,7 +23,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
submodules: false
|
||||
|
||||
@@ -73,15 +73,15 @@ jobs:
|
||||
apt-get install -y git
|
||||
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v7
|
||||
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
|
||||
git submodule update --init --recursive -- deps/verifiers deps/renderers deps/prime-envs deps/pydantic-config
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v7
|
||||
uses: astral-sh/setup-uv@v10.0.1
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: "uv.lock"
|
||||
|
||||
@@ -15,17 +15,17 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v7
|
||||
# Submodules are excluded from ruff via pyproject.toml; no need to fetch them.
|
||||
with:
|
||||
submodules: false
|
||||
- name: Run ruff
|
||||
uses: astral-sh/ruff-action@v4.1.0
|
||||
with:
|
||||
version: "0.13.0"
|
||||
version: "0.15.14"
|
||||
args: "check --config=pyproject.toml"
|
||||
- name: Run ruff format (check)
|
||||
uses: astral-sh/ruff-action@v4.1.0
|
||||
with:
|
||||
version: "0.13.0"
|
||||
version: "0.15.14"
|
||||
args: "format --check --config=pyproject.toml"
|
||||
|
||||
@@ -10,7 +10,7 @@ jobs:
|
||||
trigger-docs-sync:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v7
|
||||
|
||||
- name: Validate mint.json pages exist
|
||||
run: |
|
||||
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
version: ${{ steps.tag.outputs.version }}
|
||||
steps:
|
||||
- name: Checkout main
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -148,14 +148,14 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout tagged release (dispatch)
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: refs/tags/${{ inputs.tag }}
|
||||
|
||||
- name: Checkout tagged release (push)
|
||||
if: github.event_name != 'workflow_dispatch'
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
||||
+3
-18
@@ -1,26 +1,13 @@
|
||||
.vscode/*
|
||||
.claude/scheduled_tasks.lock
|
||||
.claude/worktrees/
|
||||
.codex/
|
||||
*.ipynb
|
||||
*.jsonl
|
||||
configs/endpoints.py
|
||||
|
||||
# Artifacts
|
||||
**/slurm
|
||||
!src/prime_rl/slurm
|
||||
!examples/slurm
|
||||
!docs/slurm.md
|
||||
**/torchrun
|
||||
**/weights
|
||||
**/checkpoints
|
||||
**/broadcasts
|
||||
**/rollouts
|
||||
**/logs
|
||||
**/wandb
|
||||
**/evals
|
||||
**/run_*/
|
||||
!configs/**/evals
|
||||
final_summary.json
|
||||
# Run artifacts
|
||||
outputs/
|
||||
.pydantic_config
|
||||
.chroma_db
|
||||
deps/nixl_*
|
||||
@@ -201,6 +188,4 @@ cython_debug/
|
||||
debug_I2_zero_band
|
||||
.idea
|
||||
|
||||
outputs/
|
||||
|
||||
third_party/
|
||||
|
||||
+3
-3
@@ -4,9 +4,9 @@
|
||||
[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 "prime-envs"]
|
||||
path = deps/prime-envs
|
||||
url = git@github.com:PrimeIntellect-ai/prime-envs.git
|
||||
[submodule "pydantic-config"]
|
||||
path = deps/pydantic-config
|
||||
url = https://github.com/PrimeIntellect-ai/pydantic-config
|
||||
|
||||
+35
-10
@@ -4,6 +4,16 @@
|
||||
|
||||
#inspired from https://github.com/astral-sh/uv-docker-example/blob/main/multistage.Dockerfile
|
||||
|
||||
# Every pyproject.toml + uv.lock, so the dependency sync below caches
|
||||
# independently of source edits.
|
||||
FROM nvidia/cuda:12.8.1-base-ubuntu24.04 AS manifests
|
||||
# .git is ~735 MB, changes every commit, and would land in the registry cache.
|
||||
COPY --exclude=.git . /ctx
|
||||
RUN mkdir -p /manifests \
|
||||
&& cd /ctx \
|
||||
&& find . -name .git -prune -o -type f -name pyproject.toml -exec cp --parents {} /manifests/ \; \
|
||||
&& cp uv.lock /manifests/
|
||||
|
||||
# Build stage - multi-arch base (supports amd64 + arm64)
|
||||
FROM nvidia/cuda:12.8.1-cudnn-devel-ubuntu24.04 AS builder
|
||||
LABEL maintainer="prime intellect"
|
||||
@@ -76,11 +86,23 @@ ENV UV_CACHE_DIR="/usr/local/share/uv/cache"
|
||||
# the runtime stage's `COPY /app`
|
||||
ENV UV_PROJECT_ENVIRONMENT="/app/.venv"
|
||||
|
||||
# Install Python dependencies (The gradual copies help with caching)
|
||||
# Install Python dependencies
|
||||
WORKDIR /app
|
||||
|
||||
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
|
||||
|
||||
# Third-party deps only — source edits don't bust this layer. First-party
|
||||
# editables install in the source-layer sync below. No build-context bind
|
||||
# mount here: .git would bust the cache every commit.
|
||||
COPY --from=manifests /manifests /app
|
||||
RUN --mount=type=cache,target=/usr/local/share/uv/cache \
|
||||
uv sync --all-packages --extra flash-attn --extra flash-attn-3 --extra flash-attn-cute --extra disagg --extra gpt-oss --extra quack --group mamba-ssm --locked --no-dev \
|
||||
--no-install-workspace \
|
||||
--no-install-package prime-rl-configs \
|
||||
--no-install-package verifiers \
|
||||
--no-install-package renderers \
|
||||
--no-install-package prime-pydantic-config
|
||||
|
||||
COPY pyproject.toml /app/pyproject.toml
|
||||
COPY uv.lock /app/uv.lock
|
||||
COPY README.md /app/README.md
|
||||
@@ -98,7 +120,7 @@ COPY scripts/docker-editable-pretend-versions.sh /app/scripts/docker-editable-pr
|
||||
# /app/.git/modules to the read-only context before resolving versions.
|
||||
ARG VERIFIERS_PRETEND_VERSION
|
||||
ARG RENDERERS_PRETEND_VERSION
|
||||
RUN --mount=type=cache,target=/app/.cache/uv \
|
||||
RUN --mount=type=cache,target=/usr/local/share/uv/cache \
|
||||
--mount=type=bind,source=.,target=/build-context,readonly \
|
||||
if [ -d /build-context/.git/modules ]; then mkdir -p /app/.git && ln -s /build-context/.git/modules /app/.git/modules; fi \
|
||||
&& \
|
||||
@@ -220,14 +242,9 @@ WORKDIR /app
|
||||
# own layers. BuildKit compresses and pushes layers in parallel, so shipping the whole
|
||||
# ~20 GB venv as one layer serialized the export behind a single compressor. Splitting
|
||||
# also lets nodes pull the image in parallel. Keep the excludes below in sync with the
|
||||
# per-tree copies that follow, or the data lands in the image twice.
|
||||
COPY --from=builder --chown=appuser:appuser \
|
||||
--exclude=.venv/lib/python3.12/site-packages/nvidia \
|
||||
--exclude=.venv/lib/python3.12/site-packages/torch \
|
||||
--exclude=.venv/lib/python3.12/site-packages/vllm \
|
||||
--exclude=.venv/lib/python3.12/site-packages/flash_attn \
|
||||
--exclude=.venv/lib/python3.12/site-packages/flash_attn_2_cuda*.so \
|
||||
/app /app
|
||||
# per-tree copies above, or the data lands in the image twice.
|
||||
# The volatile /app remainder goes last so a source edit re-pushes one layer,
|
||||
# not all of them.
|
||||
COPY --from=builder --chown=appuser:appuser /app/.venv/lib/python3.12/site-packages/nvidia /app/.venv/lib/python3.12/site-packages/nvidia
|
||||
COPY --from=builder --chown=appuser:appuser /app/.venv/lib/python3.12/site-packages/torch /app/.venv/lib/python3.12/site-packages/torch
|
||||
COPY --from=builder --chown=appuser:appuser /app/.venv/lib/python3.12/site-packages/vllm /app/.venv/lib/python3.12/site-packages/vllm
|
||||
@@ -239,6 +256,14 @@ COPY --from=builder /opt/ucx /opt/ucx
|
||||
COPY --chown=appuser:appuser scripts/docker-entrypoint.sh /app/docker-entrypoint.sh
|
||||
RUN chmod +x /app/docker-entrypoint.sh
|
||||
|
||||
COPY --from=builder --chown=appuser:appuser \
|
||||
--exclude=.venv/lib/python3.12/site-packages/nvidia \
|
||||
--exclude=.venv/lib/python3.12/site-packages/torch \
|
||||
--exclude=.venv/lib/python3.12/site-packages/vllm \
|
||||
--exclude=.venv/lib/python3.12/site-packages/flash_attn \
|
||||
--exclude=.venv/lib/python3.12/site-packages/flash_attn_2_cuda*.so \
|
||||
/app /app
|
||||
|
||||
# Place executables in the environment at the front of the path
|
||||
ENV PATH="/app/.venv/bin:$PATH"
|
||||
ENV UCX_HOME=/opt/ucx
|
||||
|
||||
@@ -95,7 +95,7 @@ cd prime-rl
|
||||
2. Initialize submodules
|
||||
|
||||
```bash
|
||||
git submodule update --init -- deps/verifiers deps/renderers deps/research-environments deps/pydantic-config
|
||||
git submodule update --init -- deps/verifiers deps/renderers deps/prime-envs deps/pydantic-config
|
||||
```
|
||||
|
||||
3. Install [uv](https://docs.astral.sh/uv/)
|
||||
|
||||
@@ -2,15 +2,18 @@
|
||||
"""
|
||||
Run a single benchmark configuration and output JSON results.
|
||||
|
||||
This script wraps the prime-rl training with --bench.output-json to get
|
||||
metrics directly without parsing console output.
|
||||
This script runs a normal short training (--max-steps) with the file monitor
|
||||
enabled and aggregates throughput / MFU / step time / peak memory from the
|
||||
run's metrics.jsonl.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import statistics
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
@@ -83,6 +86,8 @@ class BenchmarkConfig(BaseConfig):
|
||||
|
||||
timeout: Annotated[int, Field(description="Timeout in seconds")] = 3600
|
||||
|
||||
max_steps: Annotated[int, Field(ge=2, description="Training steps to run. The first step is warmup.")] = 4
|
||||
|
||||
micro_batches: Annotated[int, Field(ge=1, description="Number of micro batches")] = 2
|
||||
|
||||
ep: Annotated[int, Field(ge=1, description="Expert parallelism size (1 = no EP)")] = 1
|
||||
@@ -115,7 +120,7 @@ class BenchmarkConfig(BaseConfig):
|
||||
] = None
|
||||
|
||||
|
||||
def build_command(config: BenchmarkConfig) -> list[str]:
|
||||
def build_command(config: BenchmarkConfig, output_dir: Path) -> list[str]:
|
||||
"""Build the benchmark command from config."""
|
||||
# Determine training script
|
||||
if config.type == "rl":
|
||||
@@ -137,12 +142,18 @@ def build_command(config: BenchmarkConfig) -> list[str]:
|
||||
str(config.seq_len),
|
||||
"--model.attn",
|
||||
config.attention,
|
||||
"--bench.output-json",
|
||||
str(config.output),
|
||||
"--max-steps",
|
||||
str(config.max_steps),
|
||||
"--output-dir",
|
||||
str(output_dir),
|
||||
"--monitors.file.path",
|
||||
"metrics.jsonl",
|
||||
"--model.compile",
|
||||
"--dist-timeout-seconds",
|
||||
str(config.timeout),
|
||||
]
|
||||
if config.type == "sft":
|
||||
cmd.extend(["--run.name", "bench"])
|
||||
|
||||
# Add activation checkpointing if enabled
|
||||
if config.ac == "Recompute":
|
||||
@@ -198,14 +209,61 @@ def dummy_metrics() -> dict:
|
||||
}
|
||||
|
||||
|
||||
def aggregate_metrics(metrics_path: Path) -> dict:
|
||||
"""Aggregate per-step metrics from a run's metrics.jsonl.
|
||||
|
||||
Each metrics.jsonl line is one monitor.log call (``{"step": N, ...}``);
|
||||
merge the lines per step, drop the first (warmup) step, and compute
|
||||
mean/std/min/max per metric like the old --bench JSON export did.
|
||||
"""
|
||||
per_step: dict[int, dict] = {}
|
||||
with open(metrics_path) as f:
|
||||
for line in f:
|
||||
row = json.loads(line)
|
||||
per_step.setdefault(row["step"], {}).update(row)
|
||||
|
||||
steps = sorted(per_step)[1:] # Exclude first warmup step
|
||||
columns = {
|
||||
"perf/mfu": "mfu",
|
||||
"perf/throughput": "throughput",
|
||||
"time/step": "step_time",
|
||||
"perf/peak_memory": "peak_memory",
|
||||
}
|
||||
series = {name: [per_step[step][key] for step in steps] for key, name in columns.items()}
|
||||
|
||||
def stats(values: list[float]) -> dict:
|
||||
return {
|
||||
"mean": statistics.mean(values),
|
||||
"std": statistics.stdev(values) if len(values) > 1 else 0.0,
|
||||
"min": min(values),
|
||||
"max": max(values),
|
||||
}
|
||||
|
||||
total_memory_gib = torch.cuda.mem_get_info()[1] / 1024**3
|
||||
peak_memory_gib = statistics.mean(series["peak_memory"])
|
||||
return {
|
||||
"mfu": stats(series["mfu"]),
|
||||
"throughput": stats(series["throughput"]),
|
||||
"step_time": stats(series["step_time"]),
|
||||
"peak_memory": {
|
||||
"gib": peak_memory_gib,
|
||||
"pct": peak_memory_gib / total_memory_gib * 100,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def run_benchmark(config: BenchmarkConfig) -> None:
|
||||
"""Run a single benchmark and write results to output path."""
|
||||
cmd = build_command(config)
|
||||
output_dir = Path(tempfile.mkdtemp(prefix="benchmark-run-"))
|
||||
cmd = build_command(config, output_dir)
|
||||
print(f"Running: {' '.join(cmd)}")
|
||||
|
||||
if config.dry_run:
|
||||
return
|
||||
|
||||
# The SFT entrypoint writes to output_dir/<run.name>, the RL trainer to output_dir directly
|
||||
metrics_path = output_dir / "bench" / "metrics.jsonl" if config.type == "sft" else output_dir / "metrics.jsonl"
|
||||
|
||||
start_time = time.perf_counter()
|
||||
try:
|
||||
config.output.parent.mkdir(parents=True, exist_ok=True)
|
||||
@@ -221,14 +279,13 @@ def run_benchmark(config: BenchmarkConfig) -> None:
|
||||
config.success = False
|
||||
config.error_reason = extract_oom_error_reason(output) or f"Non-zero exit code: {result.returncode}"
|
||||
print(f"Process exited with code {result.returncode}: {output}")
|
||||
if not config.output.exists():
|
||||
if not metrics_path.exists():
|
||||
config.success = False
|
||||
config.error_reason = config.error_reason or extract_oom_error_reason(output) or "No JSON output written"
|
||||
config.error_reason = config.error_reason or extract_oom_error_reason(output) or "No metrics.jsonl written"
|
||||
print(f"Process exited with code {result.returncode}: {output}")
|
||||
print("Benchmark completed but no JSON output was written")
|
||||
print("Benchmark completed but no metrics.jsonl was written")
|
||||
else:
|
||||
with open(config.output) as f:
|
||||
metrics = json.load(f)
|
||||
metrics = aggregate_metrics(metrics_path)
|
||||
lines = output.splitlines()
|
||||
print("\n".join(lines))
|
||||
except subprocess.TimeoutExpired:
|
||||
|
||||
@@ -11,7 +11,7 @@ num_infer_gpus = 1
|
||||
[model]
|
||||
name = "Qwen/Qwen3-4B-Instruct-2507"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "alphabet-sort"
|
||||
name = "alphabet-sort"
|
||||
|
||||
@@ -36,7 +36,7 @@ max_completion_tokens = 768
|
||||
name = "alphabet-sort"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "alphabet-sort-v1"
|
||||
id = "alphabet-sort"
|
||||
min_turns = 3
|
||||
max_turns = 5
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ num_infer_gpus = 1
|
||||
[model]
|
||||
name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "hendrycks-sanity"
|
||||
name = "hendrycks-sanity"
|
||||
|
||||
@@ -23,7 +23,7 @@ seq_len = 8192
|
||||
name = "hendrycks-math"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "math-env-v1"
|
||||
id = "math-env"
|
||||
dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B"
|
||||
dataset_subset = "default"
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ num_infer_gpus = 1
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "reverse-text"
|
||||
name = "reverse-text"
|
||||
|
||||
@@ -26,7 +26,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
# SFT warmup for reverse-text on 2 GPUs. Dev-sized mirror of examples/basic/reverse-text/sft.toml.
|
||||
# SFT warmup for reverse-text on 2 GPUs (1 train + 1 infer for online evals).
|
||||
# Dev-sized mirror of examples/basic/reverse-text/sft.toml.
|
||||
|
||||
max_steps = 100
|
||||
|
||||
[deployment]
|
||||
num_gpus = 2
|
||||
num_train_gpus = 1
|
||||
num_infer_gpus = 1
|
||||
|
||||
[ckpt] # Checkpoint at the end of training
|
||||
|
||||
@@ -17,3 +19,24 @@ batch_size = 32
|
||||
|
||||
[optim]
|
||||
lr = 2e-5
|
||||
|
||||
[eval]
|
||||
interval = 25
|
||||
num_examples = 32
|
||||
|
||||
[eval.sampling]
|
||||
max_completion_tokens = 1024
|
||||
|
||||
[[eval.source]]
|
||||
name = "reverse-text"
|
||||
|
||||
[eval.source.env.taskset]
|
||||
id = "reverse-text"
|
||||
|
||||
[eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[eval.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[inference]
|
||||
|
||||
@@ -12,7 +12,7 @@ num_infer_gpus = 1
|
||||
[model]
|
||||
name = "Qwen/Qwen3-4B-Instruct-2507"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "wiki-search"
|
||||
name = "wiki-search"
|
||||
|
||||
@@ -44,7 +44,7 @@ max_completion_tokens = 512
|
||||
name = "wiki-search"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "wiki-search-v1"
|
||||
id = "wiki-search"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -8,7 +8,7 @@ seq_len = 8192
|
||||
num_train_gpus = 1
|
||||
num_infer_gpus = 1
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "wordle"
|
||||
name = "wordle"
|
||||
|
||||
@@ -25,7 +25,7 @@ group_size = 8
|
||||
name = "wordle"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "wordle-v1"
|
||||
id = "wordle"
|
||||
|
||||
[orchestrator.train.source.env.player.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
max_steps = 20
|
||||
|
||||
[deployment]
|
||||
num_gpus = 2
|
||||
num_train_gpus = 2
|
||||
|
||||
[ckpt] # Checkpoint at the end of training
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@ lr = 1e-5
|
||||
batch_size = 128
|
||||
group_size = 8
|
||||
|
||||
[orchestrator.concurrency]
|
||||
max_inflight = 128
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 384
|
||||
|
||||
@@ -26,7 +29,7 @@ max_completion_tokens = 384
|
||||
name = "alphabet-sort"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "alphabet-sort-v1"
|
||||
id = "alphabet-sort"
|
||||
min_turns = 2
|
||||
max_turns = 2
|
||||
min_names_per_turn = 1
|
||||
|
||||
@@ -2,7 +2,9 @@ max_steps = 20
|
||||
seq_len = 2048
|
||||
|
||||
[ckpt]
|
||||
resume_step = 15
|
||||
|
||||
[resume]
|
||||
step = 15
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
@@ -20,6 +22,9 @@ save_adapter_separately = true
|
||||
batch_size = 128
|
||||
group_size = 16
|
||||
|
||||
[orchestrator.concurrency]
|
||||
max_inflight = 128
|
||||
|
||||
[orchestrator.model.lora]
|
||||
name = "r8-1e-4"
|
||||
|
||||
@@ -30,7 +35,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -19,6 +19,9 @@ save_adapter_separately = true
|
||||
batch_size = 128
|
||||
group_size = 16
|
||||
|
||||
[orchestrator.concurrency]
|
||||
max_inflight = 128
|
||||
|
||||
[orchestrator.model.lora]
|
||||
name = "r8-1e-4"
|
||||
|
||||
@@ -29,7 +32,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -22,6 +22,9 @@ impl = "custom"
|
||||
batch_size = 128
|
||||
group_size = 16
|
||||
|
||||
[orchestrator.concurrency]
|
||||
max_inflight = 128
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
@@ -29,7 +32,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -16,7 +16,7 @@ type = "filesystem"
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "reverse-text-ci"
|
||||
name = "ci-rl-opd"
|
||||
|
||||
@@ -24,6 +24,9 @@ name = "ci-rl-opd"
|
||||
batch_size = 128
|
||||
group_size = 16
|
||||
|
||||
[orchestrator.concurrency]
|
||||
max_inflight = 128
|
||||
|
||||
[orchestrator.algo]
|
||||
type = "opd"
|
||||
|
||||
@@ -41,7 +44,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -60,7 +63,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -16,7 +16,7 @@ type = "filesystem"
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "reverse-text-ci"
|
||||
name = "ci-rl-sft"
|
||||
|
||||
@@ -24,6 +24,9 @@ name = "ci-rl-sft"
|
||||
batch_size = 128
|
||||
group_size = 16
|
||||
|
||||
[orchestrator.concurrency]
|
||||
max_inflight = 128
|
||||
|
||||
[orchestrator.algo]
|
||||
type = "sft"
|
||||
|
||||
@@ -47,7 +50,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -66,7 +69,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
max_steps = 10
|
||||
|
||||
[ckpt]
|
||||
resume_step = 5
|
||||
|
||||
[resume]
|
||||
step = 5
|
||||
|
||||
[ckpt.weights]
|
||||
save_adapter_separately = true
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
max_steps = 6
|
||||
|
||||
[ckpt]
|
||||
skip_optimizer = true
|
||||
skip_scheduler = true
|
||||
|
||||
[resume]
|
||||
step = 5
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B"
|
||||
optim_cpu_offload = false
|
||||
full_offload = true
|
||||
|
||||
[optim]
|
||||
lr = 0.0
|
||||
|
||||
[data]
|
||||
name = "PrimeIntellect/Reverse-Text-SFT"
|
||||
batch_size = 4
|
||||
seq_len = 1024
|
||||
@@ -1,7 +1,9 @@
|
||||
max_steps = 10
|
||||
|
||||
[ckpt]
|
||||
resume_step = 5
|
||||
|
||||
[resume]
|
||||
step = 5
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B"
|
||||
|
||||
@@ -8,7 +8,9 @@ seq_len = 2048
|
||||
type = "filesystem"
|
||||
|
||||
[ckpt]
|
||||
resume_step = 15
|
||||
|
||||
[resume]
|
||||
step = 15
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
@@ -20,6 +22,9 @@ lr = 3e-6
|
||||
batch_size = 128
|
||||
group_size = 16
|
||||
|
||||
[orchestrator.concurrency]
|
||||
max_inflight = 128
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
@@ -27,7 +32,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -19,6 +19,9 @@ lr = 3e-6
|
||||
batch_size = 128
|
||||
group_size = 16
|
||||
|
||||
[orchestrator.concurrency]
|
||||
max_inflight = 128
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
@@ -26,7 +29,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -5,7 +5,7 @@ seq_len = 2048
|
||||
num_train_gpus = 4
|
||||
num_infer_gpus = 4
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "alphabet-sort"
|
||||
name = "alphabet-sort"
|
||||
|
||||
@@ -18,11 +18,14 @@ name = "Qwen/Qwen3-4B-Instruct-2507"
|
||||
batch_size = 512
|
||||
group_size = 16
|
||||
|
||||
[orchestrator.concurrency]
|
||||
max_inflight = 128
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "alphabet-sort"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "alphabet-sort-v1"
|
||||
id = "alphabet-sort"
|
||||
min_turns = 3
|
||||
max_turns = 5
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ max_steps = 5000
|
||||
num_train_gpus = 4
|
||||
num_infer_gpus = 4
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "hendrycks-sanity"
|
||||
name = "hendrycks-sanity"
|
||||
|
||||
@@ -18,11 +18,14 @@ batch_size = 512
|
||||
group_size = 8
|
||||
seq_len = 8192
|
||||
|
||||
[orchestrator.concurrency]
|
||||
max_inflight = 128
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "hendrycks-math"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "math-env-v1"
|
||||
id = "math-env"
|
||||
dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B"
|
||||
dataset_subset = "default"
|
||||
|
||||
@@ -40,7 +43,7 @@ name = "aime2024"
|
||||
group_size = 32
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "aime24-v1"
|
||||
id = "aime24"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -5,7 +5,7 @@ seq_len = 2048
|
||||
num_train_gpus = 1
|
||||
num_infer_gpus = 1
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "reverse-text"
|
||||
name = "reverse-text"
|
||||
|
||||
@@ -18,11 +18,14 @@ name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
batch_size = 128
|
||||
group_size = 16
|
||||
|
||||
[orchestrator.concurrency]
|
||||
max_inflight = 128
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -5,7 +5,7 @@ seq_len = 4096
|
||||
num_train_gpus = 4
|
||||
num_infer_gpus = 4
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "wiki-search"
|
||||
name = "wiki-search"
|
||||
|
||||
@@ -17,17 +17,16 @@ name = "Qwen/Qwen3-4B-Instruct-2507"
|
||||
[orchestrator]
|
||||
batch_size = 512
|
||||
group_size = 16
|
||||
oversampling_factor = 2.0
|
||||
|
||||
[[orchestrator.pre_batch_filters]]
|
||||
type = "zero_advantage"
|
||||
enforce = true
|
||||
[orchestrator.concurrency]
|
||||
initial_inflight = 128
|
||||
max_inflight = 128
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "wiki-search"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "wiki-search-v1"
|
||||
id = "wiki-search"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -5,7 +5,7 @@ seq_len = 8192
|
||||
num_train_gpus = 2
|
||||
num_infer_gpus = 6
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "wordle"
|
||||
name = "wordle"
|
||||
|
||||
@@ -18,11 +18,14 @@ name = "PrimeIntellect/Qwen3-1.7B-Wordle-SFT"
|
||||
batch_size = 512
|
||||
group_size = 16
|
||||
|
||||
[orchestrator.concurrency]
|
||||
max_inflight = 128
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "wordle"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "wordle-v1"
|
||||
id = "wordle"
|
||||
|
||||
[orchestrator.train.source.env.player.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -17,6 +17,9 @@ language_model_attr = "model.language_model"
|
||||
batch_size = 256
|
||||
group_size = 16
|
||||
|
||||
[orchestrator.concurrency]
|
||||
max_inflight = 128
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 64
|
||||
|
||||
@@ -24,7 +27,7 @@ max_completion_tokens = 64
|
||||
name = "color-codeword"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "color-codeword-v1"
|
||||
id = "color-codeword"
|
||||
images_per_turn = 1
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
|
||||
@@ -32,7 +32,7 @@ CUDA_VISIBLE_DEVICES=1 uv run inference \
|
||||
|
||||
## Run the debug configs
|
||||
|
||||
Every config writes to the default `outputs/` directory, so running two back-to-back — or re-running one — fails with `FileExistsError`. Pass a distinct `--output-dir outputs/<algo>` per config (recommended for a sweep) or `--clean-output-dir` to wipe and restart.
|
||||
Every config writes to the default `outputs/` directory, so running two back-to-back — or re-running one — fails with `FileExistsError`. Pass a distinct `--output-dir outputs/<algo>` per config (recommended for a sweep) or `--clean` to wipe and restart.
|
||||
|
||||
```bash
|
||||
# GRPO (no frozen model)
|
||||
|
||||
@@ -8,7 +8,7 @@ seq_len = 4096
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "algorithms-debug"
|
||||
name = "debug-echo"
|
||||
|
||||
@@ -28,7 +28,7 @@ alpha = 0.1
|
||||
name = "alphabet-sort"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "alphabet-sort-v1"
|
||||
id = "alphabet-sort"
|
||||
min_turns = 3
|
||||
max_turns = 5
|
||||
|
||||
@@ -44,12 +44,6 @@ type = "subprocess"
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 512
|
||||
|
||||
# ECHO learns from observation tokens even when the GRPO advantage collapses
|
||||
# to zero — keep zero-advantage rollouts in the batch.
|
||||
[[orchestrator.post_batch_filters]]
|
||||
type = "zero_advantage"
|
||||
enforce = false
|
||||
|
||||
# Fine-tune inherits the PrimeIntellect Qwen3 template byte-for-byte.
|
||||
[orchestrator.renderer]
|
||||
name = "prime-qwen3"
|
||||
|
||||
@@ -4,7 +4,7 @@ seq_len = 2048
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "algorithms-debug"
|
||||
name = "debug-rl"
|
||||
|
||||
@@ -25,7 +25,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -44,7 +44,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -4,7 +4,7 @@ seq_len = 2048
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "algorithms-debug"
|
||||
name = "debug-max-rl"
|
||||
|
||||
@@ -25,7 +25,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -44,7 +44,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -14,7 +14,7 @@ seq_len = 2048
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "algorithms-debug"
|
||||
name = "debug-mixed-grpo-opd"
|
||||
|
||||
@@ -35,7 +35,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text-grpo"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -47,7 +47,7 @@ type = "subprocess"
|
||||
name = "reverse-text-opd"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -73,7 +73,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -11,7 +11,7 @@ seq_len = 2048
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "algorithms-debug"
|
||||
name = "debug-opd"
|
||||
|
||||
@@ -37,7 +37,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -56,7 +56,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -11,7 +11,7 @@ seq_len = 2048
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "algorithms-debug"
|
||||
name = "debug-opd-lora"
|
||||
|
||||
@@ -37,7 +37,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -56,7 +56,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -4,7 +4,7 @@ seq_len = 4096
|
||||
[model]
|
||||
name = "Qwen/Qwen3-0.6B"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "algorithms-debug"
|
||||
name = "debug-rae"
|
||||
|
||||
@@ -25,7 +25,7 @@ max_completion_tokens = 512
|
||||
name = "kuhn-poker"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "kuhn-poker-v1"
|
||||
id = "kuhn-poker"
|
||||
|
||||
[orchestrator.train.source.env.player0.harness]
|
||||
id = "null"
|
||||
@@ -50,7 +50,7 @@ max_completion_tokens = 512
|
||||
name = "kuhn-poker"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "kuhn-poker-v1"
|
||||
id = "kuhn-poker"
|
||||
|
||||
[orchestrator.eval.source.env.player0.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -10,7 +10,7 @@ seq_len = 2048
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "algorithms-debug"
|
||||
name = "debug-self-distill"
|
||||
|
||||
@@ -33,7 +33,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -52,7 +52,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -11,7 +11,7 @@ seq_len = 2048
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "algorithms-debug"
|
||||
name = "debug-sft"
|
||||
|
||||
@@ -42,7 +42,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -61,7 +61,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -11,7 +11,7 @@ seq_len = 2048
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "algorithms-debug"
|
||||
name = "debug-sft-lora"
|
||||
|
||||
@@ -42,7 +42,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -61,7 +61,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
# Concurrency-controller debug run: GLM-4.5-Air on the v1 `scaleswe` SWE taskset,
|
||||
# bash harness on a prime sandbox runtime, 1 train + 1 infer node, eval on 100
|
||||
# SWE-Bench Verified instances. Concurrency is fully default: the controller
|
||||
# derives its start from the measured KV budget and adapts from there — watch
|
||||
# the concurrency/* gauges in W&B or the "Concurrency ..." lines in the
|
||||
# orchestrator log.
|
||||
#
|
||||
# Inference serves FP8 via online per-tensor quantization of the bf16
|
||||
# checkpoint; weight broadcasts re-quantize through the same path on every
|
||||
# update. The trainer fits on one node via cp=4 (ulysses), full CPU optimizer
|
||||
# offload with the stateless sign-SGD optimizer, plus the memory improvements
|
||||
# from the GLM-5.1 prod run: LM-head token chunking, activation checkpointing
|
||||
# (freq=1) + activation offloading (max_inflight=1), and skip-gather /
|
||||
# skip-optimizer checkpointing. Router replay is enabled — GLM-4.5-Air is a
|
||||
# glm4_moe model, which supports routed_experts.
|
||||
#
|
||||
# GRPO uses the linear length penalty with the input-token and turns
|
||||
# coefficients set to 0.1.
|
||||
|
||||
max_steps = 1000
|
||||
seq_len = 131072
|
||||
|
||||
# Redirect compile/JIT caches to node-local /tmp (per user + job) to avoid
|
||||
# slow/contended shared-FS caches and FS lock deadlocks.
|
||||
[env_vars]
|
||||
TRITON_CACHE_DIR = "/tmp/.triton-cache"
|
||||
|
||||
[slurm]
|
||||
job_name = "debug-concurrency"
|
||||
partition = "all"
|
||||
# Clean up this run's orphaned prime sandboxes before launch (hardcoded label, matches the harness labels below).
|
||||
pre_run_command = 'timeout 120 prime sandbox delete --label "debug-concurrency" -y || true'
|
||||
|
||||
[deployment]
|
||||
type = "multi_node"
|
||||
num_train_nodes = 1
|
||||
num_infer_nodes = 1
|
||||
num_infer_replicas = 1
|
||||
|
||||
[monitors.wandb]
|
||||
project = "swe-ablations"
|
||||
name = "debug-concurrency"
|
||||
|
||||
[weight_broadcast]
|
||||
type = "nccl"
|
||||
timeout = 3600
|
||||
|
||||
[ckpt]
|
||||
interval = 50
|
||||
keep_last = 1
|
||||
|
||||
[resume]
|
||||
|
||||
# --- Trainer ---
|
||||
|
||||
[trainer]
|
||||
dist_timeout_seconds = 3600
|
||||
enable_router_replay = true
|
||||
|
||||
[model]
|
||||
name = "zai-org/GLM-4.5-Air"
|
||||
|
||||
[trainer.model]
|
||||
impl = "custom"
|
||||
attn = "flash_attention_3"
|
||||
cp = 4
|
||||
cp_style = "ulysses"
|
||||
optim_cpu_offload = false
|
||||
full_offload = true
|
||||
fused_lm_head_token_chunk_size = 1024
|
||||
|
||||
[trainer.model.ac]
|
||||
|
||||
[trainer.model.ac_offloading]
|
||||
max_inflight_activations = 1
|
||||
|
||||
[trainer.model.compile]
|
||||
|
||||
[trainer.ckpt]
|
||||
skip_gather_master_weights = true
|
||||
skip_optimizer = true
|
||||
|
||||
[trainer.optim]
|
||||
type = "sign_sgd"
|
||||
|
||||
# --- Orchestrator ---
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 128
|
||||
group_size = 8
|
||||
max_off_policy_steps = 32
|
||||
|
||||
[orchestrator.algo]
|
||||
type = "grpo"
|
||||
|
||||
[orchestrator.algo.length_penalty]
|
||||
type = "linear"
|
||||
num_output_tokens_weight = 0.0
|
||||
num_input_tokens_weight = 0.1
|
||||
num_turns_weight = 0.1
|
||||
|
||||
[orchestrator.renderer]
|
||||
name = "glm-4.5"
|
||||
thinking_retention = "all"
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "scaleswe"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "scaleswe"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
labels = ["debug-concurrency"]
|
||||
|
||||
[monitors.prime]
|
||||
|
||||
# --- Eval: SWE-Bench Verified at step 0 + every 20 steps, rlm harness on prime ---
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 20
|
||||
|
||||
[[orchestrator.eval.source]]
|
||||
name = "swebench-verified"
|
||||
num_examples = 100
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
labels = ["debug-concurrency"]
|
||||
|
||||
[orchestrator.eval.source.env.agent.timeout]
|
||||
rollout = 3600
|
||||
|
||||
# --- Inference ---
|
||||
|
||||
[inference]
|
||||
|
||||
|
||||
# vLLM + FlashInfer caches on node-local /tmp (see [env_vars]).
|
||||
[inference.env_vars]
|
||||
VLLM_CACHE_ROOT = "/tmp/.vllm-cache"
|
||||
FLASHINFER_WORKSPACE_BASE = "/tmp/.flashinfer-cache"
|
||||
|
||||
[inference.vllm]
|
||||
max_model_len = 131072
|
||||
tensor_parallel_size = 8
|
||||
quantization = "fp8"
|
||||
enable_return_routed_experts = true
|
||||
@@ -21,7 +21,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text-a"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -33,7 +33,7 @@ type = "subprocess"
|
||||
name = "reverse-text-b"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -52,7 +52,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
+1
Submodule deps/prime-envs added at b30aad3637
Vendored
+1
-1
Submodule deps/pydantic-config updated: 4f5ae37358...65b15dffba
Vendored
+1
-1
Submodule deps/renderers updated: 2a7e77eb14...2846a3dcd2
Vendored
-1
Submodule deps/research-environments deleted from b10db7640b
Vendored
+1
-1
Submodule deps/verifiers updated: 29e3a0f7a3...6bcedc7625
+45
-32
@@ -1,6 +1,6 @@
|
||||
# Algorithms
|
||||
|
||||
This page covers the math and the configurable algorithmic components: the algorithm abstraction and its algorithms, how off-policy training works, the loss components and advantage functions, how to plug in your own, the filters applied between rollout and training, and how multi-turn rollouts get merged into training samples.
|
||||
This page covers the math and the configurable algorithmic components: the algorithm abstraction and its algorithms, how off-policy training works, the loss components and advantage functions, curricula, and how multi-turn rollouts get merged into training samples.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
@@ -21,7 +21,7 @@ This page covers the math and the configurable algorithmic components: the algor
|
||||
- [Self-Play Advantage (RAE)](#self-play-advantage-rae)
|
||||
- [Authoring an Algorithm](#authoring-an-algorithm)
|
||||
- [Reference Scoring](#reference-scoring)
|
||||
- [Filters](#filters)
|
||||
- [Curricula](#curricula)
|
||||
- [Multi-Turn Trajectories](#multi-turn-trajectories)
|
||||
- [Extension Property](#extension-property)
|
||||
- [Best-Effort Interleaving](#best-effort-interleaving)
|
||||
@@ -126,7 +126,7 @@ type = "grpo"
|
||||
name = "math" # inherits the top-level grpo
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "math-v1"
|
||||
id = "math"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -138,7 +138,7 @@ type = "subprocess"
|
||||
name = "terminal"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "terminal-v1"
|
||||
id = "terminal"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "bash"
|
||||
@@ -164,12 +164,12 @@ At runtime, each env's resolved config builds two objects: a `Sampler` (`prime_r
|
||||
| `hierarchical_grpo` | `HierarchicalGRPOAlgorithm` | `score_group`: GRPO baseline per episode for solvers, per group for the proposer |
|
||||
| `opd` | `OPDAlgorithm` | `score_rollout`: own-context prefill under the teacher |
|
||||
| `opsd` | `OPSDAlgorithm` | `score_rollout`: demo-conditioned prefill under the live policy |
|
||||
| `sft` | `SFTDistillAlgorithm` | `score_group`: group-norm credit (feeds filters) |
|
||||
| `sft` | `SFTDistillAlgorithm` | no credit assignment; CE on sampled tokens |
|
||||
|
||||
Each class owns its hooks outright — reading one top to bottom reads the algorithm, and everything on the class is an override point. The two hooks are one scope-and-timing ladder — the wider scope is unlocked by a later barrier, so the two axes coincide. Each is handed the `Rollout` directly — the env's typed trace (`reward`, `nodes`, `num_turns`, ...) with `samples` attached, plus `assign_advantages` to write credit:
|
||||
|
||||
- `async score_rollout(rollout)` — one rollout, **on arrival** (as it's tokenized, before its group is complete): rollout-local credit (`rollout.assign_advantages(...)`, scalar broadcast or per-token), observation ce weights, **or** model I/O — query a reference pool (e.g. `self.teacher_pool`, connected in `setup()` via `self.connect(...)`, or the live `self.policy_pool` for opsd) and attach per-token results (e.g. teacher logprobs) with bounded concurrency. No siblings. `echo` weights observation tokens here, identifying env-provided observation nodes by their non-sampled status and source step role attribution, applying the optional user filter, and writing the `ce_weights` stream. Model I/O runs *before* the pre-batch filters, so it pays compute on rollouts that may then be filtered out.
|
||||
- `score_group(group)` — the cohort, **before filtering** (filters read the streams), synchronous: group-relative credit (GRPO/MaxRL baselines). `group` is a list of `Rollout`.
|
||||
- `async score_rollout(rollout)` — one rollout, **on arrival** (as it's tokenized, before its group is complete): rollout-local credit (`rollout.assign_advantages(...)`, scalar broadcast or per-token), observation ce weights, **or** model I/O — query a reference pool (e.g. `self.teacher_pool`, connected in `setup()` via `self.connect(...)`, or the live `self.policy_pool` for opsd) and attach per-token results (e.g. teacher logprobs) with bounded concurrency. No siblings. `echo` weights observation tokens here, identifying env-provided observation nodes by their non-sampled status and source step role attribution, applying the optional user filter, and writing the `ce_weights` stream.
|
||||
- `score_group(group)` — the completed cohort, synchronous: group-relative credit (GRPO/MaxRL baselines). `group` is a list of `Rollout`.
|
||||
|
||||
The pipeline drives the hooks through two non-virtual methods it never looks inside: `algorithm.finalize_rollout(rollout)` per arrival (rollout-local scoring + reference I/O) and `algorithm.finalize_group(rollouts)` per group (scoring + wire stamping; after this the records are frozen — groups die at stamping). Sample construction (interleaving) is pure pipeline — observation-token provenance is available through structural attribution (`node.sampled`, `node.is_content`) for any algorithm that trains on env-provided tokens.
|
||||
|
||||
@@ -305,8 +305,8 @@ The per-token training signal is set by `algo.type` and the [algorithm](#the-alg
|
||||
| `rae` | `rl` | Reward minus a per-agent EMA baseline (SPIRAL's role-conditioned advantage estimation) — for multi-agent self-play envs. |
|
||||
| `hierarchical_grpo` | `rl` | GRPO for proposer-solver envs: solvers are compared within one proposed problem, while proposers are compared across proposals. |
|
||||
| `echo` | `rl` + `ce` | Group-norm on action tokens, plus weighted CE on env-provided tokens selected by message role (each role's `alpha` is its ECHO λ), optionally narrowed by a user filter. |
|
||||
| `opd` | `ref_kl` | On-policy distillation: per-token reverse KL to a reference model (`teacher`, an inline frozen hosted model), evaluated in the trainer from shipped reference logprobs. No credit — rollouts keep `advantages = None` (advantage-based filters never fire) and ship no advantage stream; `group_size` only fans out sampling. |
|
||||
| `opsd` | `ref_kl` | SDFT: per-token reverse KL to a demo-conditioned reference. No credit — rollouts keep `advantages = None` (advantage-based filters never fire) and ship no advantage stream. |
|
||||
| `opd` | `ref_kl` | On-policy distillation: per-token reverse KL to a reference model (`teacher`, an inline frozen hosted model), evaluated in the trainer from shipped reference logprobs. No credit — rollouts keep `advantages = None` and ship no advantage stream; `group_size` only fans out sampling. |
|
||||
| `opsd` | `ref_kl` | SDFT: per-token reverse KL to a demo-conditioned reference. No credit — rollouts keep `advantages = None` and ship no advantage stream. |
|
||||
| `sft` | `ce` | Cross-entropy on the sampled tokens. Assigns no advantage — trains on every sampled token. |
|
||||
|
||||
### Default Advantage
|
||||
@@ -354,7 +354,7 @@ The solver attempts for A should not be compared with the solver attempts for B:
|
||||
|
||||
For example, if three solvers receive rewards `[1, 1, 0]` on one proposed problem, their average is `2/3` and their advantages are `[1/3, 1/3, -2/3]`. Solver rewards from other proposed problems do not affect those values. The proposers are scored separately according to how useful their problems were for the solvers, then compared with the other proposers in the group.
|
||||
|
||||
Configure which roles are compared within a single proposed problem with `episode_agents`. For `proposer-solver-v1`, that role is `solver`:
|
||||
Configure which roles are compared within a single proposed problem with `episode_agents`. For `proposer-solver`, that role is `solver`:
|
||||
|
||||
```toml
|
||||
[orchestrator.algo]
|
||||
@@ -367,7 +367,7 @@ group_size = 4 # proposed problems per source task
|
||||
env.n = 4 # solver attempts per proposed problem
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "proposer-solver-v1"
|
||||
id = "proposer-solver"
|
||||
|
||||
[orchestrator.train.source.env.proposer.harness]
|
||||
id = "null"
|
||||
@@ -382,7 +382,7 @@ id = "null"
|
||||
type = "subprocess"
|
||||
```
|
||||
|
||||
`group_size` controls how many problems are proposed from each source task. `env.n` controls how many solvers attempt each proposed problem. If a comparison contains only one trace—for example, a solver when `env.n = 1`—its advantage is zero and the zero-advantage filter removes it.
|
||||
`group_size` controls how many problems are proposed from each source task. `env.n` controls how many solvers attempt each proposed problem. If a comparison contains only one trace—for example, a solver when `env.n = 1`—its advantage is zero.
|
||||
|
||||
This algorithm is accepted only for proposer-solver envs. Use the env's `train_proposer` and `train_solver` settings if you want to train only one role.
|
||||
|
||||
@@ -401,7 +401,7 @@ decay = 0.95
|
||||
name = "kuhn-poker"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "kuhn-poker-v1"
|
||||
id = "kuhn-poker"
|
||||
|
||||
[orchestrator.train.source.env.player0.harness]
|
||||
id = "null"
|
||||
@@ -416,7 +416,7 @@ id = "null"
|
||||
type = "subprocess"
|
||||
```
|
||||
|
||||
Both of `kuhn-poker-v1`'s agents late-bind to the run's own model — shared-policy self-play against a continuously improving opponent. Pin one agent to a frozen endpoint (`env.player1.model = ...`) for asymmetric play; its traces are marked untrainable by the env and never reach the advantage computation. A single-agent env under `rae` degrades to REINFORCE with an EMA baseline.
|
||||
Both of `kuhn-poker`'s agents late-bind to the run's own model — shared-policy self-play against a continuously improving opponent. Pin one agent to a frozen endpoint (`env.player1.model = ...`) for asymmetric play; its traces are marked untrainable by the env and never reach the advantage computation. A single-agent env under `rae` degrades to REINFORCE with an EMA baseline.
|
||||
|
||||
### Authoring an Algorithm
|
||||
|
||||
@@ -439,7 +439,7 @@ class MyAlgorithm(Algorithm):
|
||||
|
||||
Add a typed `MyAlgoConfig` to `prime_rl.configs.algorithm` and its discriminated union, then register `"my_algo": MyAlgorithm` in `ALGORITHM_CLASSES`. Pick the hook by *when* your signal is ready: `score_rollout` for per-arrival credit or credit that needs a model call (it's `async`), `score_group` for group-relative credit (GRPO/MaxRL). `assign_advantages` takes a scalar (broadcast over the rollout's trainable tokens — the common case) or a full-length per-token list aligned to the concatenated sample token_ids (process rewards, step-level credit; `0.0` off-mask).
|
||||
|
||||
Each per-token list must match the rollout's completion-token count exactly — validated loudly when the view writes it. Advantage-based filters and metrics derive from the streams (the zero-advantage filter checks for all-zero streams; logged distributions use per-rollout means). Signals that depend on the live policy's weights (like OPD's reverse KL) cannot be precomputed here; those are reference-scoring algorithms, evaluated in the trainer.
|
||||
Each per-token list must match the rollout's completion-token count exactly — validated loudly when the view writes it. Curriculum admission and metrics can inspect these streams after group scoring. Signals that depend on the live policy's weights (like OPD's reverse KL) cannot be precomputed here; those are reference-scoring algorithms, evaluated in the trainer.
|
||||
|
||||
### Reference Scoring
|
||||
|
||||
@@ -454,34 +454,47 @@ type = "opsd"
|
||||
demo_key = "demonstration"
|
||||
```
|
||||
|
||||
Scoring runs at arrival, *before* the pre-batch filters, so a rollout that is later filtered still cost its reference compute — accepted for the simpler one-rollout-at-a-time shape (advantage-based filters never fire for opd/opsd anyway, since neither assigns an advantage).
|
||||
Scoring runs at arrival, before curriculum admission, so a rollout that is later rejected still costs its reference compute.
|
||||
|
||||
## Filters
|
||||
By default, zero-advantage RL tokens are removed after a complete batch cohort has been collected and before its payload is packed for the trainer. This does not backfill the batch. Samples that still carry CE or reference-KL components are retained, while pure zero-advantage RL samples are not shipped. Removing an RL token also removes its trainer/inference mismatch-KL contribution. Set `orchestrator.train.filter_zero_advantages = false` to retain them.
|
||||
|
||||
Filters drop rollouts between scoring and training. Built-ins (composable):
|
||||
## Curricula
|
||||
|
||||
| Filter | Effect |
|
||||
|---|---|
|
||||
| `gibberish` | Drops rollouts whose mean log-prob fall below a threshold — usually a sign of degenerate output. |
|
||||
| `repetition` | Drops rollouts with high n-gram repetition. |
|
||||
| `zero_advantage` | Drops rollouts whose advantage is zero, so the trainer doesn't waste tokens on them. |
|
||||
Each training source has a `Curriculum` composed from one `TaskSampler` and any number of named `AdmissionGate`s. The sampler chooses tasks and observes every finalized result. Every gate evaluates every result; the group trains only if every gate admits it. Rejected groups remain observable while the orchestrator samples again to fill the batch.
|
||||
|
||||
The default `[orchestrator]` config registers all three in both filter slots: `post_batch_filters` enforce by default (flagged rollouts are recorded but not shipped to the trainer), while `pre_batch_filters` run in monitor mode (`enforce = false`); flip `enforce = true` there to drop matching rollouts before they consume a slot in the batch. Setting a slot replaces its defaults wholesale:
|
||||
Samplers and gates can be stateful. Their `state_dict`, `load_state_dict`, and `metrics` methods are included in orchestrator checkpoints and logged under `curriculum/<env>/`.
|
||||
|
||||
Three small implementations are included:
|
||||
|
||||
- `StandardSampler` is the default: it advances the task iterator and cycles finite tasksets in source order.
|
||||
- `DifficultyPoolSampler` samples finite tasksets with replacement and tracks each task's latest valid mean group reward. Each named pool has an inclusive reward threshold and a relative per-task sampling weight; weight `0` disables sampling from that pool. Unseen tasks use neutral weight `1.0`, so pool observations affect sampling immediately without waiting for a full taskset pass.
|
||||
- `AdvRangeGate` rejects a group when every trainable-token advantage falls inside `reject_min` through `reject_max`. Unlike the built-in post-batch zero-advantage filtering, rejection requests replacement work. Groups without an advantage stream are admitted.
|
||||
|
||||
```toml
|
||||
[[orchestrator.post_batch_filters]]
|
||||
type = "zero_advantage"
|
||||
[orchestrator.train.source.curriculum.sampler]
|
||||
type = "difficulty_pool"
|
||||
|
||||
[[orchestrator.post_batch_filters]]
|
||||
type = "repetition"
|
||||
threshold = 0.4
|
||||
[orchestrator.train.source.curriculum.sampler.pools.hard]
|
||||
threshold = 0.25
|
||||
weight = 0.2
|
||||
|
||||
[orchestrator.train.source.curriculum.sampler.pools.normal]
|
||||
threshold = 0.75
|
||||
weight = 1.0
|
||||
|
||||
[orchestrator.train.source.curriculum.sampler.pools.easy]
|
||||
threshold = 1.0
|
||||
weight = 0.2
|
||||
|
||||
[orchestrator.train.source.curriculum.gates.low_signal]
|
||||
type = "advantage_range"
|
||||
reject_min = -0.05
|
||||
reject_max = 0.05
|
||||
```
|
||||
|
||||
Filtered rollouts still appear in W&B distributions, just not in the trainer batch — useful for spotting whether filtering is doing its job.
|
||||
|
||||
## Multi-Turn Trajectories
|
||||
|
||||
Multi-turn rollouts (tool use, browser environments, long conversations) used to be stitched into a single fake "single-turn" sample, which silently corrupted the importance ratio when chat templates didn't roundtrip. Since [`verifiers` v0.1.8](https://github.com/PrimeIntellect-ai/verifiers/releases/tag/v0.1.8), `prime-rl` records each LLM request/response as an independent **trajectory step** and merges them at training time using best-effort interleaving — with [renderers](#renderers) as the mechanism that keeps the merge safe by construction.
|
||||
For multi-turn rollouts (tool use, browser environments, long conversations), `prime-rl` records each LLM request/response as an independent **trajectory step** and merges them at training time using best-effort interleaving — with [renderers](#renderers) as the mechanism that keeps the merge safe by construction.
|
||||
|
||||
### Extension Property
|
||||
|
||||
|
||||
+13
-12
@@ -61,7 +61,7 @@ CLI flags mirror the TOML tree using dots:
|
||||
|
||||
```bash
|
||||
uv run rl --help # full schema
|
||||
uv run rl @ rl.toml --dry-run --output-dir /tmp/check # write resolved configs
|
||||
uv run rl @ rl.toml --dry-run --output-dir /tmp --run.name check # write resolved configs (JSON) to /tmp/check/configs
|
||||
```
|
||||
|
||||
## Syntax
|
||||
@@ -71,12 +71,12 @@ uv run rl @ rl.toml --dry-run --output-dir /tmp/check # write resolved configs
|
||||
CLI uses paired flags: bare `--flag` sets `True`, `--no-flag` sets `False`. TOML must be explicit:
|
||||
|
||||
```bash
|
||||
uv run rl @ rl.toml --clean-output-dir # True
|
||||
uv run rl @ rl.toml --no-clean-output-dir # False
|
||||
uv run rl @ rl.toml --clean # True
|
||||
uv run rl @ rl.toml --no-clean # False
|
||||
```
|
||||
|
||||
```toml
|
||||
clean_output_dir = true
|
||||
clean = true
|
||||
```
|
||||
|
||||
### Lists
|
||||
@@ -155,7 +155,7 @@ name = "gsm8k"
|
||||
ratio = 3 # 75% of batches
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "gsm8k-v1"
|
||||
id = "gsm8k"
|
||||
split = "train"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
@@ -169,7 +169,7 @@ name = "reverse-text"
|
||||
ratio = 1 # default — 25% of batches
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -181,7 +181,7 @@ type = "subprocess"
|
||||
name = "gsm8k-eval"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "gsm8k-v1"
|
||||
id = "gsm8k"
|
||||
split = "test"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
@@ -218,7 +218,7 @@ PYTORCH_CUDA_ALLOC_CONF = "expandable_segments:False"
|
||||
VLLM_USE_DEEP_GEMM = "1"
|
||||
|
||||
[orchestrator.env_vars]
|
||||
PI_USAGE_BASE_URL = "https://..."
|
||||
PRIME_LOG_LEVEL = "debug"
|
||||
```
|
||||
|
||||
The `rl` launcher applies these the same way in both single-node and multi-node (SLURM) runs. Precedence, low to high:
|
||||
@@ -257,17 +257,18 @@ Start from a shipped base config, override two fields on the CLI, and dry-run:
|
||||
|
||||
```bash
|
||||
uv run rl @ examples/basic/reverse-text/rl.toml \
|
||||
--wandb.name my-experiment \
|
||||
--monitors.wandb.name my-experiment \
|
||||
--trainer.optim.lr 5e-6 \
|
||||
--output-dir /tmp/reverse-dry \
|
||||
--run.name check \
|
||||
--dry-run
|
||||
```
|
||||
|
||||
Then inspect the resolved config:
|
||||
|
||||
```bash
|
||||
ls /tmp/reverse-dry/configs/
|
||||
# rl.toml trainer.toml orchestrator.toml inference.toml
|
||||
ls /tmp/reverse-dry/check/configs/
|
||||
# rl.json trainer.json orchestrator.json inference.json
|
||||
```
|
||||
|
||||
Each per-process TOML reflects the final, validated configuration that the actual run would consume — exactly what each process sees when started standalone (`uv run trainer @ /tmp/reverse-dry/configs/trainer.toml`, etc.). This is the easiest way to bisect a misbehaving config: dry-run a known-good base, dry-run your overlay, diff the two.
|
||||
Each per-process TOML reflects the final, validated configuration that the actual run would consume — exactly what each process sees when started standalone (`uv run trainer @ /tmp/reverse-dry/check/configs/trainer.json`, etc.). This is the easiest way to bisect a misbehaving config: dry-run a known-good base, dry-run your overlay, diff the two.
|
||||
|
||||
+14
-1
@@ -12,6 +12,7 @@ This page covers the inference configuration and the supported features/deployme
|
||||
- [P/D Disaggregation](#pd-disaggregation)
|
||||
- [Router](#router)
|
||||
- [Routing policies](#routing-policies)
|
||||
- [Adaptive Concurrency](#adaptive-concurrency)
|
||||
- [Advanced Configuration](#advanced-configuration)
|
||||
- [KV Cache Offload](#kv-cache-offload)
|
||||
- [Optimized P/D disaggregation deployment](#optimized-pd-disaggregation-deployment)
|
||||
@@ -72,7 +73,7 @@ data_parallel_size = 4
|
||||
type = "single_node"
|
||||
```
|
||||
|
||||
We reccomend choosing your parallelism based on the expected throughput and latency requirements. High `dp` might create high latency, however it will also give you the highest throughput. This is a tradeoff you need to make based on your use case and required `orchestrator.max_inflight_requests`. Setting `tp` to a higher value will usually give you lower latency, but the inference server also will become saturated faster with lower number of requests.
|
||||
We reccomend choosing your parallelism based on the expected throughput and latency requirements. High `dp` might create high latency, however it will also give you the highest throughput. This is a tradeoff you need to make based on your use case and required concurrency (see [Adaptive Concurrency](#adaptive-concurrency)). Setting `tp` to a higher value will usually give you lower latency, but the inference server also will become saturated faster with lower number of requests.
|
||||
|
||||
Another thing to consider, is the memory usage. You need to make sure that the model will fit into the available GPU memory. We will not go into the details on how to do this in this document. Related thing to consider, is the space for the KV cache. This will heavily affect the amount of requests your inference server can handle. You want to shard your model, either using `inference.vllm.enable_expert_parallel` or `inference.vllm.tensor_parallel_size` to maximize the available GPU memory.
|
||||
|
||||
@@ -203,6 +204,18 @@ X-Session-ID = "trajectory_id" # this is the default - each rollout has a unique
|
||||
- `round_robin` - this policy will round-robin the requests between the available replicas. This is useful if you want to balance the load between the replicas. This might give you better results if you don't have enough rollouts to make `consistent_hash` hashing saturated.
|
||||
|
||||
|
||||
## Adaptive Concurrency
|
||||
|
||||
The orchestrator continuously sizes how many episodes run against the inference engines at once. A static cap cannot be right: too low starves the engines, too high crosses into KV thrash — the engines evict prefix cache, re-prefill the evicted work, and throughput collapses. The optimal value depends on the model, the deployment, and the workload's episode lengths, and it moves as training changes the policy.
|
||||
|
||||
The controller's idea is to treat the engines as ground truth and probe, instead of modeling episode cost: while the engines show headroom, admit a little more; when they show pressure, back off. Three behaviors, in increasing severity:
|
||||
|
||||
- **Grow**: while the engines look healthy and the current cap is fully used, raise it multiplicatively. Growth is clocked by the pipeline itself — the cap rises by a fixed factor each time the in-flight pool has turned over once — so a fast single-turn workload ramps in seconds while a slow agentic workload ramps at its own pace, with no tuning per workload.
|
||||
- **Trim**: episodes grow their context *while running*, so a pool that fit comfortably an hour ago can outgrow memory without a single new admission. When KV usage nears the ceiling, the controller first lowers the cap and lets completions drain the pool naturally (soft — no work lost); only if usage keeps climbing despite the closed gate does it also cancel the youngest episodes (hard — least work lost).
|
||||
- **Cut**: when the engines are demonstrably overloaded — requests being preempted, or piling up in the waiting queue — cut the pool hard, cancel the excess, and hold further cuts until the system settles.
|
||||
|
||||
The cap starts from a safe bound derived from the engines (KV capacity divided by the maximum context length), or from `initial_inflight` when a good value is known, and always stays within `[min_inflight, max_inflight]`.
|
||||
|
||||
## Advanced Configuration
|
||||
|
||||
### KV Cache Offload
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ The three processes communicate through configurable transports — by default t
|
||||
curl -sSL https://raw.githubusercontent.com/PrimeIntellect-ai/prime-rl/main/scripts/install.sh | bash
|
||||
```
|
||||
|
||||
The script clones the repo, initializes the [`verifiers`](https://github.com/PrimeIntellect-ai/verifiers) / [`renderers`](https://github.com/PrimeIntellect-ai/renderers) / [`research-environments`](https://github.com/PrimeIntellect-ai/research-environments) submodules, installs `uv`, and runs `uv sync --all-extras`. For manual setup, or troubleshooting, see the [README](https://github.com/PrimeIntellect-ai/prime-rl#setup).
|
||||
The script clones the repo, initializes the [`verifiers`](https://github.com/PrimeIntellect-ai/verifiers) / [`renderers`](https://github.com/PrimeIntellect-ai/renderers) / [`prime-envs`](https://github.com/PrimeIntellect-ai/prime-envs) submodules, installs `uv`, and runs `uv sync --all-extras`. For manual setup, or troubleshooting, see the [README](https://github.com/PrimeIntellect-ai/prime-rl#setup).
|
||||
|
||||
You need at least one NVIDIA GPU (RTX 3090/4090/5090, A100, H100, H200, or B200). Single-GPU runs are supported for debugging; production RL is typically 1× inference node + 1+ trainer nodes.
|
||||
|
||||
@@ -32,7 +32,7 @@ Train an SFT-warmed `Qwen3-0.6B` on the `reverse-text` task — the env is bundl
|
||||
uv run rl @ examples/basic/reverse-text/rl.toml
|
||||
```
|
||||
|
||||
The `rl` entrypoint reads `examples/basic/reverse-text/rl.toml`, splits it into per-process sub-configs, picks GPU 0 for inference and GPU 1 for the trainer, launches all three processes, and tees their stdout into `outputs/logs/{trainer,orchestrator,inference}.log`. Within a minute the trainer should log `step 1` and a reward sample; after 20 steps the run completes and final HF-compatible weights land at `outputs/weights/step_20`.
|
||||
The `rl` entrypoint reads `examples/basic/reverse-text/rl.toml`, splits it into per-process sub-configs, picks GPU 0 for inference and GPU 1 for the trainer, launches all three processes, and tees their stdout into the run directory at `outputs/<run_name>/logs/{trainer,orchestrator,inference}.log` (`run.name` auto-generates as `<envs>--<model>--<short-id>`; pass `--run.name <name>` for a predictable path). Within a minute the trainer should log `step 1` and a reward sample; after 20 steps the run completes and final HF-compatible weights land at `outputs/<run_name>/weights/step_20`.
|
||||
|
||||
## Documentation
|
||||
|
||||
|
||||
+10
-24
@@ -48,14 +48,14 @@ For quick A/B ablations on the same node, run two RL instances side-by-side in s
|
||||
```bash
|
||||
# session 1, GPUs 0–1, default port 8000
|
||||
bash scripts/tmux.sh -s exp1 -o outputs/exp1
|
||||
CUDA_VISIBLE_DEVICES=0,1 uv run rl @ rl.toml --output-dir outputs/exp1
|
||||
CUDA_VISIBLE_DEVICES=0,1 uv run rl @ rl.toml --run.name exp1
|
||||
|
||||
# session 2, GPUs 2–3, port 8001
|
||||
bash scripts/tmux.sh -s exp2 -o outputs/exp2
|
||||
CUDA_VISIBLE_DEVICES=2,3 uv run rl @ rl.toml \
|
||||
--inference.server.port 8001 \
|
||||
--orchestrator.model.client.base-url http://localhost:8001/v1 \
|
||||
--output-dir outputs/exp2
|
||||
--run.name exp2
|
||||
```
|
||||
|
||||
#### SFT and Torchrun
|
||||
@@ -69,7 +69,7 @@ uv run torchrun \
|
||||
src/prime_rl/trainer/sft/train.py @ sft.toml
|
||||
```
|
||||
|
||||
`--local-ranks-filter 0` keeps console output to rank 0 only; per-rank stdout/stderr is still captured in `<output_dir>/logs/trainer/torchrun/`.
|
||||
`--local-ranks-filter 0` keeps console output to rank 0 only; per-rank stdout/stderr is still captured in `<run_dir>/logs/latest/trainer/torchrun/`.
|
||||
|
||||
### Multi-Node
|
||||
|
||||
@@ -86,7 +86,8 @@ FSDP2 is the default model sharding strategy. By default the trainer fully shard
|
||||
| `trainer.model.dp_replicate` | Number of dimensions to **replicate** instead of shard. Set to 2 to run 2-way DP replication × FSDP sharding within each replica — useful for very large clusters where pure FSDP communication dominates. |
|
||||
| `trainer.model.reshard_after_forward` | If `true` (default), parameters are resharded after the forward pass to free memory; the backward pass re-gathers. Set `false` to keep params resident — faster but more memory. |
|
||||
| `trainer.model.fsdp_cpu_offload` | Offload params + grads + optimizer state to CPU. Big memory win, large throughput hit. |
|
||||
| `trainer.model.optim_cpu_offload` | Offload only optimizer state. Mid-ground — small throughput cost, decent memory savings, especially at low GPU count. |
|
||||
| `trainer.model.optim_cpu_offload` | Offload optimizer state to CPU between steps. Enabled by default. |
|
||||
| `trainer.model.full_offload` | Offload gradients, FP32 masters, and optimizer state and run the optimizer (AdamW or SignSGD) on CPU during backward. Disabled by default. |
|
||||
|
||||
### Expert Parallelism
|
||||
|
||||
@@ -137,14 +138,7 @@ targets = ["norm", "attn_proj"] # see Reference for the full list per architect
|
||||
|
||||
### Optimizer Offloading
|
||||
|
||||
Offloading optimizer states to CPU is enabled by default (`optim_cpu_offload = true`) — a near-free memory win at low GPU counts:
|
||||
|
||||
```toml
|
||||
[trainer.model]
|
||||
optim_cpu_offload = true # already the default
|
||||
```
|
||||
|
||||
Mutually exclusive with `fsdp_cpu_offload`. Muon doesn't support `fsdp_cpu_offload` but does support `optim_cpu_offload`.
|
||||
State-only optimizer offload remains enabled by default with `model.optim_cpu_offload = true`. For full offload, set `model.optim_cpu_offload = false` and `model.full_offload = true`; this keeps BF16 compute weights on GPU and runs CPU optimizer chunks as gradients become ready during backward. Full offload only supports AdamW and SignSGD (`optim.type = "sign_sgd"`) and disables gradient clipping. SignSGD is stateless, so it halves the host RAM footprint versus AdamW (8 instead of 16 bytes per parameter: FP32 master + FP32 accumulated gradient, no moments).
|
||||
|
||||
### LM Head Chunking
|
||||
|
||||
@@ -245,22 +239,14 @@ The default templates live under [`src/prime_rl/templates/`](https://github.com/
|
||||
|
||||
## Benchmarking
|
||||
|
||||
Every entrypoint supports a `--bench` flag that runs a few warm-up + measurement steps with fake data and prints a rich-formatted throughput / MFU table:
|
||||
To benchmark a parallelism config before committing a multi-day run, run a short training with fake data and a step cap, and read throughput / MFU / step time / peak memory from the logs:
|
||||
|
||||
```bash
|
||||
# SFT trainer alone
|
||||
uv run sft @ sft.toml --bench
|
||||
uv run sft ... --data.type fake --data.length variable --bench # variable-length fake data
|
||||
uv run sft @ sft.toml --data.type fake --max-steps 4
|
||||
|
||||
# RL trainer alone (no inference involved)
|
||||
uv run trainer @ train.toml --data.fake --bench
|
||||
|
||||
# Inference alone — start the server normally, then bench the orchestrator
|
||||
uv run inference @ infer.toml
|
||||
uv run orchestrator @ orch.toml --bench
|
||||
|
||||
# Full RL stack (trainer with fake data, inference with real data from orchestrator)
|
||||
uv run rl @ rl.toml --bench
|
||||
uv run trainer @ train.toml --data.fake --max-steps 4
|
||||
```
|
||||
|
||||
Persist results with `--bench.output-json`. Use this to compare parallelism configs before committing a multi-day run.
|
||||
Every step logs `Throughput`, `MFU`, and `Peak Mem.` to the console. For machine-readable numbers, the file monitor writes `metrics.jsonl` to the run's output directory by default (`monitors.file`); aggregate `perf/throughput`, `perf/mfu`, `time/step`, and `perf/peak_memory` from the run's `metrics.jsonl` — skip the first step, it is warmup. [`benchmarks/scripts/run_single_benchmark.py`](https://github.com/PrimeIntellect-ai/prime-rl/blob/main/benchmarks/scripts/run_single_benchmark.py) does exactly this and is what the CI benchmark matrix runs.
|
||||
|
||||
+99
-46
@@ -70,17 +70,18 @@ A condensed view of the knobs you'll most often tune. For trainer-side paralleli
|
||||
|---|---|
|
||||
| `log.level` | Process log level for trainer + orchestrator (`info` default; falls back to `$PRIME_LOG_LEVEL`). Set per-process via `trainer.log.level` / `orchestrator.log.level`, or globally on the `rl` entrypoint to propagate to both. |
|
||||
| `orchestrator.log.vf_level` | Env-worker / [`verifiers`](https://github.com/PrimeIntellect-ai/verifiers) log level (`info` default; `debug` is noisy but useful for env debugging). |
|
||||
| `--wandb` (+ `--wandb.project`, `--wandb.name`) | Enable Weights & Biases logging. See [Weights & Biases](#weights--biases). |
|
||||
| `--orchestrator.prime-monitor` | Stream metrics to the Prime Intellect platform (Prime Lab). See [Platform monitoring](#platform-monitoring). |
|
||||
| `--monitors.wandb` (+ `--monitors.wandb.project`, `--monitors.wandb.name`) | Enable Weights & Biases logging. See [Weights & Biases](#weights--biases). |
|
||||
| `--monitors.prime` | Stream metrics and episodes to the Prime Intellect platform (Prime Lab). See [Platform monitoring](#platform-monitoring). |
|
||||
|
||||
**Run management:**
|
||||
|
||||
| Knob | What it does |
|
||||
|---|---|
|
||||
| `--clean-output-dir` | Wipe `<output_dir>` before starting. Useful when re-running an experiment with the same name during iteration. |
|
||||
| `--output-dir outputs/<name>` | Per-run output directory. Always set this when running more than one experiment in parallel. |
|
||||
| `--output-dir outputs` | Directory that groups related runs. Each run writes its artifacts to its own run directory `<output_dir>/<run_name>` (`<run_dir>` below). |
|
||||
| `--run.name <name>` | Run name, also the run directory name under `<output_dir>` (override the directory separately via `--run.dir`). Auto-generated as `<envs>--<model>--<short-id>` when unset, so every launch gets a fresh, readable run directory. Set an explicit name for a predictable path — required to resume the run later. |
|
||||
| `--clean` | Wipe the run directory before starting. Useful when re-running a named run during iteration. |
|
||||
| `--max-steps N` | Stop after `N` trainer steps. Overrides the config value. |
|
||||
| `--dry-run` | Resolve + validate the full config, write per-process TOMLs to `<output_dir>/configs/`, and exit without launching. The fastest way to debug a misbehaving config. |
|
||||
| `--dry-run` | Resolve + validate the full config, write per-process TOMLs to `<run_dir>/configs/`, and exit without launching. The fastest way to debug a misbehaving config. |
|
||||
|
||||
### Algorithms
|
||||
|
||||
@@ -90,7 +91,7 @@ The RL entrypoint supports several training algorithms, switched via `[orchestra
|
||||
|---|---|---|
|
||||
| `grpo` (default) | None | Standard group-relative RL |
|
||||
| `max_rl` | None | [MaxRL](https://arxiv.org/abs/2602.02710): GRPO with mean-normalized advantages (maximum-likelihood RL) |
|
||||
| `rae` | None | [SPIRAL](https://arxiv.org/abs/2506.24119)'s role-conditioned advantage estimation: reward minus a per-agent EMA baseline, for multi-agent self-play envs (e.g. `kuhn-poker-v1`) |
|
||||
| `rae` | None | [SPIRAL](https://arxiv.org/abs/2506.24119)'s role-conditioned advantage estimation: reward minus a per-agent EMA baseline, for multi-agent self-play envs (e.g. `kuhn-poker`) |
|
||||
| `hierarchical_grpo` | None | GRPO for proposer-solver envs: compare solvers only with attempts on the same proposed problem, and compare proposers with the other proposals in the group |
|
||||
| `opd` | Required, must be vLLM (needs `prompt_logprobs`) | [On-policy distillation](https://thinkingmachines.ai/blog/on-policy-distillation/): the policy generates rollouts, the trainer minimizes per-token reverse KL to a reference model |
|
||||
| `sft` | Required, any OpenAI-compatible endpoint | Hard-distill: a frozen model generates rollouts, the policy trains on its tokens |
|
||||
@@ -170,11 +171,60 @@ See [Algorithms § Multi-Turn Trajectories](algorithms.md#multi-turn-trajectorie
|
||||
The minimal SFT run trains `Qwen3-0.6B` on the `reverse-text` SFT dataset:
|
||||
|
||||
```bash
|
||||
uv run sft @ examples/basic/reverse-text/sft.toml --wandb
|
||||
uv run sft @ examples/basic/reverse-text/sft.toml --monitors.wandb
|
||||
```
|
||||
|
||||
Multi-GPU and multi-node use torchrun under the hood (the `sft` entrypoint manages this for you — see [Scaling § SFT and Torchrun](scaling.md#sft-and-torchrun) for non-default layouts; multi-node SFT goes through [SLURM](scaling.md#slurm)).
|
||||
|
||||
### Online Evals
|
||||
|
||||
`uv run sft` can evaluate the model on rollout-based envs as it trains, reusing the RL orchestrator's eval machinery. Configure an `[eval]` block — the same shape as `[orchestrator.eval]`: multiple `[[eval.source]]` envs with per-source `interval` / `num_examples` / `group_size` / sampling overrides — plus an `[inference]` block for the vLLM server:
|
||||
|
||||
```toml
|
||||
[eval]
|
||||
interval = 25
|
||||
num_examples = 32
|
||||
|
||||
[[eval.source]]
|
||||
name = "reverse-text"
|
||||
|
||||
[eval.source.env.taskset]
|
||||
id = "reverse-text"
|
||||
|
||||
[eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[eval.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[inference]
|
||||
|
||||
[deployment]
|
||||
num_train_gpus = 1 # trainer
|
||||
num_infer_gpus = 1 # inference
|
||||
```
|
||||
|
||||
The launcher starts the inference server, one env server per eval source, and an `evals` process next to the trainer. The handoff is the filesystem, not NCCL: the trainer writes an HF weight checkpoint at every step an eval env is due (in addition to `ckpt.interval`), and the evals process watches `weights/step_{n}`, points the inference server at each stable checkpoint (`/update_weights` reload from disk), and runs the due envs against it — sequentially per checkpoint, so every epoch measures exactly one policy version. The base model is evaluated before the first step (disable with `eval.skip_first_step`), and the final checkpoint always fires every env. In-flight eval episodes are sized by the same adaptive concurrency controller as the orchestrator; bound it with `[eval.concurrency]` (`min_inflight` / `max_inflight`; set them equal for fixed concurrency).
|
||||
|
||||
#### Multi-Node (Decoupled Trainer and Inference Pool)
|
||||
|
||||
On a `multi_node` deployment (SLURM), the trainer and the eval deployment are **two independent SLURM jobs**. `deployment.num_nodes` sizes the trainer job; `deployment.num_infer_nodes` sizes the eval job, which runs the inference pool (one vLLM engine per DP rank behind a single router, `gpus_per_node / inference.vllm.tensor_parallel_size` engines per node), one env server per eval source, and the evals process:
|
||||
|
||||
```toml
|
||||
[deployment]
|
||||
type = "multi_node"
|
||||
num_train_nodes = 2 # trainer job
|
||||
num_infer_nodes = 1 # eval job (inference pool + evals)
|
||||
|
||||
[inference.vllm]
|
||||
tensor_parallel_size = 8
|
||||
|
||||
[slurm]
|
||||
job_name = "my-run"
|
||||
```
|
||||
|
||||
The only coupling is weight checkpoints on the shared filesystem, so the jobs' lifetimes are independent: when training finishes, the trainer job exits and releases its nodes even while evals are still running; the eval job keeps draining pending checkpoints and exits after evaluating the final one (`max_steps` — without it the eval job never sees a final checkpoint and holds its allocation until walltime). Trainer and evals log to a single shared W&B run across both jobs — the trainer creates it, the evals process finalizes it. Any train × inference layout works: `num_nodes` and `num_infer_nodes` are fully independent.
|
||||
|
||||
### SFT-Specific Knobs
|
||||
|
||||
| Knob | What it controls |
|
||||
@@ -184,6 +234,7 @@ Multi-GPU and multi-node use torchrun under the hood (the `sft` entrypoint manag
|
||||
| `data.seq_len` | Per-sample sequence length |
|
||||
| `loss_mask.*` | Which roles contribute to loss (system / user / assistant / tool). |
|
||||
| `val.interval` | Run validation every N steps; `val.data` mirrors `data` |
|
||||
| `eval.interval` | Run online evals every N steps; see [Online Evals](#online-evals) |
|
||||
|
||||
### Important Metrics
|
||||
|
||||
@@ -191,15 +242,16 @@ Pulled from the console log and mirrored to W&B.
|
||||
|
||||
**Progress and loss:**
|
||||
|
||||
- `loss/mean` — main signal. Should decrease through the run.
|
||||
- `val/loss` — validation loss when `[val]` is set, logged every `val.interval` steps.
|
||||
- `loss/mean`, `loss/perplexity` — main signal. Should decrease through the run.
|
||||
- `val/loss`, `val/perplexity` — validation metrics when `[val]` is set, logged every `val.interval` steps.
|
||||
- `eval/{env}/...` — online eval metrics when `[eval]` is set, logged at each evaluated checkpoint step.
|
||||
- `progress/epoch`, `progress/num_samples`, `progress/num_tokens` — dataset progress.
|
||||
- `progress/<subset>/ratio_{samples,tokens}` — when training on multiple HF subsets/splits, the realized mixing ratio.
|
||||
|
||||
**Stability and optimization:**
|
||||
|
||||
- `optim/grad_norm` — spikes precede divergence.
|
||||
- `optim/lr`, `optim/zero_grad_ratio` — LR schedule and the fraction of params that received zero gradients (high → dead path or wrong loss masking).
|
||||
- `optim/lr` — LR schedule.
|
||||
- For MoE: `max_vio/mean` (load-balancing violation), `routing_confidence/mean` — both are logged when non-zero.
|
||||
|
||||
**Performance:**
|
||||
@@ -217,10 +269,10 @@ Checkpointing is split across processes because the orchestrator and trainer can
|
||||
|
||||
| Process | What's saved | Where |
|
||||
|---|---|---|
|
||||
| Trainer | FSDP-sharded model (DCP), optimizer, scheduler, progress | `<output_dir>/checkpoints/step_N/trainer/` |
|
||||
| Orchestrator | Progress, per-env data state | `<output_dir>/checkpoints/step_N/orchestrator/` |
|
||||
| Trainer | FSDP-sharded model (DCP), optimizer, scheduler, progress | `<run_dir>/checkpoints/step_N/trainer/` |
|
||||
| Orchestrator | Progress, per-env data state | `<run_dir>/checkpoints/step_N/orchestrator/` |
|
||||
| Inference | _nothing_ — re-pushed from the latest checkpoint on restart | n/a |
|
||||
| Trainer (HF weights) | HF-compatible weight snapshot for serving | `<output_dir>/weights/step_N/` |
|
||||
| Trainer (HF weights) | HF-compatible weight snapshot for serving | `<run_dir>/weights/step_N/` |
|
||||
|
||||
### Enabling Checkpoints
|
||||
|
||||
@@ -235,22 +287,29 @@ uv run rl @ rl.toml --ckpt.interval 25 --ckpt.keep-interval 100 # …plus perma
|
||||
|
||||
### Resuming a Run
|
||||
|
||||
Re-run the same launch command and pass `--ckpt.resume-step <N>` (or `-1` for "latest"). Make sure `--max-steps` is at least the target final step, not the remaining delta:
|
||||
Re-run the same launch command and pass `--resume` (latest checkpoint) or `--resume.step <N>`. Resuming reuses the run directory, so the run needs a name you can point back at — launch with `--run.name` (or pass the first run's auto-generated name). Make sure `--max-steps` is at least the target final step, not the remaining delta:
|
||||
|
||||
```bash
|
||||
# First run: steps 1–10
|
||||
uv run rl @ rl.toml --max-steps 10 --ckpt
|
||||
uv run rl @ rl.toml --max-steps 10 --ckpt --run.name my-run
|
||||
|
||||
# Resume: continue to step 20
|
||||
uv run rl @ rl.toml --max-steps 20 --ckpt.resume-step 10
|
||||
# Resume from the latest checkpoint: continue to step 20
|
||||
uv run rl @ rl.toml --max-steps 20 --ckpt --resume --run.name my-run
|
||||
|
||||
# ...or from a specific step
|
||||
uv run rl @ rl.toml --max-steps 20 --ckpt --resume.step 10 --run.name my-run
|
||||
|
||||
# ...or fork another run's checkpoint into a fresh run
|
||||
uv run rl @ rl.toml --max-steps 20 --ckpt --run.name my-fork \
|
||||
--resume.dir outputs/my-run/checkpoints/step_10
|
||||
```
|
||||
|
||||
### Serving Checkpoints
|
||||
|
||||
HF-compatible weight snapshots are written under `<output_dir>/weights/step_N/` whenever a full checkpoint runs (or you can write weights-only via `--ckpt.weights-only` for cheaper snapshots). Upload directly:
|
||||
HF-compatible weight snapshots are written under `<run_dir>/weights/step_N/` whenever a full checkpoint runs (or you can write weights-only via `--ckpt.weights-only` for cheaper snapshots). Upload directly:
|
||||
|
||||
```bash
|
||||
uv run hf upload <user>/<model>-RL outputs/weights/step_100
|
||||
uv run hf upload <user>/<model>-RL outputs/<run_name>/weights/step_100
|
||||
```
|
||||
|
||||
For LoRA runs, set `ckpt.weights.save_adapter_separately = true` to also write the raw adapter alongside the merged weights — useful when serving the adapter through a separate `/load_lora_adapter` call.
|
||||
@@ -259,10 +318,10 @@ For LoRA runs, set `ckpt.weights.save_adapter_separately = true` to also write t
|
||||
|
||||
### Log Files
|
||||
|
||||
The launcher tees every process's stdout/stderr into `<output_dir>/logs/`. The full layout (single-node runs skip the `node_*.log` and `router.log` files — there the router logs into `inference.log`):
|
||||
The launcher tees every process's stdout/stderr into `<run_dir>/logs/attempt_<n>/` — every launch (fresh or resumed) gets its own numbered attempt directory, and `logs/latest` symlinks to the current one. The full layout (single-node runs skip the `node_*.log` and `router.log` files — there the router logs into `inference.log`):
|
||||
|
||||
```
|
||||
<output_dir>/logs/
|
||||
<run_dir>/logs/latest/ # symlink -> attempt_<n>, one per launch
|
||||
├── trainer.log # rank 0 only; symlink → trainer/node_0.log on multi-node
|
||||
├── orchestrator.log # single instance, single file
|
||||
├── inference.log # symlink → inference/node_0.log on multi-node
|
||||
@@ -280,9 +339,9 @@ Env logs are the first place to look for env-side errors (most user code lives t
|
||||
Live tailing from a single point (works on the head node for multi-node runs over a shared filesystem):
|
||||
|
||||
```bash
|
||||
tail -F <output_dir>/logs/{trainer,orchestrator,inference}.log
|
||||
tail -F <output_dir>/logs/trainer/node_*.log # multi-node only
|
||||
tail -F <output_dir>/logs/inference/router.log # multi-node only
|
||||
tail -F <run_dir>/logs/latest/{trainer,orchestrator,inference}.log
|
||||
tail -F <run_dir>/logs/latest/trainer/node_*.log # multi-node only
|
||||
tail -F <run_dir>/logs/latest/inference/router.log # multi-node only
|
||||
```
|
||||
|
||||
### Console Output
|
||||
@@ -290,50 +349,44 @@ tail -F <output_dir>/logs/inference/router.log # multi-node only
|
||||
`scripts/tmux.sh` opens a 4-pane tmux session that follows `trainer.log`, `orchestrator.log`, `inference.log`, and the union of env worker logs. Start it before launching:
|
||||
|
||||
```bash
|
||||
bash scripts/tmux.sh
|
||||
bash scripts/tmux.sh -o outputs/my-run
|
||||
# then in the Launcher window:
|
||||
uv run rl @ ... --output-dir outputs/my-run
|
||||
uv run rl @ ... --run.name my-run
|
||||
```
|
||||
|
||||
Pass `-s <session>` and `-o <output_dir>` to run multiple parallel experiments side-by-side in different sessions. The helper also works on a SLURM head node — `bash scripts/tmux.sh my-rl-job /shared/outputs/my-rl-job`.
|
||||
Pass `-s <session>` and `-o <run_dir>` (the run directory, `<output_dir>/<run_name>`) to run multiple parallel experiments side-by-side in different sessions. The helper also works on a SLURM head node — `bash scripts/tmux.sh my-rl-job /shared/outputs/my-rl-job`.
|
||||
|
||||
### Weights & Biases
|
||||
|
||||
W&B is off by default. Enable with `--wandb`:
|
||||
W&B is off by default (the file monitor, which writes `metrics.jsonl` and the per-step trace files to the run directory, is on by default):
|
||||
|
||||
```bash
|
||||
uv run rl @ rl.toml --wandb # default project, random name
|
||||
uv run rl @ rl.toml --wandb.project my-proj --wandb.name run-42
|
||||
uv run rl @ rl.toml --no-wandb # force-disable even if the TOML enables it
|
||||
uv run rl @ rl.toml --monitors.wandb # default project, random name
|
||||
uv run rl @ rl.toml --monitors.wandb.project my-proj --monitors.wandb.name run-42
|
||||
uv run rl @ rl.toml --no-monitors.file # disable the local metric/trace files
|
||||
```
|
||||
|
||||
The trainer and orchestrator log into a **single shared W&B run**, so all metrics from both processes land in one place. Shared mode requires the W&B SDK ≥ 0.19.9 and is incompatible with `wandb.offline = true`.
|
||||
The trainer and orchestrator log into a **single shared W&B run**, so all metrics from both processes land in one place. Shared mode requires the W&B SDK ≥ 0.19.9 and is incompatible with `monitors.wandb.offline = true`.
|
||||
|
||||
By default, every 10 steps each process also logs a sample of prompts/completions (with rewards and advantages) and reward/advantage/entropy distributions as W&B tables. Tune via `--wandb.log-extras.interval` and `--wandb.log-extras.sample-ratio`, or disable subsets:
|
||||
|
||||
```bash
|
||||
uv run rl @ rl.toml --wandb \
|
||||
--orchestrator.wandb.log-extras.interval 50 \
|
||||
--no-trainer.wandb.log-extras.distributions
|
||||
```
|
||||
|
||||
prime-rl deliberately logs a **large number of metrics** for maximum observability: every rollout metric is emitted per subset (`all`/`effective`), per statistic (`mean`/`max`/`min`/`p10`/`p90`), and per environment alongside a cross-env aggregate, so a multi-env run can emit thousands of series. To keep that navigable, W&B mode **auto-creates an `overview` saved view** on the first run into a project — curating the handful of metrics that matter into `train`, `eval`, `stability`, and `performance` sections (with per-env breakdowns). The view is created once per project and adapts to the run's environments; if a later run uses a different set of environments, a new versioned view (`overview-v2`, …) is created instead of overwriting the first.
|
||||
prime-rl deliberately logs a **large number of metrics** for maximum observability: every rollout metric is emitted per subset (`all`/`effective`), per statistic (`mean`/`max`/`min`/`p10`/`p90`), and per environment alongside a cross-env aggregate, so a multi-env run can emit thousands of series. To keep that navigable, every training run (RL and SFT) gets an **auto-created `overview` saved view** curating the handful of metrics that matter into `train`, `eval`, `stability`, and `performance` sections (with per-env breakdowns). The view is created once per project and adapts to the run's environments; if a later run uses a different set of environments, a new versioned view (`overview-v2`, …) is created instead of overwriting the first.
|
||||
|
||||
### Platform Monitoring
|
||||
|
||||
Register a run on the Prime Intellect platform (Prime Lab) and stream training metrics, samples, and distributions to the platform dashboard. Bare flag uses defaults:
|
||||
Register a run on the Prime Intellect platform (Prime Lab) and stream training metrics and episodes to the platform dashboard. Bare flag uses defaults:
|
||||
|
||||
```bash
|
||||
uv run rl @ rl.toml --orchestrator.prime-monitor
|
||||
uv run rl @ rl.toml --monitors.prime
|
||||
```
|
||||
|
||||
Or set it in TOML:
|
||||
|
||||
```toml
|
||||
[orchestrator.prime_monitor]
|
||||
run_name = "my-experiment"
|
||||
[monitors.prime]
|
||||
name = "my-experiment"
|
||||
```
|
||||
|
||||
Every 10th step the orchestrator uploads the step's episodes (full conversations with rewards and advantages) to the run's sample viewer.
|
||||
|
||||
Requires `PRIME_API_KEY` (set via `prime login` or env var) and an allowlisted team. Currently internal-only.
|
||||
|
||||
## Rules of Thumb
|
||||
@@ -341,5 +394,5 @@ Requires `PRIME_API_KEY` (set via `prime login` or env var) and an allowlisted t
|
||||
- **Start small.** Run `examples/basic/reverse-text/rl.toml` end-to-end on 2 GPUs before scaling. If the smoke run finishes cleanly, your install is good.
|
||||
- **Batch size ≥ 64.** Smaller batches give noisy gradient estimates and the trainer's overhead-per-step dominates throughput. 64 is the practical floor; 128–512 is the range for quick ablations; production RL often runs at 1024+.
|
||||
- **Group size ≥ 8.** Bigger groups (`orchestrator.group_size`) make it more likely that a task produces a mix of high- and low-reward rollouts, which is what gives the trainer a usable signal — if all rollouts in a group succeed or all fail, the within-group advantage collapses to zero and the trainer learns nothing from that task. Bigger groups also tighten advantage normalization. 8 is the floor; 16–32 is common.
|
||||
- **Pin `output_dir` per run.** Sharing a directory across runs will mix rollouts and break resumes. `--output-dir outputs/<unique-name>` is the simplest discipline.
|
||||
- **Runs never share a directory.** Every launch writes to its own run directory `<output_dir>/<run_name>`, auto-named `<envs>--<model>--<short-id>` by default. Name runs you want to find again or resume with `--run.name <name>`; re-using a name blocks unless you resume or pass `--clean`.
|
||||
- **Use `--dry-run` before SLURM.** Validators (e.g. CP needs flash-attention) fail fast in dry-run and slow in queue.
|
||||
|
||||
@@ -21,7 +21,7 @@ num_train_nodes = 2
|
||||
num_infer_nodes = 1
|
||||
num_infer_replicas = 4
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "search-ablations"
|
||||
name = "glm45air-search"
|
||||
|
||||
@@ -32,7 +32,8 @@ timeout = 3600
|
||||
[ckpt]
|
||||
interval = 50
|
||||
keep_last = 1
|
||||
resume_step = -1
|
||||
|
||||
[resume]
|
||||
|
||||
[model]
|
||||
name = "zai-org/GLM-4.5-Air"
|
||||
@@ -49,7 +50,6 @@ attn = "flash_attention_3"
|
||||
cp = 4
|
||||
cp_style = "ulysses"
|
||||
fused_lm_head_token_chunk_size = 1024
|
||||
optim_cpu_offload = true
|
||||
|
||||
[trainer.model.ac]
|
||||
|
||||
@@ -71,7 +71,10 @@ type = "muon"
|
||||
batch_size = 256
|
||||
group_size = 16
|
||||
max_off_policy_steps = 32
|
||||
max_inflight_episodes = 512
|
||||
|
||||
[orchestrator.concurrency]
|
||||
initial_inflight = 256
|
||||
max_inflight = 512
|
||||
|
||||
[orchestrator.renderer]
|
||||
name = "glm-4.5"
|
||||
@@ -86,7 +89,7 @@ num_output_tokens_weight = 0.0
|
||||
num_input_tokens_weight = 0.1
|
||||
num_turns_weight = 0.0
|
||||
|
||||
[orchestrator.prime_monitor]
|
||||
[monitors.prime]
|
||||
|
||||
# --- Train: the search envs with usable training data (rlm `search` skill, prime sandbox) ---
|
||||
|
||||
@@ -103,13 +106,10 @@ forward_env = ["SERPER_API_KEY"]
|
||||
summarize_at_tokens = [65536, 131072]
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["glm45air-search"]
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "openseeker-v1"
|
||||
id = "openseeker"
|
||||
|
||||
[[orchestrator.train.source.env.taskset.task.judges]]
|
||||
id = "reference"
|
||||
@@ -122,7 +122,7 @@ choices = ["A", "B"]
|
||||
# [[orchestrator.train.source.env.taskset.task.judges]]
|
||||
# id = "rubric"
|
||||
# name = "rlm"
|
||||
# path = "deps/research-environments/rubrics/rlm.toml"
|
||||
# path = "deps/prime-envs/rubrics/rlm.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
@@ -136,13 +136,10 @@ forward_env = ["SERPER_API_KEY"]
|
||||
summarize_at_tokens = [65536, 131072]
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["glm45air-search"]
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "redsearcher-v1" # optional `difficulty` filter (easy/medium/hard)
|
||||
id = "redsearcher" # optional `difficulty` filter (easy/medium/hard)
|
||||
|
||||
[[orchestrator.train.source.env.taskset.task.judges]]
|
||||
id = "reference"
|
||||
@@ -155,7 +152,7 @@ choices = ["A", "B"]
|
||||
# [[orchestrator.train.source.env.taskset.task.judges]]
|
||||
# id = "rubric"
|
||||
# name = "rlm"
|
||||
# path = "deps/research-environments/rubrics/rlm.toml"
|
||||
# path = "deps/prime-envs/rubrics/rlm.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
@@ -175,16 +172,13 @@ forward_env = ["SERPER_API_KEY"]
|
||||
summarize_at_tokens = 98304
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["glm45air-search"]
|
||||
|
||||
[orchestrator.eval.source.env.agent.timeout]
|
||||
rollout = 3600
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "browsecomp-v1"
|
||||
id = "browsecomp"
|
||||
|
||||
[orchestrator.eval.source.env.taskset.task.judge]
|
||||
model = "Qwen/Qwen3-235B-A22B-Instruct-2507"
|
||||
@@ -193,7 +187,7 @@ model = "Qwen/Qwen3-235B-A22B-Instruct-2507"
|
||||
# [[orchestrator.eval.source.env.taskset.task.judges]]
|
||||
# id = "rubric"
|
||||
# name = "rlm"
|
||||
# path = "deps/research-environments/rubrics/rlm.toml"
|
||||
# path = "deps/prime-envs/rubrics/rlm.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# v1 RL: GLM-4.5-Air (100B MoE) on the v1 `scaleswe-v1` SWE taskset, rlm harness on a prime sandbox
|
||||
# v1 RL: GLM-4.5-Air (100B MoE) on the v1 `scaleswe` SWE taskset, rlm harness on a prime sandbox
|
||||
# runtime; eval on SWE-Bench Verified. Router replay is enabled (trainer.enable_router_replay replays
|
||||
# the routed-expert decisions returned by inference via enable_return_routed_experts) — GLM-4.5-Air is
|
||||
# a glm4_moe model, which supports routed_experts.
|
||||
@@ -7,10 +7,14 @@
|
||||
# term is pass_rate-scaled and normalized by the group's own max before the GRPO baseline
|
||||
# subtraction.
|
||||
#
|
||||
# 2 train + 4 infer nodes. Trainer uses cp=4 (ulysses) plus
|
||||
# 1 train + 3 infer nodes. Inference serves FP8 via online per-tensor quantization of the bf16
|
||||
# checkpoint; weight broadcasts re-quantize through the same path on every update. The trainer fits on one
|
||||
# node via cp=4 (ulysses), full CPU optimizer offload with the stateless sign-SGD optimizer, plus
|
||||
# the memory improvements from the GLM-5.1 prod run (research-prod rlm5/prod.toml): LM-head token
|
||||
# chunking, activation checkpointing (freq=1) + activation offloading (max_inflight=1), optimizer
|
||||
# CPU offload, and skip-gather / skip-optimizer checkpointing.
|
||||
# chunking, activation checkpointing (freq=1) + activation offloading (max_inflight=1), and
|
||||
# skip-gather / skip-optimizer checkpointing.
|
||||
# Concurrency is fully default: the controller derives its start from the measured KV budget and
|
||||
# adapts from there.
|
||||
|
||||
max_steps = 1000
|
||||
seq_len = 131072
|
||||
@@ -28,11 +32,11 @@ pre_run_command = 'timeout 120 prime sandbox delete --label "glm45air-swe" -y ||
|
||||
|
||||
[deployment]
|
||||
type = "multi_node"
|
||||
num_train_nodes = 2
|
||||
num_train_nodes = 1
|
||||
num_infer_nodes = 1
|
||||
num_infer_replicas = 4
|
||||
num_infer_replicas = 3
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "swe-ablations"
|
||||
name = "glm45air-scaleswe"
|
||||
|
||||
@@ -43,10 +47,8 @@ timeout = 3600
|
||||
[ckpt]
|
||||
interval = 50
|
||||
keep_last = 1
|
||||
resume_step = -1
|
||||
|
||||
[model]
|
||||
name = "zai-org/GLM-4.5-Air"
|
||||
[resume]
|
||||
|
||||
# --- Trainer ---
|
||||
|
||||
@@ -54,13 +56,17 @@ name = "zai-org/GLM-4.5-Air"
|
||||
dist_timeout_seconds = 3600
|
||||
enable_router_replay = true
|
||||
|
||||
[model]
|
||||
name = "zai-org/GLM-4.5-Air"
|
||||
|
||||
[trainer.model]
|
||||
impl = "custom"
|
||||
attn = "flash_attention_3"
|
||||
cp = 4
|
||||
cp_style = "ulysses"
|
||||
optim_cpu_offload = false
|
||||
full_offload = true
|
||||
fused_lm_head_token_chunk_size = 1024
|
||||
optim_cpu_offload = true
|
||||
|
||||
[trainer.model.ac]
|
||||
|
||||
@@ -74,7 +80,7 @@ skip_gather_master_weights = true
|
||||
skip_optimizer = true
|
||||
|
||||
[trainer.optim]
|
||||
type = "muon"
|
||||
type = "sign_sgd"
|
||||
|
||||
# --- Orchestrator ---
|
||||
|
||||
@@ -82,7 +88,6 @@ type = "muon"
|
||||
batch_size = 256
|
||||
group_size = 16
|
||||
max_off_policy_steps = 32
|
||||
max_inflight_episodes = 512
|
||||
|
||||
[orchestrator.algo]
|
||||
type = "grpo"
|
||||
@@ -101,19 +106,16 @@ thinking_retention = "all"
|
||||
name = "scaleswe"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "scaleswe-v1"
|
||||
id = "scaleswe"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
summarize_at_tokens = [65536, 131072]
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["glm45air-swe"]
|
||||
|
||||
[orchestrator.prime_monitor]
|
||||
[monitors.prime]
|
||||
|
||||
# --- Eval: SWE-Bench Verified at step 0 + every 20 steps, rlm harness on prime ---
|
||||
|
||||
@@ -124,16 +126,13 @@ interval = 20
|
||||
name = "swebench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
id = "swebench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
summarize_at_tokens = 98304
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["glm45air-swe"]
|
||||
|
||||
[orchestrator.eval.source.env.agent.timeout]
|
||||
@@ -143,6 +142,7 @@ rollout = 3600
|
||||
|
||||
[inference]
|
||||
|
||||
|
||||
# vLLM + FlashInfer caches on node-local /tmp (see [env_vars]).
|
||||
[inference.env_vars]
|
||||
VLLM_CACHE_ROOT = "/tmp/.vllm-cache"
|
||||
@@ -151,4 +151,5 @@ FLASHINFER_WORKSPACE_BASE = "/tmp/.flashinfer-cache"
|
||||
[inference.vllm]
|
||||
max_model_len = 131072
|
||||
tensor_parallel_size = 8
|
||||
quantization = "fp8"
|
||||
enable_return_routed_experts = true
|
||||
|
||||
@@ -22,7 +22,7 @@ num_train_nodes = 2
|
||||
num_infer_nodes = 1
|
||||
num_infer_replicas = 4
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "terminal-ablations"
|
||||
name = "glm45air-terminal"
|
||||
|
||||
@@ -33,7 +33,8 @@ timeout = 3600
|
||||
[ckpt]
|
||||
interval = 50
|
||||
keep_last = 1
|
||||
resume_step = -1
|
||||
|
||||
[resume]
|
||||
|
||||
[model]
|
||||
name = "zai-org/GLM-4.5-Air"
|
||||
@@ -50,7 +51,6 @@ attn = "flash_attention_3"
|
||||
cp = 4
|
||||
cp_style = "ulysses"
|
||||
fused_lm_head_token_chunk_size = 1024
|
||||
optim_cpu_offload = true
|
||||
|
||||
[trainer.model.ac]
|
||||
|
||||
@@ -72,7 +72,10 @@ type = "muon"
|
||||
batch_size = 256
|
||||
group_size = 16
|
||||
max_off_policy_steps = 32
|
||||
max_inflight_episodes = 512
|
||||
|
||||
[orchestrator.concurrency]
|
||||
initial_inflight = 256
|
||||
max_inflight = 512
|
||||
|
||||
[orchestrator.renderer]
|
||||
name = "glm-4.5"
|
||||
@@ -87,7 +90,7 @@ num_output_tokens_weight = 0.0
|
||||
num_input_tokens_weight = 0.1
|
||||
num_turns_weight = 0.1
|
||||
|
||||
[orchestrator.prime_monitor]
|
||||
[monitors.prime]
|
||||
|
||||
# --- Train: tmax (per-task Docker image in a prime sandbox, rlm ipython) ---
|
||||
|
||||
@@ -99,26 +102,23 @@ id = "rlm"
|
||||
summarize_at_tokens = [65536, 131072]
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["glm45air-terminal"]
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "tmax-v1"
|
||||
id = "tmax"
|
||||
|
||||
# # Metric-only monitors (weight 0): rlm harness-mechanics + swe code-usage rubrics, judged by GLM-5.2.
|
||||
# [[orchestrator.train.source.env.taskset.judges]]
|
||||
# id = "rubric"
|
||||
# name = "rlm"
|
||||
# path = "deps/research-environments/rubrics/rlm.toml"
|
||||
# path = "deps/prime-envs/rubrics/rlm.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
# [[orchestrator.train.source.env.taskset.judges]]
|
||||
# id = "rubric"
|
||||
# name = "swe"
|
||||
# path = "deps/research-environments/rubrics/swe.toml"
|
||||
# path = "deps/prime-envs/rubrics/swe.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
@@ -135,28 +135,25 @@ id = "rlm"
|
||||
summarize_at_tokens = 98304
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["glm45air-terminal"]
|
||||
|
||||
[orchestrator.eval.source.env.agent.timeout]
|
||||
rollout = 3600
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
id = "swebench-verified"
|
||||
|
||||
# [[orchestrator.eval.source.env.taskset.judges]]
|
||||
# id = "rubric"
|
||||
# name = "rlm"
|
||||
# path = "deps/research-environments/rubrics/rlm.toml"
|
||||
# path = "deps/prime-envs/rubrics/rlm.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
# [[orchestrator.eval.source.env.taskset.judges]]
|
||||
# id = "rubric"
|
||||
# name = "swe"
|
||||
# path = "deps/research-environments/rubrics/swe.toml"
|
||||
# path = "deps/prime-envs/rubrics/swe.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
@@ -169,28 +166,25 @@ id = "rlm"
|
||||
summarize_at_tokens = 98304
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["glm45air-terminal"]
|
||||
|
||||
[orchestrator.eval.source.env.agent.timeout]
|
||||
rollout = 3600
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "terminal-bench-2-v1"
|
||||
id = "terminal-bench-2"
|
||||
|
||||
# [[orchestrator.eval.source.env.taskset.judges]]
|
||||
# id = "rubric"
|
||||
# name = "rlm"
|
||||
# path = "deps/research-environments/rubrics/rlm.toml"
|
||||
# path = "deps/prime-envs/rubrics/rlm.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
# [[orchestrator.eval.source.env.taskset.judges]]
|
||||
# id = "rubric"
|
||||
# name = "swe"
|
||||
# path = "deps/research-environments/rubrics/swe.toml"
|
||||
# path = "deps/prime-envs/rubrics/swe.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
max_steps = 10000000
|
||||
seq_len = 131072
|
||||
output_dir = "/shared/outputs/glm5-llmd" # FILL IN: point at your shared filesystem
|
||||
clean_output_dir = true
|
||||
output_dir = "/shared/outputs" # FILL IN: point at your shared filesystem
|
||||
clean = true
|
||||
|
||||
[run]
|
||||
name = "glm5-llmd"
|
||||
|
||||
[log]
|
||||
level = "debug"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "glm5-llmd"
|
||||
name = "base"
|
||||
|
||||
@@ -90,7 +93,6 @@ attn = "flash_attention_2" # ignored with GLM5
|
||||
fused_lm_head_token_chunk_size = 1024
|
||||
cp = 4 # context parallel for the 131K seq len
|
||||
ep = 8
|
||||
optim_cpu_offload = true
|
||||
|
||||
[trainer.model.quantization]
|
||||
type = "fp8"
|
||||
@@ -111,9 +113,12 @@ weight_decay = 0.0
|
||||
[orchestrator]
|
||||
batch_size = 256
|
||||
group_size = 16
|
||||
max_inflight_episodes = 2048
|
||||
max_off_policy_steps = 8 # 16/32 can be better, 8 is more CPU stable
|
||||
|
||||
[orchestrator.concurrency]
|
||||
initial_inflight = 256
|
||||
max_inflight = 512
|
||||
|
||||
[orchestrator.model]
|
||||
name = "zai-org/GLM-5.1-FP8"
|
||||
|
||||
@@ -131,13 +136,12 @@ clear_thinking = false
|
||||
name = "r2e"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "r2e-gym-v1"
|
||||
id = "r2e-gym"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
labels = ["glm5-llmd"]
|
||||
|
||||
[inference]
|
||||
|
||||
@@ -3,7 +3,7 @@ seq_len = 131072
|
||||
[log]
|
||||
level = "debug"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "glm5-pd-disag"
|
||||
|
||||
[weight_broadcast]
|
||||
@@ -43,7 +43,6 @@ name = "zai-org/GLM-5"
|
||||
impl = "custom"
|
||||
attn = "flash_attention_2" # dsa is skipping flash attn anyway
|
||||
fused_lm_head_token_chunk_size = 2048
|
||||
optim_cpu_offload = true
|
||||
ep = 8
|
||||
|
||||
[trainer.model.ac]
|
||||
@@ -66,9 +65,12 @@ weight_decay = 0.1
|
||||
[orchestrator]
|
||||
batch_size = 4096
|
||||
group_size = 16
|
||||
oversampling_factor = 3
|
||||
max_off_policy_steps = 16
|
||||
|
||||
[orchestrator.concurrency]
|
||||
initial_inflight = 4096
|
||||
max_inflight = 8192
|
||||
|
||||
[orchestrator.model]
|
||||
name = "zai-org/GLM-5-FP8"
|
||||
|
||||
@@ -79,20 +81,14 @@ interval = 20
|
||||
name = "swe-bench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
id = "swebench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
labels = ["glm5-pd-disag", "swe-bench-verified"]
|
||||
|
||||
[[orchestrator.post_batch_filters]]
|
||||
type = "gibberish"
|
||||
enforce = true
|
||||
|
||||
[inference]
|
||||
# we need <0.85 bc glm5 layers are too large for 0.85
|
||||
use_deep_gemm = true
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ job_name = "swe-qwen30b"
|
||||
[ckpt]
|
||||
interval = 100
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "intellect-3.1"
|
||||
|
||||
[trainer.model]
|
||||
@@ -45,28 +45,32 @@ weight_decay = 0.01
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 2048
|
||||
oversampling_factor = 2
|
||||
|
||||
[orchestrator.concurrency]
|
||||
initial_inflight = 4096
|
||||
max_inflight = 4096
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "swe"
|
||||
ratio = 0.3
|
||||
curriculum = { gates = { zero_advantage = { type = "advantage_range" } } }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "r2e-gym-v1"
|
||||
id = "r2e-gym"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
labels = ["intellect-3.1", "swe"]
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "deepdive"
|
||||
ratio = 0.2
|
||||
curriculum = { gates = { zero_advantage = { type = "advantage_range" } } }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "deepdive-v1"
|
||||
id = "deepdive"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
@@ -74,15 +78,15 @@ skills = ["search"]
|
||||
forward_env = ["SERPER_API_KEY"]
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
labels = ["intellect-3.1", "deepdive"]
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "math"
|
||||
ratio = 0.3
|
||||
curriculum = { gates = { zero_advantage = { type = "advantage_range" } } }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "i3_math_v1"
|
||||
id = "i3_math"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -93,9 +97,10 @@ type = "subprocess"
|
||||
[[orchestrator.train.source]]
|
||||
name = "logic"
|
||||
ratio = 0.2
|
||||
curriculum = { gates = { zero_advantage = { type = "advantage_range" } } }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "i3_logic_v1"
|
||||
id = "i3_logic"
|
||||
|
||||
[orchestrator.train.source.env.taskset.filter]
|
||||
max = 0.874
|
||||
@@ -109,9 +114,10 @@ type = "subprocess"
|
||||
[[orchestrator.train.source]]
|
||||
name = "code"
|
||||
ratio = 0.2
|
||||
curriculum = { gates = { zero_advantage = { type = "advantage_range" } } }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "i3_code_v1"
|
||||
id = "i3_code"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -119,10 +125,6 @@ id = "null"
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[[orchestrator.pre_batch_filters]]
|
||||
type = "zero_advantage"
|
||||
enforce = true
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 25
|
||||
|
||||
@@ -130,20 +132,19 @@ interval = 25
|
||||
name = "swe-bench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
id = "swebench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
labels = ["intellect-3.1", "swe-bench-verified"]
|
||||
|
||||
[[orchestrator.eval.source]]
|
||||
name = "aime2025"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "aime25-v1"
|
||||
id = "aime25"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -20,7 +20,7 @@ job_name = "swe-minimax"
|
||||
[ckpt]
|
||||
interval = 100
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "minimax-swe"
|
||||
|
||||
[trainer.model]
|
||||
@@ -45,20 +45,22 @@ weight_decay = 0.01
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 2048
|
||||
oversampling_factor = 2
|
||||
max_off_policy_steps = 16
|
||||
|
||||
[orchestrator.concurrency]
|
||||
initial_inflight = 4096
|
||||
max_inflight = 4096
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "swe"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "r2e-gym-v1"
|
||||
id = "r2e-gym"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
labels = ["minimax-swe", "swe"]
|
||||
|
||||
[orchestrator.eval]
|
||||
@@ -68,13 +70,12 @@ interval = 25
|
||||
name = "swe-bench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
id = "swebench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
labels = ["minimax-swe", "swe-bench-verified"]
|
||||
|
||||
[inference.vllm]
|
||||
|
||||
@@ -18,7 +18,7 @@ num_train_nodes = 4
|
||||
num_infer_nodes = 1
|
||||
num_infer_replicas = 4
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "nemotron-3-super"
|
||||
name = "nemotron-3-super-swe"
|
||||
|
||||
@@ -29,7 +29,8 @@ timeout = 3600
|
||||
[ckpt]
|
||||
interval = 50
|
||||
keep_last = 1
|
||||
resume_step = -1
|
||||
|
||||
[resume]
|
||||
|
||||
[model]
|
||||
name = "nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-BF16"
|
||||
@@ -46,7 +47,6 @@ cp = 8
|
||||
cp_style = "ulysses"
|
||||
ep = 8
|
||||
fused_lm_head_token_chunk_size = 1024
|
||||
optim_cpu_offload = true
|
||||
|
||||
[trainer.model.ac]
|
||||
|
||||
@@ -66,7 +66,10 @@ type = "adamw"
|
||||
batch_size = 256
|
||||
group_size = 16
|
||||
max_off_policy_steps = 32
|
||||
max_inflight_episodes = 1536
|
||||
|
||||
[orchestrator.concurrency]
|
||||
initial_inflight = 1536
|
||||
max_inflight = 1536
|
||||
|
||||
[orchestrator.algo]
|
||||
type = "grpo"
|
||||
@@ -85,19 +88,16 @@ truncate_history_thinking = false
|
||||
name = "scaleswe"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "scaleswe-v1"
|
||||
id = "scaleswe"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
summarize_at_tokens = [65536, 131072]
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["nemotron-3-super-swe"]
|
||||
|
||||
[orchestrator.prime_monitor]
|
||||
[monitors.prime]
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 20
|
||||
@@ -106,16 +106,13 @@ interval = 20
|
||||
name = "swebench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
id = "swebench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
summarize_at_tokens = 98304
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["nemotron-3-super-swe"]
|
||||
|
||||
[orchestrator.eval.source.env.agent.timeout]
|
||||
|
||||
@@ -20,7 +20,7 @@ job_name = "math-qwen30b"
|
||||
[ckpt]
|
||||
interval = 100
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "qwen30b-math"
|
||||
|
||||
[trainer.model]
|
||||
@@ -42,9 +42,11 @@ lr = 1e-6
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 512
|
||||
oversampling_factor = 2
|
||||
max_off_policy_steps = 8
|
||||
|
||||
[orchestrator.concurrency]
|
||||
initial_inflight = 1024
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 32768
|
||||
|
||||
@@ -52,7 +54,7 @@ max_completion_tokens = 32768
|
||||
name = "math"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "i3_math_v1"
|
||||
id = "i3_math"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -67,7 +69,7 @@ interval = 25
|
||||
name = "aime2025"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "aime25-v1"
|
||||
id = "aime25"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -20,7 +20,7 @@ job_name = "swe-qwen30b"
|
||||
[ckpt]
|
||||
interval = 100
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "qwen30b-swe"
|
||||
|
||||
[trainer.model]
|
||||
@@ -43,20 +43,21 @@ lr = 1e-6
|
||||
|
||||
[orchestrator]
|
||||
batch_size = 512
|
||||
oversampling_factor = 2
|
||||
max_off_policy_steps = 16
|
||||
|
||||
[orchestrator.concurrency]
|
||||
initial_inflight = 1024
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "swe"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "r2e-gym-v1"
|
||||
id = "r2e-gym"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
labels = ["qwen30b-swe", "swe"]
|
||||
|
||||
[orchestrator.eval]
|
||||
@@ -66,13 +67,12 @@ interval = 25
|
||||
name = "swe-bench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
id = "swebench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
labels = ["qwen30b-swe", "swe-bench-verified"]
|
||||
|
||||
[inference.vllm]
|
||||
|
||||
@@ -9,7 +9,7 @@ type = "multi_node"
|
||||
num_train_nodes = 1
|
||||
num_infer_nodes = 1
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "general-agent-debug"
|
||||
name = "qwen3-30b-a3b-rlm"
|
||||
|
||||
@@ -38,7 +38,7 @@ max_off_policy_steps = 32
|
||||
[[orchestrator.train.source]]
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "general-agent-v1"
|
||||
id = "general-agent"
|
||||
min_tier = 1
|
||||
|
||||
[orchestrator.train.source.env.taskset.task.tools]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Alphabet Sort
|
||||
|
||||
In this example, we demonstrate how to train `Qwen3-4B-Instruct-2507` to sort names alphabetically using LoRA. Unlike other examples, this task doesn't require SFT warmup as the base model already understands the conversation format. We proceed directly to multi-turn RL against the `alphabet-sort-v1` taskset.
|
||||
In this example, we demonstrate how to train `Qwen3-4B-Instruct-2507` to sort names alphabetically using LoRA. Unlike other examples, this task doesn't require SFT warmup as the base model already understands the conversation format. We proceed directly to multi-turn RL against the `alphabet-sort` taskset.
|
||||
|
||||
> This example runs on a single H100 GPU.
|
||||
|
||||
@@ -9,7 +9,7 @@ In this example, we demonstrate how to train `Qwen3-4B-Instruct-2507` to sort na
|
||||
The taskset is included through the Verifiers workspace. After syncing the repository, verify it with:
|
||||
|
||||
```bash
|
||||
uv run python -c "import alphabet_sort_v1"
|
||||
uv run python -c "import alphabet_sort"
|
||||
```
|
||||
|
||||
Start the tmux session:
|
||||
@@ -38,7 +38,7 @@ uv run inference --vllm.enable-lora --vllm.model Qwen/Qwen3-4B-Instruct-2507
|
||||
Evaluate the base model:
|
||||
```bash
|
||||
# In the `Trainer` pane
|
||||
uv run eval alphabet-sort-v1 --harness.id null \
|
||||
uv run eval alphabet-sort --harness.id null \
|
||||
-m Qwen/Qwen3-4B-Instruct-2507 \
|
||||
--client.base-url http://localhost:8000/v1 \
|
||||
-n 20 \
|
||||
@@ -93,14 +93,15 @@ We train with LoRA (rank 32, alpha 64) for 100 steps.
|
||||
```bash
|
||||
# In the `Trainer` pane
|
||||
uv run rl @ examples/basic/alphabet-sort/rl.toml \
|
||||
--wandb.project ... \
|
||||
--wandb.name ...
|
||||
--run.name rl \
|
||||
--monitors.wandb.project ... \
|
||||
--monitors.wandb.name ...
|
||||
```
|
||||
|
||||
This will write a weight checkpoint in `outputs/weights/step_100`. Upload it to HF to be able to use it as the final model for evaluation.
|
||||
This will write a weight checkpoint in `outputs/rl/weights/step_100`. Upload it to HF to be able to use it as the final model for evaluation.
|
||||
|
||||
```bash
|
||||
uv run hf upload <user>/Qwen3-4B-Instruct-AlphabetSort-RL outputs/weights/step_100
|
||||
uv run hf upload <user>/Qwen3-4B-Instruct-AlphabetSort-RL outputs/rl/weights/step_100
|
||||
```
|
||||
|
||||
We have uploaded the final model as [`PrimeIntellect/Qwen3-4B-Instruct-AlphabetSort-RL`](https://huggingface.co/PrimeIntellect/Qwen3-4B-Instruct-AlphabetSort-RL).
|
||||
@@ -115,7 +116,7 @@ uv run inference --vllm.enable-lora --vllm.model PrimeIntellect/Qwen3-4B-Instruc
|
||||
|
||||
```bash
|
||||
# In the `Trainer` pane
|
||||
uv run eval alphabet-sort-v1 --harness.id null \
|
||||
uv run eval alphabet-sort --harness.id null \
|
||||
-m PrimeIntellect/Qwen3-4B-Instruct-AlphabetSort-RL \
|
||||
--client.base-url http://localhost:8000/v1 \
|
||||
-n 20 \
|
||||
|
||||
@@ -7,7 +7,7 @@ seq_len = 2048
|
||||
[model]
|
||||
name = "Qwen/Qwen3-4B-Instruct-2507"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "alphabet-sort"
|
||||
name = "alphabet-sort"
|
||||
|
||||
@@ -35,7 +35,7 @@ max_completion_tokens = 768
|
||||
name = "alphabet-sort"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "alphabet-sort-v1"
|
||||
id = "alphabet-sort"
|
||||
min_turns = 3
|
||||
max_turns = 5
|
||||
|
||||
|
||||
@@ -12,6 +12,6 @@ Schedule training locally on a node with 8 GPUs
|
||||
|
||||
```bash
|
||||
uv run rl @ examples/basic/hendrycks-sanity/rl.toml \
|
||||
--wandb.project your-project \
|
||||
--wandb.name your-run
|
||||
--monitors.wandb.project your-project \
|
||||
--monitors.wandb.name your-run
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
max_steps = 5000
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "hendrycks-sanity"
|
||||
name = "hendrycks-sanity"
|
||||
|
||||
@@ -20,7 +20,7 @@ seq_len = 8192
|
||||
name = "hendrycks-math"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "math-env-v1"
|
||||
id = "math-env"
|
||||
dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B"
|
||||
dataset_subset = "default"
|
||||
|
||||
@@ -38,7 +38,7 @@ name = "aime2024"
|
||||
group_size = 32
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "aime24-v1"
|
||||
id = "aime24"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
# Reverse Text
|
||||
|
||||
We demonstrate how to train `Qwen3-0.6B` to reverse a small chunk of text. We will use a SFT warmup to learn the skill of text reversal on longer documents and then a quick RL run on the `reverse-text-v1` taskset. We use a similar setup in our CI and for development.
|
||||
We demonstrate how to train `Qwen3-0.6B` to reverse a small chunk of text. We will use a SFT warmup to learn the skill of text reversal on longer documents and then a quick RL run on the `reverse-text` taskset. We use a similar setup in our CI and for development.
|
||||
|
||||
> The commands in this example were designed to be run on 2 GPUs (one trainer and one inference GPU). It is possible to run on less or more GPUs using different deployment strategies. If you run on a different setup, you may need to adjust the start commands.
|
||||
|
||||
## Setup
|
||||
|
||||
The `reverse-text-v1` taskset is included through the Verifiers workspace. After syncing the repository, verify it with:
|
||||
The `reverse-text` taskset is included through the Verifiers workspace. After syncing the repository, verify it with:
|
||||
|
||||
```bash
|
||||
uv run python -c "import reverse_text_v1"
|
||||
uv run python -c "import reverse_text"
|
||||
```
|
||||
|
||||
First, let's start a `tmux` session which we will use throughout the experiment.
|
||||
@@ -27,7 +27,7 @@ uv run inference --vllm.model Qwen/Qwen3-0.6B
|
||||
|
||||
```bash
|
||||
# Run this in the `Trainer` pane
|
||||
uv run eval reverse-text-v1 --harness.id null -m Qwen/Qwen3-0.6B --client.base-url http://localhost:8000/v1 -n 20 -r 3 --sampling.max-tokens 1024 --no-push
|
||||
uv run eval reverse-text --harness.id null -m Qwen/Qwen3-0.6B --client.base-url http://localhost:8000/v1 -n 20 -r 3 --sampling.max-tokens 1024 --no-push
|
||||
```
|
||||
|
||||
This is of course just a quick vibe check and no full-fledged evaluation, but we can see that the model struggles with this task. In this specific instance, we got an **average reward of ~0.05** across the 20x3 rollouts. Let's do some training!
|
||||
@@ -43,8 +43,9 @@ To train on a single GPU, run
|
||||
```bash
|
||||
# In the `Trainer` pane
|
||||
uv run sft @ examples/basic/reverse-text/sft.toml \
|
||||
--wandb.project ... \
|
||||
--wandb.name ...
|
||||
--run.name sft \
|
||||
--monitors.wandb.project ... \
|
||||
--monitors.wandb.name ...
|
||||
```
|
||||
|
||||
To train on multiple GPUs, run
|
||||
@@ -55,14 +56,14 @@ uv run torchrun \
|
||||
--local-ranks-filter 0 \
|
||||
--nproc-per-node ... \
|
||||
src/prime_rl/trainer/sft/train.py @ examples/basic/reverse-text/sft.toml \
|
||||
--wandb.project ... \
|
||||
--wandb.name ...
|
||||
--monitors.wandb.project ... \
|
||||
--monitors.wandb.name ...
|
||||
```
|
||||
|
||||
This should write a weight checkpoint in `outputs/weights/step_100`. Upload it to HF to be able to use it as the base model for RL.
|
||||
This should write a weight checkpoint in `outputs/sft/weights/step_100`. Upload it to HF to be able to use it as the base model for RL.
|
||||
|
||||
```bash
|
||||
uv run hf upload <user>/Qwen3-0.6B-Reverse-Text-SFT outputs/weights/step_100
|
||||
uv run hf upload <user>/Qwen3-0.6B-Reverse-Text-SFT outputs/sft/weights/step_100
|
||||
```
|
||||
|
||||
We have uploaded the final model as [`PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT`](https://huggingface.co/PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT).
|
||||
@@ -77,14 +78,15 @@ For the RL we will only do 20 steps at 8x16 rollouts, for a total batch size of
|
||||
# Run this in the `Trainer` pane
|
||||
uv run rl @ examples/basic/reverse-text/rl.toml \
|
||||
--model.name ... \
|
||||
--wandb.project ... \
|
||||
--wandb.name ...
|
||||
--run.name rl \
|
||||
--monitors.wandb.project ... \
|
||||
--monitors.wandb.name ...
|
||||
```
|
||||
|
||||
This will write a weight checkpoint in `outputs/weights/step_20`. As before, let's upload it to HF.
|
||||
This will write a weight checkpoint in `outputs/rl/weights/step_20`. As before, let's upload it to HF.
|
||||
|
||||
```bash
|
||||
uv run hf upload <user>/Qwen3-0.6B-Reverse-Text-RL outputs/weights/step_20
|
||||
uv run hf upload <user>/Qwen3-0.6B-Reverse-Text-RL outputs/rl/weights/step_20
|
||||
```
|
||||
|
||||
We have uploaded the final model as [`PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL`](https://huggingface.co/PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL).
|
||||
@@ -100,7 +102,7 @@ uv run inference --vllm.model PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL
|
||||
|
||||
```bash
|
||||
# Run this in the `Trainer` pane
|
||||
uv run eval reverse-text-v1 --harness.id null -m PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL --client.base-url http://localhost:8000/v1 -n 20 -r 3 --sampling.max-tokens 1024 --no-push
|
||||
uv run eval reverse-text --harness.id null -m PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL --client.base-url http://localhost:8000/v1 -n 20 -r 3 --sampling.max-tokens 1024 --no-push
|
||||
```
|
||||
|
||||
Way better! Now we get an **average reward of ~0.8**.
|
||||
@@ -131,18 +133,18 @@ Exec into the trainer pod and run SFT:
|
||||
|
||||
```bash
|
||||
kubectl exec -it my-exp-trainer-0 -- bash
|
||||
uv run sft @ /app/examples/basic/reverse-text/sft.toml --output-dir /data/outputs
|
||||
# This will save checkpoints to /data/outputs/weights/step_100
|
||||
uv run sft @ /app/examples/basic/reverse-text/sft.toml --output-dir /data/outputs --run.name sft
|
||||
# This will save checkpoints to /data/outputs/sft/weights/step_100
|
||||
```
|
||||
|
||||
Upload the checkpoint to HuggingFace or use it directly from shared storage:
|
||||
|
||||
```bash
|
||||
# Option 1: Upload to HuggingFace (from within the pod)
|
||||
uv run hf upload <user>/Qwen3-0.6B-Reverse-Text-SFT /data/outputs/weights/step_100
|
||||
uv run hf upload <user>/Qwen3-0.6B-Reverse-Text-SFT /data/outputs/sft/weights/step_100
|
||||
|
||||
# Option 2: Use local checkpoint path in RL config
|
||||
# Update the model.name in the RL configs to point to /data/outputs/weights/step_100
|
||||
# Update the model.name in the RL configs to point to /data/outputs/sft/weights/step_100
|
||||
```
|
||||
|
||||
### Step 3: Deploy RL Training
|
||||
@@ -213,7 +215,7 @@ kubectl exec -it my-exp-inference-0 -- bash
|
||||
uv run inference --vllm.model /data/outputs/weights/step_20
|
||||
|
||||
# Back in trainer pod, run evaluation
|
||||
uv run eval reverse-text-v1 --harness.id null \
|
||||
uv run eval reverse-text --harness.id null \
|
||||
-m /data/outputs/weights/step_20 \
|
||||
--client.base-url $INFERENCE_URL \
|
||||
-n 20 -r 3 --sampling.max-tokens 1024 --no-push
|
||||
@@ -223,8 +225,8 @@ uv run eval reverse-text-v1 --harness.id null \
|
||||
|
||||
```bash
|
||||
helm uninstall my-exp
|
||||
# Optionally delete shared data:
|
||||
kubectl delete pvc prime-rl-shared-data
|
||||
# Optionally delete shared data. The PVC is named <release-name>-shared-data:
|
||||
kubectl delete pvc my-exp-shared-data
|
||||
```
|
||||
|
||||
**What the Helm chart provides:**
|
||||
|
||||
@@ -4,7 +4,7 @@ seq_len = 2048
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "reverse-text"
|
||||
name = "reverse-text"
|
||||
|
||||
@@ -19,7 +19,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -8,7 +8,32 @@ name = "PrimeIntellect/Qwen3-0.6B"
|
||||
[data]
|
||||
name = "willcb/R1-reverse-wikipedia-paragraphs-v1-1000"
|
||||
seq_len = 4096
|
||||
batch_size = 32
|
||||
batch_size = 32
|
||||
|
||||
[optim]
|
||||
lr = 2e-5
|
||||
lr = 2e-5
|
||||
|
||||
[eval]
|
||||
interval = 25
|
||||
num_examples = 32
|
||||
|
||||
[eval.sampling]
|
||||
max_completion_tokens = 1024
|
||||
|
||||
[[eval.source]]
|
||||
name = "reverse-text"
|
||||
|
||||
[eval.source.env.taskset]
|
||||
id = "reverse-text"
|
||||
|
||||
[eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[eval.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[inference]
|
||||
|
||||
[deployment]
|
||||
num_train_gpus = 1
|
||||
num_infer_gpus = 1
|
||||
|
||||
@@ -16,7 +16,7 @@ In this example, we demonstrate how to train `Qwen3-4B-Instruct-2507` to answer
|
||||
The taskset is included through the Verifiers workspace. After syncing the repository, verify it with:
|
||||
|
||||
```bash
|
||||
uv run python -c "import wiki_search_v1"
|
||||
uv run python -c "import wiki_search"
|
||||
```
|
||||
|
||||
Set up the credentials for the configured reference judge:
|
||||
@@ -77,7 +77,7 @@ Evaluate the base model:
|
||||
|
||||
```bash
|
||||
# In the `Trainer` pane
|
||||
uv run eval wiki-search-v1 --harness.id null \
|
||||
uv run eval wiki-search --harness.id null \
|
||||
-m Qwen/Qwen3-4B-Instruct-2507 \
|
||||
--client.base-url http://localhost:8000/v1 \
|
||||
-n 20 \
|
||||
@@ -93,8 +93,9 @@ Train with the unified config file:
|
||||
```bash
|
||||
# In the `Trainer` pane
|
||||
uv run rl @ examples/basic/wiki-search/rl.toml \
|
||||
--wandb.project your-project-name \
|
||||
--wandb.name your-run-name
|
||||
--run.name rl \
|
||||
--monitors.wandb.project your-project-name \
|
||||
--monitors.wandb.name your-run-name
|
||||
```
|
||||
|
||||
The unified config file automatically configures:
|
||||
@@ -102,10 +103,10 @@ The unified config file automatically configures:
|
||||
- **Orchestrator**: Rollout generation with tool calling enabled
|
||||
- **Inference**: vLLM server for Qwen3-4B-Instruct-2507 with tool parsing enabled
|
||||
|
||||
This will write weight checkpoints in `outputs/weights/step_*`. Upload the final checkpoint to HuggingFace:
|
||||
This will write weight checkpoints in `outputs/rl/weights/step_*`. Upload the final checkpoint to HuggingFace:
|
||||
|
||||
```bash
|
||||
uv run hf upload <user>/Qwen3-4B-Instruct-WikiSearch-RL outputs/weights/step_500
|
||||
uv run hf upload <user>/Qwen3-4B-Instruct-WikiSearch-RL outputs/rl/weights/step_500
|
||||
```
|
||||
|
||||
## Evaluation
|
||||
@@ -119,7 +120,7 @@ uv run inference --vllm.enable-lora --vllm.model <user>/Qwen3-4B-Instruct-WikiSe
|
||||
|
||||
```bash
|
||||
# In the `Trainer` pane
|
||||
uv run eval wiki-search-v1 --harness.id null \
|
||||
uv run eval wiki-search --harness.id null \
|
||||
-m <user>/Qwen3-4B-Instruct-WikiSearch-RL \
|
||||
--client.base-url http://localhost:8000/v1 \
|
||||
-n 20 \
|
||||
@@ -135,7 +136,7 @@ The V1 taskset fixes the question bank and searchable corpus. You can replace it
|
||||
```toml
|
||||
[[orchestrator.train.source]]
|
||||
name = "wiki-search"
|
||||
taskset = { id = "wiki-search-v1", task = { judges = [{ id = "reference", model = "openai/gpt-5.4-nano" }] } }
|
||||
taskset = { id = "wiki-search", task = { judges = [{ id = "reference", model = "openai/gpt-5.4-nano" }] } }
|
||||
harness = { id = "null" }
|
||||
runtime = { type = "subprocess" }
|
||||
```
|
||||
|
||||
@@ -8,7 +8,7 @@ num_infer_gpus = 6
|
||||
[model]
|
||||
name = "Qwen/Qwen3-4B-Instruct-2507"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "wiki-search"
|
||||
name = "wiki-search"
|
||||
|
||||
@@ -32,7 +32,9 @@ target_modules = [
|
||||
[orchestrator]
|
||||
batch_size = 512
|
||||
group_size = 16
|
||||
oversampling_factor = 2.0
|
||||
|
||||
[orchestrator.concurrency]
|
||||
initial_inflight = 1024
|
||||
|
||||
[orchestrator.model.lora]
|
||||
name = "qwen3-4b-wiki-search"
|
||||
@@ -42,9 +44,10 @@ max_completion_tokens = 512
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "wiki-search"
|
||||
curriculum = { gates = { zero_advantage = { type = "advantage_range" } } }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "wiki-search-v1"
|
||||
id = "wiki-search"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -52,10 +55,6 @@ id = "null"
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[[orchestrator.pre_batch_filters]]
|
||||
type = "zero_advantage"
|
||||
enforce = true
|
||||
|
||||
[ckpt] # Checkpoint at the end of training
|
||||
|
||||
[inference.vllm]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Wordle
|
||||
|
||||
In this example, we demonstrate how to train `Qwen3-1.7B` to play Wordle. This will require a SFT warmup to learn the format and, finally, multi-turn RL against the `wordle-v1` taskset to improve performance.
|
||||
In this example, we demonstrate how to train `Qwen3-1.7B` to play Wordle. This will require a SFT warmup to learn the format and, finally, multi-turn RL against the `wordle` taskset to improve performance.
|
||||
|
||||
> The commands in this example were designed to be run on 2 GPUs (one trainer and one inference GPU). It is possible to run on less or more GPUs using different deployment strategies. If you run on a different setup, you may need to adjust the start commands.
|
||||
|
||||
@@ -9,7 +9,7 @@ In this example, we demonstrate how to train `Qwen3-1.7B` to play Wordle. This w
|
||||
The taskset is included through the Verifiers workspace. After syncing the repository, verify it with:
|
||||
|
||||
```bash
|
||||
uv run python -c "import wordle_v1"
|
||||
uv run python -c "import wordle"
|
||||
```
|
||||
|
||||
Start the pre-layouted `tmux` session which we will use to run all experiments and view logs conveniently
|
||||
@@ -29,7 +29,7 @@ Then, use the `eval` entrypoint to evaluate the model in the `wordle` environmen
|
||||
|
||||
```bash
|
||||
# Run this in the `Trainer` pane
|
||||
uv run eval wordle-v1 --harness.id null -m Qwen/Qwen3-1.7B --client.base-url http://localhost:8000/v1 -n 20 -r 3 --sampling.max-tokens 1024 --no-push
|
||||
uv run eval wordle --harness.id null -m Qwen/Qwen3-1.7B --client.base-url http://localhost:8000/v1 -n 20 -r 3 --sampling.max-tokens 1024 --no-push
|
||||
```
|
||||
|
||||
We got an **average reward of ~0.2** across the 20x3 rollouts. From the summary, we can see that the most of the reward is coming from format and partial rewards. In fact, the model does not guess the correct word within any game, leading to a win rate of **0%**. Looking at some samples, it is evident repeatedly submitting guesses in the wrong format and is not able to revise its strategy from the environment feedback. Let's do some SFT warmup to get the model to learn the format of the environment.
|
||||
@@ -45,8 +45,9 @@ To train on a single GPU, run
|
||||
```bash
|
||||
# In the `Trainer` pane
|
||||
uv run sft @ examples/basic/wordle/sft.toml \
|
||||
--wandb.project ... \
|
||||
--wandb.name ...
|
||||
--run.name sft \
|
||||
--monitors.wandb.project ... \
|
||||
--monitors.wandb.name ...
|
||||
```
|
||||
|
||||
To train on multiple GPUs, run
|
||||
@@ -57,14 +58,14 @@ uv run torchrun \
|
||||
--local-ranks-filter 0 \
|
||||
--nproc-per-node ... \
|
||||
src/prime_rl/trainer/sft/train.py @ examples/basic/wordle/sft.toml \
|
||||
--wandb.project ... \
|
||||
--wandb.name ...
|
||||
--monitors.wandb.project ... \
|
||||
--monitors.wandb.name ...
|
||||
```
|
||||
|
||||
After training completes, you will find the final weight checkpoint in `outputs/weights/step_20`. Upload it to HF to be able to use it as the base model for RL we will do in the next section.
|
||||
After training completes, you will find the final weight checkpoint in `outputs/sft/weights/step_20`. Upload it to HF to be able to use it as the base model for RL we will do in the next section.
|
||||
|
||||
```bash
|
||||
uv run hf upload <user>/Qwen3-1.7B-Wordle-SFT outputs/weights/step_20
|
||||
uv run hf upload <user>/Qwen3-1.7B-Wordle-SFT outputs/sft/weights/step_20
|
||||
```
|
||||
|
||||
We have uploaded the final model as [`PrimeIntellect/Qwen3-1.7B-Wordle-SFT`](https://huggingface.co/PrimeIntellect/Qwen3-1.7B-Wordle-SFT).
|
||||
@@ -80,14 +81,15 @@ Finally, we will do multi-turn RL against the `wordle` environment using the mod
|
||||
# Run this in the `Trainer` pane
|
||||
uv run rl @ examples/basic/wordle/rl.toml \
|
||||
--model.name ... \
|
||||
--wandb.project ... \
|
||||
--wandb.name ...
|
||||
--run.name rl \
|
||||
--monitors.wandb.project ... \
|
||||
--monitors.wandb.name ...
|
||||
```
|
||||
|
||||
This will write a weight checkpoint in `outputs/weights/step_100`. As before, let's upload it to HF.
|
||||
This will write a weight checkpoint in `outputs/rl/weights/step_100`. As before, let's upload it to HF.
|
||||
|
||||
```bash
|
||||
uv run hf upload <user>/Qwen3-1.7B-Wordle-RL outputs/weights/step_100
|
||||
uv run hf upload <user>/Qwen3-1.7B-Wordle-RL outputs/rl/weights/step_100
|
||||
```
|
||||
|
||||
We have uploaded the final model as [`PrimeIntellect/Qwen3-1.7B-Wordle-RL`](https://huggingface.co/PrimeIntellect/Qwen3-1.7B-Wordle-RL).
|
||||
@@ -103,7 +105,7 @@ uv run inference --vllm.model PrimeIntellect/Qwen3-1.7B-Wordle-RL
|
||||
|
||||
```bash
|
||||
# Run this in the `Trainer` pane
|
||||
uv run eval wordle-v1 --harness.id null -m PrimeIntellect/Qwen3-1.7B-Wordle-RL --client.base-url http://localhost:8000/v1 -n 20 -r 3 --sampling.max-tokens 1024 --no-push
|
||||
uv run eval wordle --harness.id null -m PrimeIntellect/Qwen3-1.7B-Wordle-RL --client.base-url http://localhost:8000/v1 -n 20 -r 3 --sampling.max-tokens 1024 --no-push
|
||||
```
|
||||
|
||||
Way better! Our model now wins **~60%** and gets an average reward of **~1.5**.
|
||||
|
||||
@@ -5,7 +5,7 @@ seq_len = 8192
|
||||
num_train_gpus = 2
|
||||
num_infer_gpus = 6
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "wordle"
|
||||
name = "wordle"
|
||||
|
||||
@@ -22,7 +22,7 @@ group_size = 16
|
||||
name = "wordle"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "wordle-v1"
|
||||
id = "wordle"
|
||||
|
||||
[orchestrator.train.source.env.player.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
# Standalone SWE evals: SWE-bench Verified + Terminal-Bench 2, one epoch each,
|
||||
# against DeepSeek V4 Flash on Prime Inference.
|
||||
#
|
||||
# export PRIME_API_KEY=<your Prime Inference key>
|
||||
# uv run evals @ examples/evals/swe.toml
|
||||
#
|
||||
# The tasksets run in prime sandboxes (the default runtime), so the key also
|
||||
# authenticates sandbox creation. External API endpoints expose no vLLM
|
||||
# /metrics, so adaptive concurrency has no load signal - the band must be
|
||||
# pinned (min_inflight = max_inflight) or the evals process refuses to start.
|
||||
|
||||
model = "deepseek/deepseek-v4-flash"
|
||||
|
||||
[eval.client]
|
||||
base_url = "https://api.pinference.ai/api/v1"
|
||||
api_key_var = "PRIME_API_KEY"
|
||||
|
||||
[eval.concurrency]
|
||||
min_inflight = 32
|
||||
max_inflight = 32
|
||||
|
||||
[[eval.source]]
|
||||
name = "swebench-verified"
|
||||
|
||||
[eval.source.env.taskset]
|
||||
id = "swebench-verified"
|
||||
|
||||
[eval.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
[eval.source.env.agent.timeout]
|
||||
rollout = 3600
|
||||
|
||||
[[eval.source]]
|
||||
name = "terminal-bench-2"
|
||||
|
||||
[eval.source.env.taskset]
|
||||
id = "terminal-bench-2"
|
||||
|
||||
[eval.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
[eval.source.env.agent.timeout]
|
||||
rollout = 3600
|
||||
@@ -8,7 +8,7 @@ optimization_dtype = "bfloat16"
|
||||
reduce_dtype = "bfloat16"
|
||||
impl = "custom"
|
||||
attn = "flash_attention_2"
|
||||
ep = 8 # keep in sync with deployment.num_gpus
|
||||
ep = 8 # keep in sync with deployment.num_train_gpus
|
||||
|
||||
[renderer]
|
||||
name = "auto"
|
||||
@@ -52,4 +52,4 @@ save_adapter_separately = true
|
||||
|
||||
[deployment]
|
||||
type = "single_node"
|
||||
num_gpus = 8
|
||||
num_train_gpus = 8
|
||||
|
||||
+4
-6
@@ -2,8 +2,6 @@
|
||||
|
||||
This directory contains a Helm chart for deploying prime-rl training infrastructure on Kubernetes clusters.
|
||||
|
||||
For complete documentation, see the [Kubernetes guide](https://docs.primeintellect.ai/prime-rl/kubernetes).
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
@@ -64,11 +62,11 @@ helm install my-exp ./prime-rl \
|
||||
|
||||
```bash
|
||||
helm uninstall my-exp
|
||||
kubectl delete pvc prime-rl-shared-data # Warning: deletes data!
|
||||
|
||||
# The PVC is named <release-name>-shared-data (see templates/pvc.yaml)
|
||||
kubectl delete pvc my-exp-shared-data # Warning: deletes data!
|
||||
```
|
||||
|
||||
## Learn More
|
||||
|
||||
- [Full Kubernetes documentation](https://docs.primeintellect.ai/prime-rl/kubernetes) - Architecture, configuration, distributed training
|
||||
- [Deployment guide](https://docs.primeintellect.ai/prime-rl/deployment) - Non-Kubernetes deployments
|
||||
- [Troubleshooting](https://docs.primeintellect.ai/prime-rl/troubleshooting) - Common issues
|
||||
- [Scaling guide](https://docs.primeintellect.ai/prime-rl/scaling) - Non-Kubernetes multi-node deployment (SLURM), parallelism, benchmarking
|
||||
|
||||
@@ -6,7 +6,7 @@ group_size = 16
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "reverse-text"
|
||||
name = "reverse-text"
|
||||
|
||||
@@ -17,7 +17,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -4,7 +4,7 @@ max_steps = 20
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
seq_len = 2048
|
||||
|
||||
[wandb]
|
||||
[monitors.wandb]
|
||||
project = "reverse-text"
|
||||
name = "reverse-text"
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ readme = "README.md"
|
||||
requires-python = "~=3.12.0"
|
||||
dependencies = [
|
||||
"pydantic>=1.10.13",
|
||||
"prime-pydantic-config>=0.4.2",
|
||||
"prime-pydantic-config>=0.4.3",
|
||||
"renderers>=0.1.9",
|
||||
"tomli>=2.2.1",
|
||||
"tomli-w>=1.2.0",
|
||||
|
||||
@@ -234,8 +234,7 @@ class MaxRLAlgoConfig(BaseAlgoConfig):
|
||||
objective: low-pass-rate examples get ~1/p weight, and ``group_size`` is
|
||||
the truncation order interpolating REINFORCE (1) → exact maximum
|
||||
likelihood (∞). Designed for non-negative (canonically binary) rewards;
|
||||
a group with mean reward 0 carries zero advantages everywhere (the
|
||||
zero-advantage filter drops it, matching the paper's K=0 convention)."""
|
||||
a group with mean reward 0 carries zero advantages everywhere."""
|
||||
|
||||
action_loss_type: ClassVar[ActionLossType] = "rl"
|
||||
|
||||
@@ -246,7 +245,7 @@ class RAEAlgoConfig(BaseAlgoConfig):
|
||||
https://arxiv.org/abs/2506.24119): scalar advantage = reward minus a
|
||||
per-agent EMA baseline of that agent's own rewards, consumed by the ``rl``
|
||||
loss component. The advantage estimator for multi-agent self-play envs
|
||||
(``kuhn-poker-v1`` and friends): in a zero-sum game the group mean is ~0
|
||||
(``kuhn-poker`` and friends): in a zero-sum game the group mean is ~0
|
||||
whatever the policy does, so a group-relative baseline mixes the agents'
|
||||
opposite reward scales — a structural first-mover edge would read as
|
||||
permanent credit. Per-agent baselines measure each agent against its own
|
||||
@@ -274,16 +273,16 @@ class HierarchicalGRPOAlgoConfig(BaseAlgoConfig):
|
||||
|
||||
episode_agents: list[str] = Field(min_length=1)
|
||||
"""Roles compared within one proposed problem. Use ``["solver"]`` for
|
||||
``proposer-solver-v1``."""
|
||||
``proposer-solver``."""
|
||||
|
||||
def validate_env(self, env_config: vf.EnvConfig) -> None:
|
||||
"""Require the proposer-solver structure used by the comparisons."""
|
||||
try:
|
||||
from proposer_solver_v1 import ProposerSolverEnvConfig
|
||||
from proposer_solver import ProposerSolverEnvConfig
|
||||
except ImportError as e:
|
||||
raise ValueError(
|
||||
"algorithm 'hierarchical_grpo' requires a proposer-solver env, but the "
|
||||
"proposer-solver-v1 package is not installed (`uv sync --all-packages`)."
|
||||
"proposer-solver package is not installed (`uv sync --all-packages`)."
|
||||
) from e
|
||||
if not isinstance(env_config, ProposerSolverEnvConfig):
|
||||
raise ValueError(
|
||||
@@ -300,8 +299,8 @@ class OPDAlgoConfig(BaseAlgoConfig):
|
||||
a reference model, evaluated in the trainer from reference prefill
|
||||
logprobs scored over each sample's own context (``ref_logprobs`` on the
|
||||
wire, ``ref_kl`` loss component). No scalar advantage is assigned —
|
||||
rollouts keep ``advantages=None`` (advantage-based filters never fire) and
|
||||
samples ship no advantage stream. ``group_size`` only fans out sampling."""
|
||||
rollouts keep ``advantages=None`` and samples ship no advantage stream.
|
||||
``group_size`` only fans out sampling."""
|
||||
|
||||
action_loss_type: ClassVar[ActionLossType] = "ref_kl"
|
||||
|
||||
@@ -322,8 +321,7 @@ class OPSDAlgoConfig(BaseAlgoConfig):
|
||||
prepended as a leading system message. The sample is scored verbatim (no
|
||||
re-rendering), so it's robust to tool/multimodal prompts and works for any
|
||||
number of turns. No scalar advantage is assigned — rollouts keep
|
||||
``advantages=None`` (advantage-based filters never fire) and samples ship no
|
||||
advantage stream."""
|
||||
``advantages=None`` and samples ship no advantage stream."""
|
||||
|
||||
action_loss_type: ClassVar[ActionLossType] = "ref_kl"
|
||||
|
||||
@@ -347,8 +345,8 @@ class SFTAlgoConfig(BaseAlgoConfig):
|
||||
type: Literal["sft"] = "sft"
|
||||
"""SFT distillation: cross-entropy on the sampled tokens. The ``ce`` loss
|
||||
ignores advantages and SFT assigns none — it trains on every sampled token.
|
||||
Reward-based filtering, if wanted, is an explicit filter, not smuggled
|
||||
through an unused advantage stream."""
|
||||
A curriculum can reject results using reward or any other finalized
|
||||
rollout data."""
|
||||
|
||||
action_loss_type: ClassVar[ActionLossType] = "ce"
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ from prime_rl.utils.config import BaseConfig
|
||||
|
||||
|
||||
class EnvServerConfig(BaseConfig):
|
||||
"""``uv run env-server``: what to serve (``[env]``, or ``[legacy]`` for a classic v0
|
||||
env) and how it's hosted (``[serve]``). The ``rl`` launcher writes one of these per
|
||||
train/eval source, with ``serve.address`` set to the source's derived address."""
|
||||
"""``uv run env-server``: what to serve (``[env]``) and how it's hosted (``[serve]``).
|
||||
The ``rl`` launcher writes one of these per train/eval source, with ``serve.address``
|
||||
set to the source's derived address."""
|
||||
|
||||
env: SerializeAsAny[vf.EnvConfig] = vf.SingleAgentEnvConfig()
|
||||
"""The environment — which env, its seed taskset, each agent, its knobs. Narrowed to the selected env's config class by the env id, else the taskset id."""
|
||||
@@ -18,9 +18,6 @@ class EnvServerConfig(BaseConfig):
|
||||
serve: vf.ServeConfig = vf.ServeConfig()
|
||||
"""How it's served: the worker pool, the bind address, each worker's episode bound."""
|
||||
|
||||
legacy: vf.LegacyEnvConfig = vf.LegacyEnvConfig()
|
||||
"""A classic (v0) environment to serve through the bridge instead of ``env``."""
|
||||
|
||||
log: LogConfig = LogConfig()
|
||||
|
||||
output_dir: Path = Path("outputs")
|
||||
@@ -32,35 +29,12 @@ class EnvServerConfig(BaseConfig):
|
||||
"""Narrow ``env`` to the selected env's config class."""
|
||||
return vf.resolve_env_field(data, vf.narrowed_env_annotation(cls))
|
||||
|
||||
@property
|
||||
def is_legacy(self) -> bool:
|
||||
"""Whether this serves the v0 bridge: a legacy id and no v1 taskset."""
|
||||
return self.legacy.id is not None and not self.env.taskset.id
|
||||
|
||||
@property
|
||||
def env_id(self) -> str:
|
||||
"""The served env's identifier: the v1 env's, else the v0 env id."""
|
||||
return self.env.env_id or self.legacy.id or ""
|
||||
return self.env.env_id or ""
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_env(self):
|
||||
# A v0 id next to any v1 env identity leaves one of the two going nowhere, and
|
||||
# which one depends on `is_legacy`: a taskset makes it False, so the v0 env never
|
||||
# loads; a bare `env.id` leaves it True, so the v0 env runs under the v1 name.
|
||||
if self.legacy.id is not None and self.env.env_id:
|
||||
if self.env.taskset.id:
|
||||
raise ValueError(
|
||||
f"legacy.id {self.legacy.id!r} is a classic (v0) env and can't combine with "
|
||||
f"the v1 taskset {self.env.taskset.id!r}. Pairing a reusable env with a taskset "
|
||||
f"is env.id = {self.legacy.id!r}; to run the v0 env instead, drop the taskset."
|
||||
)
|
||||
raise ValueError(
|
||||
f"legacy.id {self.legacy.id!r} is a classic (v0) env and can't combine with the "
|
||||
f"v1 env.id {self.env.id!r}: the v0 env is what would run, stamped with the v1 "
|
||||
"env's name. Keep whichever one you meant to run."
|
||||
)
|
||||
if not self.env_id:
|
||||
raise ValueError(
|
||||
'no env configured — set env = { taskset = { id = "<id>" } } (v1) or legacy = { id = "<id>" } (v0)'
|
||||
)
|
||||
raise ValueError('no env configured — set env = { taskset = { id = "<id>" } }')
|
||||
return self
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
from pathlib import Path
|
||||
|
||||
from pydantic import Field, model_validator
|
||||
|
||||
from prime_rl.configs.monitors import MonitorsConfig
|
||||
from prime_rl.configs.orchestrator import ConcurrencyConfig, EvalConfig
|
||||
from prime_rl.configs.shared import ClientConfig, LogConfig
|
||||
from prime_rl.utils.config import BaseConfig
|
||||
|
||||
|
||||
class EvalsEvalConfig(EvalConfig):
|
||||
"""Evals against a live inference server. Extends the orchestrator ``EvalConfig``
|
||||
(sources, sampling, intervals) with the client of the inference deployment and
|
||||
evals-side knobs."""
|
||||
|
||||
client: ClientConfig = ClientConfig()
|
||||
"""Client of the inference server evals run against. Auto-wired from the
|
||||
``[inference]`` block when the launcher manages the server."""
|
||||
|
||||
env_server_base_port: int = Field(5000, ge=1, le=65535)
|
||||
"""First port of the env-server port range: the eval source at position ``i`` is
|
||||
served at ``tcp://127.0.0.1:<base + i>``. Sources with an explicit ``serve.address``
|
||||
keep it instead, without shifting the other sources' ports."""
|
||||
|
||||
concurrency: ConcurrencyConfig = ConcurrencyConfig()
|
||||
"""Adaptive in-flight episode concurrency (``[eval.concurrency]``), sized by the
|
||||
same controller as the orchestrator's ``[orchestrator.concurrency]``."""
|
||||
|
||||
@property
|
||||
def env_addresses(self) -> dict[tuple[str, str], str]:
|
||||
"""Where each eval source's env server lives, keyed by ``("eval", resolved_name)``.
|
||||
Same contract as ``OrchestratorConfig.env_addresses``: sources with an explicit
|
||||
``serve.address`` are externally managed; the evals process spawns an env server at
|
||||
the derived address for every other source."""
|
||||
return {
|
||||
("eval", source.resolved_name): source.serve.address
|
||||
or f"tcp://127.0.0.1:{self.env_server_base_port + index}"
|
||||
for index, source in enumerate(self.source)
|
||||
}
|
||||
|
||||
|
||||
class OnlineConfig(BaseConfig):
|
||||
"""Checkpoint-driven online evals: watch a weights directory for new HF checkpoints
|
||||
and evaluate each eligible one. Without this block the evals process runs every eval
|
||||
source once against the weights the inference server currently serves, then exits."""
|
||||
|
||||
weights_dir: Path | None = None
|
||||
"""Directory to watch for ``step_{n}`` HF weight checkpoints. The ``sft`` launcher
|
||||
fills it from ``ckpt.output_dir`` when checkpoints are redirected to another volume;
|
||||
defaults to ``<output_dir>/weights``."""
|
||||
|
||||
max_steps: int | None = None
|
||||
"""Trainer step at which the run ends. The final checkpoint always fires every
|
||||
eval env, and the evals process exits after processing it. If None, the evals process
|
||||
runs until terminated."""
|
||||
|
||||
resume_step: int | None = None
|
||||
"""Trainer step the run resumed from. When set, the startup (base-model) eval is
|
||||
skipped; set ``eval.retrigger_on_resume`` to re-fire interval-aligned evals at
|
||||
this step."""
|
||||
|
||||
|
||||
class EvalsConfig(BaseConfig):
|
||||
"""``uv run evals``: run the configured evals against a live inference server.
|
||||
Standalone (no ``[online]``), one epoch of every eval source runs against the
|
||||
served weights and the evals process exits. With ``[online]``, the evals process watches a
|
||||
weights directory for new HF checkpoints, points the inference server at each one
|
||||
(``/update_weights`` from disk), and runs the configured evals against the updated
|
||||
weights — the ``sft`` launcher writes this config; it also works standalone against
|
||||
any trainer that writes ``weights/step_{n}`` HF checkpoints with ``STABLE`` markers."""
|
||||
|
||||
model: str = "Qwen/Qwen3-0.6B"
|
||||
"""Name the inference server serves the model under — the ``model`` field of every
|
||||
eval request and the startup model check. Auto-filled from ``model.name`` by the
|
||||
``sft`` launcher; the name stays fixed across checkpoint reloads (weights are
|
||||
swapped in place), so per-step results are told apart by ``eval/{env}/policy_version``."""
|
||||
|
||||
eval: EvalsEvalConfig
|
||||
"""Eval sources, sampling, intervals, concurrency, and the inference client."""
|
||||
|
||||
online: OnlineConfig | None = None
|
||||
"""Checkpoint watching (``[online]``). None runs the evals once and exits."""
|
||||
|
||||
output_dir: Path = Path("outputs")
|
||||
"""Directory to write outputs to — rollout traces and logs are written as
|
||||
subdirectories. Shared with the trainer for online evals."""
|
||||
|
||||
log: LogConfig = LogConfig()
|
||||
|
||||
monitors: MonitorsConfig = MonitorsConfig()
|
||||
"""Metric monitors (``monitors.wandb``, ``monitors.file``)."""
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_weights_dir(self):
|
||||
if self.online is not None and self.online.weights_dir is None:
|
||||
self.online.weights_dir = self.output_dir / "weights"
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_skip_first_step_is_online_only(self):
|
||||
"""``skip_first_step`` gates the base-model eval between checkpoints; a
|
||||
standalone run has only that one epoch, so skipping it would exit
|
||||
successfully without evaluating anything."""
|
||||
if self.online is None and self.eval.skip_first_step:
|
||||
raise ValueError(
|
||||
"eval.skip_first_step only applies to online evals - a standalone run "
|
||||
"would skip its only eval epoch. Remove it or add an [online] block."
|
||||
)
|
||||
return self
|
||||
@@ -0,0 +1,46 @@
|
||||
from pathlib import Path
|
||||
|
||||
from prime_rl.utils.config import BaseConfig
|
||||
|
||||
|
||||
class WandbMonitorConfig(BaseConfig):
|
||||
project: str = "prime-rl"
|
||||
"""W&B project to log to."""
|
||||
|
||||
entity: str | None = None
|
||||
"""W&B entity to log to."""
|
||||
|
||||
name: str | None = None
|
||||
"""W&B run name. Inherits ``run.name`` when unset."""
|
||||
|
||||
group: str | None = None
|
||||
"""W&B group."""
|
||||
|
||||
tags: list[str] | None = None
|
||||
"""W&B tags attached to the run."""
|
||||
|
||||
offline: bool = False
|
||||
"""Run W&B in offline mode."""
|
||||
|
||||
|
||||
class FileMonitorConfig(BaseConfig):
|
||||
path: Path = Path("metrics.jsonl")
|
||||
"""Path of the JSONL file, relative to the component's ``output_dir`` (absolute paths win)."""
|
||||
|
||||
|
||||
class PrimeMonitorConfig(BaseConfig):
|
||||
name: str | None = None
|
||||
"""Run name shown on the platform. Inherits ``run.name`` when unset."""
|
||||
|
||||
|
||||
class MonitorsConfig(BaseConfig):
|
||||
wandb: WandbMonitorConfig | None = None
|
||||
"""Log metrics to Weights & Biases. Off by default; enable with ``--monitors.wandb``."""
|
||||
|
||||
file: FileMonitorConfig | None = FileMonitorConfig()
|
||||
"""Log metrics and episode traces to the run's output directory. On by default; disable with ``--no-monitors.file``."""
|
||||
|
||||
|
||||
class OrchestratorMonitorsConfig(MonitorsConfig):
|
||||
prime: PrimeMonitorConfig | None = None
|
||||
"""Log metrics and episodes to the Prime Intellect platform. If None, disabled."""
|
||||
@@ -9,16 +9,15 @@ from prime_rl.configs.algorithm import (
|
||||
AlgoConfig,
|
||||
GRPOAlgoConfig,
|
||||
)
|
||||
from prime_rl.configs.monitors import OrchestratorMonitorsConfig
|
||||
from prime_rl.configs.shared import (
|
||||
BaseModelConfig,
|
||||
ClientConfig,
|
||||
EnvVars,
|
||||
FileMonitorConfig,
|
||||
HeartbeatConfig,
|
||||
LogConfig,
|
||||
PrimeMonitorConfig,
|
||||
ResumeConfig,
|
||||
TransportConfig,
|
||||
WandbWithExtrasConfig,
|
||||
ZMQTransportConfig,
|
||||
)
|
||||
from prime_rl.configs.trainer import TokenizerConfig
|
||||
@@ -119,8 +118,7 @@ class EvalSamplingConfig(BaseConfig):
|
||||
|
||||
class EnvConfig(BaseConfig):
|
||||
"""One environment a run pulls from: the verifiers blocks it composes (``env`` — what
|
||||
runs, ``serve`` — how it's hosted, ``legacy`` — a classic v0 env instead) plus this
|
||||
orchestrator's own per-env knobs."""
|
||||
runs, ``serve`` — how it's hosted) plus this orchestrator's own per-env knobs."""
|
||||
|
||||
env: SerializeAsAny[vf.EnvConfig] = vf.SingleAgentEnvConfig()
|
||||
"""The verifiers environment — which env, its seed taskset, each agent, its knobs. Narrowed to the selected env's config class by the env id, else the taskset id."""
|
||||
@@ -128,9 +126,6 @@ class EnvConfig(BaseConfig):
|
||||
serve: vf.ServeConfig = vf.ServeConfig()
|
||||
"""How this source's env server is hosted. The sizing knobs are consumed by the launcher, which writes each source's env-server config with an unset ``address`` filled in as the derived ``tcp://127.0.0.1:<env_server_base_port + index>``. Setting ``address`` marks the server externally managed: the launchers neither write its env-server TOML nor spawn a server for it, and the orchestrator connects to the given address — e.g. a k8s deployment running env servers in their own pods."""
|
||||
|
||||
legacy: vf.LegacyEnvConfig = vf.LegacyEnvConfig()
|
||||
"""A classic (v0) environment to run through the bridge instead of ``env``."""
|
||||
|
||||
name: str | None = None
|
||||
"""Display name for this environment in logs, metrics, and buffer keys. Defaults to the taskset id. Must be unique across all envs in the same group."""
|
||||
|
||||
@@ -143,15 +138,9 @@ class EnvConfig(BaseConfig):
|
||||
"""Narrow ``env`` to the selected env's config class."""
|
||||
return vf.resolve_env_field(data, vf.narrowed_env_annotation(cls))
|
||||
|
||||
@property
|
||||
def is_legacy(self) -> bool:
|
||||
"""A classic (v0) env run through the bridge: a legacy id and no v1 taskset."""
|
||||
return self.legacy.id is not None and not self.env.taskset.id
|
||||
|
||||
@property
|
||||
def env_id(self) -> str:
|
||||
"""The env's identifier: the v1 env's, else the v0 env id."""
|
||||
return self.env.env_id or self.legacy.id or ""
|
||||
return self.env.env_id or ""
|
||||
|
||||
@property
|
||||
def resolved_name(self) -> str:
|
||||
@@ -159,48 +148,86 @@ class EnvConfig(BaseConfig):
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_env(self):
|
||||
# A v0 id next to any v1 env identity leaves one of the two going nowhere, and
|
||||
# which one depends on `is_legacy`: a taskset makes it False, so the v0 env never
|
||||
# loads; a bare `env.id` leaves it True, so the v0 env runs under the v1 name.
|
||||
if self.legacy.id is not None and self.env.env_id:
|
||||
if self.env.taskset.id:
|
||||
raise ValueError(
|
||||
f"legacy.id {self.legacy.id!r} is a classic (v0) env and can't combine with "
|
||||
f"the v1 taskset {self.env.taskset.id!r}. Pairing a reusable env with a taskset "
|
||||
f"is env.id = {self.legacy.id!r}; to run the v0 env instead, drop the taskset."
|
||||
)
|
||||
raise ValueError(
|
||||
f"legacy.id {self.legacy.id!r} is a classic (v0) env and can't combine with the "
|
||||
f"v1 env.id {self.env.id!r}: the v0 env is what would run, stamped with the v1 "
|
||||
"env's name. Keep whichever one you meant to run."
|
||||
)
|
||||
if not self.env_id:
|
||||
raise ValueError(
|
||||
'no env configured — set env = { taskset = { id = "<id>" } } (v1) or legacy = { id = "<id>" } (v0)'
|
||||
)
|
||||
raise ValueError('no env configured — set env = { taskset = { id = "<id>" } }')
|
||||
if self.resolved_name == "agg":
|
||||
raise ValueError(
|
||||
'Environment name "agg" is reserved for cross-env metric aggregation. Use a different name or id.'
|
||||
)
|
||||
return self
|
||||
|
||||
|
||||
class StandardSamplerConfig(BaseConfig):
|
||||
type: Literal["standard"] = "standard"
|
||||
|
||||
|
||||
class DifficultyPoolConfig(BaseConfig):
|
||||
threshold: float
|
||||
"""Inclusive maximum reward assigned to this pool."""
|
||||
|
||||
weight: float = Field(ge=0)
|
||||
"""Relative per-task sampling weight."""
|
||||
|
||||
|
||||
def default_difficulty_pools() -> dict[str, DifficultyPoolConfig]:
|
||||
return {
|
||||
"hard": DifficultyPoolConfig(threshold=0.25, weight=0.2),
|
||||
"normal": DifficultyPoolConfig(threshold=0.75, weight=1.0),
|
||||
"easy": DifficultyPoolConfig(threshold=1.0, weight=0.2),
|
||||
}
|
||||
|
||||
|
||||
class DifficultyPoolSamplerConfig(BaseConfig):
|
||||
type: Literal["difficulty_pool"] = "difficulty_pool"
|
||||
|
||||
pools: dict[str, DifficultyPoolConfig] = Field(default_factory=default_difficulty_pools)
|
||||
"""Named pools ordered by their reward thresholds."""
|
||||
|
||||
seed: int = 42
|
||||
|
||||
@model_validator(mode="after")
|
||||
def resolve_legacy_env_kwargs(self):
|
||||
"""For a v0/legacy env, surface the v1 knobs the legacy bridge applies via
|
||||
``legacy.extra_env_kwargs`` (``env.set_kwargs(...)``): the per-rollout wall-clock
|
||||
timeout and the multi-turn completion-token budget, read off ``env.agent``.
|
||||
(``max_seq_len`` is added per train run in ``OrchestratorConfig.resolve_env_config``,
|
||||
which knows ``seq_len``.)"""
|
||||
if self.is_legacy:
|
||||
agent = getattr(self.env, "agent", None)
|
||||
if agent is not None:
|
||||
if agent.timeout.rollout is not None:
|
||||
self.legacy.extra_env_kwargs["timeout_seconds"] = agent.timeout.rollout
|
||||
if agent.max_output_tokens is not None:
|
||||
self.legacy.extra_env_kwargs["max_total_completion_tokens"] = agent.max_output_tokens
|
||||
def validate_pools(self):
|
||||
if not self.pools:
|
||||
raise ValueError("DifficultyPoolSampler requires at least one pool")
|
||||
thresholds = [pool.threshold for pool in self.pools.values()]
|
||||
if len(set(thresholds)) != len(thresholds):
|
||||
raise ValueError("Difficulty pool thresholds must be unique")
|
||||
if not any(pool.weight > 0 for pool in self.pools.values()):
|
||||
raise ValueError("At least one difficulty pool must have a positive weight")
|
||||
return self
|
||||
|
||||
|
||||
TaskSamplerConfig: TypeAlias = Annotated[
|
||||
StandardSamplerConfig | DifficultyPoolSamplerConfig,
|
||||
Field(discriminator="type"),
|
||||
]
|
||||
|
||||
|
||||
class AdvRangeGateConfig(BaseConfig):
|
||||
type: Literal["advantage_range"] = "advantage_range"
|
||||
|
||||
reject_min: float = 0.0
|
||||
reject_max: float = 0.0
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_range(self):
|
||||
if self.reject_min > self.reject_max:
|
||||
raise ValueError("reject_min must be less than or equal to reject_max")
|
||||
return self
|
||||
|
||||
|
||||
AdmissionGateConfig: TypeAlias = AdvRangeGateConfig
|
||||
|
||||
|
||||
class CurriculumConfig(BaseConfig):
|
||||
sampler: TaskSamplerConfig = Field(default_factory=StandardSamplerConfig)
|
||||
"""Task selection policy. The default cycles through the task iterator in source order."""
|
||||
|
||||
gates: dict[str, AdmissionGateConfig] = Field(default_factory=dict)
|
||||
"""Named admission policies. Every gate observes every finalized group,
|
||||
and a group trains only when every gate admits it."""
|
||||
|
||||
|
||||
class TrainSourceConfig(EnvConfig):
|
||||
sampling: TrainSamplingConfig = TrainSamplingConfig()
|
||||
"""Per-env sampling overrides. Unset fields inherit from the group-level train sampling config."""
|
||||
@@ -214,6 +241,10 @@ class TrainSourceConfig(EnvConfig):
|
||||
``orchestrator.algo`` when unset; set ``type`` (and its params) to give
|
||||
this env its own algorithm."""
|
||||
|
||||
curriculum: CurriculumConfig | None = None
|
||||
"""User-authored task sampler and admission gates. The default cycles
|
||||
through the taskset and admits every finalized group."""
|
||||
|
||||
|
||||
class EvalSourceConfig(EnvConfig):
|
||||
sampling: EvalSamplingConfig = EvalSamplingConfig()
|
||||
@@ -236,6 +267,9 @@ class TrainConfig(BaseConfig):
|
||||
sampling: TrainSamplingConfig = TrainSamplingConfig()
|
||||
"""Shared training sampling configuration."""
|
||||
|
||||
filter_zero_advantages: bool = True
|
||||
"""Remove zero-advantage RL tokens after collecting a batch, before shipping it."""
|
||||
|
||||
@model_validator(mode="after")
|
||||
def resolve_env_defaults(self):
|
||||
"""Resolve per-env overrides: inherit group-level sampling (the worker ``pool``
|
||||
@@ -329,11 +363,8 @@ 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)
|
||||
"""Wait up to this many seconds for the startup weight directory to appear (the trainer broadcasts the incoming policy — v0 from scratch, v{resume_step} on resume — before the first step). If None, fall back to a default timeout. Raise this for large models on slow shared filesystems."""
|
||||
"""Wait up to this many seconds for the startup weight directory to appear (the trainer broadcasts the incoming policy — v0 from scratch, the resumed step's version on resume — before the first step). If None, fall back to a default timeout. Raise this for large models on slow shared filesystems."""
|
||||
|
||||
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."""
|
||||
@@ -345,50 +376,6 @@ class CheckpointConfig(BaseConfig):
|
||||
"""Skip loading the progress from checkpoint."""
|
||||
|
||||
|
||||
# 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"
|
||||
|
||||
@@ -433,6 +420,30 @@ WeightBroadcastConfig: TypeAlias = Annotated[
|
||||
]
|
||||
|
||||
|
||||
class ConcurrencyConfig(BaseConfig):
|
||||
"""Adaptive in-flight concurrency control. The orchestrator sizes the
|
||||
in-flight episode cap from engine KV capacity and learned per-env episode
|
||||
costs; these fields only bound and seed it."""
|
||||
|
||||
initial_inflight: int | None = Field(None, ge=1)
|
||||
"""Optional initial in-flight episodes to start from. Set it when a good value is known to skip the initial ramp; otherwise auto-derive a pessimistic bound at runtime."""
|
||||
|
||||
min_inflight: int = Field(1, ge=1)
|
||||
"""Minimum number of in-flight episodes. Set ``min_inflight = max_inflight`` to recover fixed concurrency."""
|
||||
|
||||
max_inflight: int | None = Field(1024, ge=1)
|
||||
"""Maximum number of in-flight episodes. Set it to avoid runaway concurrency, especially to limit other external resources (e.g. sandboxes). None removes the ceiling."""
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_bounds(self):
|
||||
if self.max_inflight is not None:
|
||||
if self.initial_inflight is not None and self.initial_inflight > self.max_inflight:
|
||||
raise ValueError("concurrency.initial_inflight must not exceed concurrency.max_inflight")
|
||||
if self.min_inflight > self.max_inflight:
|
||||
raise ValueError("concurrency.min_inflight must not exceed concurrency.max_inflight")
|
||||
return self
|
||||
|
||||
|
||||
class OrchestratorConfig(BaseConfig):
|
||||
algo: AlgoConfig = GRPOAlgoConfig()
|
||||
"""Training algorithm: sampling plus the per-token training signal (credit
|
||||
@@ -459,43 +470,24 @@ class OrchestratorConfig(BaseConfig):
|
||||
eval: EvalConfig | None = None
|
||||
"""Evaluation configuration."""
|
||||
|
||||
pre_batch_filters: list[FilterConfig] = [
|
||||
GibberishFilterConfig(enforce=False),
|
||||
RepetitionFilterConfig(enforce=False),
|
||||
ZeroAdvantageFilterConfig(enforce=False),
|
||||
]
|
||||
"""Filters applied *before* a rollout enters the training batch buffer.
|
||||
All three filter types are registered in monitor mode by default; flip ``enforce=true`` per type
|
||||
to drop matching rollouts before they consume a slot in the batch (e.g. a zero-advantage group
|
||||
never makes it into a training batch)."""
|
||||
|
||||
post_batch_filters: list[FilterConfig] = [
|
||||
GibberishFilterConfig(),
|
||||
RepetitionFilterConfig(),
|
||||
ZeroAdvantageFilterConfig(),
|
||||
]
|
||||
"""Filters applied *after* a batch has been assembled. Each filter annotates each rollout;
|
||||
rollouts flagged by an enforcing filter are still recorded but not shipped to the trainer."""
|
||||
|
||||
log: LogConfig = LogConfig()
|
||||
|
||||
env_vars: EnvVars = {}
|
||||
"""Extra environment variables for the orchestrator process(es). Merged on top of the launcher defaults."""
|
||||
|
||||
wandb: WandbWithExtrasConfig | None = None
|
||||
|
||||
prime_monitor: PrimeMonitorConfig | None = None
|
||||
|
||||
file_monitor: FileMonitorConfig | None = None
|
||||
"""Local JSONL metric sink. If set, orchestrator metrics are appended to ``<output_dir>/metrics.jsonl``."""
|
||||
monitors: OrchestratorMonitorsConfig = OrchestratorMonitorsConfig()
|
||||
"""Metric monitors (``monitors.wandb``, ``monitors.file``, ``monitors.prime``)."""
|
||||
|
||||
collect_inference_metrics: bool = True
|
||||
"""Collect inference-server metrics (requires wandb)."""
|
||||
"""Mirror inference-server metrics to W&B (requires wandb). The ``/metrics`` poll itself always runs — it feeds the concurrency controller."""
|
||||
|
||||
inference_metrics_roles: list[Literal["prefill", "decode"]] | None = None
|
||||
"""Role for each policy admin client when collecting P/D inference metrics."""
|
||||
|
||||
ckpt: CheckpointConfig | None = None
|
||||
|
||||
resume: ResumeConfig | None = None
|
||||
"""Resume the orchestrator from a checkpoint. None starts from scratch; an empty block resumes from the latest checkpoint, ``resume.step`` from that step, ``resume.dir`` from an external checkpoint step directory. Without ``ckpt`` the run loads but saves no new checkpoints."""
|
||||
"""Checkpoint configuration."""
|
||||
|
||||
weight_broadcast: WeightBroadcastConfig = FileSystemWeightBroadcastConfig()
|
||||
@@ -508,7 +500,7 @@ class OrchestratorConfig(BaseConfig):
|
||||
"""Directory to write outputs to — checkpoints, weights, rollouts, and logs are written as subdirectories. Shared with the trainer; 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."""
|
||||
"""Global rate limit on task dispatch, in tasks per minute. Recommended for sandbox-backed environments to prevent sandbox-not-ready errors during autoscaling. None disables rate limiting."""
|
||||
|
||||
env_server_base_port: int = Field(5000, ge=1, le=65535)
|
||||
"""First port of the env-server port range: the source at position ``i`` (train, then eval) is served at ``tcp://127.0.0.1:<base + i>``. Sources with an explicit ``serve.address`` keep it instead, without shifting the other sources' ports (indices stay positional). Give concurrent runs on one host distinct bases (e.g. one per multi-run orchestrator)."""
|
||||
@@ -519,11 +511,8 @@ class OrchestratorConfig(BaseConfig):
|
||||
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_episodes`` from ``batch_size`` when ``max_inflight_episodes`` is unset. Values below 1.0 intentionally cap in-flight episode capacity below ``batch_size``."""
|
||||
|
||||
max_inflight_episodes: int | None = Field(None, ge=1)
|
||||
"""Maximum number of episodes kept in-flight — one episode is one agent run at a time, whatever the env's agents are. Required for token-based batching. With ``batch_size`` set, defaults to ``batch_size * oversampling_factor`` (or ``batch_size`` when ``oversampling_factor`` is unset)."""
|
||||
concurrency: ConcurrencyConfig = ConcurrencyConfig()
|
||||
"""Adaptive in-flight concurrency control (``[orchestrator.concurrency]``)."""
|
||||
|
||||
group_size: int = Field(1, ge=1)
|
||||
"""Output sequences returned per example during training."""
|
||||
@@ -543,9 +532,6 @@ class OrchestratorConfig(BaseConfig):
|
||||
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."""
|
||||
|
||||
bench: bool = False
|
||||
"""Benchmark mode. Sets ``max_steps`` to 5 and disables W&B."""
|
||||
|
||||
heartbeat: HeartbeatConfig | None = None
|
||||
"""BetterStack heartbeat configuration for monitoring training progress."""
|
||||
|
||||
@@ -564,23 +550,13 @@ class OrchestratorConfig(BaseConfig):
|
||||
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:
|
||||
def auto_setup_prime_monitor_name(self):
|
||||
"""Default ``monitors.prime.name`` to the W&B run name when monitoring
|
||||
is enabled and the user hasn't named the platform run explicitly."""
|
||||
if self.monitors.prime is None or self.monitors.prime.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):
|
||||
for slot_name in ("pre_batch_filters", "post_batch_filters"):
|
||||
types = [f.type for f in getattr(self, slot_name)]
|
||||
if len(types) != len(set(types)):
|
||||
raise ValueError(
|
||||
f"Duplicate filter types in {slot_name}: {types}. Each filter type may only appear once per slot."
|
||||
)
|
||||
if self.monitors.wandb is not None and self.monitors.wandb.name:
|
||||
self.monitors.prime.name = self.monitors.wandb.name
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
@@ -650,29 +626,13 @@ class OrchestratorConfig(BaseConfig):
|
||||
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_episodes is None:
|
||||
raise ValueError("max_inflight_episodes must be set when token_batch_size is set")
|
||||
else:
|
||||
assert self.batch_size is not None
|
||||
if self.batch_size % self.group_size != 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_episodes = max(
|
||||
self.group_size,
|
||||
int(self.batch_size * oversampling_factor),
|
||||
)
|
||||
if self.max_inflight_episodes is not None and self.oversampling_factor is not None:
|
||||
expected_max_inflight_episodes = resolved_max_inflight_episodes
|
||||
if self.max_inflight_episodes != expected_max_inflight_episodes:
|
||||
raise ValueError("max_inflight_episodes conflicts with oversampling_factor * batch_size")
|
||||
if self.max_inflight_episodes is None:
|
||||
self.max_inflight_episodes = resolved_max_inflight_episodes
|
||||
if self.batch_size is not None and self.batch_size % self.group_size != 0:
|
||||
raise ValueError("Batch size must be divisible by the number of samples per problem")
|
||||
|
||||
if self.max_inflight_episodes is not None and self.max_inflight_episodes < self.group_size:
|
||||
raise ValueError("max_inflight_episodes must be at least the number of rollouts per example")
|
||||
for field in ("max_inflight", "initial_inflight"):
|
||||
value = getattr(self.concurrency, field)
|
||||
if value is not None and value < self.group_size:
|
||||
raise ValueError(f"concurrency.{field} must be at least the number of rollouts per example")
|
||||
|
||||
# Propagate the top-level ``group_size`` into each train env that didn't set its own.
|
||||
for env_cfg in self.train.source:
|
||||
@@ -681,23 +641,9 @@ class OrchestratorConfig(BaseConfig):
|
||||
|
||||
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
|
||||
|
||||
# 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):
|
||||
"""Set vLLM sampling defaults + legacy env kwargs on each train env from top-level fields."""
|
||||
"""Set vLLM sampling defaults on each train env from top-level fields."""
|
||||
for env in self.train.source:
|
||||
# Policy-sourced rollouts hit our vLLM server; frozen-sourced
|
||||
# rollouts may hit external OAI endpoints that reject these knobs.
|
||||
@@ -706,10 +652,6 @@ class OrchestratorConfig(BaseConfig):
|
||||
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)
|
||||
if env.is_legacy:
|
||||
# v0 env: cap per-turn response tokens to the training budget (the legacy
|
||||
# bridge applies legacy.extra_env_kwargs via env.set_kwargs).
|
||||
env.legacy.extra_env_kwargs["max_seq_len"] = self.seq_len
|
||||
return self
|
||||
|
||||
@property
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import uuid
|
||||
import warnings
|
||||
from pathlib import Path
|
||||
from typing import Annotated, Any, Literal, TypeAlias
|
||||
@@ -6,6 +7,7 @@ from pydantic import Field, model_validator
|
||||
|
||||
from prime_rl.configs.inference import InferenceConfig
|
||||
from prime_rl.configs.inference import WeightBroadcastConfig as InferenceWeightBroadcastConfig
|
||||
from prime_rl.configs.monitors import FileMonitorConfig, PrimeMonitorConfig
|
||||
from prime_rl.configs.orchestrator import (
|
||||
FileSystemWeightBroadcastConfig as OrchestratorFileSystemWeightBroadcastConfig,
|
||||
)
|
||||
@@ -20,17 +22,12 @@ from prime_rl.configs.orchestrator import (
|
||||
)
|
||||
from prime_rl.configs.shared import (
|
||||
EnvVars,
|
||||
FileMonitorConfig,
|
||||
ResumeConfig,
|
||||
RunConfig,
|
||||
SlurmConfig,
|
||||
TransportConfig,
|
||||
VLMConfig,
|
||||
)
|
||||
from prime_rl.configs.trainer import (
|
||||
BenchConfig,
|
||||
FakeDataLoaderConfig,
|
||||
TokenizerConfig,
|
||||
TrainerConfig,
|
||||
)
|
||||
from prime_rl.configs.trainer import (
|
||||
FileSystemWeightBroadcastConfig as TrainerFileSystemWeightBroadcastConfig,
|
||||
)
|
||||
@@ -40,13 +37,16 @@ from prime_rl.configs.trainer import (
|
||||
from prime_rl.configs.trainer import (
|
||||
NIXLWeightBroadcastConfig as TrainerNIXLWeightBroadcastConfig,
|
||||
)
|
||||
from prime_rl.configs.trainer import (
|
||||
TokenizerConfig,
|
||||
TrainerConfig,
|
||||
)
|
||||
from prime_rl.utils.config import BaseConfig, find_package_resource
|
||||
from prime_rl.utils.validation import (
|
||||
propagate_shared_fields,
|
||||
validate_shared_ckpt_config,
|
||||
validate_shared_max_steps,
|
||||
validate_shared_model_name,
|
||||
validate_shared_output_dir,
|
||||
validate_shared_seq_len,
|
||||
validate_shared_tokenizer,
|
||||
validate_shared_wandb_config,
|
||||
@@ -70,7 +70,7 @@ class SharedWandbConfig(BaseConfig):
|
||||
"""W&B entity."""
|
||||
|
||||
name: str | None = None
|
||||
"""W&B run name."""
|
||||
"""W&B run name. Inherits ``run.name`` when unset."""
|
||||
|
||||
group: str | None = None
|
||||
"""W&B group."""
|
||||
@@ -86,13 +86,26 @@ class SharedWandbConfig(BaseConfig):
|
||||
if self.offline:
|
||||
raise ValueError(
|
||||
"W&B shared mode is always on for the rl entrypoint and requires server "
|
||||
"connectivity; wandb.offline = true is not supported. Use offline mode "
|
||||
"via the sub-config wandb blocks (trainer.wandb.offline, "
|
||||
"orchestrator.wandb.offline) if you really need it per-process."
|
||||
"connectivity; monitors.wandb.offline = true is not supported. Use offline mode "
|
||||
"via the sub-config wandb blocks (trainer.monitors.wandb.offline, "
|
||||
"orchestrator.monitors.wandb.offline) if you really need it per-process."
|
||||
)
|
||||
return self
|
||||
|
||||
|
||||
class SharedMonitorsConfig(BaseConfig):
|
||||
"""The ``rl`` entrypoint's shared monitor configs, propagated to trainer and orchestrator."""
|
||||
|
||||
wandb: SharedWandbConfig | None = None
|
||||
"""Shared W&B config. Propagated to trainer and orchestrator."""
|
||||
|
||||
file: FileMonitorConfig | None = None
|
||||
"""Shared local JSONL metric sink. If set, enables ``<output_dir>/metrics.jsonl`` on both trainer and orchestrator."""
|
||||
|
||||
prime: PrimeMonitorConfig | None = None
|
||||
"""Prime platform monitor. Propagated to the orchestrator only — the trainer has no platform integration."""
|
||||
|
||||
|
||||
class SharedCheckpointConfig(BaseConfig):
|
||||
output_dir: Path | None = None
|
||||
"""Override directory for checkpoints and weights. When set, checkpoints and weight snapshots are written here instead of under the trainer ``output_dir``."""
|
||||
@@ -100,9 +113,6 @@ class SharedCheckpointConfig(BaseConfig):
|
||||
interval: int | None = None
|
||||
"""Interval at which to save checkpoints."""
|
||||
|
||||
resume_step: int | None = None
|
||||
"""Step to resume from. If None, does not resume from a checkpoint."""
|
||||
|
||||
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."""
|
||||
|
||||
@@ -227,11 +237,29 @@ class RLConfig(BaseConfig):
|
||||
env_vars: EnvVars = {}
|
||||
"""Extra environment variables for every launched RL component. Component-specific env_vars override these."""
|
||||
|
||||
output_dir: Path = Path("outputs")
|
||||
"""Output directory. Should be unique per experiment."""
|
||||
run: RunConfig = Field(default_factory=RunConfig)
|
||||
"""Run metadata. ``run.name`` names the run directory under ``output_dir``."""
|
||||
|
||||
clean_output_dir: bool = False
|
||||
"""Delete the output directory before starting training. Required to overwrite an output directory that contains checkpoints from a previous run when not resuming."""
|
||||
output_dir: Path = Path("outputs")
|
||||
"""Directory that groups related runs. Each run writes its artifacts to ``output_dir / run.name``."""
|
||||
|
||||
clean: bool = False
|
||||
"""Delete the run directory (``output_dir / run.name``) before starting training. Required to overwrite a run directory that contains artifacts from a previous run when not resuming."""
|
||||
|
||||
@property
|
||||
def run_dir(self) -> Path:
|
||||
assert self.run.dir is not None # resolved at construction
|
||||
return self.output_dir / self.run.dir
|
||||
|
||||
def _resolve_run_name(self) -> None:
|
||||
"""Fill the auto-generated run name and directory (idempotent — called by every
|
||||
validator that reads them, so it does not depend on validator ordering)."""
|
||||
if self.run.name is None:
|
||||
envs = "+".join(dict.fromkeys(source.resolved_name for source in self.orchestrator.train.source))
|
||||
model = self.trainer.model.name.split("/")[-1]
|
||||
self.run.name = f"{envs or 'no-env'}--{model}--{uuid.uuid4().hex[:8]}".lower()
|
||||
if self.run.dir is None:
|
||||
self.run.dir = self.run.name
|
||||
|
||||
### Shared configurations
|
||||
|
||||
@@ -241,11 +269,11 @@ class RLConfig(BaseConfig):
|
||||
ckpt: SharedCheckpointConfig | None = None
|
||||
"""Shared checkpoint config. If None, falls back to the sub-config checkpoint settings."""
|
||||
|
||||
wandb: SharedWandbConfig | None = None
|
||||
"""Shared W&B config. If None, falls back to the sub-config W&B settings."""
|
||||
resume: ResumeConfig | None = None
|
||||
"""Resume the run from a checkpoint (point at it with the previous run's ``run.name``). Without ``[ckpt]`` the run loads the checkpoint but saves no new ones. If None, does not resume."""
|
||||
|
||||
file_monitor: FileMonitorConfig | None = None
|
||||
"""Shared local JSONL metric sink. If set, enables ``<output_dir>/metrics.jsonl`` on both trainer and orchestrator. If None, falls back to the sub-config settings."""
|
||||
monitors: SharedMonitorsConfig = SharedMonitorsConfig()
|
||||
"""Shared monitor configs (``monitors.wandb``, ``monitors.file``). Propagated to trainer and orchestrator; ``[orchestrator.monitors.prime]`` configures the platform monitor."""
|
||||
|
||||
model: SharedModelConfig | None = None
|
||||
"""Shared model config. If None, falls back to the sub-config model settings."""
|
||||
@@ -263,9 +291,6 @@ class RLConfig(BaseConfig):
|
||||
|
||||
rollout_transport: TransportConfig | None = None
|
||||
|
||||
bench: bool = False
|
||||
"""Benchmark mode. Sets trainer and orchestrator to benchmark mode and, when set, suffixes the W&B project with ``-bench``."""
|
||||
|
||||
deployment: DeploymentConfig = SingleNodeDeploymentConfig()
|
||||
|
||||
slurm: SlurmConfig | None = None
|
||||
@@ -316,9 +341,9 @@ class RLConfig(BaseConfig):
|
||||
"Cannot configure inference with num_infer_nodes = 0. "
|
||||
"Either set num_infer_nodes > 0 or remove the inference config."
|
||||
)
|
||||
if num_infer_nodes == 0 and not self.trainer.data.fake and not self.bench:
|
||||
if num_infer_nodes == 0 and not self.trainer.data.fake:
|
||||
raise ValueError(
|
||||
"Must use fake data (trainer.data.fake or bench = true) when num_infer_nodes = 0, "
|
||||
"Must use fake data (trainer.data.fake) when num_infer_nodes = 0, "
|
||||
"since no orchestrator or inference server will be running."
|
||||
)
|
||||
return self
|
||||
@@ -360,12 +385,58 @@ class RLConfig(BaseConfig):
|
||||
"""
|
||||
return propagate_shared_fields(data)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_run_dir(self):
|
||||
"""Point trainer and orchestrator at the run directory (``output_dir / run.name``).
|
||||
|
||||
The sub-configs' ``output_dir`` is fully derived here: sub-processes spawned by
|
||||
the launcher receive the resolved run directory and never re-derive it.
|
||||
"""
|
||||
self._resolve_run_name()
|
||||
run_dir = self.run_dir
|
||||
for sub in (self.trainer, self.orchestrator):
|
||||
if "output_dir" in sub.model_fields_set and sub.output_dir != run_dir:
|
||||
raise ValueError(
|
||||
f"{type(sub).__name__}.output_dir ({sub.output_dir}) conflicts with the run directory "
|
||||
f"({run_dir}). Under the rl entrypoint, sub-config output directories are derived from "
|
||||
"output_dir / run.name — set those instead."
|
||||
)
|
||||
sub.output_dir = run_dir
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_resume(self):
|
||||
"""Propagate the top-level resume onto the sub-configs."""
|
||||
if self.resume is None:
|
||||
return self
|
||||
self.trainer.resume = self.resume.model_copy()
|
||||
self.orchestrator.resume = self.resume.model_copy()
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_run_identity(self):
|
||||
"""Default the W&B and Prime platform run names to ``run.name``.
|
||||
|
||||
Explicit names always win: only unset names inherit. Runs after the
|
||||
orchestrator's own ``auto_setup_prime_monitor_name``, so an explicitly
|
||||
set W&B name still takes precedence for the platform run name. The run
|
||||
identity itself is runtime-only ($PRL_RUN_ID / $PRL_RUN_NAME, set by the
|
||||
``rl`` entrypoint), never sub-config.
|
||||
"""
|
||||
self._resolve_run_name()
|
||||
for wandb in (self.monitors.wandb, self.trainer.monitors.wandb, self.orchestrator.monitors.wandb):
|
||||
if wandb is not None and wandb.name is None:
|
||||
wandb.name = self.run.name
|
||||
for prime in (self.monitors.prime, self.orchestrator.monitors.prime):
|
||||
if prime is not None and prime.name is None:
|
||||
prime.name = self.run.name
|
||||
return self
|
||||
|
||||
### Validate shared configs (after sub-config construction)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_shared_configs(self):
|
||||
"""Validate consistency of shared configs across trainer, orchestrator, and inference."""
|
||||
validate_shared_output_dir(self.trainer, self.orchestrator)
|
||||
validate_shared_model_name(self.trainer, self.orchestrator, self.inference)
|
||||
validate_shared_tokenizer(self.trainer, self.orchestrator, self.inference)
|
||||
validate_shared_max_steps(self.trainer, self.orchestrator)
|
||||
@@ -463,24 +534,6 @@ class RLConfig(BaseConfig):
|
||||
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_bench(self):
|
||||
if self.bench:
|
||||
self.trainer.bench = BenchConfig()
|
||||
self.orchestrator.bench = True
|
||||
self.trainer.data.fake = FakeDataLoaderConfig(
|
||||
batch_size=self.orchestrator.batch_size or 32,
|
||||
)
|
||||
|
||||
trainer_bench_enabled = self.trainer.bench is not None
|
||||
if trainer_bench_enabled != self.orchestrator.bench:
|
||||
raise ValueError(
|
||||
f"Trainer benchmark mode ({self.trainer.bench}) and orchestrator benchmark mode "
|
||||
f"({self.orchestrator.bench}) must match. Use the top-level bench = true to set both."
|
||||
)
|
||||
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_lora(self):
|
||||
if self.trainer.model.lora is not None:
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
import uuid
|
||||
import warnings
|
||||
from pathlib import Path
|
||||
from typing import Annotated, Literal, TypeAlias
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from pydantic import Field, model_validator
|
||||
from pydantic import AliasChoices, Field, model_validator
|
||||
from renderers import AutoRendererConfig, DefaultRendererConfig, RendererConfig
|
||||
from renderers.base import MODEL_RENDERER_MAP
|
||||
|
||||
from prime_rl.configs.evals import EvalsEvalConfig
|
||||
from prime_rl.configs.inference import InferenceConfig
|
||||
from prime_rl.configs.monitors import MonitorsConfig
|
||||
from prime_rl.configs.shared import (
|
||||
EnvVars,
|
||||
FileMonitorConfig,
|
||||
HeartbeatConfig,
|
||||
ResumeConfig,
|
||||
RunConfig,
|
||||
SlurmConfig,
|
||||
TrainerLogConfig,
|
||||
WandbConfig,
|
||||
)
|
||||
from prime_rl.configs.trainer import (
|
||||
AdamWConfig,
|
||||
BenchConfig,
|
||||
CheckpointConfig,
|
||||
ConstantSchedulerConfig,
|
||||
GCConfig,
|
||||
@@ -141,24 +145,33 @@ class BaseDeploymentConfig(BaseConfig):
|
||||
class SingleNodeDeploymentConfig(BaseDeploymentConfig):
|
||||
type: Literal["single_node"] = "single_node"
|
||||
|
||||
num_gpus: int = 1
|
||||
"""GPUs to use."""
|
||||
num_train_gpus: int = 1
|
||||
"""GPUs allocated to the trainer."""
|
||||
|
||||
num_infer_gpus: int = Field(1, validation_alias=AliasChoices("num_infer_gpus", "num_eval_gpus"))
|
||||
"""GPUs allocated to inference for online evals (alias: ``num_eval_gpus``). Only used when an ``[inference]`` block is configured."""
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_gpu_count(self):
|
||||
if self.num_gpus > self.gpus_per_node:
|
||||
raise ValueError(f"num_gpus ({self.num_gpus}) exceeds gpus_per_node ({self.gpus_per_node}).")
|
||||
if self.num_train_gpus > self.gpus_per_node:
|
||||
raise ValueError(f"num_train_gpus ({self.num_train_gpus}) exceeds gpus_per_node ({self.gpus_per_node}).")
|
||||
return self
|
||||
|
||||
|
||||
class MultiNodeDeploymentConfig(BaseDeploymentConfig):
|
||||
type: Literal["multi_node"] = "multi_node"
|
||||
|
||||
num_nodes: int = 2
|
||||
num_train_nodes: int = Field(2, ge=1)
|
||||
"""Training nodes."""
|
||||
|
||||
num_infer_nodes: int = Field(0, ge=0, validation_alias=AliasChoices("num_infer_nodes", "num_eval_nodes"))
|
||||
"""Inference nodes for online evals (alias: ``num_eval_nodes``). Submitted as a separate SLURM job, decoupled
|
||||
from the trainer job: the handoff is weight checkpoints on the shared filesystem,
|
||||
so the eval job can outlive the trainer job (evals drain after training ends) and
|
||||
exits after evaluating the final checkpoint."""
|
||||
|
||||
nodes_per_fsdp_group: int | None = None
|
||||
"""Nodes per FSDP island. Auto-sets ``model.dp_replicate = num_nodes / nodes_per_fsdp_group``."""
|
||||
"""Nodes per FSDP island. Auto-sets ``model.dp_replicate = num_train_nodes / nodes_per_fsdp_group``."""
|
||||
|
||||
|
||||
SFTDeploymentConfig: TypeAlias = Annotated[
|
||||
@@ -182,24 +195,57 @@ class SFTConfig(BaseConfig):
|
||||
val: SFTValConfig | None = None
|
||||
"""Validation configuration. If None, no validation runs."""
|
||||
|
||||
eval: EvalsEvalConfig | None = None
|
||||
"""Online evaluation configuration: rollout-based evals against a live inference
|
||||
server that reloads the trainer's HF weight checkpoints from disk. If None, no
|
||||
online evals run."""
|
||||
|
||||
inference: InferenceConfig | None = None
|
||||
"""Inference server for online evals. If None (with ``eval`` set), the launcher
|
||||
does not start a server and evals connect to ``eval.client.base_url``."""
|
||||
|
||||
optim: OptimizerConfig = AdamWConfig()
|
||||
|
||||
scheduler: SchedulerConfig = ConstantSchedulerConfig()
|
||||
|
||||
ckpt: CheckpointConfig | None = None
|
||||
|
||||
resume: ResumeConfig | None = None
|
||||
"""Resume the run from a checkpoint (point at it with the previous run's ``run.name``). Without ``[ckpt]`` the run loads the checkpoint but saves no new ones. If None, does not resume."""
|
||||
|
||||
log: TrainerLogConfig = TrainerLogConfig()
|
||||
|
||||
wandb: WandbConfig | None = None
|
||||
monitors: MonitorsConfig = MonitorsConfig()
|
||||
"""Metric monitors (``monitors.wandb``, ``monitors.file``)."""
|
||||
|
||||
file_monitor: FileMonitorConfig | None = None
|
||||
"""Local JSONL metric sink. If set, metrics are appended to ``<output_dir>/metrics.jsonl``."""
|
||||
run: RunConfig = Field(default_factory=RunConfig)
|
||||
"""Run metadata. ``run.name`` names the run directory under ``output_dir``."""
|
||||
|
||||
output_dir: Path = Path("outputs")
|
||||
"""Directory to write outputs to — checkpoints and logs are written as subdirectories. Should be a persistent directory with enough disk space and unique per experiment running on a single node."""
|
||||
"""Directory that groups related runs. Each run writes its artifacts (checkpoints, logs, ...) to ``output_dir / run.name``. Should be a persistent directory with enough disk space."""
|
||||
|
||||
clean_output_dir: bool = False
|
||||
"""Delete the output directory before starting training. Required to overwrite an output directory that contains checkpoints from a previous run when not resuming."""
|
||||
clean: bool = False
|
||||
"""Delete the run directory (``output_dir / run.name``) before starting training. Required to overwrite a run directory that contains artifacts from a previous run when not resuming."""
|
||||
|
||||
@property
|
||||
def run_dir(self) -> Path:
|
||||
assert self.run.dir is not None # resolved at construction
|
||||
return self.output_dir / self.run.dir
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_run_identity(self):
|
||||
"""Auto-generate the run name (``<dataset>--<model>--<short-id>``) when unset and
|
||||
default the run directory and W&B run name to it when not set explicitly."""
|
||||
if self.run.name is None:
|
||||
dataset = str(getattr(self.data, "name", "")).split("/")[-1]
|
||||
model = self.model.name.split("/")[-1]
|
||||
parts = [part for part in (dataset, model) if part]
|
||||
self.run.name = "--".join([*parts, uuid.uuid4().hex[:8]]).lower()
|
||||
if self.run.dir is None:
|
||||
self.run.dir = self.run.name
|
||||
if self.monitors.wandb is not None and self.monitors.wandb.name is None:
|
||||
self.monitors.wandb.name = self.run.name
|
||||
return self
|
||||
|
||||
matmul_precision: Literal["highest", "high", "medium"] = "high"
|
||||
"""Precision for float32 matrix multiplications. ``highest`` is full FP32 (required on ROCm/AMD GPUs to avoid catastrophic precision loss in softmax over large vocabularies). ``high`` enables TF32 on NVIDIA GPUs for a speedup with minor precision tradeoff. See ``torch.set_float32_matmul_precision``."""
|
||||
@@ -210,9 +256,6 @@ class SFTConfig(BaseConfig):
|
||||
memory_profiler_path: Path | None = None
|
||||
"""Path to write the memory profile to."""
|
||||
|
||||
bench: BenchConfig | None = None
|
||||
"""Benchmark-mode configuration. When set, ``max_steps`` is forced to 4 and fake data is used."""
|
||||
|
||||
gc: GCConfig | None = GCConfig()
|
||||
"""Garbage collection config. Disables automatic GC and runs deterministic collections every N steps to avoid stragglers. Set to null to use Python's default GC behavior."""
|
||||
|
||||
@@ -242,10 +285,26 @@ class SFTConfig(BaseConfig):
|
||||
return data
|
||||
deployment = data.get("deployment")
|
||||
if isinstance(deployment, dict) and deployment.get("type") == "multi_node":
|
||||
for key in ("num_gpus",):
|
||||
for key in ("num_train_gpus", "num_infer_gpus"):
|
||||
deployment.pop(key, None)
|
||||
return data
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def propagate_model_to_inference(cls, data):
|
||||
"""Fill ``inference.vllm.model`` from ``model.name`` before InferenceConfig
|
||||
construction, so its parser auto-resolution sees the right model name."""
|
||||
if not isinstance(data, dict):
|
||||
return data
|
||||
inference = data.get("inference")
|
||||
model = data.get("model")
|
||||
name = model.get("name") if isinstance(model, dict) else None
|
||||
if isinstance(inference, dict) and name:
|
||||
vllm = inference.setdefault("vllm", {})
|
||||
if isinstance(vllm, dict):
|
||||
vllm.setdefault("model", name)
|
||||
return data
|
||||
|
||||
### Validate configs (e.g. raise for unsupported (combinations of) configs)
|
||||
|
||||
@model_validator(mode="after")
|
||||
@@ -259,12 +318,152 @@ class SFTConfig(BaseConfig):
|
||||
self.optim.max_norm = None
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def full_optimizer_offload_requires_supported_optimizer(self):
|
||||
if self.model.full_offload and self.optim.type not in ("adamw", "sign_sgd"):
|
||||
raise ValueError("Full optimizer offload only supports AdamW and SignSGD")
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def full_optimizer_offload_disables_grad_clipping(self):
|
||||
if self.model.full_offload and self.optim.max_norm is not None:
|
||||
warnings.warn(
|
||||
"Gradient clipping prevents optimizer-in-backward overlap with CPU optimizer offload. "
|
||||
"Automatically setting optim.max_norm to None (disabled).",
|
||||
stacklevel=1,
|
||||
)
|
||||
self.optim.max_norm = None
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_deployment(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_online_eval(self):
|
||||
"""Wire online evals: require weight checkpoints (the disk handoff to
|
||||
inference) and connect the eval client to the launcher-managed server."""
|
||||
if self.eval is None:
|
||||
if self.inference is not None:
|
||||
raise ValueError("[inference] is only used for online evals — add an [eval] block or remove it.")
|
||||
return self
|
||||
|
||||
# The trainer's HF weight checkpoints are how inference picks up new policies.
|
||||
if self.ckpt is None:
|
||||
self.ckpt = CheckpointConfig()
|
||||
if self.ckpt.weights is None or self.ckpt.skip_gather_master_weights:
|
||||
raise ValueError(
|
||||
"Online evals require HF weight checkpoints. Enable ckpt.weights and "
|
||||
"disable ckpt.skip_gather_master_weights."
|
||||
)
|
||||
|
||||
if self.ckpt.keep_last is not None or self.ckpt.keep_interval is not None:
|
||||
warnings.warn(
|
||||
"ckpt.keep_last / ckpt.keep_interval can delete a weight checkpoint before the "
|
||||
"evals consumes it when evals run slower than training - such steps are "
|
||||
"skipped with a warning instead of evaluated.",
|
||||
stacklevel=2,
|
||||
)
|
||||
|
||||
if self.deployment.type == "multi_node":
|
||||
# Decoupled deployment: the launcher submits a dedicated SLURM job running the
|
||||
# inference pool (one engine per DP rank behind a router) plus the evals process.
|
||||
if self.inference is None:
|
||||
raise ValueError(
|
||||
"Multi-node online evals require an [inference] block - the launcher submits "
|
||||
"a dedicated SLURM job running the inference pool and the evals process."
|
||||
)
|
||||
if self.deployment.num_infer_nodes < 1:
|
||||
raise ValueError("Online evals on a multi-node deployment require deployment.num_infer_nodes >= 1.")
|
||||
if self.inference.router is None:
|
||||
raise ValueError(
|
||||
"Multi-node online evals require an inference router - the eval job starts one "
|
||||
"router in front of the per-rank engines. Remove inference.router = 'None'."
|
||||
)
|
||||
if self.inference.vllm.model != self.model.name:
|
||||
raise ValueError(
|
||||
f"inference.vllm.model ({self.inference.vllm.model}) does not match model.name "
|
||||
f"({self.model.name}). Remove inference.vllm.model to inherit it."
|
||||
)
|
||||
if self.deployment.gpus_per_node % self.inference.vllm.tensor_parallel_size != 0:
|
||||
raise ValueError(
|
||||
f"deployment.gpus_per_node ({self.deployment.gpus_per_node}) must be divisible by "
|
||||
f"inference.vllm.tensor_parallel_size ({self.inference.vllm.tensor_parallel_size})."
|
||||
)
|
||||
if self.inference.weight_broadcast.type != "filesystem":
|
||||
raise ValueError(
|
||||
"Online evals reload weights from disk — inference.weight_broadcast.type must be 'filesystem'."
|
||||
)
|
||||
if self.max_steps is None:
|
||||
warnings.warn(
|
||||
"Online evals without max_steps: the evals process never sees a final checkpoint, "
|
||||
"so the eval SLURM job holds its allocation until its walltime.",
|
||||
stacklevel=2,
|
||||
)
|
||||
# The client is wired at runtime by the eval sbatch script (the router and
|
||||
# per-rank admin URLs are only known once SLURM assigns hosts).
|
||||
return self
|
||||
|
||||
if self.inference is None:
|
||||
warnings.warn(
|
||||
"Online evals are configured without an [inference] block - the launcher will not "
|
||||
f"start an inference server. Make sure one is running at eval.client.base_url "
|
||||
f"({self.eval.client.base_url}) with weight_broadcast.type = 'filesystem', "
|
||||
"otherwise the evals process will hang waiting for it. If a router fronts the "
|
||||
"deployment, set eval.client.admin_base_url to the engine URLs - admin ops "
|
||||
"(pause/update_weights/resume) must bypass the router.",
|
||||
stacklevel=2,
|
||||
)
|
||||
return self
|
||||
|
||||
total_gpus = self.deployment.num_train_gpus + self.deployment.num_infer_gpus
|
||||
if total_gpus > self.deployment.gpus_per_node:
|
||||
raise ValueError(
|
||||
f"Total GPU count ({total_gpus} = {self.deployment.num_train_gpus} train + "
|
||||
f"{self.deployment.num_infer_gpus} infer) exceeds gpus_per_node "
|
||||
f"({self.deployment.gpus_per_node})."
|
||||
)
|
||||
|
||||
if self.inference.vllm.model != self.model.name:
|
||||
raise ValueError(
|
||||
f"inference.vllm.model ({self.inference.vllm.model}) does not match model.name "
|
||||
f"({self.model.name}). Remove inference.vllm.model to inherit it."
|
||||
)
|
||||
|
||||
# Fill inference capacity with DP ranks (mirrors RLConfig.auto_setup_deployment).
|
||||
num_infer_gpus = self.deployment.num_infer_gpus
|
||||
vllm = self.inference.vllm
|
||||
if num_infer_gpus != vllm.data_parallel_size * vllm.tensor_parallel_size:
|
||||
if num_infer_gpus % vllm.tensor_parallel_size != 0:
|
||||
raise ValueError(
|
||||
f"deployment.num_infer_gpus ({num_infer_gpus}) must be divisible by "
|
||||
f"inference.vllm.tensor_parallel_size ({vllm.tensor_parallel_size})."
|
||||
)
|
||||
vllm.data_parallel_size = num_infer_gpus // vllm.tensor_parallel_size
|
||||
if vllm.api_server_count < vllm.data_parallel_size and not vllm.enable_lora:
|
||||
vllm.api_server_count = vllm.data_parallel_size
|
||||
if self.inference.weight_broadcast.type != "filesystem":
|
||||
raise ValueError(
|
||||
"Online evals reload weights from disk — inference.weight_broadcast.type must be 'filesystem'."
|
||||
)
|
||||
|
||||
host = self.inference.server.host or "localhost"
|
||||
client = self.eval.client
|
||||
if "base_url" not in client.model_fields_set:
|
||||
client.base_url = f"http://{host}:{self.inference.server.port}/v1"
|
||||
elif urlparse(client.base_url).port != self.inference.server.port:
|
||||
raise ValueError(
|
||||
f"eval.client.base_url port ({urlparse(client.base_url).port}) does not match "
|
||||
f"inference.server.port ({self.inference.server.port})."
|
||||
)
|
||||
if self.inference.router is not None and "admin_base_url" not in client.model_fields_set:
|
||||
# Admin ops (pause/update_weights/resume) must bypass the router and hit
|
||||
# the engine directly.
|
||||
client.admin_base_url = [f"http://{host}:{self.inference.backend_port}/v1"]
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_typed_renderer(self):
|
||||
"""Require a typed renderer whenever SFT renders real samples."""
|
||||
@@ -365,14 +564,6 @@ class SFTConfig(BaseConfig):
|
||||
|
||||
### Auto-setup and validate shared configs
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_bench(self):
|
||||
if self.bench is not None:
|
||||
self.max_steps = 4 # 1 Warmup + 3 Benchmark
|
||||
if self.ckpt: # Do not checkpoint
|
||||
self.ckpt = None
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_tokenizer(self):
|
||||
if self.tokenizer.name is None:
|
||||
@@ -385,12 +576,12 @@ class SFTConfig(BaseConfig):
|
||||
def auto_setup_deployment(self):
|
||||
if self.deployment.type == "multi_node":
|
||||
if self.deployment.nodes_per_fsdp_group is not None:
|
||||
if self.deployment.num_nodes % self.deployment.nodes_per_fsdp_group != 0:
|
||||
if self.deployment.num_train_nodes % self.deployment.nodes_per_fsdp_group != 0:
|
||||
raise ValueError(
|
||||
f"deployment.num_nodes ({self.deployment.num_nodes}) must be divisible by "
|
||||
f"deployment.num_train_nodes ({self.deployment.num_train_nodes}) must be divisible by "
|
||||
f"deployment.nodes_per_fsdp_group ({self.deployment.nodes_per_fsdp_group})"
|
||||
)
|
||||
self.model.dp_replicate = self.deployment.num_nodes // self.deployment.nodes_per_fsdp_group
|
||||
self.model.dp_replicate = self.deployment.num_train_nodes // self.deployment.nodes_per_fsdp_group
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import Annotated, Literal, TypeAlias
|
||||
|
||||
@@ -10,7 +11,16 @@ from prime_rl.utils.config import BaseConfig
|
||||
# and the single shared W&B run. The launcher always sets these last, so allowing them in
|
||||
# `env_vars` would be a silent no-op (or, on multi-node, a footgun) — reject them instead.
|
||||
PROTECTED_ENV_VARS = frozenset(
|
||||
{"CUDA_VISIBLE_DEVICES", "WANDB_SHARED_MODE", "WANDB_SHARED_RUN_ID", "WANDB_SHARED_LABEL"}
|
||||
{
|
||||
"CUDA_VISIBLE_DEVICES",
|
||||
"PRL_RUN_ID",
|
||||
"PRL_RUN_NAME",
|
||||
"WANDB_RUN_ID",
|
||||
"WANDB_SHARED_MODE",
|
||||
"WANDB_SHARED_LABEL",
|
||||
"WANDB_SHARED_PRIMARY",
|
||||
"WANDB_SHARED_FINISHER",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -27,6 +37,41 @@ EnvVars: TypeAlias = Annotated[dict[str, str], AfterValidator(reject_protected_e
|
||||
"""A per-component `env_vars` mapping, validated to not clobber `PROTECTED_ENV_VARS`."""
|
||||
|
||||
|
||||
class RunConfig(BaseConfig):
|
||||
name: str | None = None
|
||||
"""Run name. Auto-generated as ``<envs>--<model>--<short-id>`` when unset, so every launch gets a fresh, readable run directory; set an explicit name (e.g. an experiment name) to get a predictable run directory, which is also required to resume a previous run. Unless set explicitly, the W&B run name and the Prime platform run name inherit it."""
|
||||
|
||||
dir: str | None = None
|
||||
"""Run directory name — the run writes all its artifacts to ``output_dir / dir``. Defaults to ``run.name``; set it only when the directory should differ from the display name."""
|
||||
|
||||
|
||||
class ResumeConfig(BaseConfig):
|
||||
"""Resume the run from a checkpoint. A bare ``--resume`` (or empty ``[resume]`` block)
|
||||
resumes from the latest checkpoint."""
|
||||
|
||||
step: int | None = Field(None, ge=1)
|
||||
"""Checkpoint step to resume from. None resumes from the latest checkpoint."""
|
||||
|
||||
dir: Path | None = None
|
||||
"""External checkpoint step directory to resume from (e.g. ``other/run/checkpoints/step_50``) — forks another run's checkpoint into this run. Mutually exclusive with ``step``."""
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_step_xor_dir(self):
|
||||
if self.step is not None and self.dir is not None:
|
||||
raise ValueError(
|
||||
"resume.step and resume.dir are mutually exclusive — the step is taken from the directory name"
|
||||
)
|
||||
if self.dir is not None and not re.fullmatch(r"step_\d+", self.dir.name):
|
||||
raise ValueError(f"resume.dir must point at a checkpoint step directory (`.../step_<N>`), got '{self.dir}'")
|
||||
return self
|
||||
|
||||
@property
|
||||
def dir_step(self) -> int:
|
||||
"""The step encoded in ``dir``'s name (validated to exist)."""
|
||||
assert self.dir is not None
|
||||
return int(self.dir.name.removeprefix("step_"))
|
||||
|
||||
|
||||
class SlurmConfig(BaseConfig):
|
||||
job_name: str = "prime-rl"
|
||||
"""SLURM job name."""
|
||||
@@ -156,78 +201,6 @@ class TrainerLogConfig(LogConfig):
|
||||
"""Trainer ranks to show in console output. Passed to ``torchrun --local-ranks-filter``."""
|
||||
|
||||
|
||||
class LogExtrasConfig(BaseConfig):
|
||||
samples: bool = True
|
||||
"""Log prompt/response samples."""
|
||||
|
||||
distributions: bool = True
|
||||
"""Log distributions (rewards, advantages, etc.)."""
|
||||
|
||||
interval: int = Field(10, ge=1)
|
||||
"""Step interval between extras logs."""
|
||||
|
||||
sample_ratio: float | None = Field(None, ge=0.0, le=1.0)
|
||||
"""Fraction of rollouts to log per step. The effective cap is ``len(rollouts) * sample_ratio``; 1.0 = all, 0.5 = half, 0.0 = none."""
|
||||
|
||||
|
||||
class WandbConfig(BaseConfig):
|
||||
# Shared configs (May be overwritten by WandbConfig from `rl.py`)
|
||||
project: str = "prime-rl"
|
||||
"""W&B project to log to."""
|
||||
|
||||
entity: str | None = None
|
||||
"""W&B entity to log to."""
|
||||
|
||||
name: str | None = None
|
||||
"""W&B run name."""
|
||||
|
||||
group: str | None = None
|
||||
"""W&B group."""
|
||||
|
||||
tags: list[str] | None = None
|
||||
"""W&B tags attached to the run."""
|
||||
|
||||
offline: bool = False
|
||||
"""Run W&B in offline mode."""
|
||||
|
||||
|
||||
class WandbWithExtrasConfig(WandbConfig):
|
||||
log_extras: LogExtrasConfig | None = LogExtrasConfig()
|
||||
"""Extras logging configuration. If None, no extras are logged."""
|
||||
|
||||
|
||||
class FileMonitorConfig(BaseConfig):
|
||||
"""Enable the local JSONL metric sink (``<output_dir>/metrics.jsonl``).
|
||||
|
||||
Present (non-None) enables it, mirroring the ``prime_monitor`` pattern. Metrics
|
||||
are the same scalars sent to W&B; useful for self-hosted dashboards or when W&B
|
||||
is disabled.
|
||||
"""
|
||||
|
||||
filename: str = "metrics.jsonl"
|
||||
"""Name of the JSONL file written under the component's ``output_dir``."""
|
||||
|
||||
|
||||
class PrimeMonitorConfig(BaseConfig):
|
||||
base_url: str = "https://api.primeintellect.ai/api/v1/rft"
|
||||
"""Base URL for the Prime Intellect monitoring API."""
|
||||
|
||||
api_key_var: str = "PRIME_API_KEY"
|
||||
"""Environment variable name containing the Prime Intellect API key, resolved via ``os.getenv``."""
|
||||
|
||||
log_extras: LogExtrasConfig | None = LogExtrasConfig()
|
||||
"""Extras logging configuration. If None, no extras are logged."""
|
||||
|
||||
run_name: str | None = None
|
||||
"""Run name shown on the platform. Defaults to the W&B run name when set, otherwise the platform auto-generates one."""
|
||||
|
||||
team_id: str | None = None
|
||||
"""Team ID to associate the run with."""
|
||||
|
||||
frontend_url: str | None = None
|
||||
"""Frontend base URL used for the dashboard link printed after registration. Defaults to the Prime CLI frontend URL when unset."""
|
||||
|
||||
|
||||
class HeartbeatConfig(BaseConfig):
|
||||
url: str
|
||||
"""URL to send the heartbeat to."""
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user