fix: AttributeError when spks=None in ConditionalCFM.solve_euler (issue #1854)#1856
Open
huyyxyshare wants to merge 2 commits intoFunAudioLLM:mainfrom
Open
fix: AttributeError when spks=None in ConditionalCFM.solve_euler (issue #1854)#1856huyyxyshare wants to merge 2 commits intoFunAudioLLM:mainfrom
huyyxyshare wants to merge 2 commits intoFunAudioLLM:mainfrom
Conversation
added 2 commits
March 18, 2026 14:13
- Changed mask logic from '== IGNORE_ID' to '!= IGNORE_ID' - Fixed gather index to use '~mask' for padding positions - This ensures DPO loss is computed on valid tokens only, not IGNORE_ID positions
FunAudioLLM#1854) - Use x.dtype as fallback when spks is None to avoid AttributeError - This prevents 'NoneType' object has no attribute 'dtype' error
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
Fix a critical bug in cosyvoice/flow/flow_matching.py that causes an AttributeError when the spks parameter is None.
Bug Description
The forward method accepts spks=None as a default value, but in the solve_euler method, lines 95-100 directly use spks.dtype without checking if spks is None.
Fix
Use x.dtype as a fallback when spks is None to avoid AttributeError.