-
Notifications
You must be signed in to change notification settings - Fork 11.6k
ggml : fix arm build #10890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ggml : fix arm build #10890
Conversation
Signed-off-by: Adrien Gallouët <[email protected]>
Signed-off-by: Adrien Gallouët <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good:
- M1 Pro
-- ARM detected
-- Performing Test COMPILER_SUPPORTS_FP16_FORMAT_I3E
-- Performing Test COMPILER_SUPPORTS_FP16_FORMAT_I3E - Failed
-- Performing Test GGML_COMPILER_SUPPORT_DOTPROD
-- Performing Test GGML_COMPILER_SUPPORT_DOTPROD - Success
-- Performing Test GGML_COMPILER_SUPPORT_I8MM
-- Performing Test GGML_COMPILER_SUPPORT_I8MM - Failed
-- ARM feature DOTPROD enabled
-- ARM feature FMA enabled
-- ARM feature FP16_VECTOR_ARITHMETIC enabled
-- Adding CPU backend variant ggml-cpu: -march=native+dotprod __ARM_FEATURE_DOTPROD
- M2 Ultra
-- ARM detected
-- Performing Test COMPILER_SUPPORTS_FP16_FORMAT_I3E
-- Performing Test COMPILER_SUPPORTS_FP16_FORMAT_I3E - Failed
-- Performing Test GGML_COMPILER_SUPPORT_DOTPROD
-- Performing Test GGML_COMPILER_SUPPORT_DOTPROD - Success
-- Performing Test GGML_COMPILER_SUPPORT_I8MM
-- Performing Test GGML_COMPILER_SUPPORT_I8MM - Success
-- ARM feature DOTPROD enabled
-- ARM feature MATMUL_INT8 enabled
-- ARM feature FMA enabled
-- ARM feature FP16_VECTOR_ARITHMETIC enabled
-- Adding CPU backend variant ggml-cpu: -march=native+dotprod+i8mm __ARM_FEATURE_DOTPROD;__ARM_FEATURE_MATMUL_INT8
Note: llamafile sgemm uses |
Just for information, that way we need to check all required features as
while
|
Ok, it is using |
And many other flags too, especially for cross-compilation, that's why I think we should have a generic flag setting when |
Which flags are you thinking about? |
Sometimes we need to force Cross-compiling is always complicated anyway, some iterations will be needed so having a generic flag could help. |
It might make more sense to pass these kind of flags with |
On Android termux Snapdragon 8 gen 1 gives With this commit it produces unusable binaries. cat /proc/cpuinfo processor : 1 processor : 2 processor : 3 processor : 4 processor : 5 processor : 6 processor : 7 |
I encounterred the error "Failed to get ARM features" when I tried to compile the Android example with this build. |
#On Android termux Snapdragon 8 gen 1 gives With Snapdragon 8 gen 1 I can only build with -march=native+nosve . Seems like it's sve implementation is bad. |
Maybe we could add more tests for features (SVE), and disable them explicitly with the |
* ggml: GGML_NATIVE uses -mcpu=native on ARM Signed-off-by: Adrien Gallouët <[email protected]> * ggml: Show detected features with GGML_NATIVE Signed-off-by: Adrien Gallouët <[email protected]> * remove msvc support, add GGML_CPU_ARM_ARCH option * disable llamafile in android example * march -> mcpu, skip adding feature macros ggml-ci --------- Signed-off-by: Adrien Gallouët <[email protected]> Co-authored-by: Adrien Gallouët <[email protected]>
Hey @slaren , @ggerganov , I see that MSVC support for ARM was removed in this PR. Is there any plan to bring it back in the future or what was the reason for this removal? Thank you! Couldn't make it work yet with the LLVM / Clang (tried with both Ninja Generator and VS generator). |
MSVC does not support inline assembly that is used for some ARM kernels. You will get worse performance, and clang is widely available alongside VS, so I don't think it is worth the effort that it takes to continue supporting MSVC. |
Thanks for the quick response! Will continue the effort to switch to clang for my ARM builds. Is there any plan to do the same for other arch? |
I don't intend to remove MSVC support for x86, but using clang is still a good idea, performance tends to be slightly better, but there is no inline assembly in the x86 code, so the difference won't be as significant. |
Short update:
Reverting to MSVC fixes the problem: https://github.com/sandrohanea/whisper.net/actions/runs/12733915488 with only commit change being: sandrohanea/whisper.net@288ce85 Unfortunately, I don't have an arm64 machine / agent to test if the deadlock is reproducing for arm64 builds of clang. Do you have any idea what can cause the deadlock for clang builds? |
* ggml: GGML_NATIVE uses -mcpu=native on ARM Signed-off-by: Adrien Gallouët <[email protected]> * ggml: Show detected features with GGML_NATIVE Signed-off-by: Adrien Gallouët <[email protected]> * remove msvc support, add GGML_CPU_ARM_ARCH option * disable llamafile in android example * march -> mcpu, skip adding feature macros ggml-ci --------- Signed-off-by: Adrien Gallouët <[email protected]> Co-authored-by: Adrien Gallouët <[email protected]>
* ggml: GGML_NATIVE uses -mcpu=native on ARM Signed-off-by: Adrien Gallouët <[email protected]> * ggml: Show detected features with GGML_NATIVE Signed-off-by: Adrien Gallouët <[email protected]> * remove msvc support, add GGML_CPU_ARM_ARCH option * disable llamafile in android example * march -> mcpu, skip adding feature macros ggml-ci --------- Signed-off-by: Adrien Gallouët <[email protected]> Co-authored-by: Adrien Gallouët <[email protected]>
-mcpu=native
withGGML_NATIVE
for arm, but additionally check for dotprod and i8mm because not every compiler enables themGGML_CPU_ARM_ARCH
that can be used to specify the architecture whenGGML_NATIVE
is disabledGGML_SVE
, use-DGGML_NATIVE=OFF -DGGML_CPU_ARM_ARCH=armv8.6-a+sve
for the same effectggml_backend_cpu_get_features
Supersedes #10752