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] Only alias inputs and outputs when force_ltc_sync == True #4575

Merged
merged 1 commit into from
Feb 7, 2023

Conversation

will-cromar
Copy link
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
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
Copy link
Collaborator

@alanwaketan alanwaketan left a comment

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.

@@ -1102,7 +1102,8 @@ XLAGraphExecutor::CompilationResult XLAGraphExecutor::Compile(
// TODO(yeounoh) aliasing is disabled for partitioned computation,
// since the current aliasing compares the unpartitioned input and output
// 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
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
3 participants