Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass mask in packing_iterator, correctly handle last batch, fix masking #65

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

EntilZha
Copy link
Contributor

@EntilZha EntilZha commented Feb 20, 2025

This commit does/fixes the following:

  1. Adds unit tests for byte and patch packing to ensure it works correctly
  2. Fixes a bug where for batches that end up with <max_length number of bytes (e.g., short patches), the mask was including elements that had value pad_id. This fixes the mask by setting it to be !=pad_id, if its not specified.
  3. Correctly handles the last batch, where previously it would crash. This didn't affect training since we had enough data and/or looped iterators, but for evaluation perplexity, it comes up if we validation on an entire file.
  4. Correctly forward the mask if it exists for byte packing

Test Plan:

pytest bytelatent/

Testing these changes more thoroughly in a stacked PR that fixes evals

Stack created with Sapling. Best reviewed with ReviewStack.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Feb 20, 2025
@EntilZha EntilZha force-pushed the pr65 branch 3 times, most recently from eac7a3f to 1ede87e Compare February 22, 2025 01:22
@EntilZha EntilZha changed the title Pass mask in packing_iterator, correctly handle last batch Pass mask in packing_iterator, correctly handle last batch, fix masking Feb 22, 2025
@EntilZha EntilZha force-pushed the pr65 branch 4 times, most recently from 6147207 to 52d5603 Compare February 25, 2025 01:38
This commit does/fixes the following:

1. Adds unit tests for byte and patch packing to ensure it works correctly
2. Fixes a bug where for batches that end up with <max_length number of bytes (e.g., short patches), the mask was including elements that had value pad_id. This fixes the mask by setting it to be !=pad_id, if its not specified.
3. Correctly handles the last batch, where previously it would crash. This didn't affect training since we had enough data and/or looped iterators, but for evaluation perplexity, it comes up if we validation on an entire file.
4. Correctly forward the mask if it exists for byte packing

Test Plan:

```
pytest bytelatent/
```

Testing these changes more thoroughly in a stacked PR that fixes evals
Copy link
Contributor

@sriniiyer sriniiyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@EntilZha EntilZha mentioned this pull request Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants