Skip to content

Commit ccda565

Browse files
authored
Merge branch 'main' into gh/SS-JIA/161/orig
2 parents f1c5e51 + 7001ac7 commit ccda565

File tree

10 files changed

+56
-26
lines changed

10 files changed

+56
-26
lines changed

.github/workflows/android-perf.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ jobs:
9898
- uses: actions/checkout@v3
9999

100100
- name: Prepare the spec
101+
id: prepare
101102
shell: bash
102103
env:
103104
BENCHMARK_CONFIG: ${{ toJSON(matrix) }}
@@ -111,7 +112,7 @@ jobs:
111112
# so let's just sed it
112113
sed -i -e 's,{{ model_path }},'"${MODEL_PATH}"',g' android-llm-device-farm-test-spec.yml.j2
113114
114-
BENCHMARK_CONFIG_ID="${{ matrix.model }}_${{ matrix.config }}"
115+
BENCHMARK_CONFIG_ID=$(echo "${{ matrix.model }}_${{ matrix.config }}" | sed -e 's/[^A-Za-z0-9._-]/_/g')
115116
# The config for this benchmark runs, we save it in the test spec so that it can be fetched
116117
# later by the upload script
117118
sed -i -e 's,{{ benchmark_config_id }},'"${BENCHMARK_CONFIG_ID}"',g' android-llm-device-farm-test-spec.yml.j2
@@ -122,6 +123,7 @@ jobs:
122123
123124
# Save the benchmark configs so that we can use it later in the dashboard
124125
echo "${BENCHMARK_CONFIG}" > "${BENCHMARK_CONFIG_ID}.json"
126+
echo "benchmark-config-id=${BENCHMARK_CONFIG_ID}" >> $GITHUB_OUTPUT
125127
126128
- name: Upload the spec
127129
uses: seemethere/upload-artifact-s3@v5
@@ -141,7 +143,7 @@ jobs:
141143
${{ github.repository }}/${{ github.run_id }}/artifacts/benchmark-configs/
142144
retention-days: 1
143145
if-no-files-found: error
144-
path: extension/benchmark/android/benchmark/${{ matrix.model }}_${{ matrix.config }}.json
146+
path: extension/benchmark/android/benchmark/${{ steps.prepare.outputs.benchmark-config-id }}.json
145147

146148
export-models:
147149
name: export-models

.github/workflows/apple-perf.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ jobs:
100100
- uses: actions/checkout@v3
101101

102102
- name: Prepare the spec
103+
id: prepare
103104
shell: bash
104105
env:
105106
BENCHMARK_CONFIG: ${{ toJSON(matrix) }}
@@ -113,7 +114,7 @@ jobs:
113114
# so let's just sed it
114115
sed -i -e 's,{{ model_path }},'"${MODEL_PATH}"',g' default-ios-device-farm-appium-test-spec.yml.j2
115116
116-
BENCHMARK_CONFIG_ID="${{ matrix.model }}_${{ matrix.config }}"
117+
BENCHMARK_CONFIG_ID=$(echo "${{ matrix.model }}_${{ matrix.config }}" | sed -e 's/[^A-Za-z0-9._-]/_/g')
117118
# The config for this benchmark runs, we save it in the test spec so that it can be fetched
118119
# later by the upload script
119120
sed -i -e 's,{{ benchmark_config_id }},'"${BENCHMARK_CONFIG_ID}"',g' default-ios-device-farm-appium-test-spec.yml.j2
@@ -124,6 +125,7 @@ jobs:
124125
125126
# Save the benchmark configs so that we can use it later in the dashboard
126127
echo "${BENCHMARK_CONFIG}" > "${BENCHMARK_CONFIG_ID}.json"
128+
echo "benchmark-config-id=${BENCHMARK_CONFIG_ID}" >> $GITHUB_OUTPUT
127129
128130
- name: Upload the spec
129131
uses: seemethere/upload-artifact-s3@v5
@@ -143,7 +145,7 @@ jobs:
143145
${{ github.repository }}/${{ github.run_id }}/artifacts/benchmark-configs/
144146
retention-days: 1
145147
if-no-files-found: error
146-
path: extension/benchmark/apple/Benchmark/${{ matrix.model }}_${{ matrix.config }}.json
148+
path: extension/benchmark/apple/Benchmark/${{ steps.prepare.outputs.benchmark-config-id }}.json
147149

148150
export-models:
149151
name: export-models

backends/cadence/aot/compiler_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,16 @@ def get_transposed_dims(node: torch.fx.Node, dims: List[int]) -> List[int]:
129129

130130

131131
# Capture the effect of permute op on incoming dimension order
132-
def get_permuted_dims(node: torch.fx.Node, dims: Optional[List[int]]) -> List[int]:
132+
def get_permuted_dims(node: torch.fx.Node, dims: Optional[Sequence[int]]) -> List[int]:
133133
"""
134134
Given a permute node, and the incoming dimension ordering of the input
135135
tensor to the permute node, return the net effect of permute op on the
136136
dimension order.
137137
"""
138138
assert node.target == exir_ops.edge.aten.permute_copy.default
139139
# Permute each index of the dimension ordering (dims)
140-
permute_dims = node.args[1]
141-
assert isinstance(permute_dims, List)
140+
# pyre-fixme[6]: This combined typecheck isn't supported yet.
141+
permute_dims: List[int] = list(node.args[1])
142142
assert all(isinstance(x, int) for x in permute_dims)
143143
# If the dims is empty, we can simply return the permute order
144144
if not dims:

backends/cadence/aot/reorder_ops.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,9 @@ def postpone_dequantize_op(self, graph_module: torch.fx.GraphModule) -> bool:
438438
args=(user, *node.args[1:]),
439439
)
440440
dequant_node.meta = user.meta.copy()
441-
# Remove meta["debug_handle"] on new node. Reassign it at the
442-
# caller level by calling generate_missing_debug_handles
443-
dequant_node.meta.pop("debug_handle")
441+
# Remove meta["debug_handle"] on new node if it exists.
442+
# Reassign it at the caller level by calling generate_missing_debug_handles
443+
dequant_node.meta.pop("debug_handle", None)
444444
user.replace_all_uses_with(dequant_node)
445445
dequant_node.args = (user, *node.args[1:])
446446

examples/demo-apps/apple_ios/LLaMA/docs/delegates/xnnpack_README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ Install dependencies
3434
```
3535
./install_requirements.sh
3636
```
37-
37+
Optional: Use the --pybind flag to install with pybindings.
38+
```
39+
./install_requirements.sh --pybind xnnpack
40+
```
3841
## Prepare Models
3942
In this demo app, we support text-only inference with up-to-date Llama models and image reasoning inference with LLaVA 1.5.
4043
* You can request and download model weights for Llama through Meta official [website](https://llama.meta.com/).

examples/models/llama/install_requirements.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
# Install sentencepiece for llama tokenizer
1010
pip install snakeviz sentencepiece
1111

12-
# Install torchao.
13-
pip install "$(dirname "$0")/../../../third-party/ao"
14-
1512
# Install lm-eval for Model Evaluation with lm-evalution-harness
1613
# Install tiktoken for tokenizer
1714
pip install lm_eval==0.4.5

examples/models/llama3_2_vision/install_requirements.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,3 @@ NIGHTLY_VERSION="dev20241112"
99

1010
# Install torchtune nightly for model definitions.
1111
pip install --pre torchtune==0.4.0.${NIGHTLY_VERSION} --extra-index-url https://download.pytorch.org/whl/nightly/cpu --no-cache-dir
12-
13-
# Install torchao.
14-
pip install "$(dirname "$0")/../../../third-party/ao"

examples/models/phi-3-mini-lora/install_requirements.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,3 @@
88
pip install torchvision
99
pip install torchtune
1010
pip install tiktoken
11-
12-
# Install torchao.
13-
pip install "$(dirname "$0")/../../../third-party/ao"

extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml.j2

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ phases:
1818
# Copy the model to sdcard. This prints too much progress info when the files
1919
# are large, so it's better to just silent them
2020
- adb -s $DEVICEFARM_DEVICE_UDID push *.bin /sdcard > /dev/null && echo OK
21+
- adb -s $DEVICEFARM_DEVICE_UDID push *.model /sdcard > /dev/null && echo OK
2122
- adb -s $DEVICEFARM_DEVICE_UDID push *.pte /sdcard > /dev/null && echo OK
2223

2324
# Prepare the model and the tokenizer
2425
- adb -s $DEVICEFARM_DEVICE_UDID shell "ls -la /sdcard/"
2526
- adb -s $DEVICEFARM_DEVICE_UDID shell "mkdir -p /data/local/tmp/minibench/"
2627
- adb -s $DEVICEFARM_DEVICE_UDID shell "mv /sdcard/*.bin /data/local/tmp/minibench/"
28+
- adb -s $DEVICEFARM_DEVICE_UDID shell "mv /sdcard/*.model /data/local/tmp/minibench/"
2729
- adb -s $DEVICEFARM_DEVICE_UDID shell "mv /sdcard/*.pte /data/local/tmp/minibench/"
2830
- adb -s $DEVICEFARM_DEVICE_UDID shell "chmod 664 /data/local/tmp/minibench/*.bin"
31+
- adb -s $DEVICEFARM_DEVICE_UDID shell "chmod 664 /data/local/tmp/minibench/*.model"
2932
- adb -s $DEVICEFARM_DEVICE_UDID shell "chmod 664 /data/local/tmp/minibench/*.pte"
3033
- adb -s $DEVICEFARM_DEVICE_UDID shell "ls -la /data/local/tmp/minibench/"
3134
- adb -s $DEVICEFARM_DEVICE_UDID shell "run-as org.pytorch.minibench rm -rf files"
@@ -86,21 +89,33 @@ phases:
8689
- |
8790
BIN_FOUND="$(adb -s $DEVICEFARM_DEVICE_UDID shell find /data/local/tmp/minibench/ -name '*.bin')"
8891
if [ -z "$BIN_FOUND" ]; then
89-
echo "No tokenizer files found in /data/local/tmp/minibench/"
92+
echo "No *.bin tokenizer files found in /data/local/tmp/minibench/"
9093
else
91-
echo "tokenizer files found in /data/local/tmp/minibench/"
94+
echo "*.bin tokenizer files found in /data/local/tmp/minibench/"
95+
fi
96+
97+
MODEL_FOUND="$(adb -s $DEVICEFARM_DEVICE_UDID shell find /data/local/tmp/minibench/ -name '*.model')"
98+
if [ -z "$MODEL_FOUND" ]; then
99+
echo "No *.model tokenizer files found in /data/local/tmp/minibench/"
100+
else
101+
echo "*.model tokenizer files found in /data/local/tmp/minibench/"
92102
fi
93103

94104
- echo "Run benchmark"
95105
- |
96106
adb -s $DEVICEFARM_DEVICE_UDID shell am force-stop org.pytorch.minibench
97-
if [ -z "$BIN_FOUND" ]; then
98-
adb -s $DEVICEFARM_DEVICE_UDID shell am start -W -n org.pytorch.minibench/.BenchmarkActivity \
99-
--es "model_dir" "/data/local/tmp/minibench"
100-
else
107+
108+
if [ -n "$BIN_FOUND" ]; then
101109
adb -s $DEVICEFARM_DEVICE_UDID shell am start -W -n org.pytorch.minibench/.LlmBenchmarkActivity \
102110
--es "model_dir" "/data/local/tmp/minibench" \
103111
--es "tokenizer_path" "/data/local/tmp/minibench/tokenizer.bin"
112+
elif [ -n "$MODEL_FOUND" ]; then
113+
adb -s $DEVICEFARM_DEVICE_UDID shell am start -W -n org.pytorch.minibench/.LlmBenchmarkActivity \
114+
--es "model_dir" "/data/local/tmp/minibench" \
115+
--es "tokenizer_path" "/data/local/tmp/minibench/tokenizer.model"
116+
else
117+
adb -s $DEVICEFARM_DEVICE_UDID shell am start -W -n org.pytorch.minibench/.BenchmarkActivity \
118+
--es "model_dir" "/data/local/tmp/minibench"
104119
fi
105120

106121

install_requirements.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,23 @@ def python_is_compatible():
170170
check=True,
171171
)
172172

173+
LOCAL_REQUIREMENTS = [
174+
"third-party/ao", # We need the latest kernels for fast iteration, so not relying on pypi.
175+
]
176+
177+
# Install packages directly from local copy instead of pypi.
178+
# This is usually not recommended.
179+
subprocess.run(
180+
[
181+
sys.executable,
182+
"-m",
183+
"pip",
184+
"install",
185+
*LOCAL_REQUIREMENTS,
186+
],
187+
check=True,
188+
)
189+
173190
#
174191
# Install executorch pip package. This also makes `flatc` available on the path.
175192
# The --extra-index-url may be necessary if pyproject.toml has a dependency on a

0 commit comments

Comments
 (0)