-
-
Notifications
You must be signed in to change notification settings - Fork 200
[Build] feat: multi-backend build system to consolidate CUDA, ROCm, CPU, etc #1540
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: main
Are you sure you want to change the base?
Changes from all 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 |
|---|---|---|
|
|
@@ -10,14 +10,30 @@ | |
|
|
||
| if not current_platform.is_tpu() and not current_platform.is_xpu(): | ||
| try: | ||
| import aphrodite._C | ||
| if current_platform.is_cuda(): | ||
| import aphrodite.extensions.cuda._C # noqa: F401 | ||
| elif current_platform.is_rocm(): | ||
| import aphrodite.extensions.rocm._C # noqa: F401 | ||
| # Also register ROCm-specific ops if present | ||
| with contextlib.suppress(ImportError): | ||
| import aphrodite.extensions.rocm._rocm_C # noqa: F401 | ||
| elif current_platform.is_cpu(): | ||
| import aphrodite.extensions.cpu._C # noqa: F401 | ||
| else: | ||
| # Other platforms not handled here | ||
| pass | ||
| except ImportError as e: | ||
| logger.warning("Failed to import from aphrodite._C with {!r}", e) | ||
| logger.warning("Failed to import platform-specific _C with {!r}", e) | ||
|
|
||
| supports_moe_ops = False | ||
| with contextlib.suppress(ImportError): | ||
| import aphrodite._moe_C # noqa: F401 | ||
| supports_moe_ops = True | ||
| if current_platform.is_cuda(): | ||
| with contextlib.suppress(ImportError): | ||
| import aphrodite.extensions.cuda._moe_C # noqa: F401 | ||
| supports_moe_ops = True | ||
| elif current_platform.is_rocm(): | ||
| with contextlib.suppress(ImportError): | ||
| import aphrodite.extensions.rocm._moe_C # noqa: F401 | ||
| supports_moe_ops = True | ||
|
Comment on lines
11
to
+36
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. The logic for importing platform-specific extensions and setting import importlib
if not current_platform.is_tpu() and not current_platform.is_xpu():
backend = None
if current_platform.is_cuda():
backend = "cuda"
elif current_platform.is_rocm():
backend = "rocm"
elif current_platform.is_cpu():
backend = "cpu"
if backend:
try:
importlib.import_module(f"aphrodite.extensions.{backend}._C")
if backend == "rocm":
# Also register ROCm-specific ops if present
with contextlib.suppress(ImportError):
importlib.import_module("aphrodite.extensions.rocm._rocm_C")
except ImportError as e:
logger.warning("Failed to import platform-specific _C for backend {} with {!r}", backend, e)
else:
# Other platforms not handled here
pass
supports_moe_ops = False
if current_platform.is_cuda() or current_platform.is_rocm():
backend = "cuda" if current_platform.is_cuda() else "rocm"
with contextlib.suppress(ImportError):
importlib.import_module(f"aphrodite.extensions.{backend}._moe_C")
supports_moe_ops = True |
||
|
|
||
| if TYPE_CHECKING: | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| This directory contains the compiled binaries for the Aphrodite extensions. By default, it's empty and will be populated when building the Aphrodite extensions. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ numba == 0.61.2; python_version > '3.9' | |
| boto3 | ||
| botocore | ||
| datasets | ||
| ray>=2.10.0,<2.45.0 | ||
| ray>=2.10.0 | ||
|
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. |
||
| peft | ||
| pytest-asyncio | ||
| tensorizer==2.10.1 | ||
|
|
||
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.
The indentation for
define_gpu_extension_targetand its arguments appears to have been accidentally changed, making it inconsistent with the surrounding code style. Please restore the original indentation to improve readability and maintain consistency.