ExecuTorch documentation

Adding support for an unsupported architecture

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

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:

  1. Export a new model that is not currently supported.
  2. 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

  1. 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.
  2. 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

Step 2: Handle Export Failures

  1. If the export fails in Step 1, report the issue by opening a GitHub issue.
  2. 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.