keras-team/keras · error · RuntimeError
Failed to convert PyTorch model to LiteRT. Common causes: un
Error message
Failed to convert PyTorch model to LiteRT. Common causes: unsupported operations, dynamic shapes, or complex control flow. Original error: {e} What it means
Error "Failed to convert PyTorch model to LiteRT. Common causes: unsupported operations, dynamic shapes, or complex control flow. Original error: {e}" thrown in keras-team/keras.
Source
Thrown at keras/src/export/litert.py:246
# Although Keras models manage training mode via the
# `training` argument to `call()`, `litert_torch.convert`
# checks `module.training` and warns when it is `True`.
# Calling `eval()` silences that warning and ensures any
# PyTorch-native submodules are in inference mode.
model.eval()
litert_torch_kwargs = _prepare_litert_kwargs(
kwargs, litert_torch
)
with _silence_output(verbose is False):
try:
edge_model = litert_torch.convert(
model, sample_inputs, **litert_torch_kwargs
)
except Exception as e:
raise RuntimeError(
"Failed to convert PyTorch model to LiteRT. "
"Common causes: unsupported operations, "
"dynamic shapes, or complex control flow. "
f"Original error: {e}"
) from e
edge_model.export(filepath)
finally:
if device != "cpu":
for v in model.variables:
v.value.data = v.value.data.to(device)
if verbose is not False:
io_utils.print_msg(f"Saved artifact at '{filepath}'.")
return filepath
View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/export/litert.py:246 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/1374a957e4656db2.
Report an issue: GitHub.