Every Loss Mask Is a Reward
A pre-registered research plan. Loss-masking truncated, over-turn, or late rollouts in agentic RL adds a reward-free term to the policy gradient that pays excluded trajectories the mean reward. We derive the term, separate the regimes in which it merely rescales the gradient from those in which it can reverse it, give each mask an unbiased replacement (a prefix-conditioned baseline for budget failures; never-drop or randomized protection for infrastructure drops), and lay out the experiments that would show the replacements win at matched compute, or not.
Policy-gradient training of LLM agents routinely excludes rollouts from the loss. Responses that hit the length limit are masked out (DAPO’s overlong filtering[2]), trajectories that exhaust their turn budget or time out are masked (DeepSWE’s compact filtering[3], Mini-o3’s over-turn masking[7]), and asynchronous systems drop rollouts that arrive too stale to be worth training on. The stated rationale is usually noise control: a truncated attempt might have been about to succeed, so scoring it as a failure injects a wrong label. This reasoning is intuitive and widely available as a switch. We will argue that it changes the objective in a precise way, and that whether the change is harmful depends on three things the rationale never mentions: which outcomes the environment has, over whom the baseline is computed, and whether the task’s budget is part of the objective.
The purpose of this post is to lay out a research plan before running it. We have a derivation we believe, a set of symptoms in the literature that the derivation explains, and a set of experiments that would confirm or falsify it. We have not run the experiments. Writing the predictions down first is the point: if the curves in the last section come out the other way, that is what we will report.
The claims, in the order we will defend them:
- Masking is paying. For any trajectory-level inclusion rule, the expected update of the masked loss is . When excluded trajectories would otherwise score zero, this is : the baseline, harmless under full inclusion, becomes a reward of size for being excluded.
- The baseline term is decided by predictability. A mask that is predictable from the prefix, in the sense , keeps the baseline zero-mean; it still reweights which states are trained, and that is not free. A mask that depends on how the trajectory ends makes the baseline a reward. Truncation, turn caps, format failures, and staleness drops are all of the second kind.
- It can rescale, reweight, or reverse. In an environment with only two outcomes (solved, or capped) the masked update is : a per-prompt rescaling toward hard prompts, with no change of direction. With a third outcome, a submitted failure, the subsidy competes with the failure penalty. And when the excluded trajectories include unobserved successes, a two-strategy construction reverses the sign: the surviving data asks for fewer thorough attempts while the true objective asks for more.
- Reweighting cannot repair it. Truncation is deterministic censoring with inclusion probability zero or one. Horvitz–Thompson corrections need a known positive probability. The only exact fixes are not to exclude, or to randomize the exclusion so a probability exists.
- It is partly already visible. Skywork-OR1 decomposed overall and non-truncated success rates, compared advantage masks, saw truncation and clip ratio rise under the mask, and chose not to mask[4]. MicroCoder found length growth increasing with the masking rate, and also that a conditional mask beat both full masking and no masking in its setting[5]. Environment steps rise through DeepSWE training[3], and staleness thresholds bias toward short responses[11]. Each of these measures the symptom along one axis; the identity separates three (mask timing, baseline population, budget semantics), and that is the part we claim.
- Each mask has an unbiased replacement. In the budget regime, what the mask removes is not noise but the signal “do not hit the cap”; the variance it buys can be bought legitimately with a baseline conditioned on the turn index reached, which is prefix-measurable and therefore unbiased. In the infrastructure regime the replacements are not dropping, or dropping with a known probability and reweighting. The experiments test whether these replacements match or beat masking at matched compute; if they do not, the paper reports a diagnosis and nothing more.
Revision note. A first draft of this plan predicted a drift toward the cap on ALFWorld. In a two-outcome environment the identity predicts only a rescaling (see the caution in the reversal section), so that prediction was inconsistent with our own math. This revision separates the regimes, weakens the “causal masks are free” claim to what the algebra supports, replaces the imputation arm with a matched-update control, adds a three-outcome environment, and corrects the compute budget. We record the change rather than hide it.
Before any math, it is worth being concrete about how common this is, because the identity below is only interesting if the switch it describes is on somewhere. We read the current main branches of the frameworks we might run on. Two things matter and differ across implementations: whether the switch is a default or an opt-in, and the population over which the baseline is computed.
| Framework | Switch | Default? | Baseline computed over | Kind |
|---|---|---|---|---|
| rLLM / DeepSWE | compact_filtering.* (max turns, max length, timeout, error) | On in the DeepSWE recipe | Survivors only: masked episodes are removed before grouping | outcome-dependent |
| TRL | mask_truncated_completions | Off (False) | All members | outcome-dependent |
| NeMo-RL | overlong_filtering (sets loss_multiplier = 0) | Opt-in; on in the DAPO guide | Flag: masked_reward_policy include | exclude | outcome-dependent |
| Miles | mask_truncated_zero_reward sample filter; --max-weight-staleness with drop | Filter opt-in; stale handler defaults to drop | All (“removed samples still count toward normalization”) | outcome-dependent |
| ROLL | Group queue drops groups older than the async ratio | On in async mode | n/a (whole group gone) | outcome-dependent |
| prime-rl | mask_stale_tokens by per-token weight version | On (max_staleness default 8) | All | mixed: version fixed at sampling, but the freshness threshold is taken at consumption time |
| verl | filter_groups (DAPO dynamic sampling) | Opt-in | n/a | outcome-dependent but harmless () |
Three rows deserve a note. The rLLM row is the DeepSWE recipe, and it removes masked episodes before the group statistics are computed, which puts it in the amplified regime of Corollary 2 below. The prime-rl row is the closest thing to a mask decided before each token is sampled, but it is not quite that: the token’s weight version is fixed at sampling, while whether it counts as stale depends on the training step at which the trajectory is consumed, which depends on how long the trajectory ran. We found no implementation that is purely predictable in the sense of Corollary 3. And the caps bind: in a recent SWE-smith run with an 80-turn budget, 84% of trajectories hit the turn cap[14], although the same report notes that successful trajectories had a median of 8 turns and that tightening the length cap did not affect successful runs. In that run the long tail was mostly failures; we return to this in the discussion.
We work with a single prompt and a policy that generates a trajectory of action tokens interleaved with environment observations. The objective is the terminal reward, and the estimator is REINFORCE with a baseline, which is what GRPO reduces to on a single step.
- : terminal reward, here binary. Partial credit does not change the argument.
- : the baseline. In GRPO it is the group mean; we first treat it as a constant equal to the population mean , then relax this.
- : the prefix before token (prompt, earlier actions, earlier observations).
- : an inclusion event. means the trajectory enters the loss. “Not truncated”, “arrived before the staleness limit”, and “parsed correctly” are all instances.
The one fact we use repeatedly is the score identity: for any prefix, . Summed over a trajectory it gives , which is exactly why a baseline is free: . Everything below is about what happens when the expectation is no longer over all trajectories.
Apply the inclusion rule to the loss and take the expectation over the full policy distribution. The two factors of separate:
Both terms are REINFORCE identities, , applied to and . The identity holds for any on-policy sample, any inclusion rule without its own parameter dependence, and any baseline that does not depend on the trajectory being scored. What it means depends on what the excluded trajectories would have scored, and there are two regimes.
Regime A: budget failure, reward known. This is the convention that motivates masking in the first place: an excluded trajectory would have been scored . Then almost surely, the first term is , and
The masked estimator is the unbiased gradient plus a term that carries no information about reward. Its direction is “make exclusion more likely” and its magnitude is . Equivalently, since a trajectory with advantage zero contributes nothing, masking a trajectory is identical to assigning it . We find this phrasing more useful than the gradient one because it says what the policy is being taught: an excluded attempt is worth exactly an average attempt. The equivalence is exact only with the baseline and every other statistic (mean, std, loss denominator, regularizers) held at the values they take under masking; if one imputes into the reward path and recomputes the group mean, the imputed sample regains a nonzero advantage and the two are no longer the same computation.
Regime B: outcome never observed. When the infrastructure cancels or discards a rollout before its result exists, or discards a finished one, the excluded set contains successes and . The masked estimator is then the exact gradient of the survivors’ objective: with set to the survivors’ mean, it is up to scale: the success rate among surviving attempts. This regime does not need the convention, and it is where the sign reversal below lives. The two regimes share the identity but not the ground truth, so we keep them apart in the experiments.
More on the derivation and its assumptions
The identity requires only that does not depend on the trajectory being scored and that the expectation is over the sampling policy. With the self-inclusive group mean over all members (TRL’s convention), the expectation is : the effective subsidy is exactly the population mean , with no extra term; with a true leave-one-out baseline the factor disappears. With per-token normalization by a -free weight the term becomes : rescaled, not removed. With a survivor-only denominator (token-mean over the micro-batch, which is verl’s default) the scale of the whole update depends on the survivor count, which is a separate, mostly benign effect we control for with constant normalization[8]. If excluded trajectories carry a nonzero reward (e.g. a format penalty of ), the subsidy is , which is why penalties behave so differently from masks in practice.
Under full inclusion the baseline is a control variate: zero mean, variance only. Under trajectory-level exclusion it stops being zero mean. The masked update equals the unbiased gradient plus . Masking is paying the excluded rollouts the mean reward.
Corollary 1: the feedback loop
The subsidy is , the mean reward. As training succeeds, rises, so the reward for being excluded rises with it. A policy at 30% success pays truncation 0.3; the same policy at 60% pays it 0.6. This is the opposite of a self-correcting effect. It is the same structural property that makes drift under training–inference mismatch compound in Score Centering[1]: a term whose magnitude is tied to the thing being optimized.
Corollary 2: survivor baselines amplify it
If the group mean is computed only over surviving members, which is what happens when masked episodes are removed before grouping (rLLM) or when masked_reward_policy: exclude is set (NeMo-RL), the baseline is itself selection-biased. Writing for the number of survivors in a group of , the expected update becomes with for large . So the total coefficient on is the survivors’ mean reward, and relative to the all-population baseline the extra term is
which grows with the exclusion rate itself. In a two-outcome environment this coefficient is degenerate: every survivor has , the survivors’ advantage is zero, and the signal vanishes rather than drifting. Under std-normalized advantages with binary rewards the per-prompt subsidy is , largest on nearly-solved prompts. We flag these as derived, not yet measured; the ablation on baseline population below is designed to separate them.
Corollary 3: predictable masks keep the baseline neutral; outcome-dependent masks do not
Formally, let be the inclusion indicator for token . The precise condition is on conditional expectations, not on causality as such: if , then and , the policy gradient reweighted by . In the tabular case this is an ascent direction for a behavior-weighted objective[18]; with shared parameters, reweighting states can lower , and the mask can delete the signal from exactly the states that matter. A mask that depends on the future is not automatically biased either: what matters is whether it is correlated with the action given the prefix. Truncation, turn caps, and duration-based drops plainly are, because the action affects the length. So the design rule is weaker than “causal masks are free”: predictable masks cost signal but not bias; outcome-dependent masks cost both. DAPO’s dynamic sampling is outcome-dependent and harmless for a different reason: it excludes whole groups whose advantages are already zero.
A bias of size on a direction that is unrelated to reward sounds like a nuisance. It is worth showing that it can flip the sign of the update in a setting that is not exotic. The construction lives in Regime B: a two-strategy coding agent under an asynchronous trainer that drops rollouts older than a staleness threshold, so that the excluded set contains successes.
| Strategy | What it does | True success | P(kept | success) | P(kept | failure) |
|---|---|---|---|---|
| Fast | Reads two files, edits, submits in ~10 turns | 0.60 | 1.0 | 1.0 |
| Thorough | Reproduces the bug, writes a regression test, edits, runs the suite; ~80 turns on success, but failures surface early | 0.90 | 0.1 | 1.0 |
Let be the probability of choosing Thorough. The true objective is , increasing in . The trainer sees the kept distribution, whose success rate is
The surviving data asks for fewer thorough attempts at every . We checked this by exact enumeration at : the full-distribution gradient with respect to is , the survivor estimate with a population-mean baseline is , and inverse-probability weighting with the known keep probabilities recovers . The numbers in the table are ours, not measured from any system; the point is that the structure, successes that finish late and failures that surface early, is the ordinary shape of careful software work.
The same identity has a second, quieter prediction for truncation masks in Regime A, provided the environment has a third outcome. A failing attempt that is masked when it runs out the clock receives advantage 0; one that submits a wrong answer receives . So on tasks the agent is going to fail anyway, the trained behavior is to keep going rather than to submit. Succeed fast, fail slow is the implied reward schedule, and it is the signature we will look for in turn-count distributions conditioned on outcome.
If the environment has only two outcomes, every failure is a cap hit, so per prompt and the masked update is
Masking then rescales each prompt’s gradient by and shifts weight toward hard prompts; it does not change direction within a prompt, and a small gradient step still raises success. With a survivor-only baseline every survivor has and the signal is zero. ALFWorld is such an environment: episodes end only on success or on the cap. It can show the rescaling, the difficulty reweighting, and the survivor-baseline collapse, but it cannot show “fail slow”, and we do not predict a drift toward the cap there. The direction claim needs a submitted-failure outcome: single-turn RLVR with a length cap (truncated / wrong / right) and WebShop (bought wrong / bought right / stepped out) have one.
The natural instinct is importance weighting: if a trajectory survives with probability , weight it by . Horvitz–Thompson corrections of this kind exist for randomized token subsampling[10]. They need and known. Truncation is deterministic censoring: a trajectory that reaches the cap is excluded with probability one, and a trajectory that does not is included with probability one. There is no weight that recovers the contribution of a sample that was never observed. The same holds for a hard staleness cutoff.
This leaves two exact options. Do not exclude: score the capped rollout with the reward its budget implies, or keep the late rollout and handle its staleness as an off-policy problem, which is what partial rollouts plus per-token corrections already do[1]. Or randomize the exclusion so that a probability exists: when the scheduler would drop a group, keep it with a known probability and weight it by . The second option is the STOPD trick[13] applied to trajectories rather than tokens; it is unbiased in expectation,
and it is not free: the variance inflation is . Whether that price is worth paying relative to simply waiting for stragglers is an empirical question we will put in the plan.
None of the remedies is new machinery. Each is the choice that the identity says is consistent with a stated objective, and the identity says that masking is consistent with none of them. That is a statement about objectives, not about training curves: a consistent estimator can still lose to an inconsistent one on variance or effective step size, and MicroCoder reports a conditional mask beating both full masking and no masking in its setting[5]. Which one trains better is what the experiments are for. But the identity also says why masking can look helpful, and that points at the replacement.
What masking removes in the budget regime is signal, not noise
In Regime A the contribution of the excluded trajectories to the unmasked estimator is
whose mean is not zero. It is the gradient that teaches the policy not to hit the cap. Masking deletes it, and in doing so also deletes the variance of a advantage spread over the thousands of tokens of a long failed trajectory. So the variance benefit of masking and its bias are the same term; there is no version of outcome-dependent masking that keeps one and drops the other. The legitimate way to buy that variance reduction is a better baseline.
The replacement: a baseline conditioned on the turn reached
“This trajectory is already long” is information that exists in the prefix. Let be the turn index of token , and define
Because depends only on (the event “this rollout reached turn ”) and on other, independent rollouts, and the estimator stays unbiased for . Its effect is exactly the one masking was reaching for: among rollouts that reached a late turn, most end at the cap with , so is small there and a long failed trajectory’s advantage is small too. The comparison with masking is one line: masking sets that advantage to (biased); the baseline sets it to (unbiased). The variance it removes is , which is measurable offline from logged rollouts before any training; a conditional leave-one-out baseline is only better than the group mean when that explained variance exceeds roughly one over the bucket count, which is why the shrinkage is part of the definition and not an option.
Two things this replacement is not. It is not a process reward: it changes no optimum, so the agent cannot game it by changing its length. And it is not new machinery: it is the state-dependent baseline of textbook REINFORCE with the cheapest possible state feature. If it matches masking on success and removes the cap-hit drift at matched compute, the recommendation is a one-line default: never mask budget failures; score them zero and baseline on the turn reached.
| Why the rollout is excluded | Objective you actually want | Consistent treatment |
|---|---|---|
| The task’s own budget ran out (turn cap, context cap defined by the task) | Solve within budget | Do not mask; assign and baseline on the turn reached. The advantage is the signal consistent with this objective, with the variance masking was buying recovered without bias. |
| Infrastructure cancelled it (staleness threshold, queue limit, timeout unrelated to the task) | Solve the task | Do not drop. Partial rollouts with per-token off-policy correction. If dropping is unavoidable: randomized protection with weight . |
| You believe a capped attempt would have succeeded with more budget | Solve eventually (budget-free) | Extend and score. Continue a capped rollout for more turns with probability , score the result, weight by ; this is randomized protection applied to the budget rather than to the scheduler, and it is unbiased for the extended-budget objective. Imputing a value is the cheaper, biased alternative. |
The first row is a few lines in the advantage function of every framework we checked. The second is a scheduler change; Miles’ async buffer already holds whole groups and has a single _drop_stale branch where a coin flip and a weight would go. The third is a rollout-time change that must be labelled as optimizing a different objective. In all three, the design principle is the same: to discard, decide before sampling; to reduce variance, change the baseline; to change the objective, change the reward and say so. None of the three needs an outcome-dependent mask.
We organize the plan around three questions, in increasing cost. Each has a measurement that could come out against us. We state the arms, the controls, and what we would conclude from each outcome before seeing any of them.
Question 1: Is the term present in real gradients?
Experiment setup. Fix a checkpoint. Collect a few thousand multi-turn rollouts with per-token log-probabilities, rewards, truncation flags, and weight versions. Miles and slime dump all of this with --save-debug-rollout-data and replay it at a fixed checkpoint with --load-debug-rollout-data --debug-train-only; swapping the sample filter changes the masking rule without regenerating anything. We will use SWE-smith rollouts from a Qwen3-4B or 8B mini-swe-agent run with a 40–80 turn cap, where the cap is known to bind for most trajectories[14], and ALFWorld rollouts as a cheap second environment.
Outcome census first. Before any gradient, count what the rollouts actually are: solved, submitted and failed, budget failure (cap or context limit), and infrastructure no-result (cancelled, timed out, dropped). The census decides which regime dominates in a realistic configuration, and therefore which ground truth applies. If budget failures are 80% of the non-solved mass and infrastructure no-results are 2%, Regime A is the story and the asynchronous experiments are secondary; if the reverse, the Fast/Thorough construction is the one to chase.
Arms. Advantages recomputed under: (a) no mask, on cap (the reference); (b) mask with baseline over all ; (c) mask with baseline over survivors; (d) mask only a random fraction of capped rollouts; (e) no mask, with the turn-reached baseline. All statistics (mean, std, denominators) are computed once from the unmasked batch and frozen, so that the arms differ only in the mask or baseline. Arm (e) also yields the offline number that decides whether the replacement can work at all: the per-token advantage variance under (a) versus (e), which should drop by . For each, the full-batch policy gradient at the fixed , flattened after backward on a single device to avoid tensor-parallel gathers.
Measurements. Cosine between each arm and the reference; the ratio of norms; the projection of the difference onto the estimated , obtained by REINFORCE on the cap indicator from the same rollouts; the same quantities bucketed by turn index and by prompt difficulty. On two-outcome data (ALFWorld) the algebra fixes the answer in advance: per prompt the masked gradient must be times the reference and the survivor-baseline variant must be zero; we use this as a correctness check of the replay pipeline, not as a finding.
What we learn. The identity is algebra and is not what is being tested. The informative numbers are, on three-outcome data, the cosine gap between (a) and (b) after removing the norm rescaling, and the fraction of that gap explained by the direction. If the direction gap is within the seed-to-seed noise of (a), the effect at this checkpoint is a rescaling and reweighting, not a distortion, and we say so before spending anything on Phase 3.
Question 2: Does the term move behavior?
Experiment setup. The direction claim needs a third outcome, so the main environments are three-outcome ones. The cheapest is single-turn RLVR with a length cap (Qwen3-1.7B on GSM8K/MATH with the cap chosen so that 20–40% of responses are truncated at initialization), which is exactly the setting of[4] and[5] and gives truncated / wrong / right. The agentic one is WebShop in verl-agent[15] with its 15-step cap, which gives bought wrong / bought right / stepped out. ALFWorld (Qwen2.5-1.5B, 50-step cap, 150 iterations on two H100s, public curves) is kept as a two-outcome control: there the identity predicts a per-prompt rescaling by and a shift of gradient share toward hard prompts, and the survivor-baseline arm should lose its signal. The default convention in all three is , so the other arms are one-line edits to the reward and mask.
Arms (3 seeds each). (i) on cap, no mask; (ii) loss-mask on cap; (iii) matched-update control: the mask arm with its learning rate rescaled each step so that its update norm matches arm (i)’s, which separates a change of direction from a change of effective step size; (iv) mask with Dr. GRPO constant normalization[8] (norm_adv_by_std_in_grpo=False, loss_agg_mode=seq-mean-token-sum-norm) to remove the length-normalization bias as a confound; (v) mask with survivor-only baseline; (vi) the proposed replacement: on cap with the turn-reached baseline. Arm (vi) is the one the paper stands or falls on: it must match or beat (ii) on success at matched compute while behaving like (i) on cap-hit rate and length.
Measurements. Cap-hit rate, submitted-failure rate and episode length per iteration; success rate; clip ratio; update norm; per-token advantage variance; the running value of , so that we can plot the rate of change of the cap-hit rate against rather than against steps; on ALFWorld, gradient share by difficulty bucket.
Question 3: Does it suppress slow successes under asynchronous drops?
Experiment setup. Miles with the SWE-smith mini-swe-agent recipe[14] scaled to Qwen3-4B or 8B on a single node, fully asynchronous. The staleness drop is the default --max-weight-staleness handler and the buffer holds complete groups, so the first experiment uses groups that are finished but stale: their rewards exist, and the only question is whether they enter the loss and with what weight. This prototype tests the selection mechanism only. Its rollout and sandbox costs are already paid, so it cannot show a saving in straggler waiting or sandbox time; those claims belong to the in-flight variant, which protects a group before it is cancelled and is a separate, harder experiment. We will choose a task subset with success rate between 0.2 and 0.5 so that is large enough for the subsidy to be visible.
Arms. (i) drop stale groups (default); (ii) never drop; (iii) randomized protection with and the weight applied as a loss weight on the whole group, with one coin per group memoized by group id so that a group that passes through the drop branch more than once is not re-drawn; (iv) a gradient oracle computed on the same cohort of rollouts and the same learner checkpoint with every group included, not a separately generated synchronous run. All arms use the same off-policy correction (per-token truncated importance ratios plus score centering[1]), so that differences are due to selection and not to the correction. An unbiased gradient is not an unbiased Adam step; we report both the gradient cosine and the training outcome.
Measurements. Turn-count distributions conditioned on outcome (the “succeed fast, fail slow” signature); the rate at which successful trajectories ran the test suite before submitting, as a proxy for thoroughness; gradient cosine to the synchronous reference; wall-clock and sandbox cost per unit of reward improvement, so that protection is charged for the stragglers it keeps alive.
Ablations
The ablations exist to pin the effect to the mechanism and to separate it from the two confounds we know about: length-normalization bias[8][9] and the genuine noise reduction that masking provides early in training.
| Ablation | Values | What it isolates | Prediction |
|---|---|---|---|
| Baseline population | all vs. survivors only | Corollary 2 amplification | Survivor arm drifts faster; gap widens with cap-hit rate |
| Advantage normalization | std on vs. off | scaling | Std on: drift concentrated on high- prompts |
| Loss normalization | token-mean vs. constant (Dr. GRPO) | Length-normalization confound | Direction unchanged; slope reduced by a constant factor |
| Task difficulty split | Subsidy | Cap-hit growth rate increases monotonically with | |
| Mask dose | mask 30 / 60 / 100% of capped rollouts | Dose–response, cf.[5] | Growth rate roughly linear in dose |
| Cap tightness | Length cap at 3 truncation rates (three-outcome task); ALFWorld 30 / 50 / 80 steps (control) | Whether the effect is cap-specific | Three-outcome: final length tracks the cap under masking, not under ; ALFWorld: only the rescaling changes |
| Group size | factor; survivor-count variance | Weak dependence for all- baseline; strong for survivor baseline | |
| PPO epochs / clip | 1 vs. 2 epochs; clip on/off | Whether clipping hides the term (ratio ≡ 1 on the first pass) | Term present at epoch 1; clipping on epoch 2 does not remove it |
| KL / entropy terms | Mask-dependent regularizers | Small modulation; sign unchanged | |
| Protection probability | Bias–variance of randomized rescue | Unbiased at all ; variance ; a sweet spot below 1 only if stragglers are expensive |
- One objective, one variable at a time, three seeds, error bands. The same discipline as[1].
- Q1 runs before any online training. If the offline gradient gap is below seed noise, we report that and stop.
- No claim about direction is made from a two-outcome environment. ALFWorld results are reported as rescaling and reweighting only; direction comes from the three-outcome environments, and only if the matched-update control does not reproduce it.
- Every online arm reports over time, so that rates are plotted against and the prediction can be checked directly.
These are predictions, written before the runs. We give them with the observation that would falsify each.
- P1 (algebra check, Q1). On two-outcome ALFWorld data with frozen statistics, the masked gradient equals times the reference per prompt to numerical precision, and the survivor-baseline variant is zero. Falsified if not; that would mean a statistic is not frozen or the implementation differs from the model, which must be fixed before anything else is run.
- P2 (direction, Q1). The difference between the masked and unmasked gradients has cosine above 0.5 with the estimated , and its norm scales with across task subsets. Falsified if the difference is isotropic relative to , or if its norm is flat in .
- P3 (drift, Q2, three-outcome environments). The cap-hit rate under masking stops falling, or rises, once exceeds roughly 0.3, while under and under the matched-update control it keeps falling; the submitted-failure rate under masking falls faster than under . Falsified if the mask and arms are indistinguishable in cap-hit rate at matched across three seeds, or if the matched-update control reproduces the drift.
- P4 (amplification, Q2 ablation). The survivor-baseline arm drifts faster than the all- arm, with a gap that grows with the cap-hit rate. Falsified if the two baselines produce the same curves.
- P5 (signature, Q3). Under staleness drops, successful trajectories get shorter and failed trajectories get longer over training relative to the never-drop arm, and the fraction of successes that ran tests before submitting falls. Falsified if the outcome-conditioned turn distributions do not separate, or separate in the other direction.
- P6 (rescue, Q3). Randomized protection at recovers the never-drop arm’s final success within seed noise at lower wall-clock than never-drop, and at it does not, because the variance inflation dominates. Falsified if never-drop is cheaper or if no matches it.
- P7 (the replacement, Q2). Offline, the turn-reached baseline cuts per-token advantage variance by at least 20% relative to the group mean on three-outcome data. Online, arm (vi) matches or beats the mask arm on final success at matched compute, with a cap-hit rate and episode length that track the arm. Falsified if the offline variance reduction is below 10% (then the fix has no lever and we fall back to reporting the diagnosis), or if the mask arm beats arm (vi) on success by more than seed noise at matched update magnitude (then masking’s benefit is not the variance we modelled, which is itself the finding).
We also expect one result that is not a confirmation: the mask arm should match or beat on success rate early in training, when is small and the label noise removed by masking is real. Reports that found overlong filtering helpful at short caps and unhelpful at long ones[6] are consistent with the crossover we would predict, and MicroCoder’s conditional mask[5] shows that a partial mask can beat both ends. If the mask arm wins throughout at matched update magnitude, the identity is still true but the noise benefit dominates the subsidy at these scales, and the honest headline is narrower: a diagnosis, not a fix.
- The offline gradient gap in Q1 is below the seed-to-seed variation of the reference gradient.
- A plain queue-policy change in Q3 (train stale, never drop) already removes the effect at no measurable cost, in which case randomized protection is unnecessary and we say so.
- Protection’s variance and sandbox cost make it lose to waiting at every .
What the identity does and does not say. It is a statement about the expected update at a fixed parameter. It does not by itself predict training dynamics, and the drift we predict depends on being a cheap direction for the policy to move along. For length and turn count it plainly is; for format failures it may not be. We also note that masking removes real noise early, so the net effect over a run can be positive for a while, and the identity does not say that it must turn negative: the extra term grows with , but its effect also depends on , on its angle with the task gradient, on the variance removed, and on the optimizer. The identity fixes the sign of the extra term, not the sign of the net effect.
Relation to prior observations. Skywork-OR1 §3.2.3 is the closest prior work[4]: it decomposed overall and non-truncated success rates, compared advantage masks on truncated samples, observed a steadily rising clip ratio and more truncation under the mask, and chose not to mask. MicroCoder found that a higher masking rate accelerates length growth with a roughly dose-dependent effect, and that a conditional mask outperformed both ends[5]. The overlong-filtering ablation in[6] found gains at short caps that vanish at long ones. DeepSWE’s report shows environment steps rising through training under compact filtering[3]. Applied Compute documented the short-response bias of staleness thresholds[11]. Our reading is that these are one mechanism seen from several angles, each along one axis; what we add is the separation of mask timing, baseline population and budget semantics, and predictions in a multi-turn agent that no single prior report makes. The experiments above are designed to test whether that reading is right.
Counter-evidence we carry with us. The SWE-smith run with 84% cap hits[14] also reports that successful trajectories had a median of 8 turns and that tightening the length cap did not affect successful runs. That is evidence for Regime A (the long tail is failures) and against the idea that slow successes were being deleted in that configuration. The outcome census in Q1 exists to settle this before Phase 3 is funded.
Relation to score centering. The two terms are different objects that share a shape. Score centering[1] cancels a drift that arises because the sampler and trainer disagree at every prefix; it is a property of the probabilities. The term here arises because the trainer never sees some trajectories; it is a property of the data pipeline. A pipeline can have both, and the remedies compose: centering handles what arrives late, and not dropping ensures that it arrives.
What would change our mind. If P2 fails, the bias exists but points somewhere the policy cannot easily follow, and the practical consequence is small. If P3 fails under constant normalization, the length drift reported in the literature is the normalization bias of[9], not ours. If the matched-update control reproduces the drift, the effect is effective step size, not direction, and the right framing is “masking is an uncontrolled learning-rate schedule”. If P5 fails, the asynchronous story reduces to the known short-response bias with nothing new added. We would publish any of these as the result.
Scope limits we accept going in. ALFWorld has two outcomes, no tests and no notion of thoroughness; it can show the rescaling and the reweighting, not the direction change, which is why it is a control. Small SWE models may have success rates so low that , and with it the effect, is negligible, which is why Q3 restricts to a mid-difficulty subset. And frontier training stacks may already use penalties or bootstraps rather than masks, in which case this is a cleanup of open-source defaults rather than a change to frontier practice. We think that is still worth doing: the defaults are what most agentic RL runs use. Finally, none of the remedies is guaranteed better by the algebra alone: the turn-reached baseline is unbiased but only helps if turn index explains enough reward variance; predictable masks still reweight states; keeping stale groups costs off-policy risk and trainer time; randomized protection trades bias for variance and cost. The deliverable is the replacement rule and the matched-compute evidence for it (P7, P5, P6); the diagnosis is what makes the rule principled, not the product.
The body of the post fixes the arms, controls, and measurements. This appendix fixes the order of operations, the code paths we will touch, and the compute we expect to spend, so that the plan can be executed as written and audited afterwards. Numbers for ALFWorld come from the published verl-agent recipe and are reliable; numbers for SWE runs are projections from comparable configurations and are to be recalibrated after the pilot.
A. Phases and go/no-go gates
| Phase | What runs | Output | Gate |
|---|---|---|---|
| 0. Algebra and census (2–3 days) | Fixed checkpoint; one batch of rollouts with frozen statistics; masked vs. gradients on two-outcome data must differ by exactly per prompt; outcome census (solved / submitted failure / budget failure / infra no-result) on real SWE rollouts | Pipeline correctness; which regime dominates | Ratio not → a statistic is not frozen; fix before anything else. Census says Regime A dominates → Phase 3 becomes secondary |
| 1. Three-outcome online (1 week) | Q2 on single-turn RLVR with a length cap and on WebShop: six arms × three seeds, then ablations; ALFWorld as the two-outcome control | Slope of cap-hit rate against ; whether the matched-update control reproduces it; whether the turn-reached baseline arm matches the mask arm on success | Mask and indistinguishable at matched , or matched-update control drifts too → no direction effect; the project becomes a diagnosis of step-size effects and stops before Phase 3. Baseline arm loses to mask on success → the replacement rule is withdrawn and the finding is reported |
| 2. SWE pilot (1 week) | Miles SWE-smith, Qwen3-8B, one arm, 100 steps; dump rollouts for Q1 | Seconds per step; cap-hit rate; range of ; offline replay data | or cap-hit rate below 30% → change the task subset before Phase 3 |
| 3. SWE online + async (2–3 weeks) | Q3: four to five arms × two to three seeds | Outcome-conditioned turn distributions; cosine to the synchronous reference; cost per unit reward | Phase 3 starts only if Phases 0–1 show a direction distortion beyond seed noise in a realistic configuration. Never-drop already removes the effect at no cost → randomized protection unnecessary; report that |
B. Engineering checklist
Phases 0–1, verl-agent (WebShop, ALFWorld) and a single-turn RLVR recipe. ALFWorld recipe: Qwen2.5-1.5B-Instruct, env.max_steps=50, group 8 × 16 groups, 150 iterations, two H100s; WebShop with the 15-step cap from the same repository; single-turn: Qwen3-1.7B on GSM8K/MATH with the length cap set so that 20–40% of initial responses truncate. Code touches: (a) the reward on a cap hit (already ); (b) zeroing response_mask for cap-hit episodes to obtain the mask arm; (c) the matched-update control: after each backward, scale the mask arm’s learning rate by the ratio of the arm’s update norm to its own, measured on the same batch; (d) the survivor-baseline arm filters before the mean inside compute_grpo_outcome_advantage; (e) the turn-reached baseline: for each rollout and turn , compute the leave-one-out mean of over group members with , shrink it toward the group mean with weight (), and broadcast to the tokens of turn ; about fifteen lines in the advantage function, using the per-token turn index verl-agent already carries. For offline replays all statistics are computed once from the unmasked batch and frozen. Controls: norm_adv_by_std_in_grpo=False and loss_agg_mode=seq-mean-token-sum-norm.
Phases 2–3, Miles (SWE-smith). Start from the public mini-swe-agent recipe[14] with Qwen3-8B, a 40-turn cap, 64k context, , 16 prompts per step. Task subset: run the pilot over the SWE-smith training set and keep tasks with success rate in , roughly one to two thousand. Code touches: (a) --rollout-sample-filter-path pointing at mask_truncated_zero_reward gives the mask arm, and omitting it gives ; (b) the RESCUE hook replaces the else-branch of fully_async_data_buffer.py::_drop_stale with a Bernoulli() keep, drawn once per group id and memoized, and attaches as a loss weight on the whole group (not a reward multiplier, which later normalization could undo); (c) never-drop raises --max-weight-staleness; all three async arms enable the same truncated importance sampling plus score centering; (d) offline replay uses --save-debug-rollout-data and --load-debug-rollout-data --debug-train-only, with a post-backward hook that flattens the gradient for the cosine computation; the Q3 oracle is the same cohort replayed with every group included at the same checkpoint.
Logging contract. Every online run logs per step: the outcome census (solved / submitted failure / budget failure / infra no-result), cap-hit rate, mean and outcome-conditioned turn counts, success rate, clip ratio, update norm, the realized baseline , staleness statistics where applicable, and wall-clock. All rate-of-change claims are plotted against as well as against steps.
C. Compute budget
Units are H100-hours. For a B200 cluster, halve only the LLM-bound items (Phases 0–1, the offline replay); the SWE items are sandbox-bound and do not shrink with the accelerator.
| Item | Per run | Runs | H100-h | Confidence |
|---|---|---|---|---|
| Phase 0 algebra check and outcome census | — | — | ~20 | high |
| Phase 1 single-turn RLVR with length cap: 6 arms × 3 seeds | 1 GPU × ~8 h ≈ 8 | 18 | ~150 | medium |
| Phase 1 WebShop: 6 arms × 3 seeds | 2 GPUs × ~15 h ≈ 30 | 18 | 540 | medium |
| Phase 1 ALFWorld control: 6 arms × 3 seeds | 2 GPUs × 15.1 h ≈ 30 (363 s/iter × 150) | 18 | 540 | high |
| Phase 1 ablations: cap tightness, group size, std, mask dose | ≈ 8–30 | ~30 | ~600 | medium |
| Phase 2 SWE pilot: 8B, 100 steps, one node | see note | 1–2 | ~150–300 | low |
| Phase 2 Q1 offline replay: 5 rules × 3 checkpoints | ≈ 3 per rule (2k sequences × 64k tokens) | 15 | ~50 | medium |
| Phase 3 SWE online: drop / never-drop / / / sync reference, × 2 seeds, 300 steps | ≈ 150 (one node × ~20 h) | 10 | ~1,500 | low |
| Phase 3 third seed and sweep | ≈ 150 | 6 | ~900 | low |
SWE step-cost note. With 128 rollouts per step averaging 25 turns and contexts growing to 30k tokens, generation is about 1.2M tokens per step and the trainer sees about 4M tokens. On one 8×H100 node the LLM side is one to two minutes, but rollouts are bounded by sandbox and tool latency; we project three to five minutes per step, so 300 steps is roughly 20 hours, or about 150 H100-hours per run. A comparable public configuration runs Qwen3-8B for 1000 steps on four B200s. The first twenty steps of the pilot calibrate this number, and Phase 3 is re-budgeted from the measured seconds per step.
Totals. Phases 0–1 alone (the round that tests the replacement rule in the budget regime and decides whether Phase 3 runs): about 1,850 H100-hours, or ten days on one 8×H100 node; the single-turn arms alone, which already test P3 and P7, are about 150 and fit on one GPU in a week. Adding the SWE pilot, the offline replay and Phase 3 with drop / never-drop / at two seeds: about 3,700 H100-hours. Full version (all ablations, three seeds, the sweep): about 4,600 H100-hours. The SWE items are projections and are re-budgeted after the pilot.
D. Allocation on a 24-node H100 cluster
With 192 GPUs the full program is about a day of saturated compute, so GPU time stops being the constraint. The plan below spends the surplus on confidence rather than on more arms, and it keeps the gate: Phase 3 is scheduled only after Phases 0–1 show a direction effect that the matched-update control does not reproduce.
| Phase | Parallelization | Wall-clock |
|---|---|---|
| 0. Algebra check and outcome census | 1 node | half a day |
| 1. Single-turn, WebShop, ALFWorld control, ablations (~85 runs) | 1–2 GPUs per run, 4–8 runs per node, 15 nodes in one wave | about 15 hours (bounded by the 2-GPU runs) |
| 2. SWE pilot | 2 nodes: 8B at cap 40 and at cap 80 | 1 day, mostly calibration |
| 2. Q1 offline replay | 1 node | half a day |
| 3. SWE online, 8B: 5 arms × 3 seeds = 15 runs | one node per run, 15 nodes concurrently | about 1 day for 300 steps; never-drop and high- arms 30–50% longer |
| 3. 30B-A3B replication: drop / never-drop × 2 seeds | 2 nodes per run, 4 runs on the remaining 9 nodes | about 2 days |
GPU wall-clock for the whole program is four to five days; with pilot calibration, code changes, and analysis, two weeks is a realistic cycle. Upgrades worth buying with the surplus: five seeds instead of three for the headline arms ( vs. mask; drop vs. never-drop); 500–1000 steps for the SWE arms, since the subsidy scales with and the crossover may sit past step 300; the 30B-A3B replication at the scale where the 84% cap-hit rate was measured[14]; a cap-tightness ablation (40 vs. 80 turns) on SWE, which ALFWorld cannot provide; and a fully-run synchronous reference as the gradient oracle for Q3. Not worth buying: more benchmarks or more model families, which dilute engineering time without touching the claim.
E. Infrastructure prerequisites
- Sandbox CPU. 128 concurrent rollouts per SWE node; 15 nodes plus the 30B runs means roughly 2,000–2,500 concurrent containers. Budget 2–3k CPU cores, a local registry with the SWE-smith images cached, and a few hundred GB of container-layer storage per node. This is the component most likely to delay the program.
- Wall-clock scheduling. Asynchronous arms finish at different times because of stragglers; the scheduler must not wait on the slowest run before starting analysis.
- Storage. Rollout dumps are 1–2 GB per step; dumping the first 50 steps of 15 runs is about 1–1.5 TB.
- Discipline. One variable per comparison, the pre-registered predictions unchanged, the stopping conditions honored. The failure mode that abundant compute invites is adding arms until an effect appears, which is the one thing this post is designed to prevent.
- [1] M. Marek, M. Ryabinin. Score Centering Stabilizes Off-policy Reinforcement Learning. arXiv:2609.20807, 2026.
- [2] Q. Yu et al. DAPO: An Open-Source LLM Reinforcement Learning System at Scale. arXiv:2503.14476, 2025. §3.4, overlong filtering.
- [3] Agentica / Together AI. DeepSWE: Training a State-of-the-Art Coding Agent from Scratch by Scaling RL. blog, 2025. Compact filtering; Figure 7.
- [4] J. He et al. Skywork Open Reasoner 1 Technical Report. arXiv:2505.22312, 2025. §3.2.3, advantage mask on truncated samples.
- [5] MicroCoder / Breaking Training Bottlenecks §2.3: masking rate vs. output-length growth, and conditional masking. arXiv:2603.07777, 2026.
- [6] Tricks or Traps? A Deep Dive into RL for LLM Reasoning. arXiv:2508.08221, 2025. §4.4.
- [7] Mini-o3: Scaling Up Reasoning Patterns and Interaction Turns for Visual Search. arXiv:2509.07969, 2025. Over-turn masking.
- [8] Z. Liu et al. Understanding R1-Zero-Like Training: A Critical Perspective (Dr. GRPO). arXiv:2503.20783, 2025.
- [9] On the impossibility of unbiased and length-invariant policy optimization. arXiv:2607.23364, 2026.
- [10] NAT: Horvitz–Thompson corrections for token subsampling in policy gradients. arXiv:2603.06619, 2026.
- [11] Applied Compute. Staleness in fully asynchronous RL. research note, 2026.
- [12] Withdrawn in revision. An earlier draft cited a NeurIPS 2026 poster on latency-conditioned selection bias that we could not verify; [11] documents the short-response bias of staleness thresholds.
- [13] STOPD: Stochastic Truncation for On-Policy Distillation. arXiv:2610.21337, 2026.
- [14] LMSYS. Agentic RL on MI355X with Miles: SWE-smith with mini-swe-agent. blog, October 2026. 84% of trajectories hit the turn cap.
- [15] L. Feng et al. Group-in-Group Policy Optimization for LLM Agent Training (GiGPO) and verl-agent. arXiv:2505.10978, code, 2025.
- [16] Framework sources read for the table: TRL
grpo_trainer.py, rLLMtransform.pyandCompactFilteringConfig, NeMo-RLalgorithms/grpo.py, Milesfilter_hub/sample_filters.pyandfully_async_data_buffer.py, prime-rltrain_sink.py, verlcore_algos.py. Main branches as of November 3, 2026. - [17] NovaSky. SkyRL fully asynchronous training. docs.
- [18] T. Degris, M. White, R. Sutton. Off-Policy Actor-Critic. arXiv:1205.4839, 2012.