fix(diarization): scale known-speaker clustering for long audio - #3516
Merged
LauraGPT merged 1 commit intoAug 20, 2026
Merged
Conversation
LauraGPT
approved these changes
Aug 20, 2026
LauraGPT
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed exact head 9dbf3e1c0858706b98baebeca89b4b428855cc2f against main@bff70399427fe5a06ea5244d1410dd729efe462e.
- The base regression fails because
N=2048with a known speaker count still enters dense spectral clustering. - The two new focused tests pass on the PR head.
- The related server, realtime, and clustering suite passes: 82/82.
python -m compileall -q funasr examples testspasses.- A synthetic
10639 x 192,K=2case completes in 0.171 seconds and returns the expected two clusters. - Production callers pass CPU tensors, and the backend still returns NumPy labels.
The change preserves small-input spectral clustering and large-input unknown-count UMAP/HDBSCAN routing. Approved.
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.
Summary
Closes #3514.
When
preset_spk_numis set,ClusterBackendcurrently sends every input size through spectral clustering. For long recordings this bypasses the existing 2,048-embedding safeguard and builds an O(N²) dense affinity/Laplacian matrix before an O(N³) eigendecomposition.This change keeps the existing dispatch for small inputs and for large inputs with an unknown speaker count, while adding a bounded-memory fixed-K path for large inputs with a known count:
oracle_num.Type of change
Validation
python -m compileall funasr examples testsCommands and results:
pytest -q tests/test_cluster_backend.py tests/test_top_level_import.py— 3 passedpython -m build— sdist and wheel built successfullyfunasr --help— CLI started successfullyoracle_num=2: the fullClusterBackendpath completed in 0.098 seconds on CPU, returned exactly two clusters, and separated the two cosine clusters with 100% purity.The dispatch regression fails on the previous implementation because it observes a call to dense spectral clustering at the 2,048 boundary.
User impact
Users can provide
preset_spk_numfor long recordings without turning a scalable clustering path into an effectively unbounded dense eigendecomposition. Small-recording behavior and automatic speaker-count behavior remain unchanged.Notes for reviewers
The 2,048 threshold is not changed. The new tests cover both dispatch at the threshold and the actual fixed-K clustering result. The implementation uses the existing scikit-learn dependency and does not add a package or public API.