Repository navigation
Commit a04b753
fix(xtoken): keep the offset layout for all-empty text batches
When every text in a batch tokenizes to no tokens, the tokenizer
returns offset_mapping as a (B, 0) tensor without the start/end axis.
Text batches now pad to the longest row, so such a batch is padded to
one sequence-length multiple, and concatenating (B, pad, 2) offsets onto
the (B, 0) tensor raised "Tensors must have same number of dimensions:
got 2 and 3". Reshape the offsets to (B, T, 2) from the token ids'
shape, so the batch collates to all-padding rows as it did when text
batches padded to the full context length. Non-empty batches are
unchanged.
Add a regression test for an all-empty text batch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Adithya Hanasoge <avenkateshha@nvidia.com>1 parent 6f98ca3 commit a04b753
2 files changed
Lines changed: 17 additions & 1 deletion
File tree
- nemo_rl/data/cross_tokenizer
- tests/unit/data
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
670 | 670 | | |
671 | 671 | | |
672 | 672 | | |
673 | | - | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
674 | 677 | | |
675 | 678 | | |
676 | 679 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
797 | 797 | | |
798 | 798 | | |
799 | 799 | | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
800 | 813 | | |
801 | 814 | | |
802 | 815 | | |
| |||
0 commit comments