Fix crash with Lhotse train data and float limit_train_batches - #16131
Open
VaggelisGian wants to merge 1 commit into
Open
Fix crash with Lhotse train data and float limit_train_batches#16131VaggelisGian wants to merge 1 commit into
VaggelisGian wants to merge 1 commit into
Conversation
The prompt-based RNNT and hybrid RNNT-CTC models guarded their limit_train_batches conversion on the is_tarred config key and then called len() on the built dataset. With use_lhotse=true the dataset is a map-style torch Dataset without __len__, so any float limit_train_batches (including the Lightning default 1.0) raised: TypeError: object of type 'LhotseSpeechToTextBpeDatasetWithPromptIndex' has no len() Align the guard with the base-class pattern used by the other ASR models: enter only when the dataloader holds an IterableDataset that also defines __len__. NeMo tarred datasets qualify and keep the conversion; Lhotse map-style datasets and IterableDatasetWrapper do not, so the conversion is skipped and Lightning keeps treating 1.0 as a full epoch. Fixes NVIDIA-NeMo#16004. Test Plan: python -m pytest tests/collections/asr/test_asr_rnnt_encoder_model_bpe_prompt.py -x -q -m "not pleasefixme" 13 passed, including the new regression test that reproduces the reported TypeError before the fix python -m pytest tests/collections/asr/test_asr_hybrid_rnnt_ctc_model_bpe_prompt.py -q -m "not pleasefixme" 15 passed black --check, isort --check-only, flake8 on changed files: clean Signed-off-by: Vaggelis <baggelis100@gmail.com>
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.
Important
The
Update branchbutton must only be pressed in very rare occassions.An outdated branch is never blocking the merge of a PR.
Please reach out to the automation team before pressing that button.
What does this PR do ?
Fixes #16004: training crashes with
TypeError: object of type 'LhotseSpeechToTextBpeDatasetWithPromptIndex' has no len()wheneverlimit_train_batchesis a float (including the Lightning default of 1.0) while the train data comes from Lhotse.Collection: ASR
Changelog
EncDecHybridRNNTCTCBPEModeland the prompt-based RNNT model, thelimit_train_batchesconversion now enters only when the dataloader's dataset is anIterableDatasetthat also defines__len__, matching the guard pattern already used by the base class for the other ASR models.IterableDatasetWrapperskip it, so Lightning keeps treating a float value as a fraction of one epoch.TypeErrorbefore the fix and passes after it.Root cause: both models guarded the conversion on the
is_tarredconfig key and then calledlen()on the built dataset. Withuse_lhotse=truethe dataset is map-style without__len__, so any floatlimit_train_batchesraised the crash from the linked issue.Usage
No configuration change is required. With
model.train_ds.use_lhotse=true, any floattrainer.limit_train_batchesnow trains normally instead of crashing:GitHub Actions CI
The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.
Trusted PRs run automatically through copy-pr-bot. For an untrusted PR, a maintainer can trigger CI by commenting
/ok to test <head-sha>; repeat this after a new push if the PR remains untrusted.Before your PR is "Ready for review"
Pre checks:
tests/collections/asr/test_asr_rnnt_encoder_model_bpe_prompt.py, fails before the fix (TypeError ... has no len()) and passes after.PR Type:
Who can review?
Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.
Additional Information
Exact checks run locally (Python 3.12.6, torch 2.11.0+cu128):
Intentionally skipped: full ASR suite (blast radius of this change is two setup methods plus their base-class pattern), docs build (
uvunavailable on this machine),pre-commitbinary absent locally; black/isort/flake8 were run directly against the same pinned configs instead.