Fix Gemma 4 audio inference dtype mismatch - #308
#308Draft
Auro-rium wants to merge 1 commit into
unslothai:mainunslothai/notebooks:mainfrom
Auro-rium:agent/fix-gemma4-audio-dtypeAuro-rium/notebooks:agent/fix-gemma4-audio-dtypeCopy head branch name to clipboard
Draft
Fix Gemma 4 audio inference dtype mismatch#308Auro-rium wants to merge 1 commit intounslothai:mainunslothai/notebooks:mainfrom Auro-rium:agent/fix-gemma4-audio-dtypeAuro-rium/notebooks:agent/fix-gemma4-audio-dtypeCopy head branch name to clipboard
Auro-rium wants to merge 1 commit into
unslothai:mainunslothai/notebooks:mainfrom
Auro-rium:agent/fix-gemma4-audio-dtypeAuro-rium/notebooks:agent/fix-gemma4-audio-dtypeCopy head branch name to clipboard
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.
Summary
model.dtypebefore Gemma 4 generation.Root cause
The notebook moved processor outputs to CUDA but did not normalize floating-point dtypes. On a T4, Gemma 4 runs in FP16 while audio features can remain FP32, causing
masked_scatter_to fail with a Float/Half mismatch during multimodal fusion.Change
Updated the inference helper to use
.to("cuda", dtype=model.dtype). Integer token IDs remain integer tensors.Validation
git diff --checkpasses.Note
This patch was prepared with assistance from Codex.