* feat: bump verifiers to 0.2.2.dev7, adopt the multi-agent episode wire
Companion to PrimeIntellect-ai/verifiers#1939 (multi-agent api). Re-pins
deps/verifiers to 192fd8ef0 (= 0.2.2.dev7) and deps/pydantic-config to
v0.4.2 (verifiers now requires prime-pydantic-config>=0.4.2).
- Serve wire: the env-server route run_rollout -> run, answering one
Episode envelope ({id, env, ok, errors, traces}) per env-rollout.
Env.run returns list[Rollout]; an episode that failed before minting
any trace raises (the dispatcher synthesizes its error marker), and a
not-ok episode marks its clean traces failed so a broken episode's
partial seats are never trained on.
- The episode is the pipeline currency: the dispatcher emits one episode
(list[Rollout]) per completed task onto out_q (a legacy run_group
result emits its traces as single-trace episodes), and both sinks
count episodes - never loose traces - toward group_size and eval epoch
sizes. episode_id is stamped into info so saved records keep grouping.
- ok is the success sentinel: has_error now reads it, so the dispatcher's
empty-trajectory promotion also flips ok, and error markers carry it.
- Only the trainable subset becomes training samples: a trace stamped
untrainable (a multi-agent env's frozen agent) is never tokenized,
never enters the group advantage, and never ships; it still lands in
the trace files and observation window.
- Config shape: everything env lives under the env block, following the
new vf.EnvServerConfig (env.taskset, env.agent.harness, per-agent caps
under env.agent.*). All checked-in TOMLs migrated; the spawned env
server receives the picklable env block via env_config_data.
- run_group survives only for v0/legacy bridge envs (a v1 server refuses
it and always reports requires_group_scoring=False); vf's @group_reward
removal doesn't touch prime-rl's own Algorithm.score_group.
Verified: tests/unit green (487 passed; config-loading params covered all
migrated TOMLs), ruff clean, and a 3-step reverse-text RL run on 2 GPUs
trains at 0% errors with every saved trace carrying ok, agent.name,
agent.trainable, and a distinct info.episode_id.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* chore: trim narrative comments to the load-bearing facts
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix: count buffered sink progress in episodes; explicit ok=False on cancel markers
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix: keep untrainable traces out of the effective views and the derived avg@k
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Under Ulysses CP the DeltaNet layer built its fla CP context from a
fabricated single-sequence cu_seqlens, so the gated delta rule carried
state across packed documents. The causal conv used shard-local
cu_seqlens, resetting mid-document at every shard boundary even for
unpacked rows.
Build the CP context from the full pre-shard cu_seqlens published by
setup_cp_params (fla derives per-rank boundaries and document-aware
state passing from them) and run the convolution through fla's CP conv,
which resets at true document boundaries and exchanges tail tokens
across ranks for straddling documents.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: samsja <55492238+samsja@users.noreply.github.com>
Bumps the deps/renderers submodule 89ab3f0 (v0.1.8.dev35) -> 35c2407
(v0.1.8.dev37), pulling in PrimeIntellect-ai/renderers#75: apply the
config-build fallback to ``_get_offset_tokenizer`` too.
#72 only wired the fallback into ``load_tokenizer``;
``_get_offset_tokenizer`` still called ``AutoTokenizer.from_pretrained``
directly to avoid the fastokens shim and so kept hitting HF's RoPE
validator on Laguna-family models. Every rollout through a hand-coded
renderer (LagunaXS2, Qwen35, ...) crashed with the same KeyError #72
was supposed to fix.
Verified end-to-end against poolside/Laguna-XS.2 with reverse-text:
two RL steps complete cleanly (reward 0.36 / 0.31, ~100 tok/sample);
the run then hits an unrelated single-GPU FSDP OOM on the 256-expert
trainer, which is a config-sizing issue, not the renderers bug.
Also pulls in renderers#74 (``message_tool_names`` field for per-message
tool attribution).
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Bumps the deps/renderers submodule 2ec28a8 (v0.1.8.dev28) -> 89ab3f0
(v0.1.8.dev35), pulling in PrimeIntellect-ai/renderers#72: when
AutoTokenizer.from_pretrained fails while building the model config
(e.g. HF RoPE validation rejecting nested rope_parameters for
poolside/Laguna-XS.2), fall back to loading the repo's self-contained
tokenizer.json directly. Fixes the tokenizer load crash for the Laguna
model series; loads under the fastokens fast path.
Re-locks uv.lock: renderers now floors openai-harmony at >=0.0.4 (renderers#69).
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Consume the typed RendererConfig surface
Reshapes the orchestrator / SFT renderer plumbing around
``renderers.RendererConfig`` (the typed discriminated union) instead of
flat strings + booleans.
- ``configs.shared.RendererConfig`` now composes ``renderers.RendererConfig``
as a single ``settings`` field; ``pool_size`` stays as a separate
prime-rl-side concern. The flat ``name`` / ``tool_parser`` /
``reasoning_parser`` / ``preserve_*`` fields are gone.
- ``setup_inference_pool`` / ``setup_clients`` / ``StaticInferencePool``
/ ``ElasticInferencePool`` collapse their six-arg renderer surface to
a single ``renderer_config: RendererConfig | None`` plus the orthogonal
``renderer_model_name`` / ``renderer_pool_size`` fields.
- Orchestrator + SFT trainer call sites pass the typed config straight
through to ``create_renderer(tokenizer, config.renderer.settings)``.
- Cross-env / unmapped-model validators rewritten to inspect
``renderer.settings`` (discriminated-union shape) instead of the flat
field names.
- Tests updated to construct typed configs (``Qwen3VLRendererConfig()``,
etc.) and assert against the new call shapes.
Pins ``deps/renderers`` and the ``prime-rl-configs`` ``renderers`` dep to
the renderers PR's tip
(``4c9099debbc9bc4fcc3eb6a118bbfa5c364ec395``) until it merges and a dev
release ships.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Bump renderers pin to the merged v0.1.8.dev27
The typed-config refactor landed on renderers main as ``c86c50b``
(tag ``renderers-v0.1.8.dev27``). Switching:
- ``deps/renderers`` submodule pointer → ``c86c50b``
- ``prime-rl-configs`` git URL pin → ``@renderers-v0.1.8.dev27``
Same commit, more readable, and stable to anyone reading the diff
after the feature branch is deleted. PyPI dev release for the same
version is pending a publisher-config fix; once it lands the git URL
pin can collapse to a plain ``renderers>=0.1.8.dev27`` PyPI pin.
* Migrate in-repo TOMLs to the typed renderer schema
The new RendererConfig accepts only `settings` (typed
`renderers.RendererConfig` discriminated union) and `pool_size`, so
flat `name`/`reasoning_parser`/`preserve_*` keys under
`[orchestrator.renderer]` now fail pydantic validation. Move those
keys under `[orchestrator.renderer.settings]`. `pool_size` stays in
the outer block. Two configs that only set `preserve_all_thinking`
gain an explicit `name = "auto"` since the discriminator is required.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Use renderers.RendererConfig directly; None means MITO
Per Mika's review: drop prime-rl's RendererConfig wrapper that nested
the renderers' discriminated union under a ``.settings`` field. The
wrapper bought a parallel ``pool_size`` attribute but cost a clunky
two-level TOML layout and made every call site dereference ``.settings``.
Use ``renderers.RendererConfig`` (the typed discriminated union) as
the field type directly. Pool size moves up one level to
``orchestrator.renderer_pool_size``. ``use_renderer: bool`` is gone —
``renderer: RendererConfig | None`` with ``None`` for MITO replaces it
(consistent with how SFT, optimizer, and other optional sub-configs
express absence). TOML callers spell MITO with ``renderer = "None"``,
which ``prime_pydantic_config.BaseConfig._none_str_to_none`` coerces
back to Python None.
Net effect on TOMLs is a wash with the previous commit: 26 in-repo
configs lose the ``.settings`` indirection they gained yesterday, and
one (multimodal) splits ``pool_size`` out of the renderer block.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Pin renderers via PyPI now that 0.1.8.dev27 is published
The slim ``prime-rl-configs`` wheel (installed standalone, outside the
workspace) now resolves ``renderers`` from PyPI instead of the git tag
URL it used while the dev release was waiting on PyPI trusted-publisher
config. The full ``prime-rl`` workspace still pulls renderers from the
``deps/renderers`` submodule, so this only affects downstream slim
consumers.
Re-locks to refresh the lockfile against the same workspace state.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Lazy-import renderers in the typed config schema
The slim ``prime-rl-configs`` install path (configs only, no GPU
deps) asserts that importing the config classes doesn't pull in
``transformers``. ``from renderers import RendererConfig`` at the top
of ``orchestrator.py`` / ``sft.py`` broke that: ``renderers/__init__``
eagerly imports every concrete renderer module (DefaultRenderer,
Qwen3Renderer, …), each of which imports
``transformers.tokenization_utils.PreTrainedTokenizer``.
Defer the renderers import via:
- ``TYPE_CHECKING``-guarded ``from renderers import RendererConfig``
so static type checkers still see the typed discriminated union.
- ``renderer: Any`` field annotation at runtime, so no resolution
happens at class definition.
- ``model_validator(mode="before") _resolve_renderer`` that
lazy-imports ``renderers``, fills the orchestrator default
(``AutoRendererConfig()``), and coerces dict input through the
typed union via ``TypeAdapter``. SFT's default stays ``None``.
End-user semantics unchanged; class import is now transformers-free.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Restore typed renderer field; pin renderers to dev28
dev28 lazy-loads concrete renderer classes via PEP 562
``__getattr__`` (renderers#64), so ``from renderers import
RendererConfig`` no longer drags ``transformers`` into ``sys.modules``.
The slim-install CI gate is satisfied without the prior workaround.
Drop the ``Any`` annotation and the ``_resolve_renderer``
model-validator that lazy-resolved the discriminated union from
``OrchestratorConfig`` and ``SFTConfig``. The fields are typed
``RendererConfig | None`` again, and pydantic does the full
discriminator validation at class definition.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Bump deps/renderers (dev28) and deps/verifiers (typed ClientConfig)
- deps/renderers c86c50b -> 2ec28a8 — picks up the PEP 562
``__getattr__`` so the workspace install path also lazy-loads
concrete renderer classes.
- deps/verifiers 04651be -> d107442 — adds the typed
``ClientConfig.renderer_config`` field that ``setup_clients``
forwards. Fixes the unit-test
``test_setup_clients_assigns_renderer_and_dp_rank_headers``
AttributeError on ``renderer_config``.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Preserve MITO across orch.toml round-trip; drop RendererConfig alias
Two cleanups on the typed renderer surface:
1. Per Samsja: drop the ``RendererConfig as RendererSettings`` alias
in ``client.py`` / ``elastic.py``. The alias was a workaround for the
former local ``RendererConfig`` wrapper class; with that gone, we
just import ``RendererConfig`` from renderers directly.
2. Per Cursor bugbot: ``OrchestratorConfig.renderer = None`` (MITO) was
silently dropped by ``model_dump(exclude_none=True)``, so any saved
``control/orch.toml`` would reload as the default
``AutoRendererConfig()`` (TITO). Add a wrapping ``model_serializer``
that re-injects ``renderer = "None"`` (string) when the field is
``None``, matching what ``BaseConfig._none_str_to_none`` accepts on
reload. MITO and TITO now round-trip through TOML.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Address mika review on #2635: rename pool_size, drop factory, trim docstring
- renderer field uses direct AutoRendererConfig() default (frozen, no
factory needed)
- renderer_pool_size -> pool_size on OrchestratorConfig; cascade through
client.py, elastic.py, orchestrator.py call sites and the test;
vf.ClientConfig kwarg name (verifiers-side) stays renderer_pool_size
- shorter docstring on the renderer field
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Bump deps/verifiers to f9c68eb2 (both renderer PRs merged to main)
Picks up verifiers main with PR #1463 (surface every parsed tool_call,
drop status filter) and PR #1468 (pipe chat_template_kwargs into typed
RendererConfig) now that both are merged. verifiers 0.1.15.dev11.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Eli Gottlieb <eli@primeintellect.ai>
* feat: drop use_renderer=True VLM skip; pack pixel_values from renderer
interleave_rollout now consumes renderer-emitted multi_modal_data on each
trajectory step (when present), packs the per-image pixel_values and
image_grid_thw onto the TrainingSample, and computes mm_token_type_ids —
no VLMImageCache lookup required when the rollout went through a
multimodal renderer. VLMImageCache stays as the fallback for
MITO/chat-completions rollouts.
build_trajectory_step (renderers package) was updated separately to
surface mm_data on its output, so the pretokenize-fallback path also
carries images through correctly.
Other changes:
- orchestrator config: removed validate_renderer_vs_vlm validator that
previously rejected use_renderer=True for VLMs (it's now supported).
- e2e test: a real Qwen3VLRenderer + RendererClient -> /inference/v1/generate
mock POST, plus a roundtrip through vllm's GenerateRequest pydantic
model and decode_mm_kwargs_item. Strongest end-to-end check we can
run without a GPU.
- 20-step A/B configs for color-codeword (feat-renderer vs main-mito),
both logging to W&B project 'multimodal-renderer'.
126 orchestrator unit tests pass (+2 new for renderer-mm packing).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* refactor(orchestrator): rip MITO multimodal path, renderer-only for VLMs
Delete the MITO chat-completions multimodal branch from the orchestrator
and the ~370 lines of image-cache/preprocess machinery in trajectories.py
that supported it. VLM training now goes through the renderer path
exclusively — the renderer owns the processor, ships byte-identical
pixel_values to both vLLM (via /inference/v1/generate features) and the
trainer (via mm_kwargs).
Renderer-shipped mm_token_type_ids: the orchestrator reads the renderer's
`mm_token_type_id_map` property (1=image_pad, 2=video_pad) and stamps a
per-token list onto each TrainingSample. Trainer's `_get_qwen3_vl_mm_token_type_ids`
auto-path remains as a fallback but the renderer is now the source of truth.
forward() now takes a generic `mm_kwargs: dict` (e.g. {pixel_values,
image_grid_thw}) instead of the Qwen3-VL-specific (pixel_values, image_grid_thw)
keyword pair, so adding new VLM families (Gemma3, LLaVA, etc.) doesn't
require touching forward.
Config validator: orchestrator.use_renderer must be true when model.vlm is
set — fail at config-load instead of producing cryptic runtime errors.
Test cleanup: drop 25 tests for removed helpers (VLMImageCache, _extract_images,
etc.); update the one remaining renderer-mm trajectory test to pass
`mm_token_type_ids_mapping` directly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix: align with renderer-multimodal PR surface (configs + deps + tests)
CI was failing for three reasons after the cherry-pick of the renderer
multimodal commits onto current origin/main. Three fixes:
1. Multimodal configs missing the renderer flag pair. The orchestrator
config validator (added in the same PR) requires
``use_renderer = true`` when ``model.vlm`` is set, AND it's mutually
exclusive with ``use_token_client`` (default ``true``). Three configs
(``rl_color_codeword_test.toml``, ``rl_color_codeword.toml``,
``ci/nightly/multimodal_color_codeword.toml``) needed both flags set
explicitly in ``[orchestrator]``. Delete
``rl_color_codeword_main_mito.toml`` — that was the A/B reference for
the legacy MITO path, which this PR rips out. With MITO gone the
config is no longer runnable; the ``rl_color_codeword_feat_renderer``
counterpart already covers the new renderer-driven path.
2. ``test_model_forward.py`` was still calling ``forward(...,
pixel_values=..., image_grid_thw=...)``. ``forward()`` now takes a
generic ``mm_kwargs: dict`` (so adding new VLM families doesn't
require touching the trainer signature) — update both tests to pass
``mm_kwargs={"pixel_values": ..., "image_grid_thw": ...}`` instead.
3. ``renderers`` / ``verifiers`` deps stale. The orchestrator imports
``MultiModalData`` from ``renderers.base`` (introduced in the
companion renderers PR) and threads ``multi_modal_data`` end-to-end
via the verifiers ``RendererClient`` changes. Pin both to their
feature branches until the upstream PRs merge and PyPI / git
rev-pins are bumped:
- renderers @ feat/multimodal-vlm
- verifiers @ feat/renderer-multimodal-passthrough
Drops the ``renderers==0.1.6`` PyPI pin (the new symbols are post-0.1.6).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore: bump renderers + verifiers to latest feature-branch commits
Picks up:
- renderers c3feaa5: RendererPool implements Renderer protocol structurally
(callers can drop pool unwrap + isinstance branching), size=1 fast path,
is_multimodal helper with per-type cache.
- verifiers 64f2555a: bugbot pass — multimodal dispatch fix (was broken
for pooled renderers), tighter is_json_serializable, response-tokens
mm_data strip on intermediate steps.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore: bump renderers + verifiers to pick up isinstance dispatch fix
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore: drop renderers git source, pin to released 0.1.7
renderers v0.1.7 is now on PyPI with the multimodal feature set this
branch consumes (RenderedTokens, MultiModalData, MultimodalRenderer
protocol, mm_token_type_id_map, RendererPool delegation).
verifiers still pinned to feat/renderer-multimodal-passthrough until
that companion PR merges.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore: repin verifiers to main + bump renderers to 0.1.8.dev2
The multimodal renderer-passthrough work has merged on verifiers
(verifiers#1346 → c7731bbb, on main since 2026-05-12), so we no longer
need the feature-branch pin. Switching to a `rev =` pin on main
(f633365f) — consistent with how every other git source in this file
is pinned — and bumping renderers to 0.1.8.dev2 to match what verifiers
main now requires.
Pin updates:
- verifiers: branch `feat/renderer-multimodal-passthrough`
(0.1.14 @ 397b8aa5) -> rev `f633365f` (0.1.15.dev7)
- renderers: `>=0.1.7` -> `>=0.1.8.dev2`
- prime-sandboxes: 0.2.22 -> 0.2.26 (transitive from verifiers main)
- fastokens added (transitive from renderers 0.1.8.dev1+; renderers
routes `load_tokenizer` through fastokens by default)
What's in the verifiers delta (397b8aa5..f633365f) that touches our
surface:
- `RendererClient.from_native_response` migrated to renderers'
`ParsedToolCall` dataclass shape and filters non-OK parse attempts
(verifiers#1366 / renderers#22). Internal — the Response we consume
is unchanged.
- Routed-experts payloads now flow as opaque bytes through the chat
completions clients (verifiers PRs around the `routed_experts`
changes). Prime-rl consumes the surface that emits these; no caller
change needed.
Test plan:
- [x] `uv run pytest tests/unit/orchestrator` — 101 passed against the
new pins, including `test_qwen3_vl_e2e` which exercises the renderer
-> RendererClient -> /inference/v1/generate roundtrip path.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore: drop renderers version pin, defer to verifiers' transitive constraint
We import directly from `renderers` (orchestrator + tests), so the dep
needs to be declared — but pinning a floor here is just second-guessing
verifiers, which already requires `renderers>=0.1.8.dev2`. Let verifiers
be the source of truth for the version.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(trainer): drop mm_token_type_ids auto-compute, trust renderer
The auto-compute path (`_get_qwen3_vl_mm_token_type_ids`) was preferred
over the renderer-shipped `mm_token_type_ids` in `forward()`. For
Qwen3-VL the auto function never returns `None` (allocates
`torch.zeros_like(input_ids)` then masked_fills), so the explicit
orchestrator-shipped list was silently discarded — contradicting both
the "renderer is source of truth" design and the trajectories.py
comment noting the explicit list produces ~30x lower mismatch KL.
The new `vlm_requires_renderer` validator (this PR) mandates the
renderer for every VLM config, so the auto path is no longer reachable
as a real fallback. Deleting it. The renderer's `mm_token_type_id_map`
is now the sole source of truth, exactly as advertised.
Also adding the CHANGELOG entry the validator missed — removing the
`[model.vlm]` + `use_renderer = false` combo is a breaking config
change per CHANGELOG.md's stated policy.
The remaining `if "image_grid_thw" not in mm_kwargs` branch is *not*
renderer-replaceable: it skips `position_ids` for MRoPE families
because HF's Qwen-VL `forward()` internally recomputes 3D positions
from `image_grid_thw` and breaks if given the trainer's pre-computed
1D `position_ids`. Duck-typed against the kwargs schema so any future
MRoPE family that ships `image_grid_thw` is handled without a
`model_type` enumeration.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(orchestrator): union per-step delta mm_data across sample's step range
verifiers ≥ c7731bbb (PR #1346 merge) replaced ``_strip_intermediate_mm_data``
with ``_delta_intermediate_mm_data`` (commit 9aafa659): each trajectory
step now carries only the items whose ``mm_hash`` was NOT in the prior
step's cumulative set, with multiset-aware semantics. The intended
contract is that per-window assemblers union deltas to recover the
per-sample cumulative.
Prime-rl's ``interleave_rollout`` was that assembler but still read
``prepared_steps[last_step_idx].get("multi_modal_data")`` alone,
assuming the last step held the cumulative set. With the new delta
encoding, the last step often holds **0 items** (everything was a
duplicate of step 0's cumulative set) — so the trainer was given
pixel_values for only the first turn's images. For ``color-codeword``
with ``max_turns=2, images_per_turn=2`` (4 images total), the trainer
saw a subset → wildly wrong attention → mismatch KL jumped from
~0.04 to ~7 (>100× regression). On Qwen3-VL the model raised
``ValueError: Image features and image tokens do not match`` when the
delta drop left the trainer with fewer feature blocks than placeholder
runs.
Fix: track ``start_step_idx`` per active sample and concatenate
``mm_items`` / ``mm_hashes`` across ``[start_step_idx, last_step_idx]``
in step order. No dedup here — verifiers' delta already handled
cross-step dedup with multiset semantics (legitimate duplicate
placeholders, where the same image appears in two turns' separate
placeholder runs, are preserved).
Test plan:
- ``uv run pytest tests/unit/orchestrator/test_trajectories.py`` — 20 passed
- ``uv run pytest tests/unit/orchestrator tests/unit/train`` — 216 passed, 6 skipped, 1 xfailed
- ``uv run rl @ configs/multimodal/rl_color_codeword_feat_renderer.toml``
on 2× RTX PRO 6000: Step 0 KL **0.020** (was 7.0), Step 1 **0.090**,
Step 2 **0.253** — all within the baseline range published in #2473
(max 0.487 across 20 steps).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(orchestrator): track explicit step indices per sample for mm union
interleave_rollout used (start_step_idx, last_step_idx) to bound the
mm_data union per sample. When agents interleave (e.g. agent1 at steps
0,1,3 and agent2 at step 2), the range [0,3] over-collects step 2 and
agent2's delta mm_items leak into agent1's sample.mm_kwargs — placeholder
count vs. patch count mismatches at the VLM forward.
Replace the (start, last) pair with the explicit list of prepared_steps
positions merged into the sample. _union_step_mm_data iterates the list
directly, so non-owned steps are skipped by construction.
Non-interleaved trajectories produce step_indices = [0..N], iterating
identically to the old range — bit-for-bit unchanged for the common path.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: eligotts <78387377+eligotts@users.noreply.github.com>
* feat(renderer): expose preserve_*_thinking flags in RendererConfig
Adds two new fields to RendererConfig:
- preserve_all_thinking
- preserve_thinking_between_tool_calls
The orchestrator forwards them in two places so train and infer stay
consistent:
1. create_renderer() — bound at construction on the training-side
renderer used by build_trajectory_step / render_ids.
2. setup_inference_pool() → setup_clients() → vf.ClientConfig — the
verifiers RendererClient picks them up and forwards to its
create_renderer_pool, so every inference render carries the same
thinking-preservation behaviour.
Both flags are off by default → zero behaviour change for existing
configs. Setting either without orchestrator.use_renderer=True is
rejected by validate_renderer_args, matching the existing renderer
knobs.
Bumps source pins:
- verifiers 3b77145 → a7516a1 (PR #1298: ClientConfig propagation)
- renderers (now a separate repo): pinned to fe67f9f (PR #4:
construction-time preserve flags)
Re-applies #2433, which was merged into feat/unify-inference-generate
by mistake.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(sft): forward preserve_*_thinking flags through SFT renderer path
The flags were added to the shared RendererConfig but only wired up
in the orchestrator. SFT also constructs a renderer via create_renderer
for training-side tokenization, so it must forward both flags or
silently ignore them.
Also tighten validate_renderer_args to reject either flag when
use_renderer=False, matching the orchestrator validator.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds `use_renderer` flag to SFTConfig, mirroring the RL path. When enabled,
SFTDataset tokenizes via `renderers.base.build_training_sample` instead of
the incremental Jinja `apply_chat_template` path, fixing multiturn sample
drops and position-dependent template crashes.
Co-authored-by: Eric Botti <ericjbotti@gmail.com>
* feat: weighted length shaping over completion + tool-response tokens
Generalize the length_shaping brevity bonus to a weighted combination of
model-completion tokens and tool-response tokens, so the brevity signal
can penalize tool-response token consumption (read from a harness metric
like rlm_total_tool_response_tokens) independently from model output.
- Add `tool_response_lengths` to AdvantageInputs (optional)
- Add `length_shaping_completion_weight` (default 1.0) and
`length_shaping_tool_response_weight` (default 0.0) to
DefaultAdvantageConfig — defaults preserve existing behavior.
- effective_lengths = a * completion + b * tool_response, fed to the
existing correctness-gated brevity bonus.
- Add get_tool_response_len() that pulls *_total_tool_response_tokens
from rollout metrics and returns 0 if absent (no-op for non-tool envs).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(advantage): guard zero-cost division in efficiency shaping
When `mean_correct_cost == 0` (e.g. tool-only shaping without a harness
metric, or all-zero turn counts), `costs / mean_correct_cost` was 0/0 →
NaN advantages. `clamp(0, 1)` doesn't recover from NaN.
Detect zero mean and zero out the bonus, falling back to plain GRPO for
that group. Also a latent bug for `length_penalty="turns"` if a group
ever had all empty trajectories — same fix covers it.
* fix(advantage): constrain weights to finite non-negative; cast rewards to float
- Config: add `ge=0, allow_inf_nan=False` on both weight fields. Negative
weights would invert the shaping (reward more tokens); inf/nan poison
advantages downstream.
- `default_advantage_fn`: cast rewards to float32. The previous
`dtype=rewards.dtype` for costs truncated fractional weighted sums when
rollouts emitted integer rewards. Casting also fixes a latent crash on
int rewards in `_efficiency_shaping`'s `rewards.mean()` (Long unsupported).
* refactor(advantage): discriminated length_penalty sub-config
Replace the scalar `length_penalty: Literal["tokens","turns"] | None` plus
two flat weight fields with a discriminated union on `type`:
TokensLengthPenaltyConfig(completion_weight, tool_response_weight)
TurnsLengthPenaltyConfig
Default for the tokens config is (1.0, 1.0), making total-context shaping
the default when token-shaping is enabled. The discriminator pattern
matches the existing AdvantageConfig (default | custom) shape and keeps
weight semantics scoped to the variant they apply to — no cross-field
validator needed.
CHANGELOG entry added.
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore: bump vllm 0.19 → 0.20
vLLM 0.20.0 lands MoE LoRA refactor (#40338) and CPU offloading fix
(#39617) upstream — drop now-redundant prime-rl monkey patches:
monkey_patch_fused_moe_lora_dp and monkey_patch_offloading_connector_
cpu_block_count.
PyPI vllm-0.20.0 is built against CUDA 13 and links libcudart.so.13;
our env is pytorch-cu128 (CUDA 12). Pin vllm to the cu129 wheel from
wheels.vllm.ai (libcudart.so.12) for binary compat. Promote
torchvision/torchaudio to direct deps so [tool.uv.sources] pins them
to pytorch-cu128 (cu13 transitive resolution would break torch ops).
Add vllm = false exemption to the 7-day exclude-newer cooldown since
0.20.0 was published 2026-04-27, inside the window.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat: migrate cu128 → cu130
Now that vllm 0.20.0 is the floor and PyPI ships it for CUDA 13
natively, drop our cu129-wheel detour and move the rest of the
GPU stack to cu130:
- pytorch-cu128{,-test} indices → pytorch-cu130{,-test}
torch/torchvision/torchaudio/flash_attn_3 follow.
- flash-attn extra: bump to v0.9.4 cu130torch2.11 prebuilt wheel.
- Drop the wheels.vllm.ai cu129 URL pin — PyPI vllm 0.20.0 (cu13)
is now the default.
- override-dependencies: nvidia-cudnn-cu12 → nvidia-cudnn-cu13.
Lockfile pulls torch 2.11.0+cu130, torchvision/torchaudio 0.26.0/2.11.0
+cu130, flash-attn 2.8.3+cu130torch2.11, vllm 0.20.0, and swaps every
nvidia-*-cu12 transitive for its cu13 counterpart.
Not addressed in this change (draft until ready):
- Host driver upgrade: 575.64.03 → ≥580.65.06 required for CUDA 13.
- samsja prebuilt wheels (deep-ep, deep-gemm, nixl-cu12) still
point at cu12 builds — runtime-incompatible with cu13. Need
rebuilds before merging.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore(deps): bump vllm 0.20.0 → 0.20.1
Picks up the DeepSeek V4 patch release and a handful of bug fixes
(CUDA-graph max_num_batched_token, num_gpu_blocks_override, cumem
expandable_segments, structured-output kwargs). Strict patch — none
of the kept/dropped monkey-patches are touched.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore(deps): ship cu13 disagg wheels, switch nixl to PyPI
deep-ep / deep-gemm: rebuilt against CUDA 13.1, stamped with `.cu13`
local version, uploaded alongside the existing cu12 wheels at v0.5.0.
nixl: dropped the URL pin entirely. PyPI `nixl-cu13` 1.0.1 ships UCX
auditwheel'd with mlx5_ib / rdmacm / cuda transports — verified
end-to-end with a 2-node basic_two_peers.py run that picked rc_mlx5
for inter-node RMA. The custom install_nixl_from_source.sh path is
kept (now generates `nixl-cuMAJOR` per torch's CUDA major) for
clusters that need a vendored UCX, but it's no longer the default.
install_ep_kernels.sh:
- Falls back to /usr/local/cuda-${MAJOR} when torch reports 13.0
but only cuda-13 (-> 13.1) is installed; rejects toolkit/torch
major mismatches.
- Exports CPATH=$CUDA_HOME/include/cccl for CUDA 13, where CCCL
headers (e.g. <cuda/std/tuple>) moved into the cccl/ subdir and
torch's CUDAExtension doesn't add it on its own.
- Post-build --set-runpath /tmp/deepep_build/nvshmem/lib rewrites
the DT_RUNPATH on deep_ep_cpp.so to match the cu12 convention the
existing inference/RL templates already hook (they symlink the
user's NVSHMEM at that path on each compute node).
install_deep_gemm.sh: post-build cu-suffix stamp.
scripts/wheel_add_cu_suffix.py (new): repacks a wheel with
+...cuXX appended to its local version, optionally stripping or
rewriting DT_RUNPATH on every .so. Keeps METADATA / dist-info /
RECORD / filename consistent.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(templates): fall back to ep_kernels_workspace nvshmem in disagg launchers
inference.sbatch.j2 and multi_node_rl.sbatch.j2 still set up the
/tmp/deepep_build/nvshmem/lib symlink the deep_ep wheel needs at
runtime, but now also try $PROJECT_DIR/ep_kernels_workspace/nvshmem/lib
(where install_ep_kernels.sh actually places NVSHMEM) if
$OUTPUT_DIR/nvshmem isn't staged.
Also adds the same hook to multi_node_rl.sbatch.j2's disagg block
(was previously only in inference.sbatch.j2, despite multi_node_rl
running deep_ep in-process when disagg is enabled).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* style: drop unused shutil import, apply ruff format
Caught by the Style workflow — `shutil` was speculatively imported
when wheel_add_cu_suffix.py was first sketched but never used, and
ruff's formatter wanted a couple of cosmetic tweaks.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(deps): exempt torchvision/torchaudio from exclude-newer cooldown
Both are sourced from the `pytorch-cu130` index alongside `torch` and
`flash_attn_3`. That index doesn't publish upload dates, so any package
pulled from it must be exempt from the 7-day `exclude-newer` cooldown
or `uv lock` may fail to resolve when a new release lands inside the
window.
Caught by bugbot.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore(deps): refresh uv.lock metadata under uv 0.11.9
Previous lockfile was generated with uv 0.11.7. After the bugbot
fix added `torchvision`/`torchaudio` to `exclude-newer-package`,
CI (which runs uv 0.11.9) detected a metadata drift and failed
`uv sync --locked`, even though the resolved packages were
identical.
Re-locking with uv 0.11.9 reorders the `exclude-newer-package`
section and normalizes the `exclude-newer` value; no resolution
changes.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* add cu12 cudart to venv dep
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Jackmin801 <ongjackm@gmail.com>
The transformers @auto_docstring decorator prints a warning at import
time for any forward-method param missing from the docstring. The five
custom *ForCausalLM models accept cache_position only for HuggingFace
API compatibility — training asserts use_cache is None and never decodes
autoregressively, so the param is unused. Documenting that fact makes
the behavior explicit and clears the warnings.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix: handle DTensor weights in MultiLoRAGroupedExperts for EP compatibility
When Expert Parallelism is enabled, distribute_module() converts all
parameters to DTensors sharded across the EP mesh. The base GroupedExperts
path handles this via the @expert_parallel decorator, but
MultiLoRAGroupedExperts.forward() bypassed the decorator entirely,
passing DTensors directly to torch._grouped_mm alongside regular tensors.
Mirror the @expert_parallel decorator logic: convert DTensors to local
shards, apply generate_permute_indices for token reordering and alignment
padding, and unpermute the output.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: gather EP-sharded LoRA weights in state_dict and exclude base_layer from modules_to_save
Two fixes for EP + LoRA MoE weight broadcast:
1. state_dict_for_adapter: call full_tensor() on DTensor LoRA weights
before per-expert indexing. With EP, these weights are sharded across
ranks and direct indexing triggers a DTensor redistribute assertion.
2. save_lora_config: exclude "base_layer" params from modules_to_save
detection. After EP/FSDP wrapping, base layer params can have
requires_grad=True, causing them to be incorrectly added to
modules_to_save which vLLM rejects.
Tested end-to-end: Qwen3-30B-A3B EP=4, LoRA rank 16, 30 steps at
batch sizes 128 and 256 on H200.
* fix: re-freeze base params after EP replaces them with DTensors
ExpertParallel() replaces expert params with DTensors that default to
requires_grad=True, overriding the freeze applied by LoRA setup.
Re-run freeze_all_except_lora_and_specified after apply_ep to restore
correct grad state.
This also reverts the save_lora_config workaround (base_layer filter)
since the root cause is now fixed.
* fix: use new_zeros instead of new_empty for unpermuted output buffer
new_empty leaves uninitialized memory in positions not covered by
permuted_indices, which could leak garbage values into the output.
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
MergedColumnParallelLinearWithShardedLoRA.slice_lora_a was hardcoded
for exactly 2 subloras, causing IndexError with Qwen3.5's 4-way
qkvz fusion when fully_sharded_loras=True.
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: add Qwen 3.5 MoE model support with EP and CP integration
Adds a custom Qwen 3.5 MoE (GatedDeltaNet + MoE) implementation with:
- HF <-> PrimeRL weight conversion (fused/unfused expert formats)
- Expert Parallelism support (MoE layers auto-detected by apply_ep)
- Context Parallelism support (ring attention patching for flash attention layers)
- Router replay via routed_experts argument
- Unit tests for forward pass, weight roundtrip, router replay, and CP patching
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* remove vflm warning
* feat: add custom VLM support for Qwen 3.5 MoE
Extend Qwen3_5MoeForCausalLM to handle both text-only and VLM configs.
When the config has a vision_config, the model creates a composite body
(HF frozen vision encoder + custom PrimeRL text model). Weight conversion
auto-detects VLM keys and remaps accordingly.
- Unified model class (no separate VLM file) driven by config
- Config-based VLM detection fallback for local model paths
- VLM dispatch in get_model() via _CUSTOM_VLM_MAPPING
- mini_moe.py preset for qwen3_5_moe_vlm testing
- 6 new GPU tests covering forward/backward/weights/roundtrip/router/meta
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* chore: add debug SFT config for real Qwen3.5-35B-A3B VLM
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: support VLM layer key format in weight broadcast
VLM models use `model.language_model.layers.*` instead of
`model.layers.*`, which crashed get_max_layer_num and caused
filter_state_dict_by_layers to silently drop layer weights.
Also fixes off-by-one in filter_state_dict_by_layers that
skipped layer 0.
* use registry-based approach
* run ruff
* chore: remove debug SFT configs for Qwen3.5 MoE
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: sami jaghouar <sami@primeintellect.ai>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: sami jaghouar <sami.jaghouar@gmail.com>
* fix vlm in transformers 5
* improve
* fix bug
* rename
* fix: auto-install transformers v5 compat hook for vLLM workers
* refactor: use vLLM plugin system instead of .pth hook for transformers v5 compat (#1810)
Replace the runtime site-packages mutation (.pth file + generated module)
with a vllm.general_plugins entry-point. vLLM loads general plugins in
every process it spawns (workers, engine core, API servers), so the patch
survives multiprocessing spawn without writing to site-packages.
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* minor fixes
* add nightly for multimodal
* improve exact config
---------
Co-authored-by: samsja <55492238+samsja@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* add skills dir & first skill for vllm
* remove unimplemented stuff
* make symlink relative
* make separate config skill
* update AGENTS.md & skills
* make more explicit
* bump ruff version & move to ruff-check
* add ruff format to CI
* run ruff format
* fix ruff
---------
Co-authored-by: sami jaghouar <sami@primeintellect.ai>