fix(adaptive): guard None history in convergence improvement delta - #541
Merged
Conversation
apply_convergence_marks computed the per-bucket round-over-round improvement as `hist[-2]["aggregated_uncertainty"] - hist[-1]["aggregated_uncertainty"]` with no None guard. aggregated_uncertainty is `float | None`: a bucket is None when the axis can't score that round — e.g. the utterance axis marks buckets comparison_status="incomparable" (-> None) when a window has no comparable ASR words, common on sparse/gappy speech. A bucket can flip None<->float across adaptive rounds (reprocessing adds/removes words), so its history can hold a None next to a float and the subtraction raises `TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'`, crashing the loop for the whole clip even though the *current* value is guarded a few lines up. Observed: adaptive_loop failed on 5/30 clips in a real batch — all sparse-speech (Word-color-Stroop, Random-Item-Generation, Story-recall, Picture-description), which have many incomparable utterance buckets. Fix: guard both history entries; if either is None we can't measure improvement across that round, so leave improvement=None (bucket stays open, not "stalled") rather than crashing. No behavior change when both rounds are scored. Same test blind spot as the sibling venv fixes: the adaptive tests don't exercise a clip with incomparable (None) buckets in the cross-round history. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jul 28, 2026
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.
Problem
apply_convergence_marks(adaptive/convergence.py) computed the per-bucket round-over-round improvement ashist[-2]["aggregated_uncertainty"] - hist[-1]["aggregated_uncertainty"]with noNoneguard.aggregated_uncertaintyisfloat | None— a bucket isNonewhen the axis can't score that round. The utterance axis marks a bucketcomparison_status="incomparable"(→None) when a window has no comparable ASR words, common on sparse/gappy speech. A bucket can flipNone↔floatacross adaptive rounds (reprocessing adds/removes words), so its history can hold aNonenext to afloat, and the subtraction raisesTypeError: unsupported operand type(s) for -: 'NoneType' and 'float'— crashing the loop for the whole clip, even though the current value is already guarded a few lines up (if u is None: continue).Impact:
adaptive_loopfailed on 5/30 clips in a real batch — all sparse-speech (Word-color-Stroop, Random-Item-Generation, Story-recall, Picture-description), which have many incomparable utterance buckets.Fix
Guard both history entries; if either round was
None, improvement is unmeasurable across it, so leaveimprovement=None(bucket staysopen, notstalled) instead of crashing. No behavior change when both rounds are scored.Testing gap
Same blind spot as the recent subprocess-venv fixes: the adaptive tests don't exercise a clip whose cross-round history contains incomparable (
None) buckets. A fixture with aNone→floathistory transition would regression-cover it.Base:
alpha.🤖 Generated with Claude Code
Version
Published prerelease version:
1.3.1-alpha.37Changelog
🐛 Bug Fix
Authors: 3