CUDA-to-Ascend ecosystem compatibility bridge — fixes the last mile between torch_npu and your existing CUDA code
Project description
cuda-morph
Run PyTorch workloads on non-NVIDIA hardware with minimal code changes.
Existing CUDA-style PyTorch scripts keep running — cuda-morph redirects calls to available backends or falls back to CPU.
Why this exists
A lot of ML code assumes torch.cuda everywhere. On non-NVIDIA setups, that often means immediate runtime errors and expensive rewrites.
cuda-morph is a runtime compatibility layer that helps you keep the same workflow and ship faster.
Visual walkthrough
- Start with existing CUDA-oriented code.
- Activate
cuda-morph. - Run with backend-aware routing and fallback behavior.
Quick start
pip install cuda-morph
import ascend_compat
ascend_compat.activate()
# Existing CUDA-style code stays the same
model = model.cuda()
cuda-morph info
cuda-morph check model.py
Core capabilities
- Zero-rewrite activation for many CUDA-style PyTorch flows.
- Backend routing across Ascend / ROCm / Intel XPU / CPU fallback paths.
- CLI tooling for environment checks, porting hints, and validation commands.
- Ecosystem patches for key libraries (current depth varies by backend).
Full matrix: docs/compatibility_matrix.md
Validation snapshot
- 460+ tests passing in CPU-fallback mode.
- Real hardware proof captured on RunPod AMD ROCm:
.cuda()matmul ran oncuda:0and reportedAMD Radeon Graphics. - Core
.cuda()routing on non-NVIDIA hardware is now validated; broader operator and ecosystem coverage is still in progress.
If you can test on non-NVIDIA accelerators, feedback is highly valuable: open an issue.
Backend status (current)
| Backend | Hardware | Status |
|---|---|---|
| Huawei Ascend | 910B, 310P | Full shim + ecosystem patches (flash-attn, HuggingFace, DeepSpeed, vLLM). Needs hardware validation. |
| AMD ROCm | MI210, MI250X, MI300X | Detection + device routing. Ecosystem patches not yet implemented. |
| Intel XPU | Max 1550, Flex, Arc | Detection + device routing. Ecosystem patches not yet implemented. |
| Cambricon | MLU370, MLU590 | Detection + device routing. Ecosystem patches not yet implemented. |
CLI
cuda-morph check model.py # check a script for compatibility issues
cuda-morph port model.py # generate porting suggestions
cuda-morph doctor # environment diagnostics
cuda-morph doctor --full
cuda-morph verify --device npu
cuda-morph bench overhead
cuda-morph info
Development
git clone https://github.com/JosephAhn23/cuda-morph.git
cd cuda-morph
pip install -e ".[dev]"
pytest tests/ -v
pytest tests/ -v --run-hardware
See also
License
Apache 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cuda_morph-0.9.1.tar.gz.
File metadata
- Download URL: cuda_morph-0.9.1.tar.gz
- Upload date:
- Size: 151.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d04d6894e4e63051dffe9df827f623505492f5d4da23279ed05d4a8b77e6cc30
|
|
| MD5 |
502e2329523663740b14deb5eaf963c0
|
|
| BLAKE2b-256 |
7329c9823b2d5148df6a57c7dd99791d9a6c4a5ebd990d62a1cf1a3ea8c5767d
|
Provenance
The following attestation bundles were made for cuda_morph-0.9.1.tar.gz:
Publisher:
publish.yml on JosephAhn23/cuda-morph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cuda_morph-0.9.1.tar.gz -
Subject digest:
d04d6894e4e63051dffe9df827f623505492f5d4da23279ed05d4a8b77e6cc30 - Sigstore transparency entry: 1070655180
- Sigstore integration time:
-
Permalink:
JosephAhn23/cuda-morph@dd7e253fd876b82007ac85aaa8e49f122f645ff9 -
Branch / Tag:
refs/tags/v0.9.1 - Owner: https://github.com/JosephAhn23
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@dd7e253fd876b82007ac85aaa8e49f122f645ff9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file cuda_morph-0.9.1-py3-none-any.whl.
File metadata
- Download URL: cuda_morph-0.9.1-py3-none-any.whl
- Upload date:
- Size: 143.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98f9b099f715c5e737c4c8ae0fa0a8198b7f263a5094d7a0b03412030de27b99
|
|
| MD5 |
16f7b8fbc0c624d68b9628ae6950ab66
|
|
| BLAKE2b-256 |
9f3fc9dc9b915667ca71f082c64dd3f73d6d224c9ac8a9789c9405fef4c1ba6f
|
Provenance
The following attestation bundles were made for cuda_morph-0.9.1-py3-none-any.whl:
Publisher:
publish.yml on JosephAhn23/cuda-morph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cuda_morph-0.9.1-py3-none-any.whl -
Subject digest:
98f9b099f715c5e737c4c8ae0fa0a8198b7f263a5094d7a0b03412030de27b99 - Sigstore transparency entry: 1070655181
- Sigstore integration time:
-
Permalink:
JosephAhn23/cuda-morph@dd7e253fd876b82007ac85aaa8e49f122f645ff9 -
Branch / Tag:
refs/tags/v0.9.1 - Owner: https://github.com/JosephAhn23
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@dd7e253fd876b82007ac85aaa8e49f122f645ff9 -
Trigger Event:
release
-
Statement type: