Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f811c01a8 | ||
|
|
2d6dc64efd | ||
|
|
07ebe34570 |
Vendored
+1
-1
Submodule deps/verifiers updated: 5a69fb4d25...28f0893974
@@ -406,8 +406,9 @@ const INFERENCE_PANELS = [
|
||||
["inference/agg/num_requests_running/mean", "inference/agg/num_requests_running/min", "inference/agg/num_requests_running/max"],
|
||||
["inference/agg/num_requests_waiting/mean", "inference/agg/num_requests_waiting/min", "inference/agg/num_requests_waiting/max"],
|
||||
["inference/agg/prefix_cache_hit_rate/pooled", "inference/agg/prefix_cache_hit_rate/min"],
|
||||
["inference/agg/generation_tokens_total:rate/sum", "inference/agg/generation_tokens_total:rate/min"],
|
||||
["inference/agg/prompt_tokens_total:rate/sum", "inference/agg/prompt_tokens_total:rate/max"],
|
||||
["inference/agg/generation_tokens_total:rate/sum"],
|
||||
["inference/agg/prompt_tokens_total:rate/sum"],
|
||||
["dispatcher/inflight/train", "dispatcher/inflight/eval", "concurrency/max_inflight"],
|
||||
];
|
||||
|
||||
const TRAINER_KEY_RE = /^(perf|optim|loss|entropy|system|mismatch_kl|kl_ent_ratio|is_masked|masked_|unmasked_|max_vio|routing_|ref_kl|val)[/_]?/;
|
||||
|
||||
@@ -531,7 +531,8 @@ def write_slurm_script(config: RLConfig, config_dir: Path, log_dir: Path, script
|
||||
use_zmq_transport=config.rollout_transport is not None and config.rollout_transport.type == "zmq",
|
||||
ranks_filter=",".join(map(str, config.trainer.log.ranks_filter)),
|
||||
orchestrator_on_inference=config.deployment.orchestrator_on_inference,
|
||||
env_names={"train": train_env_names, "eval": eval_env_names},
|
||||
train_env_names=train_env_names,
|
||||
eval_env_names=eval_env_names,
|
||||
**modelexpress_vars,
|
||||
)
|
||||
else:
|
||||
@@ -571,7 +572,8 @@ def write_slurm_script(config: RLConfig, config_dir: Path, log_dir: Path, script
|
||||
trainer_env_vars=trainer_env_vars,
|
||||
orchestrator_env_vars=orchestrator_env_vars,
|
||||
inference_env_vars=inference_env_vars,
|
||||
env_names={"train": train_env_names, "eval": eval_env_names},
|
||||
train_env_names=train_env_names,
|
||||
eval_env_names=eval_env_names,
|
||||
**modelexpress_vars,
|
||||
)
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ from prime_rl.orchestrator import live
|
||||
from prime_rl.orchestrator.annotations import stamp_arrival, stamp_batch
|
||||
from prime_rl.orchestrator.clients import AdminPlane, InferenceClient
|
||||
from prime_rl.orchestrator.concurrency import ConcurrencyController
|
||||
from prime_rl.orchestrator.dispatcher import Dispatcher, DispatcherMetrics, DispatcherMode
|
||||
from prime_rl.orchestrator.dispatcher import Dispatcher, DispatcherMode
|
||||
from prime_rl.orchestrator.envs import EvalEnvs
|
||||
from prime_rl.orchestrator.eval_sink import EvalSink
|
||||
from prime_rl.orchestrator.eval_source import EvalSource
|
||||
@@ -79,7 +79,6 @@ class EvalRunner:
|
||||
# The launcher-set $PRL_RUN_ID is the run identity; standalone runs mint a local one.
|
||||
self.run_id = os.environ.get("PRL_RUN_ID") or uuid.uuid4().hex
|
||||
self.run_name = os.environ.get("PRL_RUN_NAME")
|
||||
wandb_enabled = monitors.get(monitors.WandbMonitor) is not None
|
||||
|
||||
get_logger().info(f"Initializing inference pool (base_url={config.client.base_url}, model={config.model})")
|
||||
self.clients = InferenceClient(config.client, model_name=config.model)
|
||||
@@ -153,13 +152,7 @@ class EvalRunner:
|
||||
self.periodic_logger = PeriodicLogger(
|
||||
name="Eval",
|
||||
collect=self.collect_pipeline_view,
|
||||
metric_keys=[
|
||||
*list(self.dispatcher.gauges().keys()),
|
||||
*list(self.concurrency.gauges().keys()),
|
||||
*DispatcherMetrics.drain_keys(train_envs=set(), eval_envs={env.name for env in self.eval_envs}),
|
||||
],
|
||||
interval=config.log.interval,
|
||||
wandb_enabled=wandb_enabled,
|
||||
)
|
||||
|
||||
async def start(self) -> None:
|
||||
|
||||
@@ -73,9 +73,9 @@ INFERENCE_PANELS = [
|
||||
"inference/agg/num_requests_waiting/max",
|
||||
],
|
||||
["inference/agg/prefix_cache_hit_rate/pooled", "inference/agg/prefix_cache_hit_rate/min"],
|
||||
["inference/agg/generation_tokens_total:rate/sum", "inference/agg/generation_tokens_total:rate/min"],
|
||||
["inference/agg/prompt_tokens_total:rate/sum", "inference/agg/prompt_tokens_total:rate/max"],
|
||||
["dispatcher/inflight/train", "dispatcher/inflight/eval"],
|
||||
["inference/agg/generation_tokens_total:rate/sum"],
|
||||
["inference/agg/prompt_tokens_total:rate/sum"],
|
||||
["dispatcher/inflight/train", "dispatcher/inflight/eval", "concurrency/max_inflight"],
|
||||
]
|
||||
|
||||
# SFT flavor: no rollout-based train sections — the training signal is the loss curve.
|
||||
|
||||
@@ -92,8 +92,8 @@ class DispatcherMetrics:
|
||||
|
||||
def drained(self, *, train_envs: set[str], eval_envs: set[str]) -> dict[str, float]:
|
||||
"""Return per-tick counters and clear them. Emits the full pre-
|
||||
registered key set every tick (zero when no activity) so the wandb
|
||||
time axis stays dense and ``define_metric`` lines up."""
|
||||
registered key set every tick (zero when no activity) so the
|
||||
time-keyed series stay dense on every monitor."""
|
||||
out: dict[str, float] = {}
|
||||
for kind in ("train", "eval"):
|
||||
envs = train_envs if kind == "train" else eval_envs
|
||||
@@ -112,21 +112,6 @@ class DispatcherMetrics:
|
||||
self.errored_by_kind_env.clear()
|
||||
return out
|
||||
|
||||
@staticmethod
|
||||
def drain_keys(*, train_envs: set[str], eval_envs: set[str]) -> list[str]:
|
||||
"""Full set of keys ``drained`` may emit; used by the periodic
|
||||
logger for ``wandb.define_metric``."""
|
||||
keys = [
|
||||
"dispatcher/cancelled/train",
|
||||
"dispatcher/cancelled/eval",
|
||||
"dispatcher/errored/train",
|
||||
"dispatcher/errored/eval",
|
||||
]
|
||||
for env in train_envs | eval_envs:
|
||||
keys.append(f"dispatcher/cancelled/{env}")
|
||||
keys.append(f"dispatcher/errored/{env}")
|
||||
return keys
|
||||
|
||||
|
||||
def _validate_episode_task(episode: vf.WireEpisode, task: vf.Task) -> None:
|
||||
expected = (task.key, task.hash)
|
||||
|
||||
@@ -11,7 +11,7 @@ and drives the pipeline. Components are single-purpose:
|
||||
- ``TrainEpisodes`` / ``EvalEpisodes`` preserve episode boundaries and build per-step metrics.
|
||||
- ``WeightWatcher`` advances ``Policy`` and notifies observers.
|
||||
- ``PeriodicLogger`` polls the components on a shared interval for the
|
||||
``_timestamp``-axis pipeline log.
|
||||
pipeline log, a time-keyed row through the monitors.
|
||||
|
||||
Components don't reference the orchestrator. The orchestrator wires them
|
||||
in ``setup()`` and drives them from ``main_loop()``.
|
||||
@@ -41,7 +41,7 @@ from prime_rl.orchestrator.annotations import stamp_arrival, stamp_batch
|
||||
from prime_rl.orchestrator.ckpt import setup_ckpt_manager
|
||||
from prime_rl.orchestrator.clients import AdminPlane, InferenceClient, setup_admin_plane
|
||||
from prime_rl.orchestrator.concurrency import ConcurrencyController
|
||||
from prime_rl.orchestrator.dispatcher import Dispatcher, DispatcherMetrics, DispatcherMode
|
||||
from prime_rl.orchestrator.dispatcher import Dispatcher, DispatcherMode
|
||||
from prime_rl.orchestrator.envs import EvalEnvs, TrainEnvs
|
||||
from prime_rl.orchestrator.eval_sink import EvalSink
|
||||
from prime_rl.orchestrator.eval_source import EvalSource
|
||||
@@ -336,7 +336,6 @@ class Orchestrator:
|
||||
)
|
||||
|
||||
log_interval = config.log.interval
|
||||
wandb_enabled = monitors.get(monitors.WandbMonitor) is not None
|
||||
|
||||
self.concurrency = ConcurrencyController(config.concurrency, fallback_cost=config.seq_len)
|
||||
self.dispatcher = Dispatcher(
|
||||
@@ -398,24 +397,7 @@ class Orchestrator:
|
||||
self.periodic_logger = PeriodicLogger(
|
||||
name="Pipeline",
|
||||
collect=self.collect_pipeline_view,
|
||||
metric_keys=[
|
||||
*list(self.dispatcher.gauges().keys()),
|
||||
*list(self.concurrency.gauges().keys()),
|
||||
*DispatcherMetrics.drain_keys(
|
||||
train_envs={e.name for e in self.train_envs},
|
||||
eval_envs={e.name for e in self.eval_envs} if self.eval_envs is not None else set(),
|
||||
),
|
||||
*list(self.watcher.gauges().keys()),
|
||||
"event_loop_lag/min",
|
||||
"event_loop_lag/mean",
|
||||
"event_loop_lag/median",
|
||||
"event_loop_lag/p90",
|
||||
"event_loop_lag/p99",
|
||||
"event_loop_lag/max",
|
||||
"event_loop_lag/n",
|
||||
],
|
||||
interval=log_interval,
|
||||
wandb_enabled=wandb_enabled,
|
||||
)
|
||||
|
||||
get_logger().info(f"Syncing inference to the trainer's startup broadcast (v{sync_version})")
|
||||
@@ -457,10 +439,12 @@ class Orchestrator:
|
||||
elapsed = format_time(time.perf_counter() - start_time)
|
||||
if clean_exit:
|
||||
get_logger().success(f"Orchestrator step loop done in {elapsed}")
|
||||
# The collector logs to the W&B run, so it must stop before
|
||||
# finalize marks the run finished
|
||||
# The background loggers write through the monitors, so they must
|
||||
# stop before finalize marks the run finished
|
||||
if self.inference_metrics is not None:
|
||||
await self.inference_metrics.stop()
|
||||
if self.periodic_logger is not None:
|
||||
await self.periodic_logger.stop()
|
||||
# Finalize only on a clean exit — a crashed run must not be marked
|
||||
# completed; the platform run's atexit hook marks it failed instead.
|
||||
await monitors.finalize()
|
||||
@@ -830,7 +814,7 @@ class Orchestrator:
|
||||
|
||||
def collect_pipeline_view(self) -> tuple[str, dict[str, float]]:
|
||||
"""Pipeline view for the orchestrator's ``PeriodicLogger``. Returns
|
||||
``(console_body, wandb_payload)``. Per-env ``(env=N, …)``
|
||||
``(console_body, payload)``. Per-env ``(env=N, …)``
|
||||
breakdowns inline only when there's more than one train / eval env;
|
||||
the eval halves drop entirely when nothing is accumulating."""
|
||||
disp_gauges = self.dispatcher.gauges()
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
"""PeriodicLogger: orchestrator's pipeline view, fires every ``interval``
|
||||
seconds. ``collect()`` returns ``(console_body, wandb_payload)`` in one
|
||||
call so drain-on-read counters fire exactly once per tick. Wandb writes
|
||||
land on the ``_timestamp`` axis."""
|
||||
seconds. ``collect()`` returns ``(console_body, payload)`` in one call so
|
||||
drain-on-read counters fire exactly once per tick. The payload goes to every
|
||||
registered monitor as a time-keyed row (``step=None``)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import time
|
||||
from typing import Callable
|
||||
|
||||
import wandb
|
||||
|
||||
from prime_rl import monitors
|
||||
from prime_rl.utils.async_utils import safe_cancel
|
||||
from prime_rl.utils.logger import get_logger
|
||||
|
||||
@@ -21,21 +19,14 @@ class PeriodicLogger:
|
||||
*,
|
||||
name: str,
|
||||
collect: Callable[[], tuple[str, dict[str, float]]],
|
||||
metric_keys: list[str],
|
||||
interval: float,
|
||||
wandb_enabled: bool,
|
||||
) -> None:
|
||||
self.name = name
|
||||
self.collect = collect
|
||||
self.interval = interval
|
||||
self.wandb_enabled = wandb_enabled
|
||||
self.task: asyncio.Task | None = None
|
||||
self.stopped = asyncio.Event()
|
||||
|
||||
if self.wandb_enabled:
|
||||
for key in metric_keys:
|
||||
wandb.define_metric(key, step_metric="_timestamp")
|
||||
|
||||
async def start(self) -> None:
|
||||
self.task = asyncio.create_task(self.run(), name=f"{self.name}_periodic_logger")
|
||||
|
||||
@@ -46,16 +37,17 @@ class PeriodicLogger:
|
||||
await asyncio.wait_for(self.stopped.wait(), timeout=self.interval)
|
||||
except asyncio.TimeoutError:
|
||||
pass
|
||||
self.emit()
|
||||
await self.emit()
|
||||
except asyncio.CancelledError:
|
||||
return
|
||||
|
||||
def emit(self) -> None:
|
||||
async def emit(self) -> None:
|
||||
body, payload = self.collect()
|
||||
get_logger().info(body)
|
||||
if self.wandb_enabled and payload:
|
||||
payload["_timestamp"] = time.time()
|
||||
wandb.log(payload)
|
||||
if payload:
|
||||
# Time-keyed row: the pipeline view is sampled on wall time, not
|
||||
# the training step. Each monitor stamps its own time axis.
|
||||
await monitors.log(payload, step=None)
|
||||
|
||||
async def stop(self) -> None:
|
||||
self.stopped.set()
|
||||
|
||||
Reference in New Issue
Block a user