Skip to content

Commit 1aaeaa7

Browse files
author
pytorchbot
committed
2024-10-17 nightly release (ad0e5e8)
1 parent 400150b commit 1aaeaa7

File tree

174 files changed

+1918
-1321
lines changed

Some content is hidden

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

174 files changed

+1918
-1321
lines changed

.ci/scripts/build_llama_android.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ build_llama_runner() {
4848
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
4949
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
5050
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
51-
-Bcmake-android-out/examples/models/llama2 examples/models/llama2
51+
-Bcmake-android-out/examples/models/llama examples/models/llama
5252

53-
cmake --build cmake-android-out/examples/models/llama2 -j4 --config Release
53+
cmake --build cmake-android-out/examples/models/llama -j4 --config Release
5454
}
5555
install_flatc_from_source
5656
install_executorch_and_backend_lib

.ci/scripts/test_llama.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ cmake_install_executorch_libraries() {
125125

126126
cmake_build_llama_runner() {
127127
echo "Building llama runner"
128-
dir="examples/models/llama2"
128+
dir="examples/models/llama"
129129
retry cmake \
130130
-DCMAKE_INSTALL_PREFIX=cmake-out \
131131
-DCMAKE_BUILD_TYPE=Debug \
@@ -206,7 +206,7 @@ if [[ "${QNN}" == "ON" ]]; then
206206
EXPORT_ARGS="${EXPORT_ARGS} -kv -v --qnn --disable_dynamic_shape"
207207
fi
208208
# Add dynamically linked library location
209-
$PYTHON_EXECUTABLE -m examples.models.llama2.export_llama ${EXPORT_ARGS}
209+
$PYTHON_EXECUTABLE -m examples.models.llama.export_llama ${EXPORT_ARGS}
210210

211211
# Create tokenizer.bin.
212212
echo "Creating tokenizer.bin"
@@ -219,15 +219,15 @@ echo "Running ${EXPORTED_MODEL_NAME} in portable mode"
219219
if [[ "${BUILD_TOOL}" == "buck2" ]]; then
220220
# Run model.
221221
# shellcheck source=/dev/null
222-
$BUCK run examples/models/llama2:main -- ${RUNTIME_ARGS} > result.txt
222+
$BUCK run examples/models/llama:main -- ${RUNTIME_ARGS} > result.txt
223223
elif [[ "${BUILD_TOOL}" == "cmake" ]]; then
224224
cmake_install_executorch_libraries
225225
cmake_build_llama_runner
226226
# Run llama runner
227227
NOW=$(date +"%H:%M:%S")
228228
echo "Starting to run llama runner at ${NOW}"
229229
# shellcheck source=/dev/null
230-
cmake-out/examples/models/llama2/llama_main ${RUNTIME_ARGS} > result.txt
230+
cmake-out/examples/models/llama/llama_main ${RUNTIME_ARGS} > result.txt
231231
NOW=$(date +"%H:%M:%S")
232232
echo "Finished at ${NOW}"
233233
else

.ci/scripts/test_model.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ run_portable_executor_runner() {
7575
test_model() {
7676
if [[ "${MODEL_NAME}" == "llama2" ]]; then
7777
# Install requirements for export_llama
78-
bash examples/models/llama2/install_requirements.sh
79-
# Test export_llama script: python3 -m examples.models.llama2.export_llama
80-
"${PYTHON_EXECUTABLE}" -m examples.models.llama2.export_llama -c examples/models/llama2/params/demo_rand_params.pth -p examples/models/llama2/params/demo_config.json
78+
bash examples/models/llama/install_requirements.sh
79+
# Test export_llama script: python3 -m examples.models.llama.export_llama
80+
"${PYTHON_EXECUTABLE}" -m examples.models.llama.export_llama -c examples/models/llama/params/demo_rand_params.pth -p examples/models/llama/params/demo_config.json
8181
run_portable_executor_runner
8282
rm "./${MODEL_NAME}.pte"
8383
fi

.github/workflows/android-perf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ jobs:
160160
161161
if [[ ${{ matrix.model }} =~ ^stories* ]]; then
162162
# Install requirements for export_llama
163-
PYTHON_EXECUTABLE=python bash examples/models/llama2/install_requirements.sh
163+
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
164164
# Test llama2
165165
if [[ ${{ matrix.delegate }} == "xnnpack" ]]; then
166166
DELEGATE_CONFIG="xnnpack+custom+qe"

.github/workflows/apple-perf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ jobs:
162162
if [[ ${{ matrix.model }} =~ ^stories* ]]; then
163163
# Install requirements for export_llama
164164
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
165-
bash examples/models/llama2/install_requirements.sh
165+
bash examples/models/llama/install_requirements.sh
166166
167167
# Test llama2
168168
if [[ ${{ matrix.delegate }} == "xnnpack" ]]; then

.github/workflows/pull.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ jobs:
9898
- dtype: bf16
9999
build-tool: buck2
100100
mode: portable
101+
- dtype: bf16
102+
build-tool: cmake
103+
mode: custom
104+
- dtype: bf16
105+
build-tool: buck2
106+
mode: custom
101107
fail-fast: false
102108
with:
103109
runner: linux.2xlarge
@@ -117,7 +123,7 @@ jobs:
117123
# Setup executorch
118124
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh buck2
119125
# Install requirements for export_llama
120-
PYTHON_EXECUTABLE=python bash examples/models/llama2/install_requirements.sh
126+
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
121127
# Test llama2
122128
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh stories110M "${BUILD_TOOL}" "${DTYPE}" "${MODE}"
123129
@@ -216,7 +222,7 @@ jobs:
216222
bash install_requirements.sh --pybind xnnpack
217223
218224
# install Llava requirements
219-
bash examples/models/llama2/install_requirements.sh
225+
bash examples/models/llama/install_requirements.sh
220226
bash examples/models/llava/install_requirements.sh
221227
222228
# run python unittest
@@ -411,7 +417,7 @@ jobs:
411417
# Setup executorch
412418
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh buck2
413419
# Install requirements for export_llama
414-
PYTHON_EXECUTABLE=python bash examples/models/llama2/install_requirements.sh
420+
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
415421
# Test llama2
416422
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh stories110M "${BUILD_TOOL}" "${DTYPE}" "${MODE}"
417423

.github/workflows/trunk.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ jobs:
227227
include:
228228
- dtype: bf16
229229
mode: portable
230+
- dtype: bf16
231+
mode: custom
230232
fail-fast: false
231233
with:
232234
runner: macos-m1-stable
@@ -255,7 +257,7 @@ jobs:
255257
fi
256258
257259
# Install requirements for export_llama
258-
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash examples/models/llama2/install_requirements.sh
260+
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash examples/models/llama/install_requirements.sh
259261
# Test llama2
260262
PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_llama.sh stories110M cmake "${DTYPE}" "${MODE}"
261263
@@ -279,7 +281,7 @@ jobs:
279281
# GITHUB_RUNNER=1 PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/setup-macos.sh "${BUILD_TOOL}"
280282

281283
# # install Llava requirements
282-
# ${CONDA_RUN} bash examples/models/llama2/install_requirements.sh
284+
# ${CONDA_RUN} bash examples/models/llama/install_requirements.sh
283285
# ${CONDA_RUN} bash examples/models/llava/install_requirements.sh
284286

285287
# # run python unittest
@@ -385,7 +387,7 @@ jobs:
385387
cmake --build cmake-out -j9 --target install --config Release
386388
387389
echo "Build llama runner"
388-
dir="examples/models/llama2"
390+
dir="examples/models/llama"
389391
cmake \
390392
-DCMAKE_INSTALL_PREFIX=cmake-out \
391393
-DCMAKE_BUILD_TYPE=Release \
@@ -437,5 +439,5 @@ jobs:
437439
438440
python -m extension.export_util.export_hf_model -hfm=${{ matrix.hf_model_repo }} -o ${ET_MODEL_NAME}
439441
440-
cmake-out/examples/models/llama2/llama_main --model_path=${ET_MODEL_NAME}.pte --tokenizer_path=${TOKENIZER_BIN_FILE} --prompt="My name is"
442+
cmake-out/examples/models/llama/llama_main --model_path=${ET_MODEL_NAME}.pte --tokenizer_path=${TOKENIZER_BIN_FILE} --prompt="My name is"
441443
echo "::endgroup::"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ please visit our documentation website [for the latest release](https://pytorch.
2222

2323
Check out the [Getting Started](https://pytorch.org/executorch/stable/getting-started-setup.html#quick-setup-colab-jupyter-notebook-prototype) page for a quick spin.
2424

25-
Check out the examples of [Llama](./examples/models/llama2/README.md), [Llava](./examples/models/llava/README.md) and [other models](./examples/README.md) running on edge devices using ExecuTorch.
25+
Check out the examples of [Llama](./examples/models/llama/README.md), [Llava](./examples/models/llava/README.md) and [other models](./examples/README.md) running on edge devices using ExecuTorch.
2626

2727

28-
**[UPDATE - 09/25]** We have added support for running [Llama 3.2 1B/3B](./examples/models/llama2/README.md) models via ExecuTorch.
28+
**[UPDATE - 09/25]** We have added support for running [Llama 3.2 1B/3B](./examples/models/llama/README.md) models via ExecuTorch.
2929

3030
## Feedback
3131

backends/apple/coreml/runtime/inmemoryfs/inmemory_filesystem.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,11 @@ bool write_directory_node(InMemoryDirectoryNode* node,
253253
return false;
254254
}
255255

256-
for (const auto& [_, node]: node->get_items()) {
257-
if (node.get()->isDirectory() && !recursive) {
256+
for (const auto& [_, node_2]: node->get_items()) {
257+
if (node_2.get()->isDirectory() && !recursive) {
258258
continue;
259259
}
260-
if (!write_node(node.get(), dir_path, recursive, error)) {
260+
if (!write_node(node_2.get(), dir_path, recursive, error)) {
261261
return false;
262262
}
263263
}
@@ -383,9 +383,9 @@ FlattenedInMemoryNode::unflatten(const std::vector<FlattenedInMemoryNode>& flatt
383383
case InMemoryFileSystem::InMemoryNode::Kind::Directory: {
384384
std::unordered_map<std::string, std::unique_ptr<InMemoryFileSystem::InMemoryNode>> items;
385385
items.reserve(flattened_node_metadata.child_name_to_indices_map.size());
386-
for (const auto& [name, index]: flattened_node_metadata.child_name_to_indices_map) {
387-
auto moveIt = std::make_move_iterator(nodes.begin() + index);
388-
items[name] = *moveIt;
386+
for (const auto& [name_2, index_2]: flattened_node_metadata.child_name_to_indices_map) {
387+
auto moveIt = std::make_move_iterator(nodes.begin() + index_2);
388+
items[name_2] = *moveIt;
389389
}
390390
auto directory_node =
391391
std::make_unique<InMemoryDirectoryNode>(std::move(name), std::move(attributes), std::move(items));

backends/qualcomm/_passes/annotate_quant_attrs.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@ class AnnotateQuantAttrs(ExportPass):
2727
generated after quatization process.
2828
"""
2929

30-
def __init__(self, edge_program: torch.export.ExportedProgram):
30+
def __init__(
31+
self, edge_program: torch.export.ExportedProgram, skip_advanced_requat: bool
32+
):
3133
super(AnnotateQuantAttrs, self).__init__()
3234
self.edge_program = edge_program
35+
self.skip_advanced_requant = skip_advanced_requat
3336

3437
def _annotate_source_nodes(
3538
self, quant_node: torch.fx.Node, quant_attrs: Dict[str, Any]
@@ -68,9 +71,26 @@ def _annotate_requant(self, n):
6871

6972
# TODO: Store multiple pairs of requantize attributes when we have an op builder
7073
# that has multiple outputs that requires quant attributes.
71-
if q_attrs["dtype"] != dq_attrs["dtype"]:
72-
dq_attrs[QCOM_ENCODING] = q_attrs[QCOM_ENCODING]
73-
n.args[0].meta[QCOM_REQUANTIZE] = dq_attrs
74+
if self.skip_advanced_requant:
75+
if q_attrs["dtype"] != dq_attrs["dtype"]:
76+
dq_attrs[QCOM_ENCODING] = q_attrs[QCOM_ENCODING]
77+
n.args[0].meta[QCOM_REQUANTIZE] = dq_attrs
78+
else:
79+
# When dtype is the same but other specs such as scale and offset are different,
80+
# insert requant to improve accuracy.
81+
# Users can turn this feature off if any inference speed drop is observed.
82+
if any(
83+
q_attrs[attr] != dq_attrs[attr]
84+
for attr in [
85+
"scale",
86+
"zero_point",
87+
"quant_min",
88+
"quant_max",
89+
"dtype",
90+
]
91+
):
92+
dq_attrs[QCOM_ENCODING] = q_attrs[QCOM_ENCODING]
93+
n.args[0].meta[QCOM_REQUANTIZE] = dq_attrs
7494

7595
# Dequant all the fold_quant parameters back to fp32.
7696
# If an operation is not supported by QNN and got fallback, it will expect a fp32 param.

0 commit comments

Comments
 (0)