Skip to content

fix(buffer): reshuffle with correct epoch in ShuffleSelector#593

Merged
pan-x-c merged 1 commit into
agentscope-ai:mainfrom
MengsD:fix/data-shuffle
Jun 26, 2026
Merged

fix(buffer): reshuffle with correct epoch in ShuffleSelector#593
pan-x-c merged 1 commit into
agentscope-ai:mainfrom
MengsD:fix/data-shuffle

Conversation

@MengsD

@MengsD MengsD commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Description

[Please describe the background, purpose, changes made, and how to test this PR]

Background

ShuffleSelector regenerates its shuffle order via _get_orders(), which derives the epoch from current_index // dataset_size. Because current_index was incremented after the reshuffle, the epoch number lagged by one.

Purpose

Fix an off-by-one bug where consecutive epochs reused the same permutation (epoch 0 == epoch 1), and checkpoint resume diverged from a continuous run.

Changes

  • trinity/buffer/selector/selector.py: move current_index += batch_size before _get_orders() so each epoch reshuffles with the correct (next) epoch seed.
  • tests/buffer/task_scheduler_test.py: add TestShuffleSelector.test_reshuffles_between_epochs asserting each epoch is a full permutation and consecutive epochs differ.

How to test

pytest tests/buffer/task_scheduler_test.py -q
Verified on DSW (env trinity): 9 passed; the new test fails on the pre-fix code (epoch0 == epoch1) and passes after the fix.

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has passed all tests
  • Docstrings have been added/updated in Google Style
  • Documentation has been updated
  • Code is ready for review

@MengsD

MengsD commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator Author

/unittest-diff

@github-actions

Copy link
Copy Markdown

unittest: Run #1786

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Pending ⏳ Other ❓ Flaky 🍂 Duration ⏱️
372 367 0 5 0 0 0 2h 41m

🎉 All tests passed!

Github Test Reporter by CTRF 💚

@pan-x-c pan-x-c merged commit 35722db into agentscope-ai:main Jun 26, 2026
1 check passed
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.

2 participants