Skip to content

fix: use batch_sampler for HybridEnvSampler in DataLoader#126

Merged
dzorlu merged 1 commit intomainfrom
fix/hybrid-sampler-batch
Feb 6, 2026
Merged

fix: use batch_sampler for HybridEnvSampler in DataLoader#126
dzorlu merged 1 commit intomainfrom
fix/hybrid-sampler-batch

Conversation

@dzorlu
Copy link
Collaborator

@dzorlu dzorlu commented Feb 6, 2026

Summary

  • Fixed build_dataloader to use batch_sampler= instead of sampler= for HybridEnvSampler
  • HybridEnvSampler yields batches of indices (lists), not individual indices
  • Using sampler= caused collate_fn to receive raw indices instead of dataset items
  • Added integration tests to prevent regression

Error Fixed

ValueError: not enough values to unpack (expected 4, got 1)
  File "skyrl_train/dataset/dataset.py", line 81, in collate_fn
    for prompt, env_class, env_extras, item_uids in item_list:

Test plan

  • Added test_hybrid_env_sampler_dataloader_integration - verifies correct batch structure
  • Added test_hybrid_env_sampler_wrong_usage_fails - documents the bug
  • Run training with hybrid sampling enabled

🤖 Generated with Claude Code

The HybridEnvSampler yields batches of indices (lists), not individual
indices. DataLoader's `sampler` parameter expects individual indices,
while `batch_sampler` expects batches. Using `sampler=` caused:

  ValueError: not enough values to unpack (expected 4, got 1)

because collate_fn received raw indices instead of dataset items.

Also adds integration tests to catch this regression:
- test_hybrid_env_sampler_dataloader_integration: verifies correct usage
- test_hybrid_env_sampler_wrong_usage_fails: documents the bug

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@dzorlu dzorlu merged commit d70a515 into main Feb 6, 2026
2 of 3 checks 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.

1 participant