diff --git a/examples/models/llama/runner/native.py b/examples/models/llama/runner/native.py index 6d5d4730844..089f775557d 100644 --- a/examples/models/llama/runner/native.py +++ b/examples/models/llama/runner/native.py @@ -23,7 +23,10 @@ from executorch.examples.models.llama.runner.generation import LlamaRunner # Note: import this after portable_lib -from executorch.extension.llm.custom_ops import custom_ops # noqa # usort: skip +try: + from executorch.extension.llm.custom_ops import custom_ops # noqa # usort: skip +except Exception: + pass # Not needed for pybindings inference. from executorch.kernels import quantized # noqa diff --git a/examples/models/llama3_2_vision/runner/native.py b/examples/models/llama3_2_vision/runner/native.py index 2b4d709f9b4..683bd6ba3a7 100644 --- a/examples/models/llama3_2_vision/runner/native.py +++ b/examples/models/llama3_2_vision/runner/native.py @@ -26,7 +26,10 @@ from executorch.extension.pybindings import portable_lib # noqa # usort: skip # Note: import this after portable_lib -from executorch.extension.llm.custom_ops import custom_ops # noqa # usort: skip +try: + from executorch.extension.llm.custom_ops import custom_ops # noqa # usort: skip +except Exception: + pass # Not needed for pybindings inference. from executorch.kernels import quantized # noqa diff --git a/extension/llm/custom_ops/custom_ops.py b/extension/llm/custom_ops/custom_ops.py index 9aacded4b4c..3f647c0207f 100644 --- a/extension/llm/custom_ops/custom_ops.py +++ b/extension/llm/custom_ops/custom_ops.py @@ -41,7 +41,12 @@ libs = list(package_path.glob("**/*custom_ops_aot_lib.*")) - assert len(libs) == 1, f"Expected 1 library but got {len(libs)}" + assert len(libs) == 1, ( + f"Expected 1 custom_ops_aot_lib library but got {len(libs)} " + f"(searched in {package_path}). " + "If building from source, re-build with " + "-DEXECUTORCH_BUILD_KERNELS_LLM_AOT=ON or use the pybind cmake preset." + ) logging.info(f"Loading custom ops library: {libs[0]}") torch.ops.load_library(libs[0]) op = torch.ops.llama.sdpa_with_kv_cache.default