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

[Neuron] Fix the XLADevice Neuron mappings for SPMD downcasts #8335

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

rpsilva-aws
Copy link
Contributor

@rpsilva-aws rpsilva-aws commented Oct 29, 2024

Currently, the downcasting mappings based on the XLA device types does not account for virtual devices (SPMD), when requiring Neuron specific casts. The same applies to the lowering and native functions. This PR fixes it by deriving the proper hardware device.

@rpsilva-aws rpsilva-aws marked this pull request as ready for review October 29, 2024 23:16
@rpsilva-aws
Copy link
Contributor Author

@aws-rhsoln @jeffhataws

return xla::PrimitiveType::F32;
}
return xla::PrimitiveType::F64;
case xla::PrimitiveType::F32:
return UseBF16() || DowncastBF16() ? xla::PrimitiveType::BF16
: xla::PrimitiveType::F32;
case xla::PrimitiveType::U16:
return hw_type != XlaDeviceType::NEURON ? xla::PrimitiveType::U16
: xla::PrimitiveType::U32;
return CheckNeuronDevice(hw_type) ? xla::PrimitiveType::U32
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the deprecating of the XLA casting env variables affect this at all?

Copy link

@aws-nm9 aws-nm9 Oct 30, 2024

Choose a reason for hiding this comment

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

No, this change only affects the check for the device type, not the downcast flag check(or the deprecation of those flags). Since the pre-existing logic incorporated the deprecated flags, the current one does the same.

The flags being deprecated will not affect this downcasting check change.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks

return xla::PrimitiveType::F32;
}
return xla::PrimitiveType::F64;
case xla::PrimitiveType::F32:
return UseBF16() || DowncastBF16() ? xla::PrimitiveType::BF16
: xla::PrimitiveType::F32;
case xla::PrimitiveType::U16:
return hw_type != XlaDeviceType::NEURON ? xla::PrimitiveType::U16
: xla::PrimitiveType::U32;
return CheckNeuronDevice(hw_type) ? xla::PrimitiveType::U32
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks

@qihqi qihqi merged commit 7c7ad4e into pytorch:master Oct 31, 2024
12 checks passed
@rpsilva-aws rpsilva-aws deleted the neuron_device_mapping branch October 31, 2024 17:15
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.

6 participants