Repository navigation
Fix frozen RNG in Whisper temperature sampling - #1461
Open
PCcoding666 wants to merge 1 commit into
Open
PCcoding666 wants to merge 1 commit into
PCcoding666 wants to merge 1 commit into
Conversation
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.
Fixes #1460.
Whisper's compiled
categoricalsampler captured a random key when MLX traced the function and reused that key on later calls. This change passesmx.random.stateas both an input and an output ofmx.compile, the pattern already used by MusicGen in this repository.The new model-free regression test seeds MLX and compares two consecutive compiled draws and their final RNG state with eager
mx.random.categorical. It fails onmainbecause the second draw repeats the first and passes with this change.Tested on Apple Silicon
Apple M2 Pro, macOS 27.2, Python 3.12.9, MLX 0.32.4, Metal backend.
mlx_whisper.transcribeon the same 1.75-second synthetic clip at temperature 1 with five seeds. Onmain, only 1 of 40 sampler calls advanced the RNG, and all five runs returned the same tokens. With this change, all 45 calls advanced the RNG and the five runs produced four distinct transcripts. The output lengths varied, accounting for the different call counts.Prepared and tested with Codex assistance.