android : fix CPU variant fallback returning LITTLE cluster count#3770
Open
jinweihan-ai wants to merge 1 commit into
Open
android : fix CPU variant fallback returning LITTLE cluster count#3770jinweihan-ai wants to merge 1 commit into
jinweihan-ai wants to merge 1 commit into
Conversation
The variant fallback in getHighPerfCpuCountByVariant() used countKeepingMin() while the primary frequency branch used countDroppingMin(). Both branches are meant to return the count of high-performance cores, so the asymmetry caused the variant branch to return the LITTLE cluster count instead. On big.LITTLE SoCs, when cpuinfo_max_freq is unreadable and the code falls back to CPU variant (verified by the reporter on Helio G85 in ggml-org#3602), whisper ends up running on the LITTLE cores and inference throughput roughly halves. Fix mirrors the suggestion in the issue: use countDroppingMin() in the variant branch, matching the frequency branch. Both the Kotlin (whisper.android) and Java (whisper.android.java) examples share the same asymmetry and are fixed together.
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
The variant fallback in
getHighPerfCpuCountByVariant()usedcountKeepingMin()while the primary frequency branch usedcountDroppingMin(). Both branches are meant to return the count of high-performance cores, so the asymmetry caused the variant branch to return the LITTLE cluster count instead of the big cluster.On big.LITTLE SoCs, when
/sys/devices/system/cpu/cpuN/cpufreq/cpuinfo_max_freqis unreadable (some restrictive Android distributions block it) and the code falls back toCPU variant, whisper ends up pinned to the LITTLE cores and inference throughput roughly halves.Verified on Helio G85 by the reporter of #3602.
The asymmetry
Before this PR, in both
WhisperCpuConfig.ktandCpuInfo.java:The two helpers are:
Fix
Swap
countKeepingMin()→countDroppingMin()in the variant branch of both the Kotlin (whisper.android) and Java (whisper.android.java) examples. Matches the suggestion in #3602.Test plan
countDroppingMin()— the fix restores symmetry rather than introducing a new behaviorFixes #3602