Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4df5b6229f | ||
|
|
ae1461e7a1 | ||
|
|
7e8355003a | ||
|
|
81822debb6 |
+1
-1
Submodule configs/private updated: 74c1330008...894caa0047
+12
-13
@@ -8,16 +8,14 @@ The `rl`, `sft`, and `inference` entrypoints all have built-in SLURM support. Ad
|
||||
# Local run
|
||||
uv run rl @ examples/reverse_text/rl.toml
|
||||
|
||||
# SLURM run (same entrypoint, just add [slurm] to the config)
|
||||
uv run rl @ examples/reverse_text/slurm_rl.toml
|
||||
# SLURM run — overlay slurm_rl.toml on top of the base config
|
||||
uv run rl @ examples/reverse_text/rl.toml @ examples/reverse_text/slurm_rl.toml
|
||||
```
|
||||
|
||||
The SLURM config is a thin overlay that inherits from a base config and adds `[slurm]` + `[deployment]` sections:
|
||||
The SLURM config is a thin overlay that adds `[slurm]` (and optionally `[deployment]`) on top of a base config. Configs are composed left-to-right via the `@` CLI syntax — see [`configs.md`](configs.md) for details.
|
||||
|
||||
```toml
|
||||
# examples/reverse_text/slurm_rl.toml
|
||||
toml_files = ["rl.toml"]
|
||||
|
||||
output_dir = "outputs/reverse-text-rl"
|
||||
|
||||
[slurm]
|
||||
@@ -140,10 +138,10 @@ freq = 1
|
||||
batch_size = 512
|
||||
group_size = 16
|
||||
|
||||
[orchestrator.sampling]
|
||||
max_tokens = 2048
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 2048
|
||||
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "math-env"
|
||||
name = "hendrycks-math"
|
||||
args = { dataset_name = "PrimeIntellect/Hendrycks-Math", dataset_subset = "default" }
|
||||
@@ -153,7 +151,7 @@ tp = 4
|
||||
dp = 2
|
||||
```
|
||||
|
||||
See [`examples/hendrycks_math/rl.toml`](../examples/hendrycks_math/rl.toml) for the full example.
|
||||
See [`examples/multinode/rl.toml`](../examples/multinode/rl.toml) for the full example.
|
||||
|
||||
---
|
||||
|
||||
@@ -202,7 +200,7 @@ batch_size = 128
|
||||
seq_len = 8192
|
||||
```
|
||||
|
||||
See [`examples/hendrycks_math/sft.toml`](../examples/hendrycks_math/sft.toml) for the full example.
|
||||
See [`examples/multinode/sft.toml`](../examples/multinode/sft.toml) for the full example.
|
||||
|
||||
---
|
||||
|
||||
@@ -213,6 +211,7 @@ See [`examples/hendrycks_math/sft.toml`](../examples/hendrycks_math/sft.toml) fo
|
||||
Run a vLLM server on a single allocated node:
|
||||
|
||||
```toml
|
||||
# my_inference.toml
|
||||
output_dir = "/shared/outputs/my-inference"
|
||||
|
||||
[model]
|
||||
@@ -226,7 +225,7 @@ job_name = "my-inference"
|
||||
```
|
||||
|
||||
```bash
|
||||
uv run inference @ inference_slurm.toml
|
||||
uv run inference @ my_inference.toml
|
||||
```
|
||||
|
||||
### Multi-node SLURM
|
||||
@@ -255,10 +254,10 @@ After submission, the SLURM template prints the inference URLs for all nodes (on
|
||||
|
||||
### Dry run
|
||||
|
||||
Use `dry_run = true` to generate the sbatch script without submitting:
|
||||
Use `--dry-run` (or `dry_run = true` in TOML) to generate the sbatch script without submitting:
|
||||
|
||||
```bash
|
||||
uv run inference @ config.toml --dry-run true
|
||||
uv run inference @ config.toml --dry-run
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -19,7 +19,7 @@ uv run rl @ examples/hendrycks_sanity/rl.toml \
|
||||
Or schedule the same training via SLURM
|
||||
|
||||
```bash
|
||||
uv run rl @ examples/hendrycks_sanity/slurm_rl.toml \
|
||||
uv run rl @ examples/hendrycks_sanity/rl.toml @ examples/hendrycks_sanity/slurm_rl.toml \
|
||||
--wandb.project your-project \
|
||||
--wandb.name your-run
|
||||
```
|
||||
|
||||
@@ -155,7 +155,7 @@ The wiki-search environment supports several configuration options:
|
||||
You can pass these via the `--env-args` flag in `vf-eval` or configure them in your `rl.toml`:
|
||||
|
||||
```toml
|
||||
[[orchestrator.env]]
|
||||
[[orchestrator.train.env]]
|
||||
id = "primeintellect/wiki-search"
|
||||
args = { max_turns = 5, judge_model = "gpt-4.1" }
|
||||
```
|
||||
|
||||
@@ -760,7 +760,7 @@ class OrchestratorConfig(BaseConfig):
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_session_headers(self):
|
||||
"""Ensure X-Session-ID header is always set for sticky DP-aware routing at the inference router."""
|
||||
self.student.client.extra_headers_from_state.setdefault("X-Session-ID", "example_id")
|
||||
self.student.client.extra_headers_from_state.setdefault("X-Session-ID", "trajectory_id")
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
|
||||
@@ -138,7 +138,7 @@ class ClientConfig(BaseConfig):
|
||||
"""Maps HTTP header names to environment variable names; each entry is resolved via ``os.getenv`` and merged into request headers. e.g. ``{"X-Prime-Team-ID": "PRIME_TEAM_ID"}``."""
|
||||
|
||||
extra_headers_from_state: dict[str, str] = {}
|
||||
"""Maps HTTP header names to rollout-state field names. The header value is read from the rollout state dict on every request. e.g. ``{"X-Session-ID": "example_id"}`` enables sticky routing at the inference router."""
|
||||
"""Maps HTTP header names to rollout-state field names. The header value is read from the rollout state dict on every request. e.g. ``{"X-Session-ID": "trajectory_id"}`` enables sticky routing at the inference router."""
|
||||
|
||||
skip_model_check: bool = False
|
||||
"""Skip checking that the model is available in the inference pool. Useful for external APIs or keys that do not expose ``/models``."""
|
||||
|
||||
+19
-5
@@ -44,11 +44,19 @@ assert_supported_platform() {
|
||||
}
|
||||
|
||||
has_ssh_access() {
|
||||
# Probe SSH auth to GitHub without prompting; treat any nonzero as "no ssh"
|
||||
# We try a quick ls-remote to avoid cloning on failure.
|
||||
# Disable -e for the probe so the script doesn't exit on a failed test.
|
||||
# Probe GitHub SSH auth directly. `ssh -T git@github.com` returns
|
||||
# "successfully authenticated" only when the local key is registered
|
||||
# with a GitHub user, which is the precondition for cloning private
|
||||
# submodules over SSH. The previous `git ls-remote` probe could
|
||||
# spuriously succeed (cached creds, public-repo edge cases) and
|
||||
# leave submodule clones to fail later.
|
||||
#
|
||||
# Note: ssh -T git@github.com always exits 1 (GitHub denies shell
|
||||
# access after authenticating), so we capture stdout/stderr to a var
|
||||
# first and grep the var. Piping directly would trigger pipefail.
|
||||
set +e
|
||||
timeout 5s git ls-remote --heads git@github.com:PrimeIntellect-ai/${REPO_ID}.git >/dev/null 2>&1
|
||||
out=$(timeout 5s ssh -o BatchMode=yes -T git@github.com 2>&1)
|
||||
echo "$out" | grep -q "successfully authenticated"
|
||||
rc=$?
|
||||
set -e
|
||||
return $rc
|
||||
@@ -122,7 +130,13 @@ main() {
|
||||
fi
|
||||
|
||||
if ! has_ssh_access; then
|
||||
git config url."https://github.com/".insteadOf "git@github.com:"
|
||||
# Propagate the rewrite via env vars so it reaches `git submodule--helper clone`,
|
||||
# which spawns fresh `git clone` processes that do not read the parent repo's
|
||||
# local `.git/config`. Local `git config url..insteadOf` is invisible to them.
|
||||
log_info "Routing git@github.com: SSH URLs to HTTPS for this run."
|
||||
export GIT_CONFIG_COUNT=1
|
||||
export GIT_CONFIG_KEY_0="url.https://github.com/.insteadOf"
|
||||
export GIT_CONFIG_VALUE_0="git@github.com:"
|
||||
fi
|
||||
|
||||
log_info "Initializing submodules..."
|
||||
|
||||
@@ -13,9 +13,9 @@ from prime_rl.orchestrator.event_loop_lag import EventLoopLagMonitor
|
||||
from prime_rl.orchestrator.inference_metrics import InferenceMetricsCollector
|
||||
from prime_rl.orchestrator.patches import monkey_patch_chat_completion_logprobs, monkey_patch_oai_iterable_types
|
||||
from prime_rl.orchestrator.trajectories import (
|
||||
backfill_rollout_tokens,
|
||||
interleave_rollout,
|
||||
offload_images_to_disk,
|
||||
pretokenize_rollout_trajectory,
|
||||
)
|
||||
from prime_rl.transport import TrainingBatch, TrainingSample, setup_training_batch_sender
|
||||
from prime_rl.utils.pathing import get_log_dir, get_rollout_dir, get_step_path
|
||||
@@ -482,16 +482,21 @@ async def orchestrate(config: OrchestratorConfig):
|
||||
# Convert rollouts to training samples
|
||||
parallel_preprocess_start = time.perf_counter()
|
||||
|
||||
# Pretokenize on threads so CPU work overlaps with inference for the
|
||||
# next batch. Skip the fanout entirely when every step already has
|
||||
# ``tokens`` (renderer path) — otherwise the 256-way to_thread fires
|
||||
# only to no-op and the GIL stampede blocks the loop.
|
||||
needs_pretokenize = any(step["tokens"] is None for rollout in train_rollouts for step in rollout["trajectory"])
|
||||
if needs_pretokenize:
|
||||
# We only expect to backfill tokens for training_mode=sft against an
|
||||
# external teacher API (OpenAI/etc.), which returns no token IDs —
|
||||
# reconstruct via tokenizer/renderer. The vLLM-served paths (RL/OPD
|
||||
# renderer + MITO, and training_mode=sft against a local vLLM teacher)
|
||||
# already populate tokens via prompt_token_ids/token_ids, so we
|
||||
# short-circuit the 256-way fanout.
|
||||
needs_backfill = any(step["tokens"] is None for rollout in train_rollouts for step in rollout["trajectory"])
|
||||
if needs_backfill:
|
||||
logger.info(
|
||||
"Backfilling tokens for rollout trajectories (expected for training_mode=sft against an external teacher API)"
|
||||
)
|
||||
await asyncio.gather(
|
||||
*(
|
||||
asyncio.to_thread(
|
||||
pretokenize_rollout_trajectory,
|
||||
backfill_rollout_tokens,
|
||||
rollout,
|
||||
tokenizer,
|
||||
renderer=renderer,
|
||||
|
||||
@@ -164,7 +164,7 @@ def _tokenize_step_with_renderer(
|
||||
return build_trajectory_step(renderer, prompt, completion, tools=tools)
|
||||
|
||||
|
||||
def pretokenize_rollout_trajectory(
|
||||
def backfill_rollout_tokens(
|
||||
output: vf.RolloutOutput,
|
||||
tokenizer: PreTrainedTokenizer,
|
||||
renderer=None,
|
||||
|
||||
@@ -2,7 +2,7 @@ from unittest.mock import MagicMock
|
||||
|
||||
import verifiers as vf
|
||||
|
||||
from prime_rl.orchestrator.trajectories import interleave_rollout, pretokenize_rollout_trajectory
|
||||
from prime_rl.orchestrator.trajectories import backfill_rollout_tokens, interleave_rollout
|
||||
|
||||
|
||||
class SimpleChatTokenizer:
|
||||
@@ -56,7 +56,7 @@ def test_interleave_rollout_missing_tokens_returns_none():
|
||||
assert interleave_rollout(output) is None
|
||||
|
||||
|
||||
def test_pretokenize_rollout_trajectory_for_sft():
|
||||
def test_backfill_rollout_tokens_for_sft():
|
||||
tokenizer = SimpleChatTokenizer()
|
||||
output = vf.RolloutOutput(
|
||||
example_id=42,
|
||||
@@ -93,7 +93,7 @@ def test_pretokenize_rollout_trajectory_for_sft():
|
||||
error=None,
|
||||
)
|
||||
|
||||
pretokenize_rollout_trajectory(output, tokenizer)
|
||||
backfill_rollout_tokens(output, tokenizer)
|
||||
|
||||
rollouts = interleave_rollout(output)
|
||||
assert rollouts is not None
|
||||
|
||||
Reference in New Issue
Block a user