Skip to content

Commit

Permalink
Update on "allow customized head_dim"
Browse files Browse the repository at this point in the history
This is for resolving the ask in this [post](https://fb.workplace.com/groups/pytorch.edge.users/permalink/1574875706716050/).

Similar change in HF: huggingface/transformers#32502

Differential Revision: [D65974454](https://our.internmc.facebook.com/intern/diff/D65974454/)

[ghstack-poisoned]
  • Loading branch information
helunwencser committed Nov 18, 2024
2 parents c083d85 + 5c9a0ed commit 0120876
Show file tree
Hide file tree
Showing 131 changed files with 828,579 additions and 1,175 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: 4 additions & 0 deletions .ci/scripts/test_model.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ test_model() {
bash examples/models/llava/install_requirements.sh
STRICT="--no-strict"
fi
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
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export --model_name="${MODEL_NAME}" "${STRICT}"
run_portable_executor_runner
Expand Down
75 changes: 67 additions & 8 deletions .github/workflows/apple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,26 @@ 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
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
Expand All @@ -39,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 @@ -57,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 @@ -75,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 @@ -112,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 @@ -121,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 @@ -171,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 @@ -194,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 @@ -213,9 +237,44 @@ 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 "pytorchbot@users.noreply.github.com"
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
Expand Down Expand Up @@ -281,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::"
4 changes: 0 additions & 4 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ jobs:
conda activate "${CONDA_ENV}"
MODEL_NAME=${{ matrix.model }}
# Install requirements for llama vision
if [[ "$MODEL_NAME" == "llama3_2_vision_encoder" ]]; then
bash examples/models/llama3_2_vision/install_requirements.sh
fi
BUILD_TOOL=${{ matrix.build-tool }}
BACKEND=${{ matrix.backend }}
DEMO_BACKEND_DELEGATION=${{ matrix.demo_backend_delegation }}
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/trunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ jobs:
bash .ci/scripts/setup-conda.sh
# Setup MacOS dependencies as there is no Docker support on MacOS atm
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/setup-macos.sh "${BUILD_TOOL}"
# Install requirements for llama vision
if [[ "$MODEL_NAME" == "llama3_2_vision_encoder" ]]; then
${CONDA_RUN} bash examples/models/llama3_2_vision/install_requirements.sh
fi
# Build and test executorch
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}" "${DEMO_BACKEND_DELEGATION}"
Expand Down Expand Up @@ -415,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
2 changes: 2 additions & 0 deletions backends/arm/_passes/arm_pass_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# 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 Optional

import torch
Expand Down
2 changes: 2 additions & 0 deletions backends/arm/_passes/cast_int64_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# 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

import torch
from executorch.exir.pass_base import ExportPass, PassResult

Expand Down
2 changes: 2 additions & 0 deletions backends/arm/_passes/conv1d_unsqueeze_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# 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


import torch
from executorch.backends.arm._passes.arm_pass_utils import (
Expand Down
2 changes: 2 additions & 0 deletions backends/arm/_passes/decompose_div_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# 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

import torch
from executorch.exir.dialects._ops import ops as exir_ops
from executorch.exir.pass_base import ExportPass
Expand Down
2 changes: 2 additions & 0 deletions backends/arm/_passes/decompose_layernorm_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# 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

import operator

import torch
Expand Down
2 changes: 2 additions & 0 deletions backends/arm/_passes/decompose_linear_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# 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

import numpy as np
from executorch.backends.arm._passes.arm_pass_utils import (
create_node,
Expand Down
2 changes: 2 additions & 0 deletions backends/arm/_passes/decompose_meandim_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# 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

import torch
from executorch.exir.dialects._ops import ops as exir_ops
from executorch.exir.pass_base import ExportPass
Expand Down
2 changes: 2 additions & 0 deletions backends/arm/_passes/decompose_softmaxes_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# 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

import torch
from executorch.exir.dialects._ops import ops as exir_ops
from executorch.exir.pass_base import ExportPass
Expand Down
2 changes: 2 additions & 0 deletions backends/arm/_passes/decompose_var_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# 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


import torch
from executorch.exir.dialects._ops import ops as exir_ops
Expand Down
2 changes: 2 additions & 0 deletions backends/arm/_passes/insert_squeeze_after_sum_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# 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
Expand Down
2 changes: 2 additions & 0 deletions backends/arm/_passes/match_arg_ranks_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# 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

from executorch.backends.arm._passes.arm_pass_utils import (
Expand Down
2 changes: 2 additions & 0 deletions backends/arm/_passes/remove_clone_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# 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 executorch.exir.dialects._ops import ops as exir_ops
from executorch.exir.pass_base import ExportPass

Expand Down
2 changes: 2 additions & 0 deletions backends/arm/_passes/scalars_to_attribute_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# 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, Union

import torch
Expand Down
2 changes: 2 additions & 0 deletions backends/arm/_passes/unsqueeze_scalar_placeholders_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# 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

import torch
from executorch.exir.pass_base import ExportPass, PassResult

Expand Down
Loading

0 comments on commit 0120876

Please sign in to comment.