Skip to content

Commit e81727a

Browse files
authored
Disable torchao kernels by default (#12779)
This PR disables building torchao kernels from source by default. To enable the builds, a user needs to explicitly define the environment variable USE_CPP=1: ``` EXECUTORCH_BUILD_TORCHAO=1 python install_executorch.py ```
1 parent 6cfb464 commit e81727a

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

.github/workflows/trunk.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ jobs:
387387
eval "$(conda shell.bash hook)"
388388
389389
# Install requirements
390-
${CONDA_RUN} python install_executorch.py
390+
${CONDA_RUN} EXECUTORCH_BUILD_TORCHAO=1 python install_executorch.py
391391
${CONDA_RUN} sh examples/models/llama/install_requirements.sh
392392
393393
# Run test

examples/models/llama/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,12 @@ Please refer to [this tutorial](https://pytorch.org/executorch/main/llm/llama-de
339339
340340
## Running with low-bit kernels
341341
342-
We now give instructions for quantizating and running your model with low-bit kernels. These are still experimental, and require you do development on an Arm-based Mac. Also note that low-bit quantization often requires QAT (quantization-aware training) to give good quality results.
342+
We now give instructions for quantizating and running your model with low-bit kernels. These are still experimental, and require you do development on an Arm-based Mac, and install executorch from source with the environment variable EXECUTORCH_BUILD_TORCHAO=1 defined:
343+
```
344+
EXECUTORCH_BUILD_TORCHAO=1 python install_executorch.py
345+
```
346+
347+
Also note that low-bit quantization often requires QAT (quantization-aware training) to give good quality results.
343348
344349
First export your model for lowbit quantization (step 2 above):
345350

install_requirements.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,14 @@ def install_requirements(use_pytorch_nightly):
118118
# Install packages directly from local copy instead of pypi.
119119
# This is usually not recommended.
120120
new_env = os.environ.copy()
121-
new_env["USE_CPP"] = "1" # install torchao kernels
121+
if ("EXECUTORCH_BUILD_TORCHAO" not in new_env) or (
122+
new_env["EXECUTORCH_BUILD_TORCHAO"] == "0"
123+
):
124+
new_env["USE_CPP"] = "0"
125+
else:
126+
assert new_env["EXECUTORCH_BUILD_TORCHAO"] == "1"
127+
new_env["USE_CPP"] = "1"
128+
new_env["CMAKE_POLICY_VERSION_MINIMUM"] = "3.5"
122129
subprocess.run(
123130
[
124131
sys.executable,

tools/cmake/preset/llm.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ set_overridable_option(EXECUTORCH_BUILD_XNNPACK ON)
1717
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
1818
set_overridable_option(EXECUTORCH_BUILD_COREML ON)
1919
set_overridable_option(EXECUTORCH_BUILD_MPS ON)
20+
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
21+
set_overridable_option(EXECUTORCH_BUILD_TORCHAO ON)
22+
endif()
2023
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
2124
# Linux-specific code here
2225
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "WIN32")

0 commit comments

Comments
 (0)