Litert_torch on Mac

Is litert_torch, formerly known as ai_edge_torch, currently NOT supported on Mac? I have an M4 chip. I’m able to successfully install litert_torch (v0.8.0) using uv, but when I try import litert_torch, I get the error:

ImportError: dlopen(/Users/brian.provost/work/test/.venv/lib/python3.12/site-packages/tensorflow/lite/python/metrics/_pywrap_tensorflow_lite_metrics_wrapper.so, 0x0002): Symbol not found: _Wrapped_PyInit__pywrap_tensorflow_lite_metrics_wrapper
  Referenced from: <B3DA96BD-AC59-3FF7-B6DD-A670BB6B54E1> /Users/brian.provost/work/test/.venv/lib/python3.12/site-packages/tensorflow/lite/python/metrics/_pywrap_tensorflow_lite_metrics_wrapper.so
  Expected in:     <562BFDD0-A53D-3FFD-A47C-7C2F81A1D900> /Users/brian.provost/work/test/.venv/lib/python3.12/site-packages/tensorflow/python/lib_pywrap_tensorflow_common.dylib
pyproject.toml
[project]
name = "test"
version = "0.1.0"
description = "test repo"
readme = "README.md"
requires-python = ">=3.10,<3.13"
dependencies = [
    "ipykernel",
    "tensorflow",
    "litert_torch"
]

[tool.uv]
package = false
required-environments = ["sys_platform == 'darwin' and platform_machine == 'arm64'"]
Package versions
Package                 Version
----------------------- ---------------------
absl-py                 2.4.0
ai-edge-litert          2.0.3
ai-edge-quantizer       0.4.0
ai-edge-tensorflow      2.21.0.dev20251110
anyio                   4.12.1
appnope                 0.1.4
asttokens               3.0.1
astunparse              1.6.3
backports-strenum       1.3.1
certifi                 2026.1.4
charset-normalizer      3.4.4
click                   8.3.1
comm                    0.2.3
debugpy                 1.8.20
decorator               5.2.1
executing               2.2.1
filelock                3.20.3
fire                    0.7.1
flatbuffers             25.12.19
fsspec                  2026.1.0
gast                    0.7.0
google-pasta            0.2.0
grpcio                  1.76.0
h11                     0.16.0
h5py                    3.14.0
hf-xet                  1.2.0
httpcore                1.0.9
httpx                   0.28.1
huggingface-hub         1.3.7
idna                    3.11
immutabledict           4.2.2
iniconfig               2.3.0
ipykernel               7.1.0
ipython                 9.10.0
ipython-pygments-lexers 1.1.1
jax                     0.9.0
jaxlib                  0.9.0
jaxtyping               0.3.7
jedi                    0.19.2
jinja2                  3.1.6
jupyter-client          8.8.0
jupyter-core            5.9.1
kagglehub               0.4.2
kagglesdk               0.1.15
keras                   3.13.2
keras-nightly           3.14.0.dev2026020104
libclang                18.1.1
litert-torch            0.8.0
markdown                3.10.1
markdown-it-py          4.0.0
markupsafe              3.0.3
matplotlib-inline       0.2.1
mdurl                   0.1.2
ml-dtypes               0.5.4
mpmath                  1.3.0
multipledispatch        1.0.0
namex                   0.1.0
nest-asyncio            1.6.0
networkx                3.6.1
numpy                   2.4.2
opt-einsum              3.4.0
optree                  0.18.0
packaging               26.0
parso                   0.8.5
pexpect                 4.9.0
pillow                  12.1.0
platformdirs            4.5.1
pluggy                  1.6.0
prompt-toolkit          3.0.52
protobuf                6.33.5
psutil                  7.2.2
ptyprocess              0.7.0
pure-eval               0.2.3
pygments                2.19.2
pytest                  8.4.2
python-dateutil         2.9.0.post0
pyyaml                  6.0.3
pyzmq                   27.1.0
regex                   2026.1.15
requests                2.32.5
rich                    14.3.2
safetensors             0.7.0
scipy                   1.17.0
setuptools              80.10.2
shellingham             1.5.4
six                     1.17.0
stack-data              0.6.3
sympy                   1.14.0
tabulate                0.9.0
tb-nightly              2.20.0a20250717
tensorboard             2.20.0
tensorboard-data-server 0.7.2
tensorflow              2.20.0
termcolor               3.3.0
tokenizers              0.22.2
torch                   2.9.0
torch-xla2              0.0.1.dev202412041639
torchao                 0.14.0
tornado                 6.5.4
tqdm                    4.67.2
traitlets               5.14.3
transformers            5.0.0
typer-slim              0.21.1
typing-extensions       4.15.0
urllib3                 2.6.3
wadler-lindig           0.1.7
wcwidth                 0.5.3
werkzeug                3.1.5
wheel                   0.46.3
wrapt                   2.1.0

Python version: 3.11.14

I was able to successfully import litert_torch using this pyproject.toml

[project]
name = "test"
version = "0.1.0"
description = "test repo"
readme = "README.md"
requires-python = ">=3.10,<3.13"
dependencies = [
    "ipykernel",
    "tensorflow; sys_platform != 'darwin' or platform_machine != 'arm64'",
    "tf_keras; sys_platform != 'darwin' or platform_machine != 'arm64'",
    "tf-nightly; sys_platform == 'darwin' and platform_machine == 'arm64'",
    "tflite",
    "litert_torch; sys_platform != 'darwin' or platform_machine != 'arm64'",
    "litert-torch-nightly; sys_platform == 'darwin' and platform_machine == 'arm64'",
]

[tool.uv]
package = false
required-environments = ["sys_platform == 'darwin' and platform_machine == 'arm64'"]
1 Like

Thank you for publishing that, @Brian_Provost !

Confirm that it works for my Apple M3. Successfully converted gemma-3-270m-it to .tflite format.

Hi @Brian_Provost, welcome here. Thanks for bringing this “binary ABI mismatch” issue for stable release v0.8.0 on apple silicon (M-series chipset). I spent some time and did this root cause analysis which community mightbe profited.


ImportError: ... Symbol not found: _Wrapped_PyInit__pywrap_tensorflow_lite_metrics_wrapper

This is the symbol mismatch. litert_torch relies on tf lite runtime for model exports and metrics. this error is comes from - macOS arm64 v0.8.0 tries to link it to std tensorflow pkg, but there were recent changes in TFLite C++ code set. the symbol names in std tensorflow wheel for macOS aren’t perfect match for what litert_torch v0.8.0 expecting, it tries to find the _Wrapped_PyInit… but that is not found in TFlite that pip/uv builder resolved.

I will look for more, also now checking your work around. Will come back soon.

Hi @Damyr_Hadiiev, big welcome here, Thanks for the info and trying the workaround. Great great !!

your working fix works best. Good sync as the nightly builds are built against exact same commit of tensorflow head as tf-nightly. every c++ symbol including that metrics will align just perfect.


sys_platform == 'darwin' and platform_machine == 'arm64'

this is helping fix macos without any disturbance to other OS. I can say you’re just supperb, stay at nightly until release of LiteRT Torch next stable release. Don’t forget to watch out for uv caching when you update any tf-nightly or litert-torch-nightly without updating the other, this error can give a surprise visit to you again. keep it sync. Thanks again.