Supporting FIPO (Future-KL Influenced Policy Optimization)#1801
Open
SeungyounShin wants to merge 9 commits intoTHUDM:mainfrom
Open
Supporting FIPO (Future-KL Influenced Policy Optimization)#1801SeungyounShin wants to merge 9 commits intoTHUDM:mainfrom
SeungyounShin wants to merge 9 commits intoTHUDM:mainfrom
Conversation
Add FIPO as a built-in loss type for dense token-level credit assignment without a value network. FIPO re-weights GRPO advantages using discounted Future-KL divergence, enabling deeper reasoning chains. Changes: - loss.py: fipo_loss_function with chunked Future-KL computation - arguments.py: --loss-type fipo_loss and 6 FIPO-specific args - scripts/models/qwen3.5-2B.sh: Qwen3.5-2B model config - examples/fipo/: sbatch training script for Qwen3.5-2B on HPC Requires multi-step training per rollout (global-batch-size < total rollout samples) so the policy drifts from the rollout policy. Ref: Ma et al., arXiv:2603.19835 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use absolute paths (SLIME_ROOT) instead of relative SCRIPT_DIR - Add venv activation and flash-attn install on compute node - Set SGLANG_DISABLE_CUDNN_CHECK=1 for driver compatibility - Use 8 GPUs per node (H100x8 cluster) - Add working-dir for ray job submit Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add HF→torch_dist checkpoint conversion step - Switch to conda env activation via PATH - Remove hardcoded wandb key - Remove flash-attn build step (pre-built wheel installed) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace hardcoded paths with configurable variables - Remove SLURM/HPC-specific configuration - Add usage instructions in header comments - Add .gitignore for local run scripts (*.local.sh) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Assert rollout_log_probs is available (required for multi-step FutureKL) - Simplify loss masking: pg_losses * final_mask (was needlessly complex) - Add --use-rollout-logprobs to example scripts Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
50de47f to
86b5782
Compare
Replace --fipo-clip-ratio with --fipo-clip-ratio-low and --fipo-clip-ratio-high to allow asymmetric clipping of influence weights. This lets ε_high > ε_low, favoring amplification of good trajectories (FutureKL > 0) over attenuation of bad ones. Example: --fipo-clip-ratio-low 0.2 --fipo-clip-ratio-high 0.28 gives f_t ∈ [0.8, 1.28], matching PPO's asymmetric eps_clip pattern. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…nfig - Add _fipo_log_token_ratios: HTML heatmap of per-token log ratio logged to wandb every 8 steps. Green = reinforced, red = suppressed. Hover shows exact ratio and f_t values. - Add Qwen3.5-0.8B model config script - Update run script to support MODEL_SIZE env var (0.8B/2B) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove _fipo_log_token_ratios (wandb HTML heatmap) from core loss. Keep only essential FIPO metrics (influence_mean/min/max). Co-Authored-By: Claude Opus 4.6 (1M context) <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.
Summary
Add FIPO (Future-KL Influenced Policy Optimization) as a built-in loss type, enabling dense token-level credit assignment for RL training without a value network.
Method
FIPO extends standard clipped PPO by re-weighting per-token advantages with Future-KL influence weights. While GRPO broadcasts a uniform sequence-level advantage to all tokens, FIPO modulates each token's contribution based on how the future trajectory evolves:
where$\Delta \log p_k = \log \pi_\theta(y_k \mid y_{<k}) - \log \pi_{\theta_{\text{old}}}(y_k \mid y_{<k})$ and $\gamma = 2^{-1/\tau}$ is an exponential decay factor.
The influence weight is computed as:
The final FIPO loss modifies the clipped PPO objective with re-weighted advantages:
Key design choices
influence_weightsare detached from the computation graph — FIPO does not backpropagate through Future-KLglobal_batch_size < rollout_batch_size × n_samples_per_prompt) so thatChanges
slime/backends/megatron_utils/loss.py_compute_future_kl()andfipo_loss_function()with dual-clip PPO, sequence filtering, and FIPO metricsslime/utils/arguments.py--loss-type fipo_lossand 6 FIPO-specific args (--fipo-decay-rate,--fipo-chunk-size,--fipo-clip-ratio,--fipo-clip-high-only,--fipo-safety-thresh,--fipo-dual-clip-c)scripts/models/qwen3.5-2B.shexamples/fipo/fipo_qwen3.5_2b.shUsage
FIPO hyperparameter guide
--fipo-decay-rate--fipo-clip-ratio--fipo-clip-high-only--fipo-safety-threshResults
FIPO consistently increases raw reward (
Qwen3.5-4B-Base)A token-level importance-ratio heatmap under FIPO. The strong emphasis on “Alternative” suggests that FIPO reinforces branching points that trigger self-reflection and exploration of alternative solution paths, rather than treating all tokens uniformly.
cc. @zhuzilin