Skip to content

Script to migrate .nemo checkpoints that used torchaudio preprocessor#15437

Open
pzelasko wants to merge 5 commits intomainfrom
migrate-torchaudio-preproc-ckpt-script
Open

Script to migrate .nemo checkpoints that used torchaudio preprocessor#15437
pzelasko wants to merge 5 commits intomainfrom
migrate-torchaudio-preproc-ckpt-script

Conversation

@pzelasko
Copy link
Collaborator

Important

The Update branch button 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 ?

Script to migrate .nemo checkpoints that used torchaudio preprocessor

Collection: asr

Changelog

  • Script to migrate .nemo checkpoints that used torchaudio preprocessor

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this 

GitHub Actions CI

The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.

The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • New Feature
  • Bugfix
  • Documentation

If you haven't finished some of the above items you can still open "Draft" PR.

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

  • Related to # (issue)

Signed-off-by: Piotr Żelasko <petezor@gmail.com>
@blisc
Copy link
Collaborator

blisc commented Feb 25, 2026

Should we define a load_state_dict override inside of the AudioPreprocessor class that does this automatically if preprocessor.use_torchaudio=True or would you prefer to keep it as a separate helper script?
The current way is ok too so long as we fix the bug the bot mentioned.

pzelasko and others added 2 commits February 25, 2026 15:54
… during tarfile extraction

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Piotr Żelasko <petezor@gmail.com>
Signed-off-by: pzelasko <pzelasko@users.noreply.github.com>
@pzelasko
Copy link
Collaborator Author

Should we define a load_state_dict override inside of the AudioPreprocessor class that does this automatically if preprocessor.use_torchaudio=True or would you prefer to keep it as a separate helper script? The current way is ok too so long as we fix the bug the bot mentioned.

@blisc I want to minimize the core code complexity, this use-case seems niche enough that a migration script should be sufficient. I committed bot's suggested fix.

blisc
blisc previously approved these changes Feb 25, 2026
@pzelasko
Copy link
Collaborator Author

@MahmoudAshraf97 I see the approval but can you confirm that tested it on your checkpoints and it works OK?

@MahmoudAshraf97
Copy link
Contributor

fortunately you didn't take my approval for granted 😄 , it is not working due to a shape mismatch, I'll work on a solution and suggest it in a review

RuntimeError: Error(s) in loading state_dict for EncDecCTCModelBPE:
	size mismatch for preprocessor.featurizer.fb: copying a param with shape torch.Size([257, 80]) from checkpoint, the shape in current model is torch.Size([1, 80, 257]).

Copy link
Contributor

@MahmoudAshraf97 MahmoudAshraf97 left a comment

Choose a reason for hiding this comment

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

it's hardcoded but I don't think we need a generalized solution for this

Co-authored-by: Mahmoud Ashraf <hassouna97.ma@gmail.com>
Signed-off-by: Piotr Żelasko <petezor@gmail.com>
@pzelasko
Copy link
Collaborator Author

Applied your fix - can you confirm that it works correctly in this version @MahmoudAshraf97 ?

Signed-off-by: Piotr Żelasko <petezor@gmail.com>
@MahmoudAshraf97
Copy link
Contributor

it does, the converted model loads and infers successfully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants