Repository navigation
Preserve sliding-window overlap between preprocessing batches - #2796
Open
林SO (Linxiushen) wants to merge 1 commit into
Open
林SO (Linxiushen) wants to merge 1 commit into
林SO (Linxiushen) wants to merge 1 commit into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the joined sliding-window preprocessing change.
No open issues 🎉
What changed in this PR
This PR fixes joined sliding-window preprocessing so token windows and labels remain consistent across processing batch sizes.
Changes:
- Preserve overlapping tokens by carrying them forward from the next scheduled window start, while retaining full-length window slices.
- Add regression tests covering row layouts, processing batch sizes, joined strategies, and optional sample limits.
| File | Description |
|---|---|
test/data_container/test_text_generation.py |
Adds 36 cases checking exact windows, attention masks, labels, and sample counts. |
olive/data/component/text_generation.py |
Corrects sliding-window carryover while preserving non-overlapping JOIN behavior. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
JOIN_SLIDING_WINDOWcurrently carries tokens over from the end of the last emitted window when tokenization moves to anotherprocessing_batch_sizebatch. The next window starts onlystridetokens later, so this discards its overlapping context. Token IDs, labels and sample counts consequently depend on the processing batch size. For example, 24 tokens in four 6-token rows withmax_seq_len=8,stride=3andprocessing_batch_size=1produce four windows instead of the six produced with one processing batch.Carry over tokens from the next scheduled window start (
begin_loc + step), while continuing to slice each completemax_seq_lenwindow. Retain all accumulated tokens when no complete window fits. Non-overlappingJOINcontinues to advance bymax_seq_len.The regression uses the existing offline
FakeTokenizerwith distinct token IDs and checks exact windows, attention masks and context-masked labels across three row layouts, processing batch sizes 1/2/1024, both joined strategies and optionalmax_samples. On the unchanged production base, 12 of the 36 cases fail; all 36 pass with the fix.Validation on Windows CPU, offline:
python -m pytest test/data_container/test_text_generation.py -q: 50 passed.python -m pytest test/data_container/test_dataset.py test/data_container/test_data_config.py test/data_container/test_template.py -q: 9 passed.lintrunner -a --skip PYLINT, followed by changed-filelintrunnerincluding PYLINT: passed.git diff --check: passed.These are native data preprocessing tests using the existing deterministic tokenizer and in-memory datasets. The full suite, real model/tokenizer execution and GPU execution were not run. AI assistance was used for implementation, tests and review.
Checklist before requesting a review
lintrunner -a(changed files; PYLINT also run separately).Release note: Preserve sliding-window overlap across tokenizer processing batches so text-generation preprocessing produces consistent samples and labels when
processing_batch_sizechanges.(Optional) Issue link
Found while inspecting the native preprocessing path; no separate issue.