Repository navigation
Conversation
jayhenry
force-pushed
the
stack/rl-ppo
branch
2 times, most recently
from
November 4, 2026 02:03
d42ce89 to
a5842b5
Compare
matrix72c
force-pushed
the
fix/routed-experts-reference-lifetime
branch
from
November 4, 2026 02:55
139519a to
76159e1
Compare
jayhenry
force-pushed
the
stack/rl-ppo
branch
2 times, most recently
from
November 4, 2026 06:46
15dffbe to
f020c41
Compare
…troller - AgentLoop.canonicalize_train_fields (base + localhost/sandbox overrides) builds the unified full-sequence train fields (input_ids/labels/logprobs) at generation time; semantic holes are baked into labels by the loops. - RolloutState drops response_mask; labels become the only supervision carrier. agent_loop_type records the producing loop class name and AGENTIC_AGENT_LOOP_TYPES discriminates agentic full-sequence samples. - TrainingController.fit accepts list[list[RolloutState]] and absorbs validation, session-clustered advantages, shift/tensorization, seq_ctx, teacher fields and data_info; BaseRLTrainer._prepare_train_data is gone. - calculate_group_effective_response_masks now bakes token staleness into labels in place (monotone, convergent) and its agentic exclusion uses agent_loop_type instead of the input_ids/labels presence heuristic.
…ut conversion - response_ids now denotes the contiguous suffix of input_ids after the prompt (env/tool tokens included) in every loop; localhost/sandbox export input_ids[len(prompt_ids):] so response_model_steps stay aligned with the full response region. - Token staleness baking becomes branch-free: effective mask = semantic mask (labels != -100 on the suffix) * per-token staleness mask; the zero-prompt suffix state becomes eligible and agent_loop_type plus AGENTIC_AGENT_LOOP_TYPES are removed. - data_info stats: prompt_len reports the original prompt length and response_len the supervised (LLM-generated) token count; env/tool injected tokens count in neither. - _rollout_groups_to_colate_items is phase-split into session reward clustering, group advantage estimation, per-state ColateItem conversion and data_info summarization.
…ing, multimodal assert
RolloutState now publishes, masks, resets and validates its own training fields and a frozen TrainMeta summary. AgentLoop, produce_utils, ReplayBuffer and rollout workers call the state methods instead of manually syncing labels and metadata.
Trajectory logging consumes RolloutState.train_meta; the legacy extra_fields key remains only as a fallback for recovered/debug states. Covers the state's Ray round-trip so metadata and methods survive transport.
Pad real and empty loss packs consistently, preserve singleton routed-expert structure, and align shuffled indices with their token lengths. Validate canonical training fields and replay token versions before use, refresh supervised token metadata after staleness masking, and separate packing layouts from advantage payload assembly. Add regression coverage and update fixtures to the canonical contracts.
… scope TrainBatch now owns the one-time shift, CPU samples, pack materialization, row unpacking and advantage installation. PackPlan makes the controller-side plan index-only, the controller loads/releases one local batch per worker, and RLTrainer releases the consumed batch's trace sessions plus remaining routed/pixel refs instead of freeing them inside the worker.
Move the LPT index planner into S2's RLDataPacker (it is an index-only strategy, not PPO-specific) and split multimodal ref resolution from the pack-level resolver so roles can reuse it. iter_cpu_packs accepts any pack index sequence.
…step CE, critic, log-prob and MTP builders now accept complete samples, compute full-sample weights and only then pad/split to the local sequence-parallel shard. build_batches performs denominator calibration only. The critic build also owns target-shape validation and supervision weights, and the strict checkpoint load and value-head initialization share one global-key decision. Adds an SP parity test that checks the actor PPO loss and critic value loss, their head gradients and one optimizer update against the SP=1 reference.
The loss context accepts one pack's frozen local labels, old/ref logprobs, IS weights and teacher targets through a structural snapshot contract and only moves them to the context device, never splitting again.
compute_rollout_is replaced ignored positions in the caller's tensor. It now installs a new masked label tensor, so the complete source data handed to the builder is never mutated.
Squashed original PPO implementation: role-first Actor/Critic workers, controller-side value collection and advantage dispatch, segment/session GAE, residencies, critic multi-pass updates and PPO recipes.
First refactor round: controller builds an index-only PackPlan, loads/releases one local batch per worker and reads RolloutState.train_meta; workers receive RankPlan, RLTrainer releases consumed trace/routed/pixel refs, and GAE modes no longer precompute group advantages. Includes the design note and pseudocode.
Second refactor round: - TokenAdvantageEstimator is a parallel interface; session targets use TrainMeta segment order and full CPU rows; TokenStats standardises the normalized action-token logging. - TrainBatch gains old-value/PPO-target installation and trajectory export; the worker holds the only batch and roles receive it by argument. - Roles track their own placement; set_residency replaces the role shadow and the prefetch thread is replaced by iter_cpu_packs. - Actor freezes per-pack ActorSnapshot records and binds them through the loss context; critic collects SP-local values and installs complete segment targets; critic passes always honour num_passes. - step_optimizer reports whether an update applied; role checkpoints store counters, scheduler definition and per-rank RNG.
jayhenry
force-pushed
the
stack/rl-ppo
branch
from
November 4, 2026 17:45
f020c41 to
a013031
Compare
Retire routed-reference holders without forcing shared Ray objects free; preserve pixel cleanup and reject out-of-band serialized vLLM ObjectRefs. Exercise actual TrainBatch materialization and release across remote consumers, repeated passes and final holder retirement.
matrix72c
force-pushed
the
fix/routed-experts-reference-lifetime
branch
from
November 5, 2026 01:33
76159e1 to
ee41379
Compare
matrix72c
marked this pull request as draft
November 5, 2026 01:34
jayhenry
force-pushed
the
stack/rl-ppo
branch
from
November 6, 2026 03:47
b06389f to
a3aef61
Compare
Contributor
Author
|
Replaced by #2263, independently based on main after the PPO merge. The shared-reference lifetime fix remains necessary. GitHub rejected retargeting this closed PR after its base branch was deleted. The replacement remains draft with current local-Ray regressions and GPU/CI limitations. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #2186 (
stack/rl-ppo), independently based on fixed snapshota01303168cfc1a57863c0d85b10208a67ece8ff7.Root Cause
Routed-expert Ray ObjectRefs are shared by partial rollouts, trace sessions, sibling samples, and repeated training passes. Explicitly freeing a shared object from one holder invalidates it for every other holder. The new stack makes TrainBatch own worker-local samples and materialization; it does not make trainer/trace-store force-free safe.
Fix
ProduceBatchResult impact: not affected; sample status, reward, and batch accounting are unchanged.
RoutedExperts impact: after transfer from LMDeploy, XTuner drops only each retiring holder; shared data remains readable until the final holder retires. This does not change pre-transfer LMDeploy cleanup.
Ray concurrency impact: existing RPC dispatch groups and scheduling are unchanged. No new concurrency lane or blocking actor RPC is added.
Test Plan — current head
pre-commit run --all-fileswas executed; mypy passed on 430 source files, but the overall run failed on existingautotestformatting/import-order violations. Unrelated formatter edits were not retained.