fix: stop DER frame counts from saturating float16 - #2043
Open
Atishyy27 wants to merge 1 commit into
Open
Conversation
Reference and hypothesis are cast to float16 before the frame counts are computed, and np.sum accumulates in the array dtype. float16 tops out at 65504, so on a recording with more active frames than that the total saturates to infinity and the error rate is reported as 0.0. At the usual frame resolution that threshold is reached after about 18 minutes of single-speaker speech, so most real recordings are affected and a wrong output silently scores as a perfect one. Accumulate the frame counts in float64. The float16 cast is left alone, so the comparison and memory behaviour are unchanged. The same function also divided by the total without checking it, so a reference containing no speech produced inf or nan. Route the three divisions through a helper that follows the convention already used by pyannote.metrics.detection: an empty reference scores 0 when nothing was detected either, and 1 otherwise.
Atishyy27
force-pushed
the
fix/der-frame-count-overflow
branch
from
July 30, 2026 08:53
1b1f0c7 to
5e402a8
Compare
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.
Closes #2042.
discrete_diarization_error_ratecasts reference and hypothesis tonp.halfbefore counting frames, andnp.sumaccumulates in the array dtype. float16 tops out at 65504, so on a recording with more active frames than that the total saturates toinfand the error rate is reported as0.0, roughly 18 minutes of single-speaker speech at the usual frame resolution, so most real recordings are affected, and a wrong output silently scores as a perfect one.This accumulates the frame counts in float64. The
np.halfcast is left in place, so the comparison and memory behaviour are unchanged.The same function divided by the total without checking it, so a reference with no speech gave
infornan(reported in #1790, closed unfixed). The three divisions now go through a small helper that follows the convention already used bypyannote.metrics.detection: an empty reference scores 0 when nothing was detected either, and 1 otherwise.Testing
Two tests in
tests/test_metrics.py, both failing ondevelop:test_discrete_der_long_recording_does_not_overflow: 450000 frames (about two hours) with 1000 false-alarm frames. Returns0.0withtotal = infbefore,0.00222withtotal = 450000.0after.test_discrete_der_empty_reference: an all-zero reference returnsnan/infbefore,0.0/1.0after.Also checked that a short recording is unaffected: 1000 frames with 100 false-alarm frames gives
0.1before and after.