Repository navigation
Enables Windows ARM64 build with MSVC cl.exe - #28362
Conversation
|
Hi @sarahwu185, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
18eaa3a to
bce6a32
Compare
|
@ggerganov @sarahwu185 just for reference, I evaluated this PR with the PR-skill; as Are the correctness-remarks valid? If so, these should be fixed before merge. |
address CI comments fix cross compile issue remove warning fix style and fix fma probing fix style
|
Hello @aendk Thank you so much for the comments!
arm64ec is in fact reachable when user specify
We only need to widen
Yes, I have fixed this, now the warnings are gone.
Fixed.
This is correct. I have fixed this.
This one does not need to be changed. MSVC has syntax support for this. I iterated locally with Claude to PR review a few times and now there are still generated issues but they seem minor/inaccurate. I also tested the new changes locally and there is no functional/performance impact. Let me know if other changes are needed. |
|
Thanks for the fixes! |
aendk
left a comment
There was a problem hiding this comment.
Looks good to me after conducting some internal testing.
|
So please rebase again and then we can merge it. Thanks! |
* can reproduce the issue vlad sees * fix fma issue * drop volatile * fix volatile runtime task * add arm flag if needed * fix hsum compile error * fix syntax in quants * strengthen sve probing * make the syntax fixes one liners * remove debug code * formatting * remove macro for float * drive down gcc instruction count * support armec * fix CI comments address CI comments fix cross compile issue remove warning fix style and fix fma probing fix style * add documentation * update documentation (cherry picked from commit 0c6a6a7)
Overview
In the current flow on WoA systems the default is to build with the
arm64-windows-llvm-releasepreset, which requires developers to install clang when building MSVC. This PR allows developers to directly usecmake -B build -S . -DGGML_NATIVE=ONto build the project on WoA systems.In addition to build with ARM64EC, users can simply do
cmake -S . -B build_arm64ec -A ARM64ECAdditional information
For context, several MSVC gaps for NEON intrinsics were identified.
For item 2 and 3, we dropped the volatile keyword in cmake, and for 5 some corresponding cmake changes were added either during flag checking or when probing happens. Additional change is in quant.c to make the syntax conform to MSVC.
However, since item 1, 4 are still pending MSVC support, native MSVC build cannot turn on all of the arm intrinsics support as compared to clang build. So there is performance gap on the CPU backend.
Profiling results
For other systems (linux, x86_64 windows), we locally tested and saw no performance degradation between PR and master.
Local profiling MSVC build vs clang.exe build performance is also on par.
Another thing to note is that MSVC does not define
__NEON_ARMby default even though there is the arm neon header in MSVC. This means in quant.c, MSVC compiler will go through generic path when compiling. However, when I forcefully turn on this flag, I see an around 37% performance drop on CPU workloads. This is because MSVC already auto-vectorizes the generic C kernels when that header is not defined, defining the macros forces the compiler down the hand written intrinsics which is less performant.Future Works
While working on this, I found that
arm64-windows-llvm-releaseis still just defaulting to cross compile for WoA. This actually automatically turn off-DGGML_NATIVEand does not actually enable some of the arm intrinsics that clang allows.I think we will need more profiling work into whether we should switch on
__NEON_ARMfor MSVC or we should just let MSVC to auto-vectorize the instructions. Especially when more missing NEON intrinsics are support in MSVC in the future.Requirements