Skip to content

fix(grpo): VLM processor metadata misalignment after token concatenation #45

Description

@abrichr

Problem

In _compute_rollout_loss (trainer.py:519-525), after concatenating action token IDs to prompt input_ids, only input_ids and attention_mask are updated. VLM-specific keys like pixel_values, image_grid_thw (Qwen2.5-VL) retain their original shapes tied to the prompt-only length. This may cause image token position misalignment during the forward pass.

Additionally, line 525 does {k: v.to(device) for k, v in full_inputs.items()} which fails if any value is not a tensor (e.g., integer metadata in processor output). Need an isinstance(v, torch.Tensor) guard.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions