Skip to content

Commit 7724fd7

Browse files
authored
Arm backend: Clarify aot_arm_compiler being a test script (pytorch#19684)
Based on the decision that aot_arm_compiler should no longer be used for production use, this patch updates the documentation to direct users away from aot_arm_compiler for production use, and instead points them to the Python API. Signed-off-by: Martin Lindström <Martin.Lindstroem@arm.com>
1 parent 9851477 commit 7724fd7

4 files changed

Lines changed: 53 additions & 13 deletions

File tree

backends/arm/README.md

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,33 @@ Developers who need local source builds can use:
116116
The current flow lowers to TOSA and converts to VGF for use in external projects,
117117
so the `executor_runner` is not typically used here.
118118

119+
### Compiling models with the Python API
120+
121+
Use the Python API as the primary way to compile your own models. It lets you
122+
keep model construction, export inputs, quantization, custom passes, and artifact
123+
generation in your application code. The `aot_arm_compiler.py` script is useful
124+
for simple examples and smoke tests, but production code should call the
125+
ExecuTorch and Arm backend APIs directly.
126+
127+
The delegated Python API flow is:
128+
129+
1. Prepare the model and representative example inputs.
130+
2. Create a target-specific Arm compile spec.
131+
3. Export the model with `torch.export.export`.
132+
4. Optionally quantize with the target-specific Arm quantizer and re-export the
133+
quantized graph.
134+
5. Create the matching Arm partitioner from the compile spec.
135+
6. Lower with `to_edge_transform_and_lower`.
136+
7. Convert to an ExecuTorch program and save the PTE file.
137+
138+
For complete examples of that flow, including quantization and target-specific
139+
compile specs, see:
140+
141+
- `docs/source/backends/arm-ethos-u/tutorials/ethos-u-getting-started.md`
142+
- `docs/source/backends/arm-vgf/tutorials/vgf-getting-started.md`
143+
144+
Additional examples are available in `examples/arm`.
145+
119146
### Direct Drive (experimental, Ethos-U85 on Linux) workflow
120147

121148
Direct Drive enables execution on Ethos-U85 via the Linux driver stack.
@@ -159,7 +186,8 @@ scp -P 2222 arm_test/cmake-out/executor_runner root@127.0.0.1:/tmp/
159186

160187
#### Direct Drive model (PTE) workflow
161188

162-
Create a PTE file:
189+
For a quick test with the example `add` model,
190+
`aot_arm_compiler.py` can be used:
163191

164192
```
165193
python3 -m backends.arm.scripts.aot_arm_compiler \
@@ -170,16 +198,30 @@ python3 -m backends.arm.scripts.aot_arm_compiler \
170198
--direct_drive
171199
```
172200

201+
For production use, the Python API described in
202+
[Compiling models with the Python API](#compiling-models-with-the-python-api)
203+
should be used. Use an Ethos-U85 target and set the Direct Drive `extra_flags` when creating the `EthosUCompileSpec`:
204+
205+
```python
206+
compile_spec = EthosUCompileSpec(
207+
target="ethos-u85-256",
208+
extra_flags=["--separate-io-regions", "--cop-format=COP2"],
209+
)
210+
```
211+
212+
Then save the generated program as e.g. `model.pte` or
213+
update the copy and run commands below to match your output file name.
214+
173215
Copy the `executor_runner` binary and the generated PTE file to the running FVP:
174216

175217
```
176-
scp -P 2222 arm_test/cmake-out/executor_runner add_arm_delegate_ethos-u85-256.pte root@127.0.0.1:/tmp/
218+
scp -P 2222 arm_test/cmake-out/executor_runner model.pte root@127.0.0.1:/tmp/
177219
```
178220

179221
Run the model on the FVP:
180222

181223
```
182-
ssh -p 2222 root@127.0.0.1 -t "/tmp/executor_runner -model_path /tmp/add_arm_delegate_ethos-u85-256.pte -num_executions 1"
224+
ssh -p 2222 root@127.0.0.1 -t "/tmp/executor_runner -model_path /tmp/model.pte -num_executions 1"
183225
```
184226

185227
## Testing

docs/source/backends/arm-ethos-u/tutorials/ethos-u-getting-started.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ In this tutorial you will learn how to export a simple PyTorch model for the Exe
2020
```{tip}
2121
If you are already familiar with this delegate, you may want to jump directly to the examples:
2222
* [Examples in the ExecuTorch repository](https://github.com/pytorch/executorch/tree/main/examples/arm)
23-
* [A commandline compiler for example models](https://github.com/pytorch/executorch/blob/main/backends/arm/scripts/aot_arm_compiler.py)
23+
* [A commandline compiler for quick tests and example models](https://github.com/pytorch/executorch/blob/main/backends/arm/scripts/aot_arm_compiler.py)
2424
```
2525

2626
This tutorial serves as an introduction to using ExecuTorch to deploy PyTorch models on Arm&reg; Ethos&trade;-U targets. It is based on `ethos_u_minimal_example.ipynb`, provided in Arm’s examples folder.
@@ -142,9 +142,10 @@ save_pte_program(executorch_program_manager, "ethos_u_minimal_example.pte")
142142

143143

144144
```{tip}
145-
For a quick start, you can use the script `backends/arm/scripts/aot_arm_compiler.py` to produce the pte.
145+
For a quick test, you can use the script `backends/arm/scripts/aot_arm_compiler.py` to produce the pte.
146146
To produce a pte file equivalent to the one above, run
147-
`python -m backends.arm.scripts.aot_arm_compiler --model_name=add --delegate --quantize --output=ethos_u_minimal_example.pte`
147+
`python -m backends.arm.scripts.aot_arm_compiler --model_name=add --delegate --quantize --output=ethos_u_minimal_example.pte`.
148+
For production use, you should instead use the stable Python API shown above.
148149
```
149150

150151
### Runtime:

docs/source/backends/arm-vgf/tutorials/vgf-getting-started.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ You may encounter some rough edges and features which may be documented or plann
2626
```{tip}
2727
If you are already familiar with this delegate, you may want to jump directly to the examples:
2828
* [Examples in the ExecuTorch repository](https://github.com/pytorch/executorch/tree/main/examples/arm)
29-
* [A commandline compiler for example models](https://github.com/pytorch/executorch/blob/main/backends/arm/scripts/aot_arm_compiler.py)
29+
* [A commandline compiler for quick tests and example models](https://github.com/pytorch/executorch/blob/main/backends/arm/scripts/aot_arm_compiler.py)
3030
```
3131

3232
This tutorial serves as an introduction to using ExecuTorch to deploy PyTorch models on VGF targets. The tutorial is based on `vgf_minimal_example.ipyb`, provided in Arm's example folder.
@@ -163,9 +163,10 @@ assert os.path.exists(pte_path), "Build failed; no .pte-file found"
163163

164164

165165
```{tip}
166-
For a quick start, you can use the script `backends/arm/scripts/aot_arm_compiler.py` to produce the pte.
166+
For a quick test, you can use the script `backends/arm/scripts/aot_arm_compiler.py` to produce the pte.
167167
To produce a pte file equivalent to the one above, run
168-
`python -m backends.arm.scripts.aot_arm_compiler --model_name=add --delegate --quantize --output=simple_example.pte --target=vgf`
168+
`python -m backends.arm.scripts.aot_arm_compiler --model_name=add --delegate --quantize --output=simple_example.pte --target=vgf`.
169+
For production use, you should instead use the stable Python API shown above.
169170
```
170171

171172
## Runtime

examples/arm/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ this can be changed with --et_build_root=<FOLDER>
2323
`aot_arm_compiler.py` is used to convert a Python model or a saved .pt model to a PTE file and is used by `run.sh`
2424
and other test script but can also be used directly.
2525

26-
If you prefer to use the ExecuTorch API, there is also the `ethos_u_minimal_example.ipynb` notebook example.
27-
This shows the workflow if you prefer to integrate a python torch.export and ExecuTorch flow directly into your
28-
model codebase. This is particularly useful if you want to perform more complex training, such as quantization
29-
aware training using the ArmQuantizer.
3026

3127
## Create a PTE file for Arm backends
3228

0 commit comments

Comments
 (0)