|
| 1 | + |
| 2 | +# Requirements |
| 3 | +In order to run the training and quantization scripts, you would need to: |
| 4 | +1) Install the [sooftware conformer model](https://github.com/sooftware/conformer) as a pip package. |
| 5 | +2) Download the [LibriSpeech dataset from torchaudio](https://docs.pytorch.org/audio/stable/generated/torchaudio.datasets.LIBRISPEECH.html) and tokenizer from the `training` folder. |
| 6 | +3) For the post-training quantization, you need to install ExecuTorch from source. We recommend you to install ExecuTorch from a python 3.10 virtual environmental variable. |
| 7 | +Clone the [ExecuTorch repository](https://github.com/pytorch/executorch/), checkout the `release/1.0` branch and run `./install_executorch.sh` from the root folder. You also need to install the |
| 8 | +Ethos-U backend dependencies within ExecuTorch, you can do that by running `./examples/arm/setup.sh --i-agree-to-the-contained-eula`. |
| 9 | +You can find detailed instructions about installing ExecuTorch from source [in the official documentation](https://docs.pytorch.org/executorch/stable/using-executorch-building-from-source.html#install-executorch-pip-package-from-source). The |
| 10 | +detailed instructions for setting up the Arm backend are in the [examples/arm folder](https://github.com/pytorch/executorch/tree/main/examples/arm#example-workflow). The key commands are: |
| 11 | +``` |
| 12 | +$ git clone [email protected]:pytorch/executorch.git |
| 13 | +$ git checkout git release/1.0 |
| 14 | +$ git submodule sync && git submodule update --init --recursive |
| 15 | +$ ./install_executorch.sh |
| 16 | +$ ./examples/arm/setup.sh --i-agree-to-the-contained-eula |
| 17 | +``` |
| 18 | + |
| 19 | +## Torchcodec |
| 20 | +We use `torchaudio` for the pre-processing of the LibriSpeech dataset. Since [August 2025](https://github.com/pytorch/audio/commit/93f582ca5001132bfcdb115f476b73ae60e6ef8a), torchaudio requires torchcodec. |
| 21 | +You need to install the correct version of the `torchcodec` in order to be able to load audio samples with torchaudio. When you install ExecuTorch from the release/1.0 branch, you will get torchaudio 2.8.0.dev20250906 : |
| 22 | +``` |
| 23 | +$ pip freeze | grep torch |
| 24 | +torch==2.9.0.dev20250906 |
| 25 | +torchaudio==2.8.0.dev20250906 |
| 26 | +torchvision==0.24.0.dev20250906 |
| 27 | +.... |
| 28 | +``` |
| 29 | +Manually install the torchcodec package corresponding to the minor version of torchaudio. In this example, you need to install minor version dev20250906 of torchcodec. |
| 30 | +``` |
| 31 | +$ pip install --pre --no-deps --index-url https://download.pytorch.org/whl/nightly/cpu \ |
| 32 | + "torchcodec==0.7.0.dev20250906" |
| 33 | +``` |
| 34 | +As per the [torchcodec documentation](https://github.com/pytorch/torchcodec?tab=readme-ov-file#installing-torchcodec), you need to ensure you have a version of `ffmpeg` smaller than 8. |
| 35 | +On a Mac OS, you also need to export the `DYLD_FALLBACK_LIBRARY_PATH` environment variable to the location of the torchcodec binaries. |
| 36 | +``` |
| 37 | +export DYLD_FALLBACK_LIBRARY_PATH="/opt/homebrew/opt/ffmpeg@7/lib:/opt/homebrew/lib" |
| 38 | +``` |
| 39 | + |
| 40 | +You can now use the latest torchaudio and load audio recordings with torchcodec. |
| 41 | + |
| 42 | +# Quantization |
| 43 | + |
| 44 | +The `ptq_evaluate_conformer_10M.py` script provides a way to quantize a Conformer speech recognition network, evaluate its accuracy on the LibriSpeech dataset and generate an ExecuTorch pte for the Ethos-U NPU. |
| 45 | +We assume you have obtained a trained checkpoint from the Training section. Run the `ptq_evaluate_10M_model.py` script to obtain a pte file that will be deployed on device in the following way: |
| 46 | + `$ python ptq_evaluate_conformer_10M.py --root <path to the LibriSpeech dataset> --dataset <dataset, usually test-clean> --checkpoint <path to checkpoint with trained weights> --sp-model <path to the tokenizer>` |
| 47 | + |
| 48 | +We obtain ~8% Word Error Rate when evaluating the quantized model on the test-clean dataset. |
0 commit comments