Skip to content

Conversation

@hinriksnaer
Copy link
Contributor

@hinriksnaer hinriksnaer commented May 19, 2025

Summary

In accordance with the following ticket, we want to enable building the torchao kernel through the main ExecuTorch CMakeLists.txt. This PR should cover all the necessary steps required to build low-bit kernels on the iOS app.

List of changes

  • Provide an optional flag EXECUTORCH_BUILD_KERNELS_TORCHAO that enables building torchao through the CMakeLists.txt.
  • Update the apple framework script to include the torchao build.
  • Updated the apple framework defaults to include torchao.

Test plan

  • Code has been successfully tested on the iPhone 16 simulator

@pytorch-bot
Copy link

pytorch-bot bot commented May 19, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/10963

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure

As of commit 935da89 with merge base da0c80a (image):

NEW FAILURE - The following job has failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot
Copy link
Contributor

Hi @hinriksnaer!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@github-actions
Copy link

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:.

If not, please add the release notes: none label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 19, 2025
CMakeLists.txt Outdated
)
target_link_options_shared_lib(torchao_ops_executorch)
list(APPEND link_libraries torchao_ops_executorch)
if(EXECUTORCH_BUILD_MPS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hinriksnaer let's remove the section on EXECUTORCH_BUILD_MPS for now.

CMakeLists.txt Outdated
${CMAKE_CURRENT_BINARY_DIR}/third-party/ao/torchao/experimental
)
target_link_options_shared_lib(torchao_ops_executorch)
list(APPEND link_libraries torchao_ops_executorch)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think link_libraries is not defined here. What we need to do to register the kernels is to link the kernel library torchao_ops_executorch against the ET library.

In the llama example, this is done by linking the op library against the llama runner executable here: https://github.com/pytorch/executorch/blob/main/examples/models/llama/CMakeLists.txt#L223.

But here, we don't have an executable, so we need to modify the logic slightly. We should link against executorch_core to register the kernels. See how kernels_custom does it. From https://github.com/pytorch/executorch/blob/main/CMakeLists.txt#L666-L669 it calls this: https://github.com/pytorch/executorch/blob/main/extension/llm/custom_ops/CMakeLists.txt#L78 for similar logic.

If it worked correctly, you should be able to follow the steps here: https://github.com/pytorch/executorch/blob/main/examples/models/llama/README.md#running-with-low-bit-kernels

But instead of building the kernels as part of the application in (by pasing -DEXECUTORCH_BUILD_TORCHAO=ON in step 2), we should be able to pass (-DEXECUTORCH_BUILD_KERNELS_TORCHAO=ON in step1 when we build executorch and not pass anything in step2).

cc @larryliu0820 if he has any other thoughts here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep let’s do what @metascroy said

libquantized_ops_lib.a,\
:"

FRAMEWORK_KERNELS_TORCHAO="kernels_torchao:\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before testing xcframework, let's verify your changes work on macOS desktop first.

@metascroy
Copy link
Contributor

Thanks @hinriksnaer! Left a few minor comments/questions and tagged @shoumikhin to look at xcframework changes.

I also kicked off the CI jobs for your PR.

Copy link
Contributor

@shoumikhin shoumikhin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding AO kernels!

A sanity check, do they really deserve a separate deliverable, or could be a part of kernels_optimized framework?

Also, notice the Package.swift has to be updated, as well as .Package.swift dir, and the corresponding files on the "swiftpm" branch.

echo -e "\033[31m[error] unknown option: ${arg}\033[0m"
exit 1
;;
-h | --help) usage ;;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: need to change the indentation?

-DCMAKE_BUILD_TYPE="${mode}" \
${CMAKE_OPTIONS_OVERRIDE[@]:-} \
--preset "${preset}"
-B "${preset_output_dir}" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: restore indentation?

//extension/module: \
//extension/tensor: \
| rsync -av --files-from=- "$SOURCE_ROOT_DIR" "$HEADERS_ABSOLUTE_PATH/executorch"
//extension/tensor: |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert?

cp "$SOURCE_ROOT_DIR/extension/apple/ExecuTorch/Exported/"*.h "$HEADERS_ABSOLUTE_PATH/executorch"

cat > "$HEADERS_ABSOLUTE_PATH/module.modulemap" << 'EOF'
cat >"$HEADERS_ABSOLUTE_PATH/module.modulemap" <<'EOF'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: restore formatting?

name=$(echo "$framework" | cut -d: -f1)
spec=$(echo "$framework" | cut -d: -f2-)
framework="${name}_$(echo "$mode" | tr '[:upper:]' '[:lower:]'):${spec}"
local name spec
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: restore indentation?

@@ -0,0 +1,34 @@
ET_PLATFORM[sdk=iphonesimulator*] = simulator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is not needed.

@metascroy
Copy link
Contributor

Thanks for adding AO kernels!

A sanity check, do they really deserve a separate deliverable, or could be a part of kernels_optimized framework?

Also, notice the Package.swift has to be updated, as well as .Package.swift dir, and the corresponding files on the "swiftpm" branch.

A sanity check, do they really deserve a separate deliverable, or could be a part of kernels_optimized framework?

Given their more experimental status, I think it makes sense for them to be separate, but maybe in future we fold into kernels_optimized?

@@ -0,0 +1,23 @@
# No quantization
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hinriksnaer this file should be removed. It looks like it is just for testing?

CMakeLists.txt Outdated
set(EXECUTORCH_LIBRARIES executorch pthreadpool extension_threadpool cpuinfo)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third-party/ao/torchao/experimental)
target_link_options_shared_lib(torchao_ops_executorch)
Copy link
Contributor

@metascroy metascroy Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hinriksnaer it looks like "target_link_options_shared_lib" was renamed to "executorch_target_link_options_shared_lib"?

endif()
endforeach()

# TODO: investigate use of install(EXPORT) to cleanly handle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hinriksnaer it looks like this file was cleaned up on main (see https://github.com/pytorch/executorch/blob/main/tools/cmake/executorch-config.cmake), and your PR is including the previous state.

I think the only changes needed now are lines 87/88.

list(APPEND TORCHAO_INCLUDE_DIRS
${EXECUTORCH_ROOT}/backends/xnnpack/third-party/pthreadpool/include
${EXECUTORCH_ROOT}/backends/xnnpack/third-party/cpuinfo/include
${EXECUTORCH_ROOT}/third-party/ao
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What adding "${EXECUTORCH_ROOT}/third-party/ao" necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing it caused the build process to fail.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the failure?

Copy link
Contributor Author

@hinriksnaer hinriksnaer Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the bottom of the terminal output

CompileC /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/quantize.o /Users/softmax/Documents/projects/executorch/third-party/ao/torchao/experimental/kernels/cpu/aarch64/quantization/quantize.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'torchao_kernels_aarch64' from project 'executorch')
    cd /Users/softmax/Documents/projects/executorch

    Using response file: /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/82b82416624d2658e5098eb0a28c15c5-common-args.resp

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -ivfsstatcache /var/folders/cq/9bb9rdrs2jvcv_9rk42bk3h80000gn/C/com.apple.DeveloperTools/16.3-16E140/Xcode/SDKStatCaches.noindex/iphoneos18.4-22E235-a09501eccf75f892bc376f81961b27ba.sdkstatcache -fmessage-length\=214 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -fcolor-diagnostics -Wno-trigraphs -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -Wno-implicit-fallthrough -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -Wno-sign-conversion -Wno-infinite-recursion -Wno-move -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-range-loop-analysis -Wno-semicolon-before-method-body -Wall -Werror -Wno-deprecated -Wno-shorten-64-to-32 @/Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/82b82416624d2658e5098eb0a28c15c5-common-args.resp -MMD -MT dependencies -MF /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/quantize.d --serialize-diagnostics /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/quantize.dia -c /Users/softmax/Documents/projects/executorch/third-party/ao/torchao/experimental/kernels/cpu/aarch64/quantization/quantize.cpp -o /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/quantize.o
/Users/softmax/Documents/projects/executorch/third-party/ao/torchao/experimental/kernels/cpu/aarch64/quantization/quantize.cpp:9:10: fatal error:
      'torchao/experimental/kernels/cpu/aarch64/quantization/quantize.h' file not found
    9 | #include <torchao/experimental/kernels/cpu/aarch64/quantization/quantize.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


CompileC /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/interleave.o /Users/softmax/Documents/projects/executorch/third-party/ao/torchao/experimental/kernels/cpu/aarch64/valpacking/interleave.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'torchao_kernels_aarch64' from project 'executorch')
    cd /Users/softmax/Documents/projects/executorch

    Using response file: /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/82b82416624d2658e5098eb0a28c15c5-common-args.resp

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -ivfsstatcache /var/folders/cq/9bb9rdrs2jvcv_9rk42bk3h80000gn/C/com.apple.DeveloperTools/16.3-16E140/Xcode/SDKStatCaches.noindex/iphoneos18.4-22E235-a09501eccf75f892bc376f81961b27ba.sdkstatcache -fmessage-length\=214 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -fcolor-diagnostics -Wno-trigraphs -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -Wno-implicit-fallthrough -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -Wno-sign-conversion -Wno-infinite-recursion -Wno-move -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-range-loop-analysis -Wno-semicolon-before-method-body -Wall -Werror -Wno-deprecated -Wno-shorten-64-to-32 @/Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/82b82416624d2658e5098eb0a28c15c5-common-args.resp -MMD -MT dependencies -MF /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/interleave.d --serialize-diagnostics /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/interleave.dia -c /Users/softmax/Documents/projects/executorch/third-party/ao/torchao/experimental/kernels/cpu/aarch64/valpacking/interleave.cpp -o /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/interleave.o
/Users/softmax/Documents/projects/executorch/third-party/ao/torchao/experimental/kernels/cpu/aarch64/valpacking/interleave.cpp:7:10: fatal error:
      'torchao/experimental/kernels/cpu/aarch64/valpacking/valpack.h' file not found
    7 | #include <torchao/experimental/kernels/cpu/aarch64/valpacking/valpack.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


CompileC /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/find_min_and_max.o /Users/softmax/Documents/projects/executorch/third-party/ao/torchao/experimental/kernels/cpu/aarch64/reduction/find_min_and_max.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'torchao_kernels_aarch64' from project 'executorch')
    cd /Users/softmax/Documents/projects/executorch

    Using response file: /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/82b82416624d2658e5098eb0a28c15c5-common-args.resp

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -ivfsstatcache /var/folders/cq/9bb9rdrs2jvcv_9rk42bk3h80000gn/C/com.apple.DeveloperTools/16.3-16E140/Xcode/SDKStatCaches.noindex/iphoneos18.4-22E235-a09501eccf75f892bc376f81961b27ba.sdkstatcache -fmessage-length\=214 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -fcolor-diagnostics -Wno-trigraphs -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -Wno-implicit-fallthrough -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -Wno-sign-conversion -Wno-infinite-recursion -Wno-move -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-range-loop-analysis -Wno-semicolon-before-method-body -Wall -Werror -Wno-deprecated -Wno-shorten-64-to-32 @/Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/82b82416624d2658e5098eb0a28c15c5-common-args.resp -MMD -MT dependencies -MF /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/find_min_and_max.d --serialize-diagnostics /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/find_min_and_max.dia -c /Users/softmax/Documents/projects/executorch/third-party/ao/torchao/experimental/kernels/cpu/aarch64/reduction/find_min_and_max.cpp -o /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/find_min_and_max.o
/Users/softmax/Documents/projects/executorch/third-party/ao/torchao/experimental/kernels/cpu/aarch64/reduction/find_min_and_max.cpp:9:10: fatal error:
      'torchao/experimental/kernels/cpu/aarch64/reduction/reduction.h' file not found
    9 | #include <torchao/experimental/kernels/cpu/aarch64/reduction/reduction.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Libtool /Users/softmax/Documents/projects/executorch/cmake-out/ios/Release/libabsl_utf8_for_code_point.a normal (in target 'utf8_for_code_point' from project 'executorch')
    cd /Users/softmax/Documents/projects/executorch
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -arch_only arm64 -D -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.4.sdk -L/Users/softmax/Documents/projects/executorch/cmake-out/ios/Release -filelist /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/utf8_for_code_point.build/Release-iphoneos/Objects-normal/arm64/absl_utf8_for_code_point.LinkFileList -dependency_info /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/utf8_for_code_point.build/Release-iphoneos/Objects-normal/arm64/absl_utf8_for_code_point_libtool_dependency_info.dat -o /Users/softmax/Documents/projects/executorch/cmake-out/ios/Release/libabsl_utf8_for_code_point.a

CompileC /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/compute_sum.o /Users/softmax/Documents/projects/executorch/third-party/ao/torchao/experimental/kernels/cpu/aarch64/reduction/compute_sum.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'torchao_kernels_aarch64' from project 'executorch')
    cd /Users/softmax/Documents/projects/executorch

    Using response file: /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/82b82416624d2658e5098eb0a28c15c5-common-args.resp

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -ivfsstatcache /var/folders/cq/9bb9rdrs2jvcv_9rk42bk3h80000gn/C/com.apple.DeveloperTools/16.3-16E140/Xcode/SDKStatCaches.noindex/iphoneos18.4-22E235-a09501eccf75f892bc376f81961b27ba.sdkstatcache -fmessage-length\=214 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -fcolor-diagnostics -Wno-trigraphs -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -Wno-implicit-fallthrough -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -Wno-sign-conversion -Wno-infinite-recursion -Wno-move -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-range-loop-analysis -Wno-semicolon-before-method-body -Wall -Werror -Wno-deprecated -Wno-shorten-64-to-32 @/Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/82b82416624d2658e5098eb0a28c15c5-common-args.resp -MMD -MT dependencies -MF /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/compute_sum.d --serialize-diagnostics /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/compute_sum.dia -c /Users/softmax/Documents/projects/executorch/third-party/ao/torchao/experimental/kernels/cpu/aarch64/reduction/compute_sum.cpp -o /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/compute_sum.o

CompileC /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/tokenizers.build/Release-iphoneos/Objects-normal/arm64/unicode.o /Users/softmax/Documents/projects/executorch/extension/llm/tokenizers/third-party/llama.cpp-unicode/src/unicode.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'tokenizers' from project 'executorch')
    cd /Users/softmax/Documents/projects/executorch

    Using response file: /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/tokenizers.build/Release-iphoneos/Objects-normal/arm64/82b82416624d2658e5098eb0a28c15c5-common-args.resp

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -ivfsstatcache /var/folders/cq/9bb9rdrs2jvcv_9rk42bk3h80000gn/C/com.apple.DeveloperTools/16.3-16E140/Xcode/SDKStatCaches.noindex/iphoneos18.4-22E235-a09501eccf75f892bc376f81961b27ba.sdkstatcache -fmessage-length\=214 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -fcolor-diagnostics -Wno-trigraphs -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -Wno-implicit-fallthrough -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -Wno-sign-conversion -Wno-infinite-recursion -Wno-move -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-range-loop-analysis -Wno-semicolon-before-method-body -Wno-attributes @/Users/softmax/Documents/projects/executorch/cmake-out/ios/build/tokenizers.build/Release-iphoneos/Objects-normal/arm64/82b82416624d2658e5098eb0a28c15c5-common-args.resp -MMD -MT dependencies -MF /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/tokenizers.build/Release-iphoneos/Objects-normal/arm64/unicode.d --serialize-diagnostics /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/tokenizers.build/Release-iphoneos/Objects-normal/arm64/unicode.dia -c /Users/softmax/Documents/projects/executorch/extension/llm/tokenizers/third-party/llama.cpp-unicode/src/unicode.cpp -o /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/tokenizers.build/Release-iphoneos/Objects-normal/arm64/unicode.o

CompileC /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/tokenizers.build/Release-iphoneos/Objects-normal/arm64/unicode-data.o /Users/softmax/Documents/projects/executorch/extension/llm/tokenizers/third-party/llama.cpp-unicode/src/unicode-data.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'tokenizers' from project 'executorch')
    cd /Users/softmax/Documents/projects/executorch

    Using response file: /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/tokenizers.build/Release-iphoneos/Objects-normal/arm64/82b82416624d2658e5098eb0a28c15c5-common-args.resp

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -ivfsstatcache /var/folders/cq/9bb9rdrs2jvcv_9rk42bk3h80000gn/C/com.apple.DeveloperTools/16.3-16E140/Xcode/SDKStatCaches.noindex/iphoneos18.4-22E235-a09501eccf75f892bc376f81961b27ba.sdkstatcache -fmessage-length\=214 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -fcolor-diagnostics -Wno-trigraphs -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -Wno-implicit-fallthrough -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -Wno-sign-conversion -Wno-infinite-recursion -Wno-move -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-range-loop-analysis -Wno-semicolon-before-method-body -Wno-attributes @/Users/softmax/Documents/projects/executorch/cmake-out/ios/build/tokenizers.build/Release-iphoneos/Objects-normal/arm64/82b82416624d2658e5098eb0a28c15c5-common-args.resp -MMD -MT dependencies -MF /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/tokenizers.build/Release-iphoneos/Objects-normal/arm64/unicode-data.d --serialize-diagnostics /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/tokenizers.build/Release-iphoneos/Objects-normal/arm64/unicode-data.dia -c /Users/softmax/Documents/projects/executorch/extension/llm/tokenizers/third-party/llama.cpp-unicode/src/unicode-data.cpp -o /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/tokenizers.build/Release-iphoneos/Objects-normal/arm64/unicode-data.o

note: Run script build phase 'Generate third-party/CMakeFiles/flatcc_external_project' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'flatcc_external_project' from project 'executorch')
note: Run script build phase 'Generate third-party/CMakeFiles/flatbuffers_external_project' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'flatbuffers_external_project' from project 'executorch')
note: Run script build phase 'Generate CMakeFiles/ZERO_CHECK' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'ZERO_CHECK' from project 'executorch')
note: Run script build phase 'Generate CMakeFiles/ALL_BUILD' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'ALL_BUILD' from project 'executorch')
note: Run script build phase 'CMake PostBuild Rules' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'extension_apple' from project 'executorch')
** BUILD FAILED **


The following build commands failed:
        CompileC /Users/softmax/Documents/projects/executorch/cmake-out/ios/build/torchao_kernels_aarch64.build/Release-iphoneos/Objects-normal/arm64/find_min_and_max.o /Users/softmax/Documents/projects/executorch/third-party/ao/torchao/experimental/kernels/cpu/aarch64/reduction/find_min_and_max.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'torchao_kernels_aarch64' from project 'executorch')
(1 failure)

@metascroy metascroy merged commit d4c78ab into pytorch:main Jul 30, 2025
227 of 229 checks passed
agrima1304 pushed a commit to agrima1304/executorch that referenced this pull request Aug 26, 2025
### Summary

In accordance with the following
[ticket](pytorch#10694), we want to
enable building the torchao kernel through the main ExecuTorch
CMakeLists.txt. This PR should cover all the necessary steps required to
build low-bit kernels on the iOS app.

#### List of changes
- Provide an optional flag `EXECUTORCH_BUILD_KERNELS_TORCHAO` that
enables building torchao through the CMakeLists.txt.
- Update the apple framework script to include the torchao build.
- Updated the apple framework defaults to include torchao.

### Test plan
- Code has been successfully tested on the iPhone 16 simulator

---------

Co-authored-by: Scott Roy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants