fix(speechlm2): keep EOS that falls in the delay_text_channel_by window - #16165
fix(speechlm2): keep EOS that falls in the delay_text_channel_by window#16165udsy19 wants to merge 3 commits into
Conversation
prepare_text_and_asr_labels's delay_text_channel_by path masks out any EOS in the last delay_by positions (they are about to be sliced off by the right-shift) and tries to relocate one of them into the slot that survives the shift by writing to target_tokens[i, -(delay_by)]. That index is itself one of the positions the following `target_tokens[:, :-delay_by]` slice drops, so the relocated EOS is discarded along with the positions it was rescued from. Every EOS that lands in the delay window is silently erased from the training labels, regardless of the rescue attempt. The slot that actually survives the slice-then-pad is target_tokens[i, -(delay_by + 1)]. label_prep.py has had exactly one commit since it was introduced (NVIDIA-NeMo#15092); the rescue branch has never been exercised by a test. Signed-off-by: Udaya Tejas <udayatejas2004@gmail.com>
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
/ok to test 29c9bb6 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 29c9bb60a4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for i in range(target_tokens.size(0)): | ||
| if eos_mask[i].any(): | ||
| target_tokens[i, -(delay_by)] = text_eos_id | ||
| target_tokens[i, -(delay_by + 1)] = text_eos_id |
There was a problem hiding this comment.
Guard the full-width delay before indexing
When delay_text_channel_by equals target_tokens.size(1) and a row contains EOS, this index becomes -T-1, so PyTorch raises IndexError before performing the shift. The previous -delay_by index remained valid at this boundary, making this a new crash for short batches whose encoded width matches the configured delay; validate that the delay is smaller than the width or handle the full-width shift explicitly, with a boundary regression test.
AGENTS.md reference: AGENTS.md:L58-L60
Useful? React with 👍 / 👎.
| import torch | ||
|
|
||
| from nemo.collections.speechlm2.parts.label_prep import maybe_prepend_prompt_tokens | ||
| from nemo.collections.speechlm2.parts.label_prep import maybe_prepend_prompt_tokens, prepare_text_and_asr_labels |
There was a problem hiding this comment.
The reviewed commit object 599996a2ccd1ea717ce60751fb6dab3e948bf807 contains no Signed-off-by trailer, so it does not satisfy the repository's mandatory DCO requirement and cannot pass contribution compliance as submitted. Recreate the commit with the appropriate sign-off trailer.
AGENTS.md reference: AGENTS.md:L52-L52
Useful? React with 👍 / 👎.
|
/ok to test 7dbdf41 |
|
/ok to test 2639b6a |
What does this PR do ?
Fixes
prepare_text_and_asr_labelssilently dropping the EOS token wheneverdelay_text_channel_byshifts it into the trailing delay window.Collection: [speechlm2]
Changelog
nemo/collections/speechlm2/parts/label_prep.py:170: the EOS-rescue write targetstarget_tokens[i, -(delay_by)], a position the very next line'starget_tokens[:, :-delay_by]slice drops. The relocated EOS was thereforediscarded along with the rest of the delay window every time. The slot that
actually survives the slice-then-pad is
target_tokens[i, -(delay_by + 1)].tests/collections/speechlm2/test_label_prep.py: newtest_prepare_text_and_asr_labels_delay_channel_keeps_eos_near_boundary,covering an EOS at the last index still inside the delay window, an EOS at the
very last index, and a control EOS well outside the window.
Usage
On
main(6281c939aa):tensor([[ 0, 1, 10, 11, 12, 13, 14]])— EOS gone. With this PR: EOS is present, shifted like every other token.Negative control: with
label_prep.pyreverted tomainand only the new test added, the file reports1 failed, 2 passed— the new boundary test fails, the two pre-existing tests are unaffected. With the fix, all three tests in the file pass (3 passed).nemo/collections/speechlm2/parts/label_prep.pyhas had exactly one commit since it was introduced (#15092); no test exercised this branch before this PR.GitHub Actions CI
Requires a maintainer
/ok to test <head-sha>.Before your PR is "Ready for review"
Pre checks:
PR Type:
Additional Information
Fixes #16164