Skip to content

Can't run example code #224

@TroyeKizzz

Description

@TroyeKizzz

I installed everything like in the README file and I don't have any previous installations. But I can't even run the example code. I'm not really familiar with optimum-executorch or even executorch so I don't even know how to make sense of it.

Steps to reproduce

conda create -n optimum-executorch python=3.11
conda activate optimum-executorch
git clone https://github.com/huggingface/optimum-executorch.git
cd optimum-executorch
pip install '.[dev]'
python install_dev.py
optimum-cli export executorch \
  --model google/gemma-3-1b-it \
  --task text-generation \
  --recipe xnnpack \
  --use_custom_sdpa \
  --use_custom_kv_cache \
  --qlinear 8da4w \
  --qembedding 8w

Output

Skipping import of cpp extensions due to incompatible torch version 2.12.0.dev20260317 for torchao version 0.17.0.dev20260317+cpu             Please see https://github.com/pytorch/ao/issues/2919 for more info
/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/torchao/dtypes/utils.py:89: UserWarning: Deprecation: PlainLayout is deprecated and will be removed in a future release of torchao, see https://github.com/pytorch/ao/issues/2752 for more details
  warnings.warn(
W0330 15:25:09.190000 69468 site-packages/torch/distributed/elastic/multiprocessing/redirects.py:29] NOTE: Redirects are currently not supported in Windows or MacOs.
/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/torchao/float8/float8_training_tensor.py:122: FutureWarning: torch._dynamo.allow_in_graph is deprecated and will be removed in a future version. Use torch._dynamo.nonstrict_trace instead.
  @torch._dynamo.allow_in_graph
/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/torchao/float8/float8_training_tensor.py:195: FutureWarning: torch._dynamo.allow_in_graph is deprecated and will be removed in a future version. Use torch._dynamo.nonstrict_trace instead.
  @torch._dynamo.allow_in_graph
/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/torchao/float8/float8_scaling_utils.py:90: FutureWarning: torch._dynamo.allow_in_graph is deprecated and will be removed in a future version. Use torch._dynamo.nonstrict_trace instead.
  @torch._dynamo.allow_in_graph
/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/torchao/float8/float8_linear.py:28: FutureWarning: torch._dynamo.allow_in_graph is deprecated and will be removed in a future version. Use torch._dynamo.nonstrict_trace instead.
  @torch._dynamo.allow_in_graph
/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/torchao/dtypes/nf4tensor.py:1176: FutureWarning: torch._dynamo.allow_in_graph is deprecated and will be removed in a future version. Use torch._dynamo.nonstrict_trace instead.
  @torch._dynamo.allow_in_graph
/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/torchao/prototype/mx_formats/mx_tensor.py:546: FutureWarning: torch._dynamo.allow_in_graph is deprecated and will be removed in a future version. Use torch._dynamo.nonstrict_trace instead.
  @torch._dynamo.allow_in_graph
/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/torchao/prototype/mx_formats/mx_tensor.py:604: FutureWarning: torch._dynamo.allow_in_graph is deprecated and will be removed in a future version. Use torch._dynamo.nonstrict_trace instead.
  @torch._dynamo.allow_in_graph
/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/transformers/modeling_utils.py:1147: FutureWarning: torch._dynamo.allow_in_graph is deprecated and will be removed in a future version. Use torch._dynamo.nonstrict_trace instead.
  @torch._dynamo.allow_in_graph
Traceback (most recent call last):
  File "/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/executorch/extension/llm/custom_ops/custom_ops.py", line 26, in <module>
    op = torch.ops.llama.sdpa_with_kv_cache.default
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/torch/_ops.py", line 1385, in __getattr__
    raise AttributeError(
AttributeError: '_OpNamespace' 'llama' object has no attribute 'sdpa_with_kv_cache'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/username-redacted/miniconda3/envs/optimum-executorch/bin/optimum-cli", line 6, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/optimum/commands/optimum_cli.py", line 219, in main
    service.run()
  File "/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/optimum/commands/export/executorch.py", line 218, in run
    from ...exporters.executorch import main_export
  File "/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/transformers/utils/import_utils.py", line 2010, in __getattr__
    module = self._get_module(self._class_to_module[name])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/transformers/utils/import_utils.py", line 2200, in _get_module
    raise e
  File "/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/transformers/utils/import_utils.py", line 2198, in _get_module
    return importlib.import_module("." + module_name, self.__name__)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/optimum/exporters/executorch/__main__.py", line 30, in <module>
    from .convert import export_to_executorch
  File "/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/optimum/exporters/executorch/convert.py", line 25, in <module>
    from optimum.executorch.attentions.custom_sdpa import custom_sdpa_with_start_pos_forward
  File "/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/optimum/executorch/attentions/custom_sdpa.py", line 18, in <module>
    from executorch.extension.llm.custom_ops.custom_ops import custom_sdpa  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/executorch/extension/llm/custom_ops/custom_ops.py", line 32, in <module>
    from executorch.extension.pybindings import portable_lib  # noqa # usort: skip
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/executorch/extension/pybindings/portable_lib.py", line 54, in <module>
    from executorch.extension.pybindings._portable_lib import (  # noqa: F401
ImportError: dlopen(/Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/executorch/extension/pybindings/_portable_lib.cpython-311-darwin.so, 0x0002): Symbol not found: _cpuinfo_isa
  Referenced from: <B9E562C1-DA96-315D-8F4B-79F9CC0F3CD2> /Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/executorch/extension/pybindings/_portable_lib.cpython-311-darwin.so
  Expected in:     <68B86CF9-7F67-33B2-989C-D8E3430AC093> /Users/username-redacted/miniconda3/envs/optimum-executorch/lib/python3.11/site-packages/torch/lib/libtorch_python.dylib

Device

MacBook Pro M1 2020
macOS: Sequoia 15.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions