Skip to content

Commit b474eac

Browse files
author
morelos
committed
Update base for Update on "[ET] enabling half dtype input for quantization"
Improving the cpu implementation op_quantize to support input half dtype and adding additional testing Differential Revision: [D76053764](https://our.internmc.facebook.com/intern/diff/D76053764/) [ghstack-poisoned]
2 parents e860e06 + 2dda7a2 commit b474eac

File tree

270 files changed

+9267
-2565
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

270 files changed

+9267
-2565
lines changed

.ci/scripts/build-qnn-sdk.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ set_up_aot() {
3232
-DQNN_SDK_ROOT=${QNN_SDK_ROOT} \
3333
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
3434
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
35+
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
36+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
3537
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
3638
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
3739
-DPYTHON_EXECUTABLE=python3

.ci/scripts/test_llama_torchao_lowbit.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ cmake -DPYTHON_EXECUTABLE=python \
3030
-DCMAKE_BUILD_TYPE=Release \
3131
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
3232
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
33+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
3334
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
3435
-DEXECUTORCH_BUILD_XNNPACK=OFF \
3536
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \

.ci/scripts/test_llava.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ EXECUTORCH_COMMON_CMAKE_ARGS=" \
3737
-DEXECUTORCH_ENABLE_LOGGING=ON \
3838
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
3939
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
40+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
4041
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
4142
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
4243
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \

.ci/scripts/test_phi_3_mini.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ cmake_install_executorch_libraries() {
2727
-DEXECUTORCH_ENABLE_LOGGING=1 \
2828
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
2929
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
30+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
3031
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
3132
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
3233
-DEXECUTORCH_BUILD_XNNPACK=ON \

.ci/scripts/unittest-buck2.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ buck2 query "//backends/apple/... + //backends/example/... + \
1515
//kernels/optimized/... + //kernels/portable/... + //kernels/quantized/... + \
1616
//kernels/test/... + //runtime/... + //schema/... + //test/... + //util/..."
1717

18-
UNBUILDABLE_OPTIMIZED_OPS_REGEX="gelu|fft_r2c|log_softmax"
18+
UNBUILDABLE_OPTIMIZED_OPS_REGEX="_elu|gelu|fft|log_softmax"
1919
BUILDABLE_OPTIMIZED_OPS=$(buck2 query //kernels/optimized/cpu/... | grep -E -v $UNBUILDABLE_OPTIMIZED_OPS_REGEX)
2020

2121
# TODO: build prim_ops_test_cpp again once supported_features works in
@@ -24,6 +24,8 @@ BUILDABLE_KERNELS_PRIM_OPS_TARGETS=$(buck2 query //kernels/prim_ops/... | grep -
2424
# TODO: expand the covered scope of Buck targets.
2525
# //runtime/kernel/... is failing because //third-party:torchgen_files's shell script can't find python on PATH.
2626
# //runtime/test/... requires Python torch, which we don't have in our OSS buck setup.
27-
buck2 test $BUILDABLE_OPTIMIZED_OPS //kernels/portable/... \
28-
$BUILDABLE_KERNELS_PRIM_OPS_TARGETS //runtime/backend/... //runtime/core/... \
29-
//runtime/executor: //runtime/kernel/... //runtime/platform/...
27+
for op in "build" "test"; do
28+
buck2 $op $BUILDABLE_OPTIMIZED_OPS //kernels/portable/... \
29+
$BUILDABLE_KERNELS_PRIM_OPS_TARGETS //runtime/backend/... //runtime/core/... \
30+
//runtime/executor: //runtime/kernel/... //runtime/platform/...
31+
done

.github/workflows/trunk.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ jobs:
262262
output=$(ls -la ${elf})
263263
arr=($output)
264264
size=${arr[4]}
265-
threshold="103068" # ~100KiB
265+
threshold="103268" # ~100KiB
266266
echo "size: $size, threshold: $threshold"
267267
if [[ "$size" -le "$threshold" ]]; then
268268
echo "Success $size <= $threshold"
@@ -552,6 +552,7 @@ jobs:
552552
-DEXECUTORCH_ENABLE_LOGGING=1 \
553553
-DCMAKE_BUILD_TYPE=Release \
554554
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
555+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
555556
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
556557
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
557558
-DEXECUTORCH_BUILD_XNNPACK=ON \
@@ -686,3 +687,32 @@ jobs:
686687
build-mode: Release
687688
build-tool: cmake
688689
docker-image: executorch-ubuntu-22.04-clang12
690+
691+
unittest-nxp-neutron:
692+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
693+
permissions:
694+
id-token: write
695+
contents: read
696+
with:
697+
runner: linux.2xlarge
698+
docker-image: executorch-ubuntu-22.04-clang12
699+
submodules: 'recursive'
700+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
701+
timeout: 90
702+
script: |
703+
set -eux
704+
705+
# The generic Linux job chooses to use base env, not the one setup by the image
706+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
707+
conda activate "${CONDA_ENV}"
708+
709+
# Build and install Executorch
710+
PYTHON_EXECUTABLE=python \
711+
CMAKE_ARGS="-DEXECUTORCH_BUILD_NXP_NEUTRON=ON" \
712+
.ci/scripts/setup-linux.sh --build-tool "cmake"
713+
714+
# Install test requirements
715+
pip install -r backends/nxp/requirements-tests.txt
716+
717+
# Run pytest
718+
PYTHON_EXECUTABLE=python bash backends/nxp/run_unittests.sh

.lintrunner.toml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ exclude_patterns = [
271271
'examples/**',
272272
'exir/verification/bindings.cpp',
273273
'extension/**',
274+
# Uses properly-gated (ET_USE_PYTORCH_HEADERS) ATen include.
275+
'kernels/portable/cpu/util/elementwise_util.h',
276+
'kernels/portable/cpu/util/math_util.h',
277+
'kernels/portable/cpu/util/vectorized_math.h',
274278
'kernels/optimized/**',
275279
'runtime/core/exec_aten/**',
276280
# Want to be able to keep c10 in sync with PyTorch core.
@@ -386,15 +390,9 @@ exclude_patterns = [
386390
"third-party/**",
387391
# TODO: remove exceptions as we migrate
388392
# backends
389-
"backends/vulkan/quantizer/**",
390-
"backends/vulkan/test/**",
391-
"backends/xnnpack/quantizer/**",
392-
"backends/xnnpack/test/**",
393-
"exir/tests/test_passes.py",
394-
"extension/llm/export/builder.py",
395-
"extension/llm/export/quantizer_lib.py",
396393
"exir/tests/test_memory_planning.py",
397394
"exir/backend/test/demos/test_xnnpack_qnnpack.py",
395+
"backends/xnnpack/test/test_xnnpack_utils.py",
398396
]
399397

400398
command = [

CMakeLists.txt

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -152,37 +152,11 @@ else()
152152
endif()
153153

154154
if(EXECUTORCH_BUILD_TESTS)
155-
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
156155
include(CTest)
157156
endif()
158157

159158
add_subdirectory(third-party)
160159

161-
if(EXECUTORCH_BUILD_EXTENSION_TRAINING)
162-
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
163-
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
164-
set(EXECUTORCH_BUILD_EXTENSION_MODULE ON)
165-
set(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
166-
endif()
167-
168-
if(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR)
169-
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
170-
endif()
171-
172-
if(EXECUTORCH_BUILD_EXTENSION_MODULE)
173-
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
174-
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
175-
endif()
176-
177-
if(EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT)
178-
set(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
179-
set(EXECUTORCH_BUILD_KERNELS_CUSTOM ON)
180-
endif()
181-
182-
if(EXECUTORCH_BUILD_KERNELS_CUSTOM)
183-
set(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON)
184-
endif()
185-
186160
if(NOT DEFINED FXDIV_SOURCE_DIR)
187161
set(ORIGINAL_CMAKE_POSITION_INDEPENDENT_CODE_FLAG
188162
${CMAKE_POSITION_INDEPENDENT_CODE}
@@ -336,7 +310,7 @@ if(EXECUTORCH_USE_CPP_CODE_COVERAGE)
336310
" -fprofile-instr-generate -fcoverage-mapping"
337311
)
338312
else()
339-
message(ERROR
313+
message(FATAL_ERROR
340314
"Code coverage for compiler ${CMAKE_CXX_COMPILER_ID} is unsupported"
341315
)
342316
endif()
@@ -456,14 +430,6 @@ endif()
456430

457431
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/configurations)
458432

459-
#
460-
# gflags: Commandline flag host library.
461-
#
462-
463-
if(EXECUTORCH_BUILD_GFLAGS)
464-
add_subdirectory(third-party/gflags)
465-
endif()
466-
467433
# Install `executorch` library as well as `executorch-config.cmake` under
468434
# ${CMAKE_INSTALL_PREFIX}/
469435
install(
@@ -548,17 +514,6 @@ if(EXECUTORCH_BUILD_CORTEX_M)
548514
endif()
549515

550516
if(EXECUTORCH_BUILD_DEVTOOLS)
551-
if(NOT EXECUTORCH_BUILD_ARM_BAREMETAL)
552-
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER
553-
ON
554-
CACHE BOOL "EXECUTORCH_BUILD_EXTENSION_DATA_LOADER" FORCE
555-
)
556-
else()
557-
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER
558-
OFF
559-
CACHE BOOL "EXECUTORCH_BUILD_EXTENSION_DATA_LOADER" FORCE
560-
)
561-
endif()
562517
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/devtools)
563518
endif()
564519

backends/apple/coreml/scripts/build_tests.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ cmake "$EXECUTORCH_ROOT_PATH" -B"$CMAKE_EXECUTORCH_BUILD_DIR_PATH" \
3333
-DPLATFORM=MAC_UNIVERSAL \
3434
-DDEPLOYMENT_TARGET=13.0 \
3535
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
36-
-DEXECUTORCH_BUILD_XNNPACK=OFF \
37-
-DEXECUTORCH_BUILD_GFLAGS=OFF
36+
-DEXECUTORCH_BUILD_XNNPACK=OFF
3837

3938
cmake --build "$CMAKE_EXECUTORCH_BUILD_DIR_PATH" -j9 -t executorch
4039

backends/arm/_passes/arm_pass_manager.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@
6262
UnsqueezeScalarPlaceholdersPass,
6363
)
6464

65-
from executorch.backends.arm.tosa_specification import TosaSpecification
65+
from executorch.backends.arm.tosa_specification import (
66+
TosaLoweringContext,
67+
TosaSpecification,
68+
)
6669
from executorch.backends.transforms.decompose_sdpa import (
6770
DecomposeScaledDotProductAttention,
6871
)
@@ -80,7 +83,8 @@ def __init__(self, tosa_spec: TosaSpecification) -> None:
8083
super().__init__()
8184

8285
def _transform(self, graph_module: GraphModule):
83-
return self(graph_module).graph_module
86+
with TosaLoweringContext(self.tosa_spec):
87+
return self(graph_module).graph_module
8488

8589
def _tosa_080_BI_pipeline(self, exported_program: ExportedProgram) -> GraphModule:
8690
self.add_pass(FuseQuantizedActivationPass())

0 commit comments

Comments
 (0)