Reduce code duplication in audio collection + some small fixes#15587
Open
racoiaws wants to merge 13 commits intoNVIDIA-NeMo:mainfrom
Open
Reduce code duplication in audio collection + some small fixes#15587racoiaws wants to merge 13 commits intoNVIDIA-NeMo:mainfrom
racoiaws wants to merge 13 commits intoNVIDIA-NeMo:mainfrom
Conversation
Move component loss logging (train_loss_encoded, train_loss_time) into _step itself, so it returns a plain scalar like all other models. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Roman Korostik <rkorostik@nvidia.com>
Replace duplicated batch parsing and 2D-to-3D reshape logic across all 6 audio model subclasses with a single _parse_batch method on the base class. FlowMatchingAudioToAudioModel overrides it to allow missing target_signal for SSL pretraining. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Roman Korostik <rkorostik@nvidia.com>
Add abstract _compute_train_loss method that each subclass implements with its model-specific loss computation. The base class training_step handles batch parsing, logging, and return. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Roman Korostik <rkorostik@nvidia.com>
_step is called from both training and evaluation. The train_loss_encoded and train_loss_time logs should only fire during training. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Roman Korostik <rkorostik@nvidia.com>
…el.__init__ Both are set identically by all 6 subclasses. setup_optimization_flags only reads self._cfg, so it is safe to call before subclass-specific module initialization. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Roman Korostik <rkorostik@nvidia.com>
ModelPT.__init__ calls set_trainer → set_world_size before any data loader setup, so the pre-super assignment is always overwritten before it can be read. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Roman Korostik <rkorostik@nvidia.com>
Consistent with all other audio model subclasses which use self.from_config_dict rather than the concrete class name. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Roman Korostik <rkorostik@nvidia.com>
Now called from base __init__, no longer requires explicit subclass call. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Roman Korostik <rkorostik@nvidia.com>
Replace repeated normalize/denormalize boilerplate across 4 forward() and 3 _step() methods with calls to shared helpers on AudioToAudioModel. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Roman Korostik <rkorostik@nvidia.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Roman Korostik <rkorostik@nvidia.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Roman Korostik <rkorostik@nvidia.com>
The test calls _step directly, which now logs component losses via self.log. Disable logging in this test since there is no active Lightning loop context. Also update to use _parse_batch and the scalar return from _step. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Roman Korostik <rkorostik@nvidia.com>
pzelasko
reviewed
Apr 7, 2026
| _denormalize to restore the original scale. | ||
| """ | ||
| norm_scale = torch.amax(signal.abs(), dim=(-1, -2), keepdim=True) | ||
| return signal / (norm_scale + self.eps), norm_scale |
Collaborator
There was a problem hiding this comment.
Should the returned norm_scale include + self.eps for identical reverse operation?
Collaborator
Author
There was a problem hiding this comment.
Good catch
I'd prefer an explicit add in the reverse operation instead of baking it into norm_scale
_normalize divides by (norm_scale + eps), so _denormalize should multiply by (norm_scale + eps) to recover the original signal. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Roman Korostik <rkorostik@nvidia.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 ?
Reduce duplicated code across the 6 AudioToAudioModel subclasses by moving shared logic into the base class.
Collection: Audio
Changelog
Usage
# Add a code snippet demonstrating how to use thisGitHub 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:
PR Type:
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.