cuda-morph is a groundbreaking CUDA compatibility layer that enables existing PyTorch models to run on Huawei Ascend NPUs and other non-NVIDIA hardware without modifications. It simplifies machine learning workflows, allowing for backend-aware routing and fallback behavior, ultimately accelerating shipping and deploying machine learning applications.
cuda-morph is designed to enable seamless execution of PyTorch workloads on non-NVIDIA hardware with minimal code changes. This innovative compatibility layer ensures that existing CUDA-based PyTorch scripts continue to function without the need for significant rewrites. By redirecting calls to available backends or falling back to CPU, cuda-morph streamlines the machine learning development process, enhancing productivity and efficiency in deploying models across diverse hardware platforms.
Key Features
- Zero-Rewrite Activation: Users can activate many existing CUDA-style PyTorch flows without rewriting code.
- Flexible Backend Routing: Automatically routes based on available hardware, including support for Ascend, ROCm, Intel XPU, and CPU fallbacks.
- Command-Line Interface (CLI): Includes tools for environment checks, porting hints, and script validation to ensure compatibility.
- Ecosystem Compatibility: Offers patches for essential libraries to facilitate integration with cuda-morph, further easing the transition to non-NVIDIA hardware.
How It Works
- Begin with existing CUDA-oriented codebase.
- Activate the cuda-morph layer.
- Run the code with optimal backend-aware routing.
Example Usage
To install the package, run:
pip install cuda-morph
Then, activate compatibility in your code:
import ascend_compat
ascend_compat.activate()
# Existing CUDA-style code remains unchanged
model = model.cuda()
Validation and Backends
cuda-morph has undergone rigorous testing with over 460 tests passing in CPU fallback mode. Users can verify compatibility on various hardware platforms and view a comprehensive matrix of supported capabilities for each backend.
Current Backend Support:
| Backend | Hardware | Status |
|---|---|---|
| Huawei Ascend | 910B, 310P | Full shim & ecosystem patches available. |
| AMD ROCm | MI210, MI250X, MI300X | Detection and device routing implemented. |
| Intel XPU | Max 1550, Flex, Arc | Detection and device routing implemented. |
| Cambricon | MLU370, MLU590 | Detection and device routing implemented. |
Diagnostic Tools
Utilize the CLI tools to assess compatibility and optimize code for different hardware setups:
cuda-morph check model.py # Check script for compatibility issues
cuda-morph port model.py # Generate porting suggestions
Further Exploration
For detailed insights and additional documentation, refer to:
- STRATEGY.md
- VALIDATION_STATUS.md
- MIGRATION.md
- Chinese README to access localized resources.
No comments yet.
Sign in to be the first to comment.