Repository navigation
Conversation
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try the Wiz Code extension for VS Code, JetBrains, or Visual Studio. |
46d37fd to
5d3e59a
Compare
With [weight_broadcast] type = "modelexpress" and pull = true, each inference server (on several nodes, the first rank of each DP group, for all its ranks) follows the versions the trainer publishes to ModelExpress: it stages the newest one while serving, then pauses, installs and labels it, and resumes. The orchestrator only reads the version each engine serves, and the trainer publishes without waiting for installs. Rebased onto the reorganized prime-rl-configs package (#4899, #4919): - pull lives on the ModelExpress section (blocks/weight_broadcast.py) and the engine's EngineWeightBroadcastConfig carries the pull settings; - the engine config builders take an EngineWeightBroadcastConfig, so rl, sft and the standalone inference entrypoint pass the full transport; - rl rejects pull with Dynamo, draft swaps, rollout checkpoints and staging_mode = "IN_PLACE" (engines would read weights the trainer is still updating); sft rejects pull. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…iner's
Batch N trains on v{N-1}, the newest version the trainer can have
published. A token labelled with a newer version comes from an engine that
outlived a trainer restart from an earlier checkpoint and still samples
with the old trainer's weights; with engines that pull their weights, such
an engine keeps serving until it installs the new trainer's first version.
The sink now keeps queued tokens whose version lies in fresh_versions(step,
max_staleness), a range from the oldest fresh version to v{step-1}, and
the trainer masks the same tokens when it builds the batch. The sweep no
longer skips traces dispatched with a fresh version, since those can hold
newer tokens; strict_staleness still drops only traces dispatched too old.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e lapsed With engines that pull their weights, P/D groups switch independently, so a decode engine can sit paused while prefill keeps serving. A paused decode engine sends no lease heartbeats; once a lease runs out, prefill frees and reuses the blocks it held, and decode would read another request's KV. When decode is about to start a read whose lease was last renewed more than half of kv_lease_duration ago, it now prefills the prompt itself. From #4779, which needs it for the same reason under filesystem pull. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a27ad19 to
d397d5b
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d397d5b. Configure here.
| version_marker = self.step_dir(step) / VERSION_MARKER | ||
| pending = installed.with_suffix(".pending") | ||
| pending.write_text(version_marker.read_text() if version_marker.exists() else "") | ||
| pending.replace(installed) |
There was a problem hiding this comment.
Pull receive writes deleted broadcast dir
High Severity
With pull, the trainer no longer waits for the orchestrator, and _clean deletes every broadcast directory older than the previous step. ModelExpressPullWeightReceiver.receive still writes .installed into that directory after engines catch up. If the trainer publishes two further versions first, the directory is already gone and the write raises FileNotFoundError, which kills the weight watcher.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit d397d5b. Configure here.
| label = await engine_client(request).get_weight_version() | ||
| except RuntimeError: | ||
| return {"version": None} | ||
| return {"version": int(label) if label.isdigit() else None} |
There was a problem hiding this comment.
Weight version endpoint rejects unset label
Medium Severity
GET /weight_version calls label.isdigit() whenever get_weight_version does not raise. Before the first update that label is None, so the handler raises AttributeError instead of returning {"version": null}. The orchestrator polls this route for the dispatch gate and startup sync, and each poll becomes a 500 until an install sets a numeric label.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit d397d5b. Configure here.


Builds on #4801 (merged). Rebased onto the reorganized
prime-rl-configspackage (#4899, #4919). The full-scale DeepSeek-V4-Flash benchmark is below.Summary
With
[weight_broadcast] type = "modelexpress"andpull = true, each inference server moves itself onto every version the trainer publishes to ModelExpress (MX). Today the orchestrator pauses every engine, posts/update_weights_from_modelexpressto each and resumes them. Under pull the orchestrator pauses and pushes nothing: it only reads the version each engine serves, for its dispatch gate, the startup sync and the final evals. The bytes already moved one-sided (engines read the trainer's host copy over NIXL); now the decision to switch is the engine's too. This is the first step towards engines that an orchestrator does not manage one by one, such as engines managed by Kubernetes.Design
Config.
pullon the ModelExpress[weight_broadcast]section (blocks/weight_broadcast.py), which reaches the trainer and the orchestrator. The engine'sEngineWeightBroadcastConfigcarries the pull settings:rlbuilds each engine's transport with the MX host, port, staging settings andtimeout, and marks who pulls. The engine config builders take anEngineWeightBroadcastConfiginstead of a transport name, so the standaloneinferenceentrypoint passes its whole[weight_broadcast]and a standalone server can pull too. Who pulls:weight_broadcast.pull);--weight-broadcast.pull --weight-broadcast.host $WEIGHT_BROADCAST_HOST --weight-broadcast.group <admin URL of every rank of the group>, and the admin token to call those ranks.weight_broadcast.groupdoes not requirepull: the template gives it to the first rank of every DP group of more than one rank, so anything else that moves a group's weights can find its ranks.weight_broadcast.model_name(defaultvllm.model) names the model versions are published under.Where the puller lives. A task in the API server (
inference/vllm/weight_pull.py), in API server 0 only under API server scale-out. It needs the engine controls (pause, resume, the weight-version label) that only the engine client reaches; the workers do the data plane. It drives anEnginesinterface (init,can_stage_live,stage,discard,pause,apply,resume,served):LocalEngine: this server's engines, in process. vLLM fans every call out to all data-parallel engines of an internal-LB server.EngineGroup: the ranks of an external-LB DP group, through admin routes on each rank:/modelexpress/can_stage_live,/modelexpress/stage,/modelexpress/discard,/modelexpress/apply, plus/pause,/resumeand/init_broadcaster. The ranks of an expert-parallel DP group share every forward pass, so the group's first rank moves all of them.Discovery. The puller polls
list_weight_versionsevery 0.2 s (MX 0.8.0 has no watch RPC) and takes the newest READY version published after the one it serves. Publication order decides, not the step, so it also follows a trainer that restarted from a checkpoint back to a lower step. Versions published in between are skipped.Staging while serving. Every worker stages the version on a background thread, with its own CUDA stream, while the engines serve; the API server polls a cheap status RPC. Staging writes only MX's own buffers, except for the first stage of a trainer's versions: it records how the trainer's tensors map onto the engine's on the live model (layout capture), so it must run paused. Workers therefore refuse to stage live until they have installed a version of the same trainer mesh, and the puller stages that first version after the pause.
staging_buffer_bytes, the stage reads the whole version into one more copy of the weights on each GPU while serving, so the pause only installs it.The switch. Once every worker of every rank has staged, the puller pauses the engines with the running requests and their KV kept (
pause_generation(mode="keep", clear_cache=False), as push does), installs the version on every worker, labels the tokens sampled from then on with its step (weight_versionson every response) and resumes. vLLM's data-parallel pause stops every rank of the group at the same step and its resume is a barrier, so no forward pass mixes versions. Groups switch independently, each as soon as it is ready: there is no global barrier, and a slow group holds up no other.Orchestrator.
ModelExpressPullWeightReceiverinitializes, pauses and pushes nothing. It waits until every engine (AdminPlane.served_versions,GET /weight_version) serves the version or a newer one of this trainer, then marks it installed. A newer version counts only if its broadcast finished, so a version from before a trainer restart does not. The watcher keeps dispatching across a swap (on_version_pendingis skipped when engines pull). The trainer and orchestrator still share the broadcast dir for its markers; no weights go through it.Trainer. Each rank publishes from one host copy (MX's COPY_TO_HOST arena), refilled on every publish, so the trainer holds one version, as with push. Before publishing the next version, the master marks the previous one RELEASING, so MX accepts no new lease on it, and every rank waits until the reads still in flight release their leases (bounded by
timeout). The trainer waits for no install, except at the end of training, where it keeps the last version available until the orchestrator marks it installed. A new trainer retires a previous trainer's READY versions, so engines do not try to install them. Trainer host memory stays at one copy of the weights.Failures.
weight_broadcast.timeoutthe server exits. It never resumes with mixed weights.IncompleteRefit.Also.
GET /weight_versionreturns the label the engine serves;?uid=truealso returns the MX version every worker installed last (modelexpress_served, cleared while an install runs). The plain read, which the orchestrator polls, does not touch the workers.WeightPuller.lockis held through every switch, for anything else that moves the same engines.rlrejects pull with draft swaps, rollout checkpoints, Dynamo andstaging_mode = "IN_PLACE"(engines would read weights the trainer is still updating); SFT rejects it.Fixes pull needs.
max_staleness: the sink keeps tokens whose version lies infresh_versions(step, max_staleness)(orchestrator/utils.py), andtransports/payload.pymasks versions abovetrained_version.strict_stalenessstill drops only traces dispatched too old.monkey_patch_nixl_prefill_lapsed_remote_kv_locallymakes decode prefill a request itself when its lease was last renewed more than half ofkv_lease_durationago.Credit
This builds on the filesystem pull stack and on an earlier MX pull attempt:
GET /weight_version,AdminPlane.served_versions, the receiver's rule that a newer version counts only if its broadcast finished, the watcher dispatching across a swap,WeightSender.acknowledged, and the rejected features. Its sparse delta format is not used.Engines/LocalEngine/EngineGroupstructure, group leaders that move their ranks through admin routes, independent groups, the template'sgroup_admin_urlsand per-rank arguments, the admin token for leaders, and the API server index. Also the P/D decode lease guard.Validation
Tiny models on one B200 node (three GPUs per run), the debug algorithm with 8 steps (every step publishes new weights), and a probe that kept long completions in flight with
return_weight_versionsthroughout:rlrl/pause,/resume,/update_weights_from_modelexpressor/init_broadcasterfrom the orchestrator. In the group-leader run, each rank received one/modelexpress/stage,/pauseand/resumeper version, from rank 0. Where the probe readGET /weight_version(both single-server runs, both ranks of the group), it went 0, 1, ..., 8, and both ranks of the group changed version at the same moments.default) were sampled from the checkpoint weights before v0, before the orchestrator dispatched anything; none follows a labeled span.Bit-exactness. #4805's tool, with a mode in which the engine pulls each version itself and the trainer waits until the version was fingerprinted before publishing the next (that mode is not part of this PR). The engine cold-loads W0, and its digests are the oracle; the trainer then publishes W0, W0 + D1, W0, W0 + D2, W0. v0 stages while paused, v1-v4 while serving. All pass: every W0 step equals the cold-load digests, and every floating-point parameter changes at both perturbed steps.
Unit tests. New: the puller's switch protocol (live and cold staging, skipped versions, a restarted trainer, stage and install failures, a failed pause), the worker's background staging, the trainer's retire-before-publish order, the receiver, the config and CLI of a group leader, and pull's config rejections including
IN_PLACE. Regression cases, each failing without its fix: a token newer than the trainer (test_partially_stale_trace_ships_fresh_tokens[newer-than-the-trainer], through the sink and the trainer's batch) and the decode lease guard on vLLM's real scheduler. CPU-only, with the pinnedverifiersandrenderers: the eleven suites this branch touches (pull, ModelExpress boundary, admin clients, Dynamo, train sink and its payloads, payload, batch transport, planner, P/D scheduler, configs) pass, 791 tests.Launcher. A multi-node
rlconfig with pull renders a SLURM script that passesbash -n, both for one expert-parallel DP group of 16 ranks over two nodes and for 1P1D. Run from the rendered script,weight_group_argsgives rank 0 of the group the pull arguments and all 16 admin URLs and the other ranks none, and rank 0's arguments parse with theengineCLI the ranks launch with. Engine configs setpullonly on a single node; on several nodes the launcher marks the leaders.Full-scale benchmark (DeepSeek-V4-Flash, 284B)
Setup:
What changes with pull:
The trainer's pre-broadcast
torch.cuda.empty_cache()(#4823) was still in all three runs. Skipping it under ModelExpress saved a further 5.4 s per broadcast plus the next step's memory re-acquisition in a separate push run.Not yet validated
Known limits
orchestrator.speculative_decoding) are off with pull. Speculative decoding runs with the draft the engines launch with; a drafter that shares the target's embedding or LM head reads the updated ones, since they alias the target's storage and MX installs in place. A draft swap would have to happen at the engine's own switch.staging_mode = "IN_PLACE"are rejected with pull.PRL_WEIGHT_BROADCAST_HOST, which Kubernetes deployments set for the trainer.🤖 Generated with Claude Code
Note
High Risk
Changes core weight sync, multi-node admin auth, and training staleness rules; failed installs can pause or exit inference servers past timeout.
Overview
Adds
weight_broadcast.pullfor ModelExpress so inference engines discover and install new policy versions on their own instead of the orchestrator pausing every engine and pushing each update.Each API server runs a
WeightPullerthat polls ModelExpress, stages weights on workers (in the background while serving when safe), then pauses with KV kept, installs, and resumes. Multi-node expert-parallel groups are coordinated by the first rank of each DP group via admin routes (/modelexpress/*,/pause,/resume) andweight_broadcast.group. The orchestrator only pollsGET /weight_versionthroughModelExpressPullWeightReceiver; the trainer publishes without waiting for installs (retiring the previous version when in-flight reads finish).Configs wire
EngineWeightBroadcastConfig, SLURM templates pass pull args and admin tokens to group leaders, and pull is rejected with draft swaps, Dynamo, rollout checkpoints,IN_PLACEstaging, and SFT online evals. Supporting fixes include staleness masking for tokens labeled newer than the trainer (fresh_versions) and a NIXL patch so decode prefills locally when KV leases may have lapsed while a rank was paused for a weight switch.Reviewed by Cursor Bugbot for commit d397d5b. Bugbot is set up for automated code reviews on this repo. Configure here.