ExecuTorch documentation
Adding support for an unsupported architecture
Adding support for an unsupported architecture
We welcome contributions to extend the functionality of ExecuTorch export. This guide provides high-level instructions for contributors who want to:
- Export a new model that is not currently supported.
- Add new recipes or support a new task for export.
Exporting a New Model
If you want to export a model that is not already supported by the library, follow these steps:
Step 1: Export and Test the Model
- Attempt to export and lower the model using an existing task and recipe. On success, it will store the exported model in a
.pte
file. - Add a test case for the model in the appropriate test suite.
- For example, you can make sure tests pass for the new
my_new_model
by running:pytest tests/executorch/export/test_*.py -k "test_my_new_model" # doctest: +SKIP pytest tests/executorch/runtime/test_*.py -k "test_my_new_model" # doctest: +SKIP
- For example, you can make sure tests pass for the new
Step 2: Handle Export Failures
- If the export fails in Step 1, report the issue by opening a GitHub issue.
- If the issue requires changes to the model’s architecture or its Hugging Face implementation, these modifications may be made upstream in the Hugging Face Transformers library.
Adding New Recipes or Tasks
To extend ExecuTorch with new recipes or tasks, follow these guidelines:
Registering a New Recipe
You can add a custom recipe to define specific optimizations or configurations for exporting models. Below is an example:
from exporters.executorch import register_recipe
@register_recipe("my_custom_recipe")
def export_with_custom_recipe(model, config, *args, **kwargs):
# Example: Apply a custom quantization
Registering a Task
The task registration process is same as adding a recipe. Besides that you may need to implement a new ExecuTorchModelForXXX
class.