Configure batch balancing and micro-batching parameters
mainTo optimize GPU utilization and prevent idle time during RL training, EasyVideoR1 uses specific mechanisms for batching:
- Sequence Balancing: The framework uses the Karmarkar-Karp algorithm to ensure each GPU receives a similar total token count, even when sequence lengths vary significantly.
- Micro-batching: During the Actor update phase, sequences are further divided into micro-batches based on the
max_token_len_per_gpuparameter. This ensures that the memory footprint of the forward and backward passes remains within GPU limits.
Key Parameters for Tuning:
rollout_batch_size: The number of prompts used for generation.n: The number of responses generated per prompt (used for GRPO group calculation).max_token_len_per_gpu: The threshold used to split sequences into micro-batches during training (e.g.,32768).