Skip to content

Qwen2.5VL-7B-Instruct model loss starts with nan #874

Open

Description

@rohitrango

For GRPO training with Qwen2.5VL-7B-Instruct, the loss at step 0 is nan and training does not proceed. token logprob errors are also consistently less than 1.05. Setting the KL loss to 0 seems to work (there are no nans). This problem does not occur with Qwen2.5VL-3B-Instruct or Qwen2VL-7B-Instruct (with kl penalty factor set to 0.01).

The problem is that the KL loss in calculate_kl_penalty_joschu2020 function overflows for high/low values of r

Steps to reproduce
uv run examples/run_vlm_grpo.py policy.model_name=Qwen/Qwen2.5VL-7B-Instruct

The simplest fix that works for me is to clamp the value of the loss before computing KL

Image

KL loss is generally very unstable (and high variance) which has led researchers to explore other forms of Bregman-divergences as well

For now, the simple fix I proposed above works.

Activity

  1. added
    bug
    on Aug 8, 2025
  2. rohitrango commented on Aug 8, 2025

    @rohitrango
    ContributorAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugt-pytdensor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions