LigerFusedLinearGRPOLoss 产生的梯度范数比 TRL 的非 Liger-Kernel 路径大 ~100 倍,原因是缺少 vLLM IS 校正和其他差异

作者: yukiu00创建于 2026年2月7日更新于 2026年8月30日

| Metric (step 1) | | vLLM IS correction | per_token_loss *= importance_sampling_ratio (L2351-L2352) | Not applied | ~100-300x (primary cause) | Yes | | 2 | dapo/cispo normalizer | num_items_in_batch / num_processes (total tokens across entire generation batch) (L2371) | all_reduce(sum(attention_mask)) / world_size (current micro-batch only), then divided by current_gradient_accumulation_steps (Liger-Kernel L116-117, TRL L2194) | Several-fold depending on length variance | Yes | | 3 | tool_mask | completion_mask * tool_mask (L2243) | completion_mask only (TRL L2178) | Proportional to tool token ratio | Yes | | 4 | use_bias_correction_kl | per_token_kl *= coef_1 (L2315-L2316) | Not implemented | KL term only | Yes | | 5 | delta (ratio clamping) | coef_1 = clamp(coef_1, max=delta) (L2326-L2327) | Not implemented | Changes clipping behavior | Yes | | 6 | off_policy_mask, top_entropy_quantile, sequence-level IS, sapo | Supported | Not supported | - | No (raises error) |

# Difference Where to fix Notes
1 vLLM IS correction Liger-Kernel + TRL Liger-Kernel: add parameter to apply per_token_loss *= is_ratio before reduction. TRL: pass it from compute_liger_loss
2 dapo/cispo normalizer Liger-Kernel + TRL Liger-Kernel: accept an external normalizer. TRL: pass num_items_in_batch
3 tool_mask TRL only Pass completion_mask * tool_mask in compute_liger_loss
4 use_bias_correction_kl Liger-Kernel + TRL Liger-Kernel: add flag to ppo_loss_fn. TRL: pass it
5 delta (ratio clamping) Liger-Kernel + TRL Liger-Kernel: add clamp argument for coef_1. TRL: pass it

With DAPO loss on a large model using vLLM in GRPOTrainer:

内容来源: linkedin/Liger-Kernel