Core updates for Streaming Sortformer inference - #16032
Open
ipmedenn wants to merge 6 commits into
Open
Conversation
Signed-off-by: ipmedenn <65592416+ipmedenn@users.noreply.github.com>
Signed-off-by: ipmedenn <65592416+ipmedenn@users.noreply.github.com>
ipmedenn
marked this pull request as ready for review
August 5, 2026 17:10
ipmedenn
requested review from
nithinraok,
stevehuang52,
tango4j and
weiqingw4ng
August 5, 2026 17:11
ipmedenn
marked this pull request as draft
August 6, 2026 18:23
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>
ipmedenn
marked this pull request as ready for review
August 7, 2026 00:10
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 ?
This PR introduces a large set of mostly inference-side updates for the upcoming 8-speaker Sortformer model release.
The main new feature is high-resolution output. Previously, Sortformer prediction resolution was tied to the encoder resolution, which is 80 ms in the standard model configurations. High-resolution mode decouples the two: the encoder continues operating at its configured resolution, while a trainable subpixel upsampling layer produces predictions at a native 10 ms resolution. These predictions can then be returned at any configured multiple of 10 ms, such as 20, 30, 80, or 160 ms. Previously released models retain their existing output resolution and behavior by default.
To make training practical for higher speaker counts, PIL and ATS targets are now generated using Hungarian assignment instead of exhaustive permutation search.
Asynchronous inference has been substantially refactored and vectorized, improving efficiency and fixing the ragged-batch correctness issues described in #16002.
The PR also adds an optional learnable silence embedding for speaker-cache compression; improves the inference script with vectorized binarization and post-processing, profiling, prediction-tensor caching, and optional encoder compilation; and fixes streaming ONNX export.
Collection: ASR / Speaker diarization
Changelog
Output resolution
high_resolutionmode with a trainable subpixel upsampling layer that produces predictions at the preprocessor frame resolution (10 ms in the standard configurations).output_subsampling_factorto control the returned prediction frame step independently of the encoder subsampling factor.ParallelExpertEncoder.Sortformer model and training
hidden_to_spksmodule for checkpoint compatibility while freezing its unused parameters.transformer_encoderto be omitted from new model configurations.find_unused_parameters=True, allowing standard DDP.Streaming correctness and asynchronous inference
async_pad_to_maxbehavior to keep encoder input shapes fixed at their maximum capacity.async_desync_updatesbehavior to randomize initial FIFO eviction and stagger speaker-cache updates across batch rows.Inference utilities and export
save_preds_tensorsoption with the explicitout_preds_tensorscache path. Validate existing cache metadata and write new caches atomically; useoverwrite_preds_tensors=trueto replace an existing cache.e2e_diarize_speech.pyfrom FP32 to BF16. Setprecision=32to retain the previous behavior.torch.compilesupport for the encoder throughcompile_encoder.Unit tests
transformer_encoder;ParallelExpertEncoderoutput-resolution alignment;Usage
Model configuration
Existing Sortformer model configurations remain backward-compatible. When
high_resolutionis omitted or set tofalse, the native prediction resolution remains tied to the encoder subsampling factor, andoutput_subsampling_factordefaults to that same value.For a standard 10 ms preprocessor frame step, high-resolution training with 10 ms returned predictions can be configured as:
In high-resolution mode,
output_subsampling_factoris expressed in preprocessor frames. With a 10 ms preprocessor frame step, values of1,2,3,8, and16correspond to returned prediction steps of 10, 20, 30, 80, and 160 ms, respectively.By default, speaker-cache compression uses the running mean silence embedding. A learnable silence embedding can be enabled with:
For new architectures that do not require the secondary transformer encoder, the
transformer_encodersection may be omitted. Previously released model configurations containing this section continue to instantiate it normally.Streaming output constraints
Streaming output downsampling is applied independently to each chunk, so chunk boundaries must align with complete downsampling windows. Configurations whose chunk length is incompatible with
output_subsampling_factorare rejected with a descriptive error.Inference script options
The inference script
e2e_diarize_speech.pyprovides the following asynchronous-streaming, caching, and performance controls:async_streaming: trueenables asynchronous batched state updates;async_pad_to_maxandasync_desync_updatesonly affect this mode.async_pad_to_max: truekeeps encoder inputs at a fixed maximum shape, trading additional padded computation for stable input shapes.async_desync_updates: truerandomizes the initial FIFO eviction to stagger speaker-cache updates across batch rows.out_preds_tensorsspecifies a prediction-cache path and enables both loading and saving of prediction tensors. Existing caches are validated before reuse. Setoverwrite_preds_tensors: trueto recompute and replace an existing cache.The default inference precision is BF16. Set
precision: 32to retain the previous FP32 behavior.Setting
compile_encoder: trueappliestorch.compile(..., dynamic=True)to the encoder only; it does not compile the complete Sortformer model.Detailed inference profiling is enabled by default and can be disabled with
profile_inference: false.ONNX export
Streaming export uses a model-sized default input example, and callers may provide an explicit input example when different physical capacities are required.
The exported ONNX graph has a fixed batch size and fixed physical cache, FIFO, and chunk capacities. Their logical lengths may vary independently for each batch row at runtime, including empty, partially filled, and fully populated states.
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:
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