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

Autocast Policy for new xla backend. #8672

Open
avizon-aws opened this issue Feb 4, 2025 · 1 comment
Open

Autocast Policy for new xla backend. #8672

avizon-aws opened this issue Feb 4, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@avizon-aws
Copy link
Collaborator

🚀 Feature

I want to add support for a new autocast policy for the NEURON backend.

Motivation

In my usecase, the device is an XLA device but the backend is different. Currently the autocast policy being used is : https://github.com/pytorch/xla/blob/master/torch_xla/csrc/autocast_mode.cpp, but if I want to have a different policy for TPU and NEURON, then I am not sure if it is currently possible. It would be nice to be able to support this feature, because even though both are xla devices, each backend can maintain its own set of operations in a different precision as needed.

Pitch

I want to be able to create a new autocast policy for my backend of interest. I also want to be able to inherit the policy from the xla device, but want the feature to be able to override it as per the need.

Alternatives

Additional context

@ysiraichi ysiraichi added enhancement New feature or request pytorch bug This bug (likely) requires changes in PyTorch to address and removed pytorch bug This bug (likely) requires changes in PyTorch to address labels Feb 5, 2025
@ysiraichi
Copy link
Collaborator

Thank you for your suggestion.

Although, there's probably no easy way to overwrite the autocast policy, separately, for each XLA backend, I believe you can make use of the custom dispatch key PrivateUse1. Specifically, you could:

  • Register autocast kernels for AutocastPrivateUse1
  • Create a new TensorImpl that inherits from XLATensorImpl
  • Replace their dispatch key from AutocastXLA to AutocastPrivateUse1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants