feat: add Geo-Mask, Seq-TIS, Seq-MIS and MIS-PO loss types (sequence-level IS ablations) - #3384
Draft
faresobeid wants to merge 4 commits into
Draft
feat: add Geo-Mask, Seq-TIS, Seq-MIS and MIS-PO loss types (sequence-level IS ablations)#3384faresobeid wants to merge 4 commits into
faresobeid wants to merge 4 commits into
Conversation
Sequence-level importance sampling behind a geometric trust region (https://richardli.xyz/post/rl-collapse-part3/): a rollout contributes gradient only if the geometric mean of its per-token importance ratios lies within [geo_mask_low, geo_mask_high]. Accepted rollouts use the plain score function; token_clip enables the Geo-Mask-Token-TIS hybrid. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sequence-level importance sampling: the detached product ratio weights the rollout's score function. seq_clip truncates the weight (Seq-TIS, on by default); optional geo_mask_low/high add a length-invariant geometric-mean trust region while keeping the untempered weight on accepted rollouts. The 2x2 spans plain Seq-IS, Seq-TIS, and both geo-masked variants. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Drop the plain and geo-masked-clipped combinations: seq_tis truncates the detached product weight at seq_clip; seq_mis drops rollouts outside a geometric-mean trust region and keeps the untempered weight on accepted ones. Two explicit types instead of one type with an XOR constraint on its knobs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Metropolis Independence Sampling-filtered policy optimization from Step 3.5 Flash (arXiv:2602.10604, eq. 2): plain score function behind dual-level binary masking — a token-level band on the trainer/inference ratio and a trajectory-level band on the geometric-mean ratio — with no importance weighting anywhere. Paper defaults: [0.5, 2] token band, [0.996, 1.001] trajectory band. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Adds four loss types to the algo-ablations set (#3381), drawing on RL collapse, part 3 (Li) and Is Frontier Asynchronous RL Solved? (Huang).
seq_tisandseq_misare the truncate-vs-mask pair for sequence-level IS;geo_maskis Li's pure-filter estimator.All three compute the rollout's summed log-ratio; they differ in what they do with it. Weights are always detached (score-function surrogates), so clipping/masking never silently zeroes gradients through the ratio.
seq_tis— truncated sequence-level IS (Huang)Every rollout keeps a (possibly damped) gradient contribution; bias is one-sided. The estimator Huang's K=12 lag experiments found most durable.
seq_clipadv_tauMetrics:
mismatch_kl,is_clipped,seq_log_ratio,geo_log_ratio,seq_weight.seq_mis— masked sequence-level IS, geometric criterion (Li × Huang)Drops the rollout wholesale unless the geometric mean of its per-token ratios is in the trust region; accepted rollouts keep the untempered product weight, so the estimator is exactly unbiased on the accepted region. The criterion is deliberately geometric rather than a product threshold (which rejects by cumulative divergence and kills all long rollouts); the weight is deliberately untempered (tempering to$w^{1/T}$ is the bias Huang shows makes GeoMean-IS track token-IS). Numerics guard caps the weight at $e^{40}$ . The mask-vs-truncate contrast with
seq_tis: no mis-weighted gradients from the divergent tail, but effective batch shrinks as policies drift (watchis_masked).geo_mask_low/geo_mask_highadv_tauMetrics:
masked/unmasked_mismatch_kl,is_masked,seq_log_ratio,geo_log_ratio,seq_weight.geo_mask— geometric trust region, pure filter (Li)Same length-invariant acceptance rule as
seq_mis, but accepted rollouts use the plain score function with no importance weighting (the post's pure-filter design: inside the trust region the ratio is ~1).token_clipenables the post's Geo-Mask-Token-TIS hybrid (score function weighted by the detached, upper-clipped per-token ratio) for full per-token IS correction.geo_mask_low/geo_mask_highadv_tautoken_clipMetrics:
masked/unmasked_mismatch_kl,is_masked,geo_log_ratio.mis_po— dual-level binary masking, pure score function (Step 3.5 Flash)From Step 3.5 Flash (eq. 2), "Metropolis Independence Sampling-filtered Policy Optimization": treat the inference policy as a proposal distribution and keep only samples close enough to the trainer, as effectively on-policy — no importance weighting anywhere:
Token-level indicator drops individually mismatched tokens; trajectory-level indicator drops the rollout when its geometric-mean ratio drifts. Structurally it is
geo_mask's trajectory filter + a token-level mismatch filter, with the paper's much tighter trajectory band (their ratios measure pre-update-snapshot/vLLM mismatch, which concentrates near 1 at 128k context — under real policy lag the band should be widened; docs note this).token_mask_low/token_mask_highgeo_mask_low/geo_mask_highadv_tauMetrics:
masked/unmasked_mismatch_kl,is_masked,is_token_masked,is_traj_masked,geo_log_ratio.Test plan
Smoke-tested all four loss fns directly (no test files added, per repo convention): exact gradients in every regime (score function with per-token drops for mis_po; score function$e^{40}$ overflow guard (finite loss/grads at summed log-ratio 800), and clean zero loss on empty masks.
-adv; clipped weight-2·adv; untempered in-region weight-e^{0.8}·adv;token_cliphybrid's detached weight), both-sided geo rejection with zero gradient while staying backward-able, masks computed only over loss-masked tokens, theruff check/ruff formatclean; all configs parse through theLossConfigdiscriminated union.🤖 Generated with Claude Code