Skip to content

Integrate torchgen exception boundary with ExecuTorch #7546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
238d6f0
Build optimized operators lib with -fexceptions
swolchok Jan 7, 2025
eacf0db
Update on "Build optimized operators lib with -fexceptions"
swolchok Jan 7, 2025
85f1f22
Update on "Build optimized operators lib with -fexceptions"
swolchok Jan 8, 2025
f375188
Update on "Build optimized operators lib with -fexceptions"
swolchok Jan 9, 2025
b405dbd
Update on "Build optimized operators lib with -fexceptions"
swolchok Jan 9, 2025
b34b10d
Update on "Build optimized operators lib with -fexceptions"
swolchok Jan 9, 2025
63119b2
Update on "Build optimized operators lib with -fexceptions"
Jan 10, 2025
a400808
Update on "Build optimized operators lib with -fexceptions"
Jan 10, 2025
d0aeeda
Update on "Build optimized operators lib with -fexceptions"
Jan 10, 2025
3805417
Update on "Build optimized operators lib with -fexceptions"
Jan 10, 2025
3e3a3e9
Update on "Build optimized operators lib with -fexceptions"
Jan 11, 2025
11f2eb0
Update on "Build optimized operators lib with -fexceptions"
Jan 13, 2025
9fad43d
Update on "Build optimized operators lib with -fexceptions"
swolchok Jan 15, 2025
672b94d
Update on "Build optimized operators lib with -fexceptions"
swolchok Jan 15, 2025
8e042ac
Update on "Build optimized operators lib with -fexceptions"
swolchok Jan 17, 2025
97972bd
Update on "Build optimized operators lib with -fexceptions"
swolchok Jan 24, 2025
f2fb0b1
Update on "Build optimized operators lib with -fexceptions"
swolchok Jan 30, 2025
de1cc23
Update on "Integrate torchgen exception boundary with ExecuTorch"
swolchok Jan 30, 2025
3ffb5d2
Update on "Integrate torchgen exception boundary with ExecuTorch"
swolchok Jan 30, 2025
00f6b85
Update on "Integrate torchgen exception boundary with ExecuTorch"
swolchok Jan 30, 2025
aff01f5
Update on "Integrate torchgen exception boundary with ExecuTorch"
Feb 4, 2025
59b5088
Update on "Integrate torchgen exception boundary with ExecuTorch"
Feb 4, 2025
99b4a3d
Update on "Integrate torchgen exception boundary with ExecuTorch"
Feb 5, 2025
078941b
Update on "Integrate torchgen exception boundary with ExecuTorch"
Feb 6, 2025
6339d09
Update on "Integrate torchgen exception boundary with ExecuTorch"
Feb 7, 2025
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
2 changes: 1 addition & 1 deletion .ci/docker/ci_commit_pins/pytorch.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2ea4b56ec872424e486c4fe2d55da061067a2ed3
f0c50a619c282a01ef1ad33690b7ab5e615d9fef
12 changes: 9 additions & 3 deletions build/Codegen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
# arguments.
function(gen_selected_ops)
set(arg_names LIB_NAME OPS_SCHEMA_YAML ROOT_OPS INCLUDE_ALL_OPS)
cmake_parse_arguments(GEN "" "" "${arg_names}" ${ARGN})
cmake_parse_arguments(GEN "${options}" "" "${arg_names}" ${ARGN})

message(STATUS "Generating operator lib:")
message(STATUS " LIB_NAME: ${GEN_LIB_NAME}")
message(STATUS " OPS_SCHEMA_YAML: ${GEN_OPS_SCHEMA_YAML}")
message(STATUS " ROOT_OPS: ${GEN_ROOT_OPS}")
message(STATUS " INCLUDE_ALL_OPS: ${GEN_INCLUDE_ALL_OPS}")
message(STATUS " ADD_EXCEPTION_BOUNDARY: ${GEN_ADD_EXCEPTION_BOUNDARTY}")

set(_oplist_yaml
${CMAKE_CURRENT_BINARY_DIR}/${GEN_LIB_NAME}/selected_operators.yaml
Expand Down Expand Up @@ -59,13 +60,15 @@ endfunction()
# Invoked as generate_bindings_for_kernels( LIB_NAME lib_name FUNCTIONS_YAML
# functions_yaml CUSTOM_OPS_YAML custom_ops_yaml )
function(generate_bindings_for_kernels)
set(options ADD_EXCEPTION_BOUNDARY)
set(arg_names LIB_NAME FUNCTIONS_YAML CUSTOM_OPS_YAML)
cmake_parse_arguments(GEN "" "${arg_names}" "" ${ARGN})
cmake_parse_arguments(GEN "${options}" "${arg_names}" "" ${ARGN})

message(STATUS "Generating kernel bindings:")
message(STATUS " LIB_NAME: ${GEN_LIB_NAME}")
message(STATUS " FUNCTIONS_YAML: ${GEN_FUNCTIONS_YAML}")
message(STATUS " CUSTOM_OPS_YAML: ${GEN_CUSTOM_OPS_YAML}")
message(STATUS " ADD_EXCEPTION_BOUNDARY: ${GEN_ADD_EXCEPTION_BOUNDARY}")

# Command to generate selected_operators.yaml from custom_ops.yaml.
file(GLOB_RECURSE _codegen_templates "${EXECUTORCH_ROOT}/codegen/templates/*")
Expand Down Expand Up @@ -93,7 +96,10 @@ function(generate_bindings_for_kernels)
--tags-path=${site-packages-out}/torchgen/packaged/ATen/native/tags.yaml
--aten-yaml-path=${site-packages-out}/torchgen/packaged/ATen/native/native_functions.yaml
--op-selection-yaml-path=${_oplist_yaml}
)
)
if(GEN_ADD_EXCEPTION_BOUNDARY)
set(_gen_command "${_gen_command} --add-exception-boundary")
Copy link
Contributor

@huydhn huydhn Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the set command use semi-colon separator instead of space, i.e. /opt/conda/envs/py_3.10/bin/python3;-m;torchgen.gen_executorch;--source-path=/pytorch/executorch/configurations/../codegen;--install-dir=/pytorch/executorch/pip-out/temp.linux-x86_64-cpython-310/cmake-out/configurations/optimized_native_cpu_ops_lib;--tags-path=/opt/conda/envs/py_3.10/lib/python3.10/site-packages/torchgen/packaged/ATen/native/tags.yaml;--aten-yaml-path=/opt/conda/envs/py_3.10/lib/python3.10/site-packages/torchgen/packaged/ATen/native/native_functions.yaml;--op-selection-yaml-path=/pytorch/executorch/pip-out/temp.linux-x86_64-cpython-310/cmake-out/configurations/optimized_native_cpu_ops_lib/selected_operators.yaml;--add-exception-boundary

The failure is complaining about a wrong filename https://github.com/pytorch/executorch/actions/runs/12660296601/job/35287265644#step:14:1992

Suggested change
set(_gen_command "${_gen_command} --add-exception-boundary")
set(_gen_command "${_gen_command}" --add-exception-boundary)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strange, I thought I built this locally. Giving it a shot now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does seem to have improved the situation (thanks!) but the torchgen version still seems to be wrong: https://github.com/pytorch/executorch/actions/runs/12680876952/job/35343491373?pr=7546#step:9:2186

Copy link
Contributor Author

@swolchok swolchok Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@huydhn still seeing at least some wrong-torchgen-version failures:

however, we do have mac successes. looking into the common thread for these failures now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ARM one is easy: the workflow directly invokes install_executorch from .ci/scripts/utils.sh without "use-pt-pinned-commit". Is there a reason "use-pt-pinned-commit" isn't the default or only option?

test-llava-runner-linux reruns install_requirements.sh and doesn't pass --use-pt-pinned-commit, same with test-phi-3-mini-runner, test-eval_llama-wikitext-linux, test-eval_llama-mmlu-linux, and test-llama_runner_eager-linux. I will send a PR to fix those.

endif()

set(_gen_command_sources
${_out_dir}/RegisterCodegenUnboxedKernelsEverything.cpp
Expand Down
3 changes: 2 additions & 1 deletion configurations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED)

generate_bindings_for_kernels(
LIB_NAME "optimized_native_cpu_ops_lib" FUNCTIONS_YAML
${CMAKE_CURRENT_BINARY_DIR}/merged.yaml
${CMAKE_CURRENT_BINARY_DIR}/merged.yaml ADD_EXCEPTION_BOUNDARY
)
message("Generated files ${gen_command_sources}")

Expand All @@ -56,6 +56,7 @@ if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
DEPS
executorch
)
target_compile_options(optimized_native_cpu_ops_lib PRIVATE "-fexceptions")

install(TARGETS optimized_native_cpu_ops_lib DESTINATION lib)
endif()
3 changes: 3 additions & 0 deletions kernels/optimized/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ endif()

set(_common_compile_options -Wno-deprecated-declarations)

add_compile_options("-fexceptions")

# Note for apple platform we can rely on Accelerate framework Will come back to
# this
include(${CMAKE_CURRENT_LIST_DIR}/External/EigenBLAS.cmake)
Expand Down Expand Up @@ -55,6 +57,7 @@ gen_selected_ops(LIB_NAME "optimized_ops_lib" OPS_SCHEMA_YAML "${_yaml}")
generate_bindings_for_kernels(
LIB_NAME "optimized_ops_lib" FUNCTIONS_YAML
${CMAKE_CURRENT_SOURCE_DIR}/optimized-oss.yaml
ADD_EXCEPTION_BOUNDARY
)
message("Generated files ${gen_command_sources}")

Expand Down
Loading