verl icon indicating copy to clipboard operation
verl copied to clipboard

Qwen3.5-4b ppo_kl != 0

Open dipta007 opened this issue 5 months ago • 7 comments

System Info

Is it normal to get ppo_kl != 0? The same run with Qwen/Qwen3-4B-Instruct-2507 get ppo_kl = 0

Image

Information

  • [ ] The official example scripts
  • [x] My own modified scripts

Tasks

  • [x] An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • [ ] My own task or dataset (give details below)

Reproduction

grpo base script

Expected behavior

It should be always 0 for stable training

dipta007 avatar Jun 23 '26 23:06 dipta007

Hello! I've been looking into these recently too. Could I ask which algorithm you used, and what hardware you ran it on to get these results?

zyang6 avatar Jul 01 '26 08:07 zyang6

Hello! I've been looking into these recently too. Could I ask which algorithm you used, and what hardware you ran it on to get these results?

I’m seeing a similar issue in GRPO training.

When training Qwen3-series models, actor/ppo_kl stays at 0 as expected. However, when training Qwen3.5-series models under a similar setup, actor/ppo_kl becomes non-zero.

Environment:

  • GRPO
  • GPUs: H20, 4 nodes × 8 GPUs
  • verl: 0.9.0.dev0
  • transformers: 5.6.2
  • sglang: 0.5.12.post1
  • vLLM: 0.9.0.dev0

SundayVHan avatar Jul 04 '26 16:07 SundayVHan

FYI issue 6280, it is believed bug in datapipeline, a workaround you can try: set rollout.log_prob_micro_batch_size_per_gpu the same as actor.ppo_micro_batch_size_per_gpu

jianwenzhzm avatar Jul 05 '26 14:07 jianwenzhzm

FYI issue 6280, it is believed bug in datapipeline, a workaround you can try: set rollout.log_prob_micro_batch_size_per_gpu the same as actor.ppo_micro_batch_size_per_gpu

Thanks. The training runs normally with this setting.

SundayVHan avatar Jul 06 '26 03:07 SundayVHan

I tracked this down on current main (Qwen3.5-0.8B, RTX 5090, FSDP engine, use_remove_padding). Without the causal-conv1d package (it isn’t in verl’s uv.lock), the transformers 5.16.1 GDN wrapper drops verl’s seq_idx, so the causal conv1d mixes the previous packed sample’s last 3 tokens into each sample, even with FLA installed. With a log-prob micro-batch of 8 and a train micro-batch of 2, ppo_kl is −0.041 and pg_clipfrac 9.2%. Equal sizes give ppo_kl 0, which hides it, but rollout_corr/kl stays at 0.040. The seq_idx guard in #8646 fixes it: ppo_kl −1.4e-4 and rollout_corr/kl 0.00051. With #8646 and batch_invariant=True, log-probs are bitwise identical across micro-batch sizes 2, 4 and 8.

JonSnow1807 avatar Nov 14 '26 04:11 JonSnow1807

I tracked this down on current main (Qwen3.5-0.8B, RTX 5090, FSDP engine, use_remove_padding). Without the causal-conv1d package (it isn’t in verl’s uv.lock), the transformers 5.16.1 GDN wrapper drops verl’s seq_idx, so the causal conv1d mixes the previous packed sample’s last 3 tokens into each sample, even with FLA installed. With a log-prob micro-batch of 8 and a train micro-batch of 2, ppo_kl is −0.041 and pg_clipfrac 9.2%. Equal sizes give ppo_kl 0, which hides it, but rollout_corr/kl stays at 0.040. The seq_idx guard in #8646 fixes it: ppo_kl −1.4e-4 and rollout_corr/kl 0.00051. With #8646 and batch_invariant=True, log-probs are bitwise identical across micro-batch sizes 2, 4 and 8.

Nice catch, this really helped! Just curious,Could this also happen in other models if the convolution reads across packed sample boundaries, or is it specific to Qwen3.5?

zyang6 avatar Nov 14 '26 04:11 zyang6

In verl it’s limited to Qwen3.5 and Qwen3.5-MoE: they’re the only models whose GDN forward verl patches to pass seq_idx, and #8646 covers both. The transformers 5.16.1 wrapper drops seq_idx the same way for every model with a short conv (Qwen3-Next, Mamba2, LFM2 and others), so code that passes it to them without causal-conv1d installed would hit the same issue.

JonSnow1807 avatar Nov 15 '26 00:11 JonSnow1807