keras-team/keras · error · ImportError
To export to LiteRT with the PyTorch backend, you must insta
Error message
To export to LiteRT with the PyTorch backend, you must install the `litert-torch` package. Install via: pip install litert-torch
What it means
Error "To export to LiteRT with the PyTorch backend, you must install the `litert-torch` package. Install via: pip install litert-torch" thrown in keras-team/keras.
Source
Thrown at keras/src/export/litert.py:208
def export_litert_via_torch(
model, filepath, input_signature=None, verbose=None, **kwargs
):
"""Export Keras model to LiteRT via PyTorch backend."""
from keras.src.backend.torch.core import device_scope
from keras.src.backend.torch.core import get_device
device = get_device()
# litert_torch internally imports JAX and unconditionally enables
# jax_enable_x64, which breaks dtype-sensitive tests elsewhere.
# We preserve the original setting and restore it after conversion.
with _preserve_jax_x64_state():
try:
import litert_torch
except ImportError:
raise ImportError(
"To export to LiteRT with the PyTorch backend, "
"you must install the `litert-torch` package. "
"Install via: pip install litert-torch"
)
if device != "cpu":
for v in model.variables:
v.value.data = v.value.data.to("cpu")
try:
with device_scope("cpu"):
if input_signature is None:
input_signature = get_input_signature(model)
sample_inputs = tree.map_structure(
lambda x: convert_spec_to_tensor(x, replace_none_number=1),
input_signature,
)View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/export/litert.py:208 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/7babe050cd7898c6.
Report an issue: GitHub.