"""Validate configs/rl.toml and prewarm every train/eval taskset loader, without rollouts. Loads each source's taskset exactly as the orchestrator does (`vf.load_taskset(env.taskset).select(source.select)`, materialized), and checks the task keys are unique, which the orchestrator's task sampler requires. Usage (from the repo root): uv run --project prime-rl --no-sync python scripts/prepare_data.py """ import gc import json import os import tempfile from collections import Counter from pathlib import Path import verifiers.v1 as vf from prime_rl.configs.rl import RLConfig from pydantic_config import cli assert os.environ.get("PYTHONHASHSEED") == "0", "run with PYTHONHASHSEED=0 to match training" # No judge requests are made while loading; an unreachable URL keeps it that way. text = Path("configs/rl.toml").read_text().replace("${JUDGE_BASE_URL}", "http://127.0.0.1:19999/v1") with tempfile.NamedTemporaryFile("w", suffix=".toml") as rendered: rendered.write(text) rendered.flush() config = cli(RLConfig, args=["@", rendered.name]) assert config.deployment.num_train_gpus == 2 assert config.deployment.num_infer_gpus == 6 vllm = config.inference.vllm assert (vllm.tensor_parallel_size, vllm.data_parallel_size) == (2, 3) assert config.trainer.model.optimization_dtype == "float32" assert config.trainer.model.reduce_dtype == "float32" print("CONFIG_VALID", flush=True) for split, source in config.orchestrator.env_sources: print("LOADING", split, source.resolved_name, flush=True) taskset = vf.load_taskset(source.env.taskset).select(source.select) tasks = list(taskset) assert tasks, (split, source.resolved_name, "empty taskset") duplicates = [key for key, count in Counter(task.key for task in tasks).items() if count > 1] assert not duplicates, (split, source.resolved_name, f"{len(duplicates)} duplicate task keys") subtasks = Counter(getattr(task.data, "subtask", "decensor") for task in tasks) print( json.dumps( {"split": split, "environment": source.resolved_name, "rows": len(tasks), "subtasks": dict(subtasks)} ), flush=True, ) del tasks, taskset gc.collect() print("DATA_READY", flush=True)