Updates for Sortformer training - #16227
Conversation
Signed-off-by: ipmedenn <65592416+ipmedenn@users.noreply.github.com>
Signed-off-by: ipmedenn <65592416+ipmedenn@users.noreply.github.com>
Signed-off-by: ipmedenn <65592416+ipmedenn@users.noreply.github.com>
Signed-off-by: ipmedenn <65592416+ipmedenn@users.noreply.github.com>
Signed-off-by: ipmedenn <65592416+ipmedenn@users.noreply.github.com>
Signed-off-by: ipmedenn <65592416+ipmedenn@users.noreply.github.com>
Signed-off-by: ipmedenn <65592416+ipmedenn@users.noreply.github.com>
Signed-off-by: ipmedenn <65592416+ipmedenn@users.noreply.github.com>
Signed-off-by: ipmedenn <65592416+ipmedenn@users.noreply.github.com>
Signed-off-by: ipmedenn <65592416+ipmedenn@users.noreply.github.com>
Signed-off-by: ipmedenn <65592416+ipmedenn@users.noreply.github.com>
Signed-off-by: ipmedenn <65592416+ipmedenn@users.noreply.github.com>
Signed-off-by: ipmedenn <65592416+ipmedenn@users.noreply.github.com>
Signed-off-by: ipmedenn <65592416+ipmedenn@users.noreply.github.com>
Signed-off-by: ipmedenn <65592416+ipmedenn@users.noreply.github.com>
User-facing documentation for the new training workflow is planned as a follow-up PR. This PR includes docstrings and inline descriptions for the new configuration parameters, and I have noted the documentation follow-up in the PR description. |
Signed-off-by: ipmedenn <65592416+ipmedenn@users.noreply.github.com>
tango4j
left a comment
There was a problem hiding this comment.
Requesting changes to approve
| return preds | ||
| return torch.sigmoid(self.forward_speaker_logits(hidden_out)) | ||
|
|
||
| def forward_activity_logits(self, hidden_out: torch.Tensor) -> Optional[torch.Tensor]: |
There was a problem hiding this comment.
Add more description on the purpose of this function as one of the loss calculation heads
|
|
||
| def _get_aux_train_evaluations(self, preds, targets, target_lens) -> dict: | ||
| @staticmethod | ||
| def _speaker_count_metrics( |
There was a problem hiding this comment.
Please consider moving this to a stand-alone file in metrics folder.
tango4j
left a comment
There was a problem hiding this comment.
Please make the changes in loss folder's aux_diarization_loss.py
| import torch.nn.functional as F | ||
|
|
||
|
|
||
| def activity_loss( |
There was a problem hiding this comment.
This activity_loss should be a class method just like other loss *.py file.
This is because "loss" is always expected to be a class type that has type definitions and variable initializations.
Please follow the convention of: class name "ActivityLoss"
input_types
output_types
init
forward
It should be just like:
https://github.com/NVIDIA-NeMo/Speech/blob/main/nemo/collections/asr/losses/bce_loss.py
There was a problem hiding this comment.
Loss class should be referred as follows:
=========
activity_loss:
target: nemo.collections.asr.losses.aux_diarization_loss.ActivityLoss
reduction: mean
| return loss | ||
|
|
||
|
|
||
| def phantom_loss( |
There was a problem hiding this comment.
This is the same as activity_loss.
loss should not be a function.
In NeMo Speech, it is expected to be a class that has forward method.
Please follow the convention of having: class name "PhantomLoss"
input_types
output_types
init
forward
It should be just like:
https://github.com/NVIDIA-NeMo/Speech/blob/main/nemo/collections/asr/losses/bce_loss.py
There was a problem hiding this comment.
Loss class should be referred as follows:
=========
phantom_loss:
target: nemo.collections.asr.losses.aux_diarization_loss.PhantomLoss
reduction: mean
| loss: | ||
| _target_: nemo.collections.asr.losses.bce_loss.BCEWithLogitsLoss | ||
| reduction: mean | ||
|
|
There was a problem hiding this comment.
here, the following should be added:
activity_loss:
target: nemo.collections.asr.losses.aux_diarization_loss.ActivityLoss
reduction: mean
phantom_loss:
target: nemo.collections.asr.losses.aux_diarization_loss.PhantomLoss
reduction: mean
tango4j
left a comment
There was a problem hiding this comment.
Please construct the loss class as other loss files (just like bce_loss)
| loss: | ||
| _target_: nemo.collections.asr.losses.bce_loss.BCEWithLogitsLoss | ||
| reduction: mean | ||
|
|
There was a problem hiding this comment.
here, the following should be added:
activity_loss:
target: nemo.collections.asr.losses.aux_diarization_loss.ActivityLoss
reduction: mean
phantom_loss:
target: nemo.collections.asr.losses.aux_diarization_loss.PhantomLoss
reduction: mean
| return loss | ||
|
|
||
|
|
||
| def phantom_loss( |
There was a problem hiding this comment.
Loss class should be referred as follows:
=========
phantom_loss:
target: nemo.collections.asr.losses.aux_diarization_loss.PhantomLoss
reduction: mean
| import torch.nn.functional as F | ||
|
|
||
|
|
||
| def activity_loss( |
There was a problem hiding this comment.
Loss class should be referred as follows:
=========
activity_loss:
target: nemo.collections.asr.losses.aux_diarization_loss.ActivityLoss
reduction: mean
Signed-off-by: ipmedenn <65592416+ipmedenn@users.noreply.github.com>
tango4j
left a comment
There was a problem hiding this comment.
Changes are made exactly as requested.
|
/ok to test f497938 |
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 ?
This PR extends Sortformer training with the functionality required for offline and streaming 8-speaker diarization. It adds new training configurations, subsegment-based data sampling, logits-based and auxiliary losses, block-causal tail augmentation, speaker-counting metrics, and improvements to checkpoint handling and long-recording inference.
The existing probability-based
BCELossremains supported, and causal-tail augmentation is disabled by default.Collection: ASR, Speaker Tasks, Common
Changelog
init_from_nemo_modelconfiguration option for warm-starting selected model submodules from a.nemocheckpoint.max_stepswhen resuming.BCEWithLogitsLossand clean up the existing probability-basedBCELoss.TransformerEncoder: the prefix remains bidirectional, while each tail block attends to the prefix and preceding blocks but not future blocks. The augmentation is disabled by default, and validation and inference continue to use full attention.max_batch_durfeature extraction by processing duration-bounded sub-batches without repeated tensor concatenation, and warn when a single recording exceeds the limit.e2e_diarize_speech.py.Usage
The offline configuration is intended for the first training stage:
The streaming configuration is intended for the second training stage. The first-stage model can be specified through
init_from_nemo_modelin the configuration:python ./streaming_sortformer_diar_train.py \ --config-path='../conf/neural_diarizer' \ --config-name='sortformer_streaming_8spk.yaml' \ model.train_ds.manifest_filepath=/path/to/train_manifest.json \ model.validation_ds.manifest_filepath=/path/to/validation_manifest.jsone2e_diarize_speech.pycan load either a local checkpoint throughmodel_pathor a registered Hugging Face model throughpretrained_name:python ./e2e_diarize_speech.py \ pretrained_name='nvidia/diar_streaming_sortformer_4spk-v2.1' \ batch_size=1 \ dataset_manifest=/path/to/diarization_manifest.jsonGitHub 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:
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.
Additional Information