Skip to content

Commit efecb1b

Browse files
Disable torchao kernels by default (#12794)
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 ``` Co-authored-by: Scott Roy <[email protected]>
1 parent 919dbd6 commit efecb1b

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
@@ -325,7 +325,7 @@ jobs:
325325
eval "$(conda shell.bash hook)"
326326
327327
# Install requirements
328-
${CONDA_RUN} python install_executorch.py
328+
${CONDA_RUN} EXECUTORCH_BUILD_TORCHAO=1 python install_executorch.py
329329
${CONDA_RUN} sh examples/models/llama/install_requirements.sh
330330
331331
# Run test

examples/models/llama/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,12 @@ Please refer to [this tutorial](https://pytorch.org/executorch/main/llm/llama-de
338338
339339
## Running with low-bit kernels
340340
341-
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.
341+
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:
342+
```
343+
EXECUTORCH_BUILD_TORCHAO=1 python install_executorch.py
344+
```
345+
346+
Also note that low-bit quantization often requires QAT (quantization-aware training) to give good quality results.
342347
343348
First export your model for lowbit quantization (step 2 above):
344349

install_requirements.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,14 @@ def install_requirements(use_pytorch_nightly):
106106
# Install packages directly from local copy instead of pypi.
107107
# This is usually not recommended.
108108
new_env = os.environ.copy()
109-
new_env["USE_CPP"] = "1" # install torchao kernels
109+
if ("EXECUTORCH_BUILD_TORCHAO" not in new_env) or (
110+
new_env["EXECUTORCH_BUILD_TORCHAO"] == "0"
111+
):
112+
new_env["USE_CPP"] = "0"
113+
else:
114+
assert new_env["EXECUTORCH_BUILD_TORCHAO"] == "1"
115+
new_env["USE_CPP"] = "1"
116+
new_env["CMAKE_POLICY_VERSION_MINIMUM"] = "3.5"
110117
subprocess.run(
111118
[
112119
sys.executable,

tools/cmake/preset/llm.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ set_overridable_option(EXECUTORCH_BUILD_XNNPACK ON)
2020
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
2121
set_overridable_option(EXECUTORCH_BUILD_COREML ON)
2222
set_overridable_option(EXECUTORCH_BUILD_MPS ON)
23+
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
24+
set_overridable_option(EXECUTORCH_BUILD_TORCHAO ON)
25+
endif()
2326
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
2427
# Linux-specific code here
2528
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "WIN32")

0 commit comments

Comments
 (0)