Skip to content
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

[PJRT] Expose ExecutionContext when executing a LoadedExecutable #20429

Closed

Conversation

Corendos
Copy link
Contributor

Currently, there is no way to provide an ExecutionContext when launching an executable. This prevents using it in custom calls through FFI.

I exposed the field in the PJRT_ExecuteOptions struct and wired it in xla::ExecuteOptions

@penpornk penpornk requested a review from ezhulenev December 11, 2024 18:54
xla/pjrt/c/pjrt_c_api.h Outdated Show resolved Hide resolved
xla/pjrt/c/pjrt_c_api.h Outdated Show resolved Hide resolved
Copy link
Member

@penpornk penpornk left a comment

Choose a reason for hiding this comment

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

Could you please help add a unit test for this as well?

@ezhulenev
Copy link
Member

I'm not sure anything useful can be added as a test, but PR needs a rebase because I bumped pjrt version yesteday

@Corendos
Copy link
Contributor Author

but PR needs a rebase because I bumped pjrt version yesteday

Addressed in 5b97f17

Copy link
Member

@penpornk penpornk left a comment

Choose a reason for hiding this comment

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

Thank you!

@penpornk penpornk added the kokoro:force-run Forces CI to rerun label Dec 18, 2024
@kokoro-team kokoro-team removed the kokoro:force-run Forces CI to rerun label Dec 18, 2024
copybara-service bot pushed a commit that referenced this pull request Dec 18, 2024
…xecutable`

Imported from GitHub PR #20429

Currently, there is no way to provide an `ExecutionContext` when launching an executable. This prevents using it in custom calls through FFI.

I exposed the field in the `PJRT_ExecuteOptions` struct and wired it in `xla::ExecuteOptions`
Copybara import of the project:

--
d22969c by Corentin Godeau <[email protected]>:

[PJRT] Expose ExecutionContext when executing a LoadedExecutable

--
67d8c21 by Corentin Godeau <[email protected]>:

Update xla/pjrt/c/pjrt_c_api.h

Co-authored-by: Steeve Morin <[email protected]>
--
5017a0e by Corentin Godeau <[email protected]>:

Added changes to the changelog

Merging this change closes #20429

FUTURE_COPYBARA_INTEGRATE_REVIEW=#20429 from Corendos:corendos/pjrt-execution-context 5b97f17
PiperOrigin-RevId: 707074459
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Dec 18, 2024
…xecutable`

Imported from GitHub PR openxla/xla#20429

Currently, there is no way to provide an `ExecutionContext` when launching an executable. This prevents using it in custom calls through FFI.

I exposed the field in the `PJRT_ExecuteOptions` struct and wired it in `xla::ExecuteOptions`
Copybara import of the project:

--
d22969c1ed76cc52dd2b99882cd6dc8d0acc7dbc by Corentin Godeau <[email protected]>:

[PJRT] Expose ExecutionContext when executing a LoadedExecutable

--
67d8c2146239558ecae141d90aaf707823f89a7d by Corentin Godeau <[email protected]>:

Update xla/pjrt/c/pjrt_c_api.h

Co-authored-by: Steeve Morin <[email protected]>
--
5017a0ed720492ecf8d47cafd8d2b09d7222cbf8 by Corentin Godeau <[email protected]>:

Added changes to the changelog

Merging this change closes #20429

FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#20429 from Corendos:corendos/pjrt-execution-context 5b97f17549fc5ec0671d19f3fe86a598973f5b61
PiperOrigin-RevId: 707074459
copybara-service bot pushed a commit that referenced this pull request Dec 18, 2024
…xecutable`

Imported from GitHub PR #20429

Currently, there is no way to provide an `ExecutionContext` when launching an executable. This prevents using it in custom calls through FFI.

I exposed the field in the `PJRT_ExecuteOptions` struct and wired it in `xla::ExecuteOptions`
Copybara import of the project:

--
d22969c by Corentin Godeau <[email protected]>:

[PJRT] Expose ExecutionContext when executing a LoadedExecutable

--
67d8c21 by Corentin Godeau <[email protected]>:

Update xla/pjrt/c/pjrt_c_api.h

Co-authored-by: Steeve Morin <[email protected]>
--
5017a0e by Corentin Godeau <[email protected]>:

Added changes to the changelog

Merging this change closes #20429

FUTURE_COPYBARA_INTEGRATE_REVIEW=#20429 from Corendos:corendos/pjrt-execution-context 5b97f17
PiperOrigin-RevId: 707074459
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Dec 18, 2024
…xecutable`

Imported from GitHub PR openxla/xla#20429

Currently, there is no way to provide an `ExecutionContext` when launching an executable. This prevents using it in custom calls through FFI.

I exposed the field in the `PJRT_ExecuteOptions` struct and wired it in `xla::ExecuteOptions`
Copybara import of the project:

--
d22969c1ed76cc52dd2b99882cd6dc8d0acc7dbc by Corentin Godeau <[email protected]>:

[PJRT] Expose ExecutionContext when executing a LoadedExecutable

--
67d8c2146239558ecae141d90aaf707823f89a7d by Corentin Godeau <[email protected]>:

Update xla/pjrt/c/pjrt_c_api.h

Co-authored-by: Steeve Morin <[email protected]>
--
5017a0ed720492ecf8d47cafd8d2b09d7222cbf8 by Corentin Godeau <[email protected]>:

Added changes to the changelog

Merging this change closes #20429

FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#20429 from Corendos:corendos/pjrt-execution-context 5b97f17549fc5ec0671d19f3fe86a598973f5b61
PiperOrigin-RevId: 707074459
copybara-service bot pushed a commit that referenced this pull request Dec 18, 2024
…xecutable`

Imported from GitHub PR #20429

Currently, there is no way to provide an `ExecutionContext` when launching an executable. This prevents using it in custom calls through FFI.

I exposed the field in the `PJRT_ExecuteOptions` struct and wired it in `xla::ExecuteOptions`
Copybara import of the project:

--
d22969c by Corentin Godeau <[email protected]>:

[PJRT] Expose ExecutionContext when executing a LoadedExecutable

--
67d8c21 by Corentin Godeau <[email protected]>:

Update xla/pjrt/c/pjrt_c_api.h

Co-authored-by: Steeve Morin <[email protected]>
--
5017a0e by Corentin Godeau <[email protected]>:

Added changes to the changelog

Merging this change closes #20429

FUTURE_COPYBARA_INTEGRATE_REVIEW=#20429 from Corendos:corendos/pjrt-execution-context 5b97f17
PiperOrigin-RevId: 707074459
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Dec 18, 2024
…xecutable`

Imported from GitHub PR openxla/xla#20429

Currently, there is no way to provide an `ExecutionContext` when launching an executable. This prevents using it in custom calls through FFI.

I exposed the field in the `PJRT_ExecuteOptions` struct and wired it in `xla::ExecuteOptions`
Copybara import of the project:

--
d22969c1ed76cc52dd2b99882cd6dc8d0acc7dbc by Corentin Godeau <[email protected]>:

[PJRT] Expose ExecutionContext when executing a LoadedExecutable

--
67d8c2146239558ecae141d90aaf707823f89a7d by Corentin Godeau <[email protected]>:

Update xla/pjrt/c/pjrt_c_api.h

Co-authored-by: Steeve Morin <[email protected]>
--
5017a0ed720492ecf8d47cafd8d2b09d7222cbf8 by Corentin Godeau <[email protected]>:

Added changes to the changelog

Merging this change closes #20429

FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#20429 from Corendos:corendos/pjrt-execution-context 5b97f17549fc5ec0671d19f3fe86a598973f5b61
PiperOrigin-RevId: 707074459
@penpornk
Copy link
Member

//xla/pjrt:pjrt_c_api_client_test failed. Could you please help take a look? Here is the XLA Linux CPU CI log.

@Corendos
Copy link
Contributor Author

//xla/pjrt:pjrt_c_api_client_test failed. Could you please help take a look? Here is the XLA Linux CPU CI log.

Indeed, thanks ! Addressed in 7128d16

@ezhulenev
Copy link
Member

I think it's bazel test //folder/..., just run all tests under pjrt, it should be enough

@Corendos Corendos force-pushed the corendos/pjrt-execution-context branch from 034e6cc to 4001094 Compare January 8, 2025 14:04
@Corendos Corendos force-pushed the corendos/pjrt-execution-context branch from 4001094 to 4e19b2a Compare January 8, 2025 14:07
@Corendos
Copy link
Contributor Author

Corendos commented Jan 8, 2025

Ok, so it was a bit harder than I thought due to struct visibility.

I had to make pjrt_c_api_client depends on //xla/pjrt/c:pjrt_c_api_wrapper_impl. I'm not sure how it's supposed to be solved properly.

Maybe we should do like the other structures and have a xla::PjRtExecuteContext ?

@Corendos
Copy link
Contributor Author

Ok, I've been thinking about this and I think it all boils down to the fact that, contrary to the other PJRT_* struct, PJRT_ExecuteOptions is not manipulated using a pointer. So we can't just predeclare it and must have access to the struct definition.

One improvement that could be done to avoid being dependent on the _impl.h would be to extract the struct definition elsewhere. Apart from that I don't really know what else could be done. If you have idea @ezhulenev happy to discuss 😁

@ezhulenev
Copy link
Member

We certainly can't include impl.h headers anywhere :( I started looking at it, and got a bit lost in all our C APIs and structs, will try to come up with something today

@ezhulenev
Copy link
Member

I think I have a plan, will send PR later today

@ezhulenev
Copy link
Member

After a few attempts I think this is the one that will work: #21317

copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Jan 11, 2025
copybara-service bot pushed a commit that referenced this pull request Jan 11, 2025
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Jan 11, 2025
@Corendos
Copy link
Contributor Author

Awesome, I'm looking forward to it being merged !

I guess I'll close this PR then

copybara-service bot pushed a commit that referenced this pull request Jan 13, 2025
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Jan 13, 2025
copybara-service bot pushed a commit that referenced this pull request Jan 13, 2025
+ Correctly (zero/value-)initialize PJRT_ExecuteOptions in tests and pjrt_c_api_client

```
If the number of initializer clauses is less than the number of members or
initializer list is completely empty, the remaining members are value-initialized
```

Context: #20429
PiperOrigin-RevId: 714327866
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Jan 13, 2025
+ Correctly (zero/value-)initialize PJRT_ExecuteOptions in tests and pjrt_c_api_client

```
If the number of initializer clauses is less than the number of members or
initializer list is completely empty, the remaining members are value-initialized
```

Context: openxla/xla#20429
PiperOrigin-RevId: 714327866
copybara-service bot pushed a commit that referenced this pull request Jan 13, 2025
+ Correctly (zero/value-)initialize PJRT_ExecuteOptions in tests and pjrt_c_api_client

```
If the number of initializer clauses is less than the number of members or
initializer list is completely empty, the remaining members are value-initialized
```

Context: #20429
PiperOrigin-RevId: 714327866
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Jan 13, 2025
+ Correctly (zero/value-)initialize PJRT_ExecuteOptions in tests and pjrt_c_api_client

```
If the number of initializer clauses is less than the number of members or
initializer list is completely empty, the remaining members are value-initialized
```

Context: openxla/xla#20429
PiperOrigin-RevId: 714327866
copybara-service bot pushed a commit that referenced this pull request Jan 15, 2025
+ Correctly (zero/value-)initialize PJRT_ExecuteOptions in tests and pjrt_c_api_client

```
If the number of initializer clauses is less than the number of members or
initializer list is completely empty, the remaining members are value-initialized
```

Context: #20429
PiperOrigin-RevId: 714327866
copybara-service bot pushed a commit that referenced this pull request Jan 15, 2025
+ Correctly (zero/value-)initialize PJRT_ExecuteOptions in tests and pjrt_c_api_client

```
If the number of initializer clauses is less than the number of members or
initializer list is completely empty, the remaining members are value-initialized
```

Context: #20429
PiperOrigin-RevId: 714327866
copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Jan 15, 2025
+ Correctly (zero/value-)initialize PJRT_ExecuteOptions in tests and pjrt_c_api_client

```
If the number of initializer clauses is less than the number of members or
initializer list is completely empty, the remaining members are value-initialized
```

Context: openxla/xla#20429
PiperOrigin-RevId: 714327866
copybara-service bot pushed a commit that referenced this pull request Jan 15, 2025
+ Correctly (zero/value-)initialize PJRT_ExecuteOptions in tests and pjrt_c_api_client

```
If the number of initializer clauses is less than the number of members or
initializer list is completely empty, the remaining members are value-initialized
```

Context: #20429
PiperOrigin-RevId: 715906024
@ezhulenev
Copy link
Member

Submitted in 7ce927a

copybara-service bot pushed a commit to tensorflow/tensorflow that referenced this pull request Jan 15, 2025
+ Correctly (zero/value-)initialize PJRT_ExecuteOptions in tests and pjrt_c_api_client

```
If the number of initializer clauses is less than the number of members or
initializer list is completely empty, the remaining members are value-initialized
```

Context: openxla/xla#20429
PiperOrigin-RevId: 715906024
@Corendos Corendos closed this Jan 16, 2025
@Corendos
Copy link
Contributor Author

Thanks a lot @ezhulenev !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to pull PR ready for merge process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants