[OpenReg] Implement device autoload mechanism#158555
[OpenReg] Implement device autoload mechanism#158555can-gaa-hou wants to merge 10 commits intopytorch:mainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/158555
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit ca3e0bf with merge base b16d3f4 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
| @@ -125,7 +125,7 @@ graph LR | |||
|
|
|||
| ### Autoload | |||
There was a problem hiding this comment.
Add a section for Autoload:
Take a introduction about background and design of Autoload, and add detailed description to show how the new accelerator to use Autoload mechinasm
There was a problem hiding this comment.
Sure, I have added more details about Autoload mechanism. Please let me know if there any other problems :)
test/cpp_extensions/open_registration_extension/torch_openreg/torch_openreg/__init__.py
Outdated
Show resolved
Hide resolved
test/cpp_extensions/open_registration_extension/torch_openreg/torch_openreg/__init__.py
Outdated
Show resolved
Hide resolved
test/cpp_extensions/open_registration_extension/torch_openreg/torch_openreg/__init__.py
Outdated
Show resolved
Hide resolved
|
What iss more , please refer to this PR to find out the tests about |
c6b901b to
223dfd9
Compare
|
@can-gaa-hou Sorry for the late reply. To get this PR reviewed better, we may need to split it into several parts:
You should base your commit on this PR, as it builds the basic framework for the tutorial, which this PR will uses. |
test/cpp_extensions/open_registration_extension/torch_openreg/setup.py
Outdated
Show resolved
Hide resolved
1fc5c53 to
5b2c2f7
Compare
Co-authored-by: Jiawei Li <ljw1101.vip@gmail.com>
Co-authored-by: Jiawei Li <ljw1101.vip@gmail.com>
…setup.py Co-authored-by: Jiawei Li <ljw1101.vip@gmail.com>
…README.md Co-authored-by: Jiawei Li <ljw1101.vip@gmail.com>
…README.md Co-authored-by: Jiawei Li <ljw1101.vip@gmail.com>
Co-authored-by: Jiawei Li <ljw1101.vip@gmail.com>
Co-authored-by: Jiawei Li <ljw1101.vip@gmail.com>
albanD
left a comment
There was a problem hiding this comment.
Looks great.
Thanks for the special care to the documentation!
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
# Implement OpenReg device autoload mechanism ## Overview The **Autoload** mechanism in PyTorch simplifies the integration of third-party device backends by enabling automatic discovery and initialization at runtime. Traditionally, integrating a new backend required explicit imports or manual initialization, which could be cumbersome and error-prone. With Autoload, PyTorch dynamically detects and initializes device backends, providing a seamless user experience. This mechanism leverages Python entry points (e.g., `torch.backends`) and dynamic module loading. When PyTorch starts, it scans for registered entry points and invokes their initialization hooks, ensuring that all available backends are ready for use without requiring explicit imports. ## Motivation This PR aims to apply [device autoload mechanism](pytorch#122468) to the OpenReg module with some simple changes. ## Change ### Before ```python import torch import torch_openreg x = torch.tensor([1, 2, 3], device="openreg") print(x) ``` ### After ```python import torch # No need to import torch_openreg manually! x = torch.tensor([1, 2, 3], device="openreg") print(x) ``` Pull Request resolved: pytorch#158555 Approved by: https://github.com/FFFrog, https://github.com/albanD Co-authored-by: Jiawei Li <ljw1101.vip@gmail.com>
# Implement OpenReg device autoload mechanism ## Overview The **Autoload** mechanism in PyTorch simplifies the integration of third-party device backends by enabling automatic discovery and initialization at runtime. Traditionally, integrating a new backend required explicit imports or manual initialization, which could be cumbersome and error-prone. With Autoload, PyTorch dynamically detects and initializes device backends, providing a seamless user experience. This mechanism leverages Python entry points (e.g., `torch.backends`) and dynamic module loading. When PyTorch starts, it scans for registered entry points and invokes their initialization hooks, ensuring that all available backends are ready for use without requiring explicit imports. ## Motivation This PR aims to apply [device autoload mechanism](pytorch#122468) to the OpenReg module with some simple changes. ## Change ### Before ```python import torch import torch_openreg x = torch.tensor([1, 2, 3], device="openreg") print(x) ``` ### After ```python import torch # No need to import torch_openreg manually! x = torch.tensor([1, 2, 3], device="openreg") print(x) ``` Pull Request resolved: pytorch#158555 Approved by: https://github.com/FFFrog, https://github.com/albanD Co-authored-by: Jiawei Li <ljw1101.vip@gmail.com>
# Implement OpenReg device autoload mechanism ## Overview The **Autoload** mechanism in PyTorch simplifies the integration of third-party device backends by enabling automatic discovery and initialization at runtime. Traditionally, integrating a new backend required explicit imports or manual initialization, which could be cumbersome and error-prone. With Autoload, PyTorch dynamically detects and initializes device backends, providing a seamless user experience. This mechanism leverages Python entry points (e.g., `torch.backends`) and dynamic module loading. When PyTorch starts, it scans for registered entry points and invokes their initialization hooks, ensuring that all available backends are ready for use without requiring explicit imports. ## Motivation This PR aims to apply [device autoload mechanism](pytorch#122468) to the OpenReg module with some simple changes. ## Change ### Before ```python import torch import torch_openreg x = torch.tensor([1, 2, 3], device="openreg") print(x) ``` ### After ```python import torch # No need to import torch_openreg manually! x = torch.tensor([1, 2, 3], device="openreg") print(x) ``` Pull Request resolved: pytorch#158555 Approved by: https://github.com/FFFrog, https://github.com/albanD Co-authored-by: Jiawei Li <ljw1101.vip@gmail.com>
# Implement OpenReg device autoload mechanism ## Overview The **Autoload** mechanism in PyTorch simplifies the integration of third-party device backends by enabling automatic discovery and initialization at runtime. Traditionally, integrating a new backend required explicit imports or manual initialization, which could be cumbersome and error-prone. With Autoload, PyTorch dynamically detects and initializes device backends, providing a seamless user experience. This mechanism leverages Python entry points (e.g., `torch.backends`) and dynamic module loading. When PyTorch starts, it scans for registered entry points and invokes their initialization hooks, ensuring that all available backends are ready for use without requiring explicit imports. ## Motivation This PR aims to apply [device autoload mechanism](pytorch#122468) to the OpenReg module with some simple changes. ## Change ### Before ```python import torch import torch_openreg x = torch.tensor([1, 2, 3], device="openreg") print(x) ``` ### After ```python import torch # No need to import torch_openreg manually! x = torch.tensor([1, 2, 3], device="openreg") print(x) ``` Pull Request resolved: pytorch#158555 Approved by: https://github.com/FFFrog, https://github.com/albanD Co-authored-by: Jiawei Li <ljw1101.vip@gmail.com>
# Implement OpenReg device autoload mechanism ## Overview The **Autoload** mechanism in PyTorch simplifies the integration of third-party device backends by enabling automatic discovery and initialization at runtime. Traditionally, integrating a new backend required explicit imports or manual initialization, which could be cumbersome and error-prone. With Autoload, PyTorch dynamically detects and initializes device backends, providing a seamless user experience. This mechanism leverages Python entry points (e.g., `torch.backends`) and dynamic module loading. When PyTorch starts, it scans for registered entry points and invokes their initialization hooks, ensuring that all available backends are ready for use without requiring explicit imports. ## Motivation This PR aims to apply [device autoload mechanism](pytorch#122468) to the OpenReg module with some simple changes. ## Change ### Before ```python import torch import torch_openreg x = torch.tensor([1, 2, 3], device="openreg") print(x) ``` ### After ```python import torch # No need to import torch_openreg manually! x = torch.tensor([1, 2, 3], device="openreg") print(x) ``` Pull Request resolved: pytorch#158555 Approved by: https://github.com/FFFrog, https://github.com/albanD Co-authored-by: Jiawei Li <ljw1101.vip@gmail.com>
Implement OpenReg device autoload mechanism
Overview
The Autoload mechanism in PyTorch simplifies the integration of third-party device backends by enabling automatic discovery and initialization at runtime. Traditionally, integrating a new backend required explicit imports or manual initialization, which could be cumbersome and error-prone. With Autoload, PyTorch dynamically detects and initializes device backends, providing a seamless user experience.
This mechanism leverages Python entry points (e.g.,
torch.backends) and dynamic module loading. When PyTorch starts, it scans for registered entry points and invokes their initialization hooks, ensuring that all available backends are ready for use without requiring explicit imports.Motivation
This PR aims to apply device autoload mechanism to the OpenReg module with some simple changes.
Change
Before
After
cc @fffrog @albanD