Skip to content

prime-runs - #3459

Draft
kcoopermiller wants to merge 6 commits into
mainfrom
cooper/prime-runs
Draft

prime-runs#3459
kcoopermiller wants to merge 6 commits into
mainfrom
cooper/prime-runs

Conversation

@kcoopermiller

@kcoopermiller kcoopermiller commented Sep 1, 2026

Copy link
Copy Markdown
Member

Replaces monitors/prime.py'sTrainRun with pr.init(kind="train", ...).

What moved where

was in prime-rl now
TrainRun.create / $RUN_ID attach pr.init(kind="train", model=, environments=, training=pr.TrainingSpec(...), config=, ...) / pr.init(kind="train", id=$RUN_ID)
TrainRun.log_metrics (fire-and-forget task per POST) run.log_metrics(values, step=) — a queue put; the SDK's uploader owns retries, Retry-After, backpressure
episodes_to_parquet_bytes + SAMPLE_SCHEMA + presign→PUT→confirm prime_runs.projection + the SDK's training samples sink (same schema, same flow)
the step % 10 cadence in log_episodes the sink (step_interval=10), keyed on each episode's run.work.step — the TrainRunInfo the dispatcher stamps
finalizePOST /finalize, fallback set_status run.finish() — drain, then an idempotent finalize; 409 on the failure path is treated as already-closed
atexit _mark_failed the SDK's atexit hook reports crashed (with a message); an attached run's failure marking stays with the launcher, as before

The kind == "train" and subset == "effective" cohort filter stays here. The monitor keeps sanitize() so dropped non-finite metric paths are still named in the log (the SDK would drop them silently). $PRIME_API_BASE still works — it historically points at …/api/v1/rft, so the monitor strips what the SDK re-adds.

Decisions

  • Step keying. The samples sink keys each episode by the step it was dispatched at (run.work.step), not the batch step; the platform keeps one Parquet object per upload and the viewer unions every object under a step, so an off-policy episode landing in a later batch adds an object rather than replacing one, and each object numbers its sample_ids in its own range (SDK side, aba26790). "Step N" in the sample viewer therefore means dispatched at N, while the metrics at N describe the batch trained at N.
  • Run identity. With an online platform run the orchestrator adopts the platform's run id for episode provenance, so Prime Traces documents carry the id the dashboard shows and the run's traces can be queried by it. W&B keeps the launcher's PRL_RUN_ID (its id is fixed at spawn; nothing else reads that variable), and in attach mode the two already agree.

Temporary

[tool.uv.sources] pins prime-runs to the SDK branch head until 0.1.0 is on PyPI (PrimeIntellect-ai/prime#856); the line is dropped and the lock refreshed then.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Fk5fBAAaTiPfJ5UpNyqxXR

kcoopermiller and others added 3 commits September 1, 2026 10:09
Replace the hand-rolled TrainRun (RFT lifecycle, per-step metrics POSTs,
every-10th-step Parquet presign->PUT->confirm, atexit failure marking)
with prime_runs' pr.init(kind="train"): the SDK owns the uploads on a
background thread with retries and backpressure, reports crashed on a
process that exits without finalizing, and adds a Prime Traces sink for
allowlisted accounts. episodes_to_parquet_bytes and SAMPLE_SCHEMA moved
into prime_runs.projection; the kind/subset cohort filter stays here,
the step cadence moves into the SDK's training samples sink.

TEMPORARY: prime-runs is not on PyPI yet; pinned to the prime repo's
feature/prime-runs-train-backend branch (#856 + #873) via uv source.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AGeqWNdRB8ckrgch1tqVzJ
kcoopermiller and others added 3 commits September 1, 2026 17:31
…tests

- pyproject/uv.lock: the temporary git source points at the SDK branch head
  (aba26790) instead of a commit that only a merged PR ref still reaches;
  it picks up the per-upload sample id ranges, the training sink cooldown,
  replayable metrics and null handling for non-finite values. Dropped once
  0.1.0 is on PyPI.
- orchestrator: with an online platform run, episodes carry the platform's
  run id, so the run's traces can be queried by the id the dashboard shows.
  W&B keeps the launcher's PRL_RUN_ID either way.
- monitor: log_metrics hops off the loop like log_episodes (a queue put can
  block under backpressure); the PRIME_RUNS_MODE value passes straight
  through; _base_url only strips /rft (the SDK strips /api/v1); a 60 s
  finish_timeout bounds the drain on finish and on the atexit crash path.
- docs/training.md: the platform-monitoring section describes the SDK,
  the team requirement, PRIME_RUNS_MODE=disabled and RUN_ID attach.
- tests/unit/monitors: first coverage of the monitor (init kwargs, attach,
  disabled switch, base URL).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fk5fBAAaTiPfJ5UpNyqxXR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant