Add per-stream speaker limits to Sortformer sessions - #16210
Open
tianyi-zhang-02 wants to merge 7 commits into
Open
Add per-stream speaker limits to Sortformer sessions#16210tianyi-zhang-02 wants to merge 7 commits into
tianyi-zhang-02 wants to merge 7 commits into
Conversation
Signed-off-by: Tianyi Zhang <123608656+tianyi-zhang-02@users.noreply.github.com>
Signed-off-by: Tianyi Zhang <123608656+tianyi-zhang-02@users.noreply.github.com>
Signed-off-by: Tianyi Zhang <123608656+tianyi-zhang-02@users.noreply.github.com>
Signed-off-by: Tianyi Zhang <123608656+tianyi-zhang-02@users.noreply.github.com>
tianyi-zhang-02
marked this pull request as ready for review
September 2, 2026 21:05
Signed-off-by: Tianyi Zhang <123608656+tianyi-zhang-02@users.noreply.github.com>
Signed-off-by: Tianyi Zhang <123608656+tianyi-zhang-02@users.noreply.github.com>
Signed-off-by: Tianyi Zhang <123608656+tianyi-zhang-02@users.noreply.github.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
This PR is intentionally stacked on #16174. Both branches include current
main(de26b3696); please do not use the Update branch button.What does this PR do?
Add a fixed per-session or per-row speaker-channel limit to raw-audio Sortformer streaming sessions.
Collection: ASR / Speaker Tasks
Changelog
max_speakerstocreate_streaming_session()as a scalar, per-row sequence, or integer tensor.StreamingSortformerStateacross reset/device moves.mean_sil_embwithout allowing that channel to mutate cache/output state.max_speakers=None.Usage
Motivation and semantics
Output-only masking is insufficient because disabled predictions can affect later chunks through FIFO and speaker-cache state. Masking before every state update fixes that, but it must not turn a speech frame into apparent silence. The implementation therefore separates the two concerns: masked predictions drive output/cache state, while pre-mask activity is consulted only when deciding whether a popped frame is truly silent.
Closes #15711.
Dependency
This is stacked on #16174, which introduces the raw-audio
SortformerStreamingSession. The current head includes #16174 at58357154cand the feature/fix atb07e61e90.Testing
[3, 5]; the fixed path counts only the true silence frame with mean[5, 7].pytest -q tests/collections/speaker_tasks/test_diar_sortformer_models.py tests/collections/speaker_tasks/test_diar_sortformer_modules.py tests/collections/speaker_tasks/utils/test_sortformer_utils.py --cpu— 228 passed.pre-commit run --files ...on the five changed files.git diff --check.b07e61e90passed 13/13 named CUDA checks on RTX 4090 / SM89 with Python 3.13.14, PyTorch 2.11.0+cu130, and CUDA 13.0. The deterministic sync/async controls reproduced the mask-only pollution and verified the corrected silence mean on CUDA.nvidia/diar_streaming_sortformer_4spk-v2.1checkpoint and exercised a heterogeneous[2, 4]batch with staggered chunks, early row-0 finalization, and later zero-length row-0 input. Across 16 asynchronous updates, row 0's disabled output/FIFO/cache channels stayed exact zero, row 1 retained channels 2/3, pre-mask activity reached the dedicated silence path, and all inspected state/update tensors were oncuda:0.The official-checkpoint smoke used synthetic audio and did not itself produce a disabled-only frame above the silence threshold. The triggering-state proof comes from the deterministic CUDA controls; the reporter's 8.1% to 6.7% DER measurement is not claimed here because their audio and downstream pipeline are unavailable.
Before your PR is "Ready for review"
Pre checks:
PR Type:
Additional Information