Skip to content

StableDiffusion3TextToImage LiteRT export fails with unresolved custom op: Erfc #2494

@pctablet505

Description

@pctablet505

Description

The test_litert_export test for StableDiffusion3TextToImage is currently failing due to an unresolved custom operation in the LiteRT model.

Steps to Reproduce

  1. Run the test: pytest keras_hub/src/models/stable_diffusion_3/stable_diffusion_3_text_to_image_test.py::StableDiffusion3TextToImageTest::test_litert_export --run_large
  2. The test attempts to export the model to LiteRT format and run inference
  3. The test fails when invoking the LiteRT interpreter due to the unsupported Erfc operation

Expected Behavior

The test should pass, successfully exporting the StableDiffusion3TextToImage model to LiteRT and running inference without errors.

Actual Behavior

The test fails with the following error:

RuntimeError: Encountered unresolved custom op: Erfc.
See instructions: https://www.tensorflow.org/lite/guide/ops_custom Node number 181 (Erfc) failed to prepare.

This indicates that the Erfc (complementary error function) operation is not natively supported in TensorFlow Lite and requires custom op implementation.

Environment

  • Python 3.12.10
  • TensorFlow/Keras (version from pyproject.toml: keras>=3.13)
  • pytest-9.0.0
  • macOS

Additional Context

  • The test is configured with allow_custom_ops=True to permit custom operations like GatherV2 and Erfc
  • However, the Erfc operation still fails to prepare in the LiteRT runtime
  • The model uses float16 precision in parts, which may contribute to the operation compatibility issues
  • This is blocking LiteRT export functionality for StableDiffusion3TextToImage models
  • The test is currently marked as skipped with @pytest.mark.skip(reason="TODO: Bug with StableDiffusion3TextToImage export")

Possible Fix

The issue likely requires implementing a custom Erfc operation for TensorFlow Lite or modifying the model export process to avoid using Erfc. The complementary error function may need to be approximated or replaced with supported operations for LiteRT compatibility.

Metadata

Metadata

Labels

type:BugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions