Skip to content

[PJRT] Only alias inputs and outputs when force_ltc_sync == True - #4575

Merged
JackCaoG merged 1 commit into
masterfrom
wcromar/aliasing
Feb 7, 2023
Merged

[PJRT] Only alias inputs and outputs when force_ltc_sync == True#4575
JackCaoG merged 1 commit into
masterfrom
wcromar/aliasing

Conversation

@will-cromar

Copy link
Copy Markdown
Collaborator

Updating logic to match comment.

According to the documentation for PJRT, when an input buffer is aliased to an output of an executable, the original input buffer is no longer available. When we reference the DataPtr that holds the buffer again, we will inevitably see this error: RuntimeError: ./tensorflow/compiler/xla/xla_client/pjrt_computation_client.h:140 : Check failed: HasValue()

Fixes the following failing C++ tests on CPU:

[  FAILED  ] AtenXlaTensorTest.TestAvgPool2DBackward
[  FAILED  ] AtenXlaTensorTest.TestAvgPool3DBackward
[  FAILED  ] AtenXlaTensorTest.TestAvgPool2DNoBatchBackward
[  FAILED  ] AtenXlaTensorTest.TestAvgPool3DNoBatchBackward
[  FAILED  ] AtenXlaTensorTest.TestAddMatMulBackward

@will-cromar

Copy link
Copy Markdown
Collaborator Author

I ran our imagenet benchmark on TPU v4 with the PJRT C API. Performance is actually a little better than the last time I checked, but that could be related to another change.

@will-cromar
will-cromar marked this pull request as ready for review February 6, 2023 21:22

@alanwaketan alanwaketan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Generally speaking, LGTM. Let's see how CI respond.

// shapes which can lead to an incorrect aliasing pairs if sharded.
if (enable_aliasing && coll.config.sync_ltc_data && !is_sharded) {
if (enable_aliasing && coll.config.sync_ltc_data &&
coll.config.force_ltc_data && !is_sharded) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

as a follow up, we should add a test to https://github.com/pytorch/xla/blob/master/test/test_input_output_aliases.py and make sure only mark_step trigger the aliasing.

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.

3 participants