Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

WindowShuffleMapDataset duplicates and omits records in incomplete windows

Open
#1,435 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@salma2vec is already working on this.

Since Oct 21, 2026.

  • #1436 by @salma2vec — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
data

Research direction

Start with WindowShuffleMapDataset._shuffled_index and compare its window calculations with WindowShuffleIterDataset(..., reverse=False). Reproduce the five-record example, then check scalar and batched access across repeated epochs; done means each epoch preserves every record, full-window seeded order is unchanged, and the first epoch agrees with the iterator variant. A linked pull request is already open.

Written by the indexing model from the issue text.

Description

type:bug

WindowShuffleMapDataset can duplicate and omit records when the parent length is not divisible by window_size. This changes the training data within an epoch without raising an error.

Reproduced on d2adadec1b275251b098215abe5c6df8b16ed6da (Python 3.12, macOS arm64):

import grain

parent = grain.MapDataset.range(5)
shuffled = grain.experimental.WindowShuffleMapDataset(
    parent, window_size=4, seed=42
)
print(list(shuffled))
# [0, 1, 2, 3, 1]

Expected: a permutation of [0, 1, 2, 3, 4], with records staying in their windows. Record 4 is missing and record 1 appears twice. The corresponding WindowShuffleIterDataset(..., reverse=False) preserves all five records.

_shuffled_index uses window_size - 1 as the shuffle bound even for an incomplete final window. An index beyond the parent length then wraps into the next epoch. The global window boundaries also drift across repeated epochs. With 1,003 records and a window of 1,000, seed 42 omits records 1,000–1,002 in the first epoch; the second epoch has six missing records. A 12-record, four-record-window control preserves every record in three consecutive epochs.

The map variant needs to bound the last window to the remaining records and compute window boundaries within each parent epoch. Full-window datasets should retain their existing seeded order. Regression coverage should include scalar and batched access, repeat, and agreement with the iterator variant for the first epoch.

Dominant language
Python
Stars
795
Forks
91
Avg merge
1d 9h
Merged PRs (30d)
15

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from google/grain

All issues in google/grain

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.