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

[Pallas] Set the major-minor layout for inputs and outputs #6826

Merged
merged 5 commits into from
Mar 27, 2024

Conversation

alanwaketan
Copy link
Collaborator

@alanwaketan alanwaketan commented Mar 26, 2024

Summary:
Mosaic only accepts major-minor layout for both its inputs and outputs. So we need to enforce those layouts by setting the expected input&output shapes in xla::CustomCallWithLayout. After this change, XLA_TPU_LAYOUT is no longer needed.

Test Plan:
PJRT_DEVICE=TPU python test/test_pallas.py

}
auto output_shape_impl = MakeTorchTensorLayout(
Copy link
Collaborator

Choose a reason for hiding this comment

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

lol can you spell out the xla::Shape directly here? I need to do a search to figure out the return type of MakeTorchTensorLayout . Same for above.

I tried to follow Google's C++ recommendation which states

Type Deduction (including auto)
Use type deduction only if it makes the code clearer to readers who aren't familiar with the project, or if it makes the code safer. Do not use it merely to avoid the inconvenience of writing an explicit type.

@@ -185,9 +185,7 @@ xla::Shape MakeArrayShapeFromDimensions(
return MakeShapeWithLayout(type, dimensions, dynamic_dimensions,
*layout_ptr);
}

bool tpu_layout_env = runtime::sys_util::GetEnvBool("XLA_TPU_LAYOUT", true);
if (tpu_layout_env && dimensions.size() > 1 && CheckTpuDevice(hw_type)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand why tpu_layout_env should be deprecated and how is it related to this pr? Are you saying we always use XLA_TPU_LAYOUT ? Does that has a implication on performance on GPU for example?

Copy link
Collaborator

Choose a reason for hiding this comment

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

well I guess it is default to true anyway.. but still I am not sure why it is deleted in this pr.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added that to partially solve this problem. Now I found the completed solution, and therefore the old solution is no longer needed.

@alanwaketan
Copy link
Collaborator Author

Thanks, Jack.

@alanwaketan alanwaketan merged commit d99ceb6 into master Mar 27, 2024
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants