Skip to content

feat: add trajectory-level batching, loss aggregation, and dynamic batching support#85

Open
lqzxt wants to merge 2 commits intoAgentR1:mainfrom
lqzxt:feat/add_traj_batching
Open

feat: add trajectory-level batching, loss aggregation, and dynamic batching support#85
lqzxt wants to merge 2 commits intoAgentR1:mainfrom
lqzxt:feat/add_traj_batching

Conversation

@lqzxt
Copy link
Copy Markdown
Collaborator

@lqzxt lqzxt commented Apr 21, 2026

Summary

This PR introduces trajectory-aware training support by batching samples at the trajectory level, aggregating loss across entire trajectories, and adding dynamic batching to better handle variable-length trajectories. These changes ensure that all multi-turn completions from the same trajectory are processed within the same forward/backward pass while improving training efficiency and reducing memory fragmentation.

Changes

  • implement trajectory-level mini-batch construction to keep all completions from the same trajectory in the same batch
  • refactor loss computation to support trajectory-level loss aggregation
  • add dynamic batching for variable-length trajectories to improve GPU memory utilization and reduce fragmentation

@lqzxt lqzxt requested a review from 0russwest0 April 21, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant