Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion examples/models/llama/runner/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
5 changes: 4 additions & 1 deletion examples/models/llama3_2_vision/runner/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
7 changes: 6 additions & 1 deletion extension/llm/custom_ops/custom_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading