Skip to content

fix[next]: Catch exceptions thrown in async build pool#2675

Open
edopao wants to merge 4 commits into
GridTools:mainfrom
edopao:dev-catch_errors_async_build
Open

fix[next]: Catch exceptions thrown in async build pool#2675
edopao wants to merge 4 commits into
GridTools:mainfrom
edopao:dev-catch_errors_async_build

Conversation

@edopao

@edopao edopao commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

The executor call in compiled backends runs as a future when asynchronous compilation is enabled. The current code did not catch exceptions thrown by the future, so any lowering/compilation error resulted in a KeyError at runtime when calling the corresponding program. This PR addresses this issue and adds test coverage.

A side effect of this change is that unit tests that call wait_for_compilation() in a multi-thread pytest session might catch exceptions thrown by other tests, because the build thread pool is a shared resource. This PR limits the pool size to 1, so that the compile failure can be caught in the unit test where it originates from.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes error surfacing for asynchronous compilation in gt4py.next compiled backends by tracking submitted compilation futures and re-raising their exceptions during gtx.wait_for_compilation(), preventing later runtime failures (e.g., KeyError on program call). It also extends integration test coverage to exercise both synchronous and asynchronous compilation modes under executor failure.

Changes:

  • Track async compilation futures in a global registry and re-raise Future exceptions in wait_for_compilation().
  • Register each submitted async compilation job in the new pending-futures registry.
  • Extend test_wait_for_compilation to cover success/failure and synchronous/asynchronous compilation modes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/gt4py/next/otf/compiled_program.py Adds global pending-futures tracking and surfaces async compilation exceptions via wait_for_compilation().
tests/next_tests/integration_tests/feature_tests/ffront_tests/test_compiled_program.py Expands integration test matrix to validate exception surfacing behavior across sync/async compilation.

Comment thread src/gt4py/next/otf/compiled_program.py
@edopao edopao requested a review from havogt June 25, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants