Skip to content

Commit 3887cad

Browse files
committed
Update on "Export a lora model"
^ Program+data combined currently, using the lora linear definition. Issue: #9580 Differential Revision: [D75153377](https://our.internmc.facebook.com/intern/diff/D75153377/) [ghstack-poisoned]
2 parents 65999f0 + c18f598 commit 3887cad

File tree

116 files changed

+4279
-598
lines changed

Some content is hidden

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

116 files changed

+4279
-598
lines changed

.ci/docker/build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ case "${IMAGE_NAME}" in
4343
ARM_SDK=yes
4444
CLANG_VERSION=12
4545
;;
46+
executorch-ubuntu-22.04-zephyr-sdk)
47+
ZEPHYR_SDK=yes
48+
GCC_VERSION=11
49+
;;
4650
executorch-ubuntu-22.04-qnn-sdk)
4751
QNN_SDK=yes
4852
CLANG_VERSION=12
@@ -87,6 +91,7 @@ docker build \
8791
--build-arg "LINTRUNNER=${LINTRUNNER:-}" \
8892
--build-arg "BUILD_DOCS=${BUILD_DOCS}" \
8993
--build-arg "ARM_SDK=${ARM_SDK:-}" \
94+
--build-arg "ZEPHYR_SDK=${ZEPHYR_SDK:-}" \
9095
--build-arg "QNN_SDK=${QNN_SDK:-}" \
9196
--build-arg "MEDIATEK_SDK=${MEDIATEK_SDK:-}" \
9297
--build-arg "ANDROID_NDK_VERSION=${ANDROID_NDK_VERSION:-}" \
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
2+
#!/bin/bash
3+
# Copyright (c) Meta Platforms, Inc. and affiliates.
4+
# All rights reserved.
5+
#
6+
# This source code is licensed under the BSD-style license found in the
7+
# LICENSE file in the root directory of this source tree.
8+
9+
set -ex
10+
11+
# Double check if the NDK version is set
12+
[ -n "${ZEPHYR_SDK}" ]
13+
14+
install_prerequiresites() {
15+
rm /var/lib/dpkg/info/libc-bin.*
16+
apt-get clean
17+
apt-get -y update
18+
apt-get install -y libc-bin
19+
apt-get -y update
20+
apt-get clean
21+
apt-get install --no-install-recommends -y dos2unix
22+
apt-get install --no-install-recommends -y ca-certificates
23+
apt-get install -y --reinstall libc-bin
24+
apt-get install --no-install-recommends -y file
25+
apt-get install --no-install-recommends -y locales
26+
apt-get install --no-install-recommends -y git
27+
apt-get install --no-install-recommends -y build-essential
28+
apt-get install --no-install-recommends -y cmake
29+
apt-get install --no-install-recommends -y ninja-build gperf
30+
apt-get install --no-install-recommends -y device-tree-compiler
31+
apt-get install --no-install-recommends -y wget
32+
apt-get install --no-install-recommends -y curl
33+
apt-get install --no-install-recommends -y xz-utils
34+
apt-get install --no-install-recommends -y dos2unix
35+
apt-get install --no-install-recommends -y vim
36+
apt-get install --no-install-recommends -y nano
37+
apt-get install --no-install-recommends -y mc
38+
apt-get install --no-install-recommends -y openssh-server
39+
apt-get install -y gdb
40+
41+
# Zephyr SDK relies on python 3.12
42+
apt install software-properties-common -y
43+
add-apt-repository ppa:deadsnakes/ppa -y
44+
apt update
45+
apt install -y python3.12 python3.12-dev python3.12-venv python3-pip
46+
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1
47+
48+
# Upgrade cmake ot 3.24
49+
apt update
50+
apt install cmake
51+
apt install software-properties-common lsb-release
52+
apt update
53+
test -f /usr/share/doc/kitware-archive-keyring/copyright || \
54+
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
55+
"deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/kitware.list > /dev/null
56+
apt update
57+
apt install cmake
58+
59+
# Install additional required software for Zephyr
60+
apt install --no-install-recommends -y ccache \
61+
dfu-util \
62+
python3-setuptools \
63+
python3-tk \
64+
python3-wheel \
65+
make \
66+
gcc \
67+
libsdl2-dev \
68+
libmagic1 \
69+
xterm \
70+
telnet \
71+
net-tools
72+
apt install --no-install-recommends -y gcc-multilib g++-multilib
73+
apt-get clean -y
74+
apt-get autoremove --purge -y
75+
rm -rf /var/lib/apt/lists/*
76+
wget https://apt.kitware.com/kitware-archive.sh && \
77+
chmod +x kitware-archive.sh && \
78+
./kitware-archive.sh && \
79+
rm -f kitware-archive.sh
80+
useradd -d /home/zephyruser -m -s /bin/bash zephyruser
81+
}
82+
83+
install_sdk() {
84+
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.0/zephyr-sdk-0.16.0_linux-x86_64.tar.xz && \
85+
tar -xf zephyr-sdk-0.16.0_linux-x86_64.tar.xz && \
86+
rm -f zephyr-sdk-0.16.0_linux-x86_64.tar.xz && \
87+
cd zephyr-sdk-0.16.0/ && \
88+
./setup.sh -c -t arm-zephyr-eabi
89+
}
90+
91+
install_prerequiresites
92+
install_sdk

.ci/docker/ubuntu/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ RUN rm install_android.sh
8484

8585
ARG ARM_SDK
8686

87+
ARG ZEPHYR_SDK
88+
COPY ./common/install_zephyr.sh install_zephyr.sh
89+
RUN if [ -n "${ZEPHYR_SDK}" ]; then bash ./install_zephyr.sh; fi
90+
RUN rm install_zephyr.sh
91+
8792
ARG QNN_SDK
8893

8994
ARG MEDIATEK_SDK

.ci/scripts/build_llama_android.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ install_executorch_and_backend_lib() {
1919
echo "Installing executorch and xnnpack backend"
2020
clean_executorch_install_folders
2121
mkdir cmake-android-out
22-
ANDROID_NDK=/opt/ndk
22+
ANDROID_NDK=${ANDROID_NDK:-/opt/ndk}
2323
BUCK2=buck2
2424
ANDROID_ABI=arm64-v8a
2525
cmake --preset llm \

.github/workflows/build-presets.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
job-name: build
4545
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
4646
runner: linux.2xlarge
47-
docker-image: ci-image:executorch-ubuntu-22.04-arm-sdk
47+
docker-image: ci-image:executorch-ubuntu-22.04-zephyr-sdk
4848
submodules: recursive
4949
timeout: 90
5050
script: |

.github/workflows/docker-builds.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
executorch-ubuntu-22.04-clang12,
3838
executorch-ubuntu-22.04-linter,
3939
executorch-ubuntu-22.04-arm-sdk,
40+
executorch-ubuntu-22.04-zephyr-sdk,
4041
executorch-ubuntu-22.04-qnn-sdk,
4142
executorch-ubuntu-22.04-mediatek-sdk,
4243
executorch-ubuntu-22.04-clang12-android

.github/workflows/pull.yml

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -632,32 +632,33 @@ jobs:
632632
# run eval_llama wikitext task
633633
PYTHON_EXECUTABLE=python bash .ci/scripts/test_eval_llama_wikitext.sh
634634
635-
test-eval_llama-mmlu-linux:
636-
name: test-eval_llama-mmlu-linux
637-
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
638-
permissions:
639-
id-token: write
640-
contents: read
641-
strategy:
642-
fail-fast: false
643-
with:
644-
runner: linux.24xlarge
645-
docker-image: ci-image:executorch-ubuntu-22.04-clang12
646-
submodules: 'recursive'
647-
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
648-
timeout: 90
649-
script: |
650-
# The generic Linux job chooses to use base env, not the one setup by the image
651-
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
652-
conda activate "${CONDA_ENV}"
653-
654-
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool "cmake"
655-
656-
# install llama requirements
657-
bash examples/models/llama/install_requirements.sh
658-
659-
# run eval_llama mmlu task
660-
PYTHON_EXECUTABLE=python bash .ci/scripts/test_eval_llama_mmlu.sh
635+
# TODO(larryliu0820): Fix this issue before reenabling it: https://gist.github.com/larryliu0820/7377ecd0d79dbc06076cec8d9f2b85d2
636+
# test-eval_llama-mmlu-linux:
637+
# name: test-eval_llama-mmlu-linux
638+
# uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
639+
# permissions:
640+
# id-token: write
641+
# contents: read
642+
# strategy:
643+
# fail-fast: false
644+
# with:
645+
# runner: linux.24xlarge
646+
# docker-image: ci-image:executorch-ubuntu-22.04-clang12
647+
# submodules: 'recursive'
648+
# ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
649+
# timeout: 90
650+
# script: |
651+
# # The generic Linux job chooses to use base env, not the one setup by the image
652+
# CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
653+
# conda activate "${CONDA_ENV}"
654+
655+
# PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool "cmake"
656+
657+
# # install llama requirements
658+
# bash examples/models/llama/install_requirements.sh
659+
660+
# # run eval_llama mmlu task
661+
# PYTHON_EXECUTABLE=python bash .ci/scripts/test_eval_llama_mmlu.sh
661662

662663
test-llama_runner_eager-linux:
663664
name: test-llama_runner_eager-linux

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ endif()
161161

162162
if(EXECUTORCH_BUILD_TESTS)
163163
include(CTest)
164+
else()
165+
# It looks like some of our third-party deps will try to turn this on if it's
166+
# not explicitly set, leading to confusing behavior.
167+
set(BUILD_TESTING OFF)
164168
endif()
165169

166170
add_subdirectory(third-party)
@@ -737,7 +741,10 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
737741
endif()
738742

739743
set(CMAKE_EXECUTABLE_SUFFIX ".html")
740-
target_link_options(executor_runner PUBLIC -sALLOW_MEMORY_GROWTH --embed-file "${WASM_MODEL_DIR}@/")
744+
target_link_options(
745+
executor_runner PUBLIC -sALLOW_MEMORY_GROWTH --embed-file
746+
"${WASM_MODEL_DIR}@/"
747+
)
741748
endif()
742749
endif()
743750

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Platform Support:
2929
- Arm
3030
- Cadence
3131
- MediaTek
32+
- NXP
3233
- OpenVINO
3334
- Qualcomm
3435
- Vulkan

backends/apple/coreml/compiler/coreml_preprocess.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
logger = logging.getLogger(__name__)
2929
logger.setLevel(logging.WARNING)
3030

31+
from executorch.backends.apple.coreml.compiler.torch_ops import * # noqa: F401, F403
32+
3133

3234
class COMPILE_SPEC_KEYS(Enum):
3335
COMPUTE_UNITS = "compute_units"

0 commit comments

Comments
 (0)