Skip to content

Commit d68e9f7

Browse files
author
pytorchbot
committed
2025-07-25 nightly release (21c8e67)
1 parent 3595425 commit d68e9f7

File tree

125 files changed

+3272
-991
lines changed

Some content is hidden

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

125 files changed

+3272
-991
lines changed

.ci/scripts/unittest-linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if [[ "$BUILD_TOOL" == "cmake" ]]; then
2222

2323
# We need the runner to test the built library.
2424
PYTHON_EXECUTABLE=python \
25-
CMAKE_ARGS="-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON -DEXECUTORCH_BUILD_TESTS=ON" \
25+
CMAKE_ARGS="-DEXECUTORCH_BUILD_EXTENSION_EVALUE_UTIL=ON -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON -DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON -DEXECUTORCH_BUILD_TESTS=ON" \
2626
.ci/scripts/setup-linux.sh "$@"
2727

2828
.ci/scripts/unittest-linux-cmake.sh

.ci/scripts/unittest-macos.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ trap 'rm -rfv ${TMP_DIR}' EXIT
2222
# Setup MacOS dependencies as there is no Docker support on MacOS atm
2323
# We need the runner to test the built library.
2424
PYTHON_EXECUTABLE=python \
25-
CMAKE_ARGS="-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON -DEXECUTORCH_BUILD_TESTS=ON" \
25+
CMAKE_ARGS="-DEXECUTORCH_BUILD_EXTENSION_EVALUE_UTIL=ON -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON -DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON -DEXECUTORCH_BUILD_TESTS=ON" \
2626
${CONDA_RUN} --no-capture-output \
2727
.ci/scripts/setup-macos.sh "$@"
2828

.github/workflows/trunk.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ jobs:
269269
if [[ ${{ matrix.os}} == "bare_metal" ]]; then
270270
bash test/build_size_test.sh "-DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake} -DEXECUTORCH_BUILD_ARM_BAREMETAL=ON"
271271
elif [[ ${{ matrix.os}} == "zephyr-preset" ]]; then
272-
CXXFLAGS=${cxx_flags} cmake --preset zephyr -DCMAKE_BUILD_TYPE=Release -DEXECUTORCH_OPTIMIZE_SIZE=ON -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out .
272+
CXXFLAGS=${cxx_flags} cmake --preset zephyr -DCMAKE_BUILD_TYPE=Release -DEXECUTORCH_OPTIMIZE_SIZE=ON -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out .
273273
cmake --build cmake-out -j9 --target install --config Release
274274
CXXFLAGS=${cxx_flags} cmake -DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out/test test
275275
cmake --build cmake-out/test -j9 --config Release
@@ -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

CMakeLists.txt

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,16 @@ if(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER)
548548
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/data_loader)
549549
endif()
550550

551+
if(EXECUTORCH_BUILD_EXTENSION_EVALUE_UTIL)
552+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/evalue_util)
553+
install(
554+
DIRECTORY extension/evalue_util/
555+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/executorch/extension/evalue_util
556+
FILES_MATCHING
557+
PATTERN "*.h"
558+
)
559+
endif()
560+
551561
if(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR)
552562
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/flat_tensor)
553563
endif()
@@ -576,6 +586,12 @@ endif()
576586

577587
if(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL)
578588
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/runner_util)
589+
install(
590+
DIRECTORY extension/runner_util/
591+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/executorch/extension/runner_util
592+
FILES_MATCHING
593+
PATTERN "*.h"
594+
)
579595
endif()
580596

581597
if(EXECUTORCH_BUILD_EXTENSION_TENSOR)
@@ -651,8 +667,7 @@ if(EXECUTORCH_BUILD_PYBIND)
651667

652668
# util lib
653669
add_library(
654-
util ${CMAKE_CURRENT_SOURCE_DIR}/extension/evalue_util/print_evalue.cpp
655-
${CMAKE_CURRENT_SOURCE_DIR}/extension/aten_util/aten_bridge.cpp
670+
util ${CMAKE_CURRENT_SOURCE_DIR}/extension/aten_util/aten_bridge.cpp
656671
)
657672
target_include_directories(
658673
util PUBLIC ${_common_include_directories} ${TORCH_INCLUDE_DIRS}
@@ -695,7 +710,9 @@ endif()
695710

696711
if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
697712
# Baseline libraries that executor_runner will link against.
698-
set(_executor_runner_libs executorch gflags)
713+
set(_executor_runner_libs executorch extension_evalue_util
714+
extension_runner_util gflags
715+
)
699716

700717
if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
701718
list(APPEND _executor_runner_libs optimized_native_cpu_ops_lib)

backends/apple/coreml/test/tester.py

Lines changed: 67 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,73 @@
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
66

7-
from typing import Any, List, Optional, Tuple
7+
import functools
8+
from typing import Any, List, Optional, Sequence, Tuple
89

10+
import coremltools as ct
911
import executorch
1012
import executorch.backends.test.harness.stages as BaseStages
11-
1213
import torch
14+
15+
from executorch.backends.apple.coreml.compiler import CoreMLBackend
1316
from executorch.backends.apple.coreml.partition import CoreMLPartitioner
17+
from executorch.backends.apple.coreml.quantizer import CoreMLQuantizer
1418
from executorch.backends.test.harness import Tester as TesterBase
1519
from executorch.backends.test.harness.stages import StageType
1620
from executorch.exir import EdgeCompileConfig
1721
from executorch.exir.backend.partitioner import Partitioner
1822

1923

24+
def _create_default_partitioner(
25+
minimum_deployment_target: Any = ct.target.iOS15,
26+
) -> CoreMLPartitioner:
27+
return CoreMLPartitioner(
28+
compile_specs=CoreMLBackend.generate_compile_specs(
29+
minimum_deployment_target=minimum_deployment_target
30+
)
31+
)
32+
33+
34+
def _get_static_int8_linear_qconfig():
35+
return ct.optimize.torch.quantization.LinearQuantizerConfig(
36+
global_config=ct.optimize.torch.quantization.ModuleLinearQuantizerConfig(
37+
quantization_scheme="symmetric",
38+
activation_dtype=torch.quint8,
39+
weight_dtype=torch.qint8,
40+
weight_per_channel=True,
41+
)
42+
)
43+
44+
45+
class Quantize(BaseStages.Quantize):
46+
def __init__(
47+
self,
48+
quantizer: Optional[CoreMLQuantizer] = None,
49+
quantization_config: Optional[Any] = None,
50+
calibrate: bool = True,
51+
calibration_samples: Optional[Sequence[Any]] = None,
52+
is_qat: Optional[bool] = False,
53+
):
54+
super().__init__(
55+
quantizer=quantizer
56+
or CoreMLQuantizer(
57+
quantization_config or _get_static_int8_linear_qconfig()
58+
),
59+
calibrate=calibrate,
60+
calibration_samples=calibration_samples,
61+
is_qat=is_qat,
62+
)
63+
64+
2065
class Partition(BaseStages.Partition):
21-
def __init__(self, partitioner: Optional[Partitioner] = None):
66+
def __init__(
67+
self,
68+
partitioner: Optional[Partitioner] = None,
69+
minimum_deployment_target: Optional[Any] = ct.target.iOS15,
70+
):
2271
super().__init__(
23-
partitioner=partitioner or CoreMLPartitioner,
72+
partitioner=partitioner
73+
or _create_default_partitioner(minimum_deployment_target),
2474
)
2575

2676

@@ -29,9 +79,12 @@ def __init__(
2979
self,
3080
partitioners: Optional[List[Partitioner]] = None,
3181
edge_compile_config: Optional[EdgeCompileConfig] = None,
82+
minimum_deployment_target: Optional[Any] = ct.target.iOS15,
3283
):
3384
super().__init__(
34-
default_partitioner_cls=CoreMLPartitioner,
85+
default_partitioner_cls=lambda: _create_default_partitioner(
86+
minimum_deployment_target
87+
),
3588
partitioners=partitioners,
3689
edge_compile_config=edge_compile_config,
3790
)
@@ -43,13 +96,20 @@ def __init__(
4396
module: torch.nn.Module,
4497
example_inputs: Tuple[torch.Tensor],
4598
dynamic_shapes: Optional[Tuple[Any]] = None,
99+
minimum_deployment_target: Optional[Any] = ct.target.iOS15,
46100
):
47101
# Specialize for XNNPACK
48102
stage_classes = (
49103
executorch.backends.test.harness.Tester.default_stage_classes()
50104
| {
51-
StageType.PARTITION: Partition,
52-
StageType.TO_EDGE_TRANSFORM_AND_LOWER: ToEdgeTransformAndLower,
105+
StageType.QUANTIZE: Quantize,
106+
StageType.PARTITION: functools.partial(
107+
Partition, minimum_deployment_target=minimum_deployment_target
108+
),
109+
StageType.TO_EDGE_TRANSFORM_AND_LOWER: functools.partial(
110+
ToEdgeTransformAndLower,
111+
minimum_deployment_target=minimum_deployment_target,
112+
),
53113
}
54114
)
55115

backends/arm/arm_backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def ethosu_compile_spec(
128128
self.compiler_flags.append("--output-format=raw")
129129
self.compiler_flags.append("--debug-force-regor")
130130

131-
base_tosa_version = "TOSA-0.80+BI"
131+
base_tosa_version = "TOSA-1.0+INT"
132132
if "u55" in target:
133133
# Add the Ethos-U55 extension marker
134134
base_tosa_version += "+u55"

backends/arm/quantizer/arm_quantizer_utils.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,21 @@
1818
from torch.fx import GraphModule, Node
1919

2020
from torchao.quantization.pt2e.quantizer import QuantizationAnnotation
21+
from torchao.quantization.pt2e.quantizer.quantizer import Q_ANNOTATION_KEY
2122

2223

2324
def is_annotated(node: Node) -> bool:
2425
"""Given a node return whether the node is annotated."""
2526
return (
26-
"quantization_annotation" in node.meta
27-
and cast(
28-
QuantizationAnnotation, node.meta["quantization_annotation"]
29-
)._annotated
27+
Q_ANNOTATION_KEY in node.meta
28+
and cast(QuantizationAnnotation, node.meta[Q_ANNOTATION_KEY])._annotated
3029
)
3130

3231

3332
def is_output_annotated(node: Node) -> bool:
3433
"""Given a node, return whether the output of the node is annotated."""
35-
if "quantization_annotation" in node.meta:
36-
annotation = cast(QuantizationAnnotation, node.meta["quantization_annotation"])
34+
if Q_ANNOTATION_KEY in node.meta:
35+
annotation = cast(QuantizationAnnotation, node.meta[Q_ANNOTATION_KEY])
3736
return annotation._annotated and annotation.output_qspec is not None
3837
else:
3938
return False
@@ -43,9 +42,9 @@ def mark_node_as_annotated(node: Node) -> None:
4342
"""Marks node as annotated. If needed, an empty QuantizationAnnotation is added
4443
to the quantization_annotation node meta entry.
4544
"""
46-
if "quantization_annotation" not in node.meta:
47-
node.meta["quantization_annotation"] = QuantizationAnnotation()
48-
node.meta["quantization_annotation"]._annotated = True
45+
if Q_ANNOTATION_KEY not in node.meta:
46+
node.meta[Q_ANNOTATION_KEY] = QuantizationAnnotation()
47+
node.meta[Q_ANNOTATION_KEY]._annotated = True
4948

5049

5150
def is_ok_for_quantization(node: Node, gm: GraphModule):

backends/arm/test/test_arm_baremetal.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ test_models_ethos-u85() { # End to End model tests using model_test.py
228228
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=ethos-u85-256 --model=mv2 --extra_flags="-DET_ATOL=2.00 -DET_RTOL=2.00"
229229
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=ethos-u85-512 --model=mv3 --extra_flags="-DET_ATOL=5.00 -DET_RTOL=5.00"
230230
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=ethos-u85-128 --model=lstm --extra_flags="-DET_ATOL=0.03 -DET_RTOL=0.03"
231-
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=ethos-u85-128 --model=w2l --extra_flags="-DET_ATOL=0.01 -DET_RTOL=0.01"
231+
#python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=ethos-u85-128 --model=w2l --extra_flags="-DET_ATOL=0.01 -DET_RTOL=0.01" # Takes long time to run
232232
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=ethos-u85-256 --model=ic4 --extra_flags="-DET_ATOL=0.8 -DET_RTOL=0.8" --timeout=2400
233233
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=ethos-u85-128 --model=resnet18 --extra_flags="-DET_ATOL=0.2 -DET_RTOL=0.2"
234234
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=ethos-u85-128 --model=resnet50 --extra_flags="-DET_ATOL=0.2 -DET_RTOL=0.2"

backends/cadence/aot/TARGETS

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ python_library(
4141
":ops_registrations",
4242
":passes",
4343
":replace_ops",
44+
":compiler_funcs",
4445
":utils",
4546
"//caffe2:torch",
4647
"//executorch/backends/cadence/aot/quantizer:fusion_pass",
@@ -332,6 +333,18 @@ python_library(
332333
],
333334
)
334335

336+
python_library(
337+
name = "compiler_funcs",
338+
srcs = [
339+
"compiler_funcs.py",
340+
],
341+
typing = True,
342+
deps = [
343+
"//caffe2:torch",
344+
"//pytorch/ao:torchao",
345+
],
346+
)
347+
335348

336349
python_unittest(
337350
name = "test_graph_builder",

0 commit comments

Comments
 (0)