GRPOTrainer#
- class GRPOTrainer(cfg)[source]#
Bases:
TrainerReinforcement-learning trainer implementing GRPO at the trainer level.
Replaces the single supervised optimization step with a rollout-based loop: each batch is sampled into a group of trajectories, then the policy is updated
policy_updates_per_rollouttimes over the cached rollout (optionally split into trajectory microbatches to bound memory). The scheduler is sized tolen(train_loader) * epoch * policy_updates_per_rolloutaccordingly, and scalar GRPO metrics are reduced across ranks with key-specific ops (min/max/mean). Inherits all model/loader/optimizer construction fromTrainer. Registered asGRPOTrainer– select viatrain = dict(type="GRPOTrainer").