Skip to content

Commit

Permalink
2024-11-18 nightly release (8526d0a)
Browse files Browse the repository at this point in the history
  • Loading branch information
pytorchbot committed Nov 18, 2024
1 parent c6936ba commit 7059b27
Show file tree
Hide file tree
Showing 99 changed files with 828,437 additions and 1,132 deletions.
1 change: 1 addition & 0 deletions .ci/scripts/gather_test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"resnet50": "linux.12xlarge",
"llava": "linux.12xlarge",
"llama3_2_vision_encoder": "linux.12xlarge",
# "llama3_2_text_decoder": "linux.12xlarge", # TODO: re-enable test when Huy's change is in / model gets smaller.
# This one causes timeout on smaller runner, the root cause is unclear (T161064121)
"dl3": "linux.12xlarge",
"emformer_join": "linux.12xlarge",
Expand Down
4 changes: 2 additions & 2 deletions .ci/scripts/test_model.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ test_model() {
bash examples/models/llava/install_requirements.sh
STRICT="--no-strict"
fi
if [[ "$MODEL_NAME" == "llama3_2_vision_encoder" ]]; then
# Install requirements for llama vision
if [[ "$MODEL_NAME" == "llama3_2_vision_encoder" || "$MODEL_NAME" == "llama3_2_text_decoder" ]]; then
# Install requirements for llama vision.
bash examples/models/llama3_2_vision/install_requirements.sh
fi
# python3 -m examples.portable.scripts.export --model_name="llama2" should works too
Expand Down
79 changes: 67 additions & 12 deletions .github/workflows/apple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,28 @@ on:
- extension/benchmark/apple/**
- extension/module/**
workflow_dispatch:
schedule:
- cron: '0 10 * * *' # Runs daily at 2 AM PST

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
cancel-in-progress: true

jobs:
set-version:
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.set_version.outputs.version }}
steps:
- name: Set VERSION variable
id: set_version
shell: bash
run: |
VERSION="0.4.0.$(TZ='PST8PDT' date +%Y%m%d)"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
build-demo-ios:
name: build-demo-ios
# NB: Don't run this on fork PRs because they won't have access to the secret and would fail anyway
if: ${{ !github.event.pull_request.head.repo.fork }}
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
secrets: inherit
with:
Expand All @@ -41,6 +53,8 @@ jobs:
secrets-env: BUILD_CERTIFICATE_BASE64 EXECUTORCH_DEMO_BUILD_PROVISION_PROFILE_BASE64 KEYCHAIN_PASSWORD
upload-artifact: ios-apps
script: |
set -eux
BUILD_TOOL=cmake
.ci/scripts/setup-conda.sh
Expand All @@ -59,7 +73,7 @@ jobs:
# Build and test iOS Demo App
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
build/test_ios_ci.sh ${ARTIFACTS_DIR_NAME}
build/test_ios_ci.sh "${ARTIFACTS_DIR_NAME}"
# Upload the test demo app to S3
upload-demo-ios:
Expand All @@ -77,6 +91,7 @@ jobs:
shell: bash
working-directory: ${{ runner.temp }}/artifacts/
run: |
set -eux
ls -lah ./
- name: Upload the artifacts to S3
Expand Down Expand Up @@ -114,6 +129,7 @@ jobs:

build-frameworks-ios:
name: build-frameworks-ios
needs: set-version
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
with:
runner: macos-latest-xlarge
Expand All @@ -123,8 +139,10 @@ jobs:
upload-artifact: executorch-frameworks-ios
timeout: 90
script: |
set -eux
BUILD_TOOL=cmake
VERSION="latest"
VERSION="${{ needs.set-version.outputs.version }}"
FRAMEWORKS=(
"executorch"
"backend_coreml"
Expand Down Expand Up @@ -173,13 +191,17 @@ jobs:
upload-frameworks-ios:
runs-on: ubuntu-22.04
needs: build-frameworks-ios
needs: [build-frameworks-ios, set-version]
timeout-minutes: 30
environment: ${{ github.ref == 'refs/heads/main' && 'cherry-pick-bot' || '' }}
permissions:
id-token: write
contents: read
contents: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GH_PYTORCHBOT_CHERRY_PICK_TOKEN || secrets.GITHUB_TOKEN }}
- uses: actions/setup-python@v4
with:
python-version: '3.11'
Expand All @@ -196,15 +218,15 @@ jobs:
name: executorch-frameworks-ios
path: ${{ runner.temp }}/frameworks-ios/
- name: Only push to S3 when running the workflow manually from main branch
if: ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' }}
if: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' }}
shell: bash
run: |
set -eux
echo "UPLOAD_ON_MAIN=1" >> "${GITHUB_ENV}"
- name: Upload the artifact to ossci-ios S3 bucket
shell: bash
run: |
set -eux
VERSION="${{ needs.set-version.outputs.version }}"
pip install awscli==1.32.18
Expand All @@ -215,14 +237,47 @@ jobs:
for FILENAME in "${RUNNER_TEMP}"/frameworks-ios/*.zip; do
[ -e "${FILENAME}" ] || continue
shasum -a 256 "${FILENAME}"
FRAMEWORK_NAME=$(basename "${FILENAME}" | sed "s/-${VERSION}.zip//")
CHECKSUM=$(shasum -a 256 "${FILENAME}" | cut -d ' ' -f1)
echo "${FRAMEWORK_NAME} ${CHECKSUM}" >> "${RUNNER_TEMP}/checksums.txt"
${AWS_CMD} "${FILENAME}" s3://ossci-ios/executorch/ --acl public-read
done
- name: Update SwiftPM
shell: bash
run: |
set -eux
VERSION="${{ needs.set-version.outputs.version }}"
BRANCH="swiftpm-${VERSION}"
git checkout swiftpm
if git show-ref --verify --quiet refs/heads/${BRANCH}; then
git checkout "${BRANCH}"
else
git checkout -b "${BRANCH}"
fi
[[ -f Package.swift ]] || mv Package.swift.template Package.swift
sed -i "s/__VERSION__/${VERSION}/g" Package.swift
while read -r FRAMEWORK CHECKSUM; do
sed -i "s/__SHA256_${FRAMEWORK}__/${CHECKSUM}/g" Package.swift
done < "${RUNNER_TEMP}/checksums.txt"
if [[ "${UPLOAD_ON_MAIN:-0}" == "1" ]]; then
git config --global user.name "PyTorch Bot"
git config --global user.email "[email protected]"
git add Package.swift
git commit -am "${VERSION}"
git push -f origin "${BRANCH}"
else
echo "Draft Package.swift:"
cat Package.swift
fi
build-benchmark-app:
name: build-benchmark-app
# NB: Don't run this on fork PRs because they won't have access to the secret and would fail anyway
if: ${{ !github.event.pull_request.head.repo.fork }}
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
secrets: inherit
with:
Expand Down Expand Up @@ -285,5 +340,5 @@ jobs:
echo "::group::Build ExecuTorch benchmark app"
mkdir -p extension/benchmark/apple/Benchmark/Models
${CONDA_RUN} --no-capture-output \
build/build_apple_llm_demo.sh ${ARTIFACTS_DIR_NAME}
build/build_apple_llm_demo.sh "${ARTIFACTS_DIR_NAME}"
echo "::endgroup::"
2 changes: 0 additions & 2 deletions .github/workflows/trunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,6 @@ jobs:
pip install -U "huggingface_hub[cli]"
huggingface-cli login --token $SECRET_EXECUTORCH_HF_TOKEN
pip install accelerate sentencepiece
# TODO(guangyang): Switch to use released transformers library after all required patches are included
pip install "git+https://github.com/huggingface/transformers.git@6cc4dfe3f1e8d421c6d6351388e06e9b123cbfe1"
pip list
echo "::endgroup::"
Expand Down
1 change: 1 addition & 0 deletions backends/arm/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ python_library(
typing = True,
deps = [
":arm_backend",
"//executorch/backends/arm/operator_support:operator_support",
"//executorch/backends/arm/_passes:passes",
"//executorch/exir:lib",
],
Expand Down
83 changes: 12 additions & 71 deletions backends/arm/arm_partitioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@
# pyre-unsafe

import logging
import operator
import os
from typing import Callable, cast, final, List, Optional, Tuple
from typing import Callable, final, List, Optional, Tuple

import torch
from executorch.backends.arm.arm_backend import ArmBackend # usort: skip
from executorch.backends.arm._passes.tag_io_quant_pass import TagIOQuantPass
from executorch.backends.arm.operator_support.tosa_supported_operators import (
TOSASupportedOperators,
)
from executorch.backends.arm.tosa_specification import TosaSpecification
from executorch.exir.backend.compile_spec_schema import CompileSpec
from executorch.exir.backend.partitioner import (
DelegationSpec,
Partitioner,
PartitionResult,
)
from executorch.exir.backend.utils import tag_constant_data
from executorch.exir.dialects._ops import ops as exir_ops
from executorch.exir.passes import PassManager
from torch.export.exported_program import ExportedProgram
from torch.fx.passes.infra.partitioner import CapabilityBasedPartitioner

from torch.fx.passes.operator_support import OperatorSupportBase

logger = logging.getLogger(__name__)
logger.setLevel(logging.WARNING)
TOSA_DBG_VERBOSE = os.environ.get("TOSA_DBG_VERBOSE") == "1"
Expand All @@ -35,71 +35,6 @@
logger.setLevel(logging.INFO)


class TOSASupportedOperators(OperatorSupportBase):
def is_node_supported(self, submodules, node: torch.fx.Node) -> bool:
supported = node.op == "call_function" and node.target in [
exir_ops.edge.aten.add.Tensor,
exir_ops.edge.aten.expand_copy.default,
exir_ops.edge.aten.cat.default,
exir_ops.edge.aten.bmm.default,
exir_ops.edge.aten.permute_copy.default,
exir_ops.edge.aten.hardtanh.default,
exir_ops.edge.aten.convolution.default,
exir_ops.edge.aten.div.Tensor,
exir_ops.edge.aten.exp.default,
exir_ops.edge.aten.log.default,
exir_ops.edge.aten.linear.default,
exir_ops.edge.aten.split_with_sizes_copy.default,
exir_ops.edge.aten.full.default,
exir_ops.edge.aten.mul.Tensor,
exir_ops.edge.aten._native_batch_norm_legit_no_training.default,
exir_ops.edge.aten.native_layer_norm.default,
exir_ops.edge.aten.avg_pool2d.default,
exir_ops.edge.aten.max_pool2d_with_indices.default,
exir_ops.edge.aten.sigmoid.default,
exir_ops.edge.aten.mm.default,
exir_ops.edge.aten.repeat.default,
exir_ops.edge.aten.reciprocal.default,
exir_ops.edge.aten.relu.default,
exir_ops.edge.aten.rsqrt.default,
exir_ops.edge.aten._softmax.default,
exir_ops.edge.aten.select_copy.int,
exir_ops.edge.aten._log_softmax.default,
exir_ops.edge.aten.slice_copy.Tensor,
exir_ops.edge.aten.sub.Tensor,
exir_ops.edge.aten.sum.dim_IntList,
exir_ops.edge.aten.tanh.default,
exir_ops.edge.aten.upsample_nearest2d.vec,
exir_ops.edge.aten.view_copy.default,
exir_ops.edge.aten.clone.default,
exir_ops.edge.aten.mean.dim,
exir_ops.edge.aten.var.correction,
exir_ops.edge.aten.unsqueeze_copy.default,
exir_ops.edge.aten.squeeze_copy.dims,
operator.getitem,
exir_ops.edge.quantized_decomposed.quantize_per_tensor.default,
exir_ops.edge.quantized_decomposed.dequantize_per_tensor.default,
]

supported &= self.is_node_supported_custom(node)

# Override partitioning based on pre partition passes
if "arm_override_partition" in node.meta:
supported = supported & node.meta["arm_override_partition"]
node.meta.pop("arm_override_partition")

return supported

def is_node_supported_custom(self, node: torch.fx.Node) -> bool:
if node.target == exir_ops.edge.aten.mean.dim:
keep_dim = node.args[2] if len(node.args) > 2 else False
return cast(bool, keep_dim)
if node.target == exir_ops.edge.aten.var.correction:
keep_dim = node.kwargs.get("keepdim", False)
return cast(bool, keep_dim)
return True


@final
class ArmPartitioner(Partitioner):
def __init__(self, compile_spec: List[CompileSpec]) -> None:
Expand All @@ -111,6 +46,12 @@ def partition(self, exported_program: ExportedProgram) -> PartitionResult:
logger.info("ArmPartitioner::partition")
partition_tags = {}

tosa_spec = TosaSpecification.create_from_compilespecs(
self.delegation_spec.compile_specs
)

logger.info(f"Partitioning for {tosa_spec}")

for spec in self.delegation_spec.compile_specs:
if spec.key == "quantize_io" and spec.value.decode() == "True":
# Exclude IO quantization from the partition
Expand All @@ -123,7 +64,7 @@ def partition(self, exported_program: ExportedProgram) -> PartitionResult:

capability_partitioner = CapabilityBasedPartitioner(
exported_program.graph_module,
TOSASupportedOperators(),
TOSASupportedOperators(tosa_spec),
allows_single_node_partition=True,
)
partition_list = capability_partitioner.propose_partitions()
Expand Down
12 changes: 12 additions & 0 deletions backends/arm/operator_support/TARGETS
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("@fbcode_macros//build_defs:python_library.bzl", "python_library")

python_library(
name = "operator_support",
srcs = glob(["*.py"]),
typing = True,
deps = [
"//executorch/backends/xnnpack/_passes:xnnpack_passes",
"//executorch/exir:lib",
"//executorch/backends/arm:tosa_specification"
],
)
8 changes: 8 additions & 0 deletions backends/arm/operator_support/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2024 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# pyre-unsafe

from . import mean_dim_support, tosa_supported_operators, var_correction_support # noqa
33 changes: 33 additions & 0 deletions backends/arm/operator_support/mean_dim_support.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2024 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# pyre-unsafe

from typing import cast

import torch.fx as fx

from executorch.backends.arm.operator_support.tosa_supported_operators import (
register_tosa_support_check,
SupportedTOSAOperatorCheck,
)
from executorch.backends.arm.tosa_specification import TosaSpecification
from executorch.exir.dialects._ops import ops as exir_ops


@register_tosa_support_check
class MeanDimSupported(SupportedTOSAOperatorCheck):
targets = [exir_ops.edge.aten.mean.dim]

tosa_specs = [
TosaSpecification.create_from_string("TOSA-0.80.0+BI"),
TosaSpecification.create_from_string("TOSA-0.80.0+MI"),
]

def is_node_supported(self, node: fx.Node, tosa_spec: TosaSpecification) -> bool:
assert node.target in self.targets

keep_dim = node.args[2] if len(node.args) > 2 else False
return cast(bool, keep_dim)
Loading

0 comments on commit 7059b27

Please sign in to comment.