-
Notifications
You must be signed in to change notification settings - Fork 759
Add entrypoint for flagos multi-backend plugin system #3107
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
base: release_v2.14
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
| import sys | ||
| import sysconfig | ||
| from typing import Optional, Tuple | ||
| import warnings | ||
|
|
||
|
|
||
| @functools.lru_cache(maxsize=None) | ||
|
|
@@ -191,6 +192,21 @@ def load_framework_extension(framework: str) -> None: | |
| sys.modules[module_name] = solib | ||
| spec.loader.exec_module(solib) | ||
|
|
||
| # Plugin system: if NVTE_ENABLE_PLUGIN=1, let plugin stub take over | ||
| # transformer_engine_torch and register original pybind as _nv for CUDA backend. | ||
| # Only applies to the PyTorch extension — JAX has no plugin stub. | ||
| if os.environ.get("NVTE_ENABLE_PLUGIN", "0") == "1" and framework == "torch": | ||
| sys.modules[module_name + "_nv"] = solib | ||
| try: | ||
| from transformer_engine_plugin_fl import load_plugins | ||
| load_plugins() | ||
| except ImportError as e: | ||
| warnings.warn( | ||
| f"NVTE_ENABLE_PLUGIN=1 but plugin import failed: {e}", | ||
| ImportWarning, | ||
| stacklevel=2, | ||
| ) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed
Comment on lines
+200
to
+216
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Capture the pre-attempt value of
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
|
|
||
|
|
||
| def sanity_checks_for_pypi_installation() -> None: | ||
| """Ensure that package is installed correctly if using PyPI.""" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we instead have a separate env variable with the name of the module rather than hardcoding FlagOS version of it? Or maybe we could have 1 env variable
NVTE_PLUGINwhich could be set to the name of the plugin module (and setting it to None or not setting it at all would disable plugin functionality)?