Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ See `src/torchada/_mappings/` for 400+ mapping rules grouped by API domain.

```
# pyproject.toml or requirements.txt
torchada>=0.1.75
torchada>=0.1.76
```

### Step 2: Conditional Import
Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ if torchada.is_gpu_device(device): # 在 CUDA 和 MUSA 上都能工作

```
# pyproject.toml 或 requirements.txt
torchada>=0.1.75
torchada>=0.1.76
```

### 步骤 2:条件导入
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmark_history.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Historical benchmark results for torchada performance tracking",
"results": [
{
"version": "0.1.75",
"version": "0.1.76",
"date": "2026-01-29",
"platform": "MUSA",
"pytorch_version": "2.7.1",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "torchada"
version = "0.1.75"
version = "0.1.76"
description = "Adapter package for torch_musa to act exactly like PyTorch CUDA"
readme = "README.md"
license = {text = "MIT"}
Expand Down
2 changes: 1 addition & 1 deletion src/torchada/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from torch.utils.cpp_extension import CUDAExtension, BuildExtension, CUDA_HOME
"""

__version__ = "0.1.75"
__version__ = "0.1.76"

from . import cuda, utils

Expand Down
4 changes: 3 additions & 1 deletion src/torchada/utils/cpp_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,14 @@ def patched_load_replaced_mapping(self):


def _narrow_cuda_header_mapping(mapping_rule):
"""Keep the cuda.h mapping from rewriting project-local header names."""
"""Port CUDA headers without rewriting project-local header names."""
narrowed = [(key, value) for key, value in mapping_rule if key != "cuda.h"]
narrowed.extend(
[
('#include <cuda.h>', '#include <musa.h>'),
('#include "cuda.h"', '#include "musa.h"'),
('#include <torch/cuda.h>', '#include <torch/musa.h>'),
('#include "torch/cuda.h"', '#include "torch/musa.h"'),
]
)
return sorted(narrowed, key=lambda item: len(item[0]), reverse=True)
Expand Down
16 changes: 16 additions & 0 deletions tests/test_cpp_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,22 @@ def test_porting_keeps_project_cuda_header_names(self):
assert rules['#include <cuda.h>'] == '#include <musa.h>'
assert rules['#include "cuda.h"'] == '#include "musa.h"'

def test_porting_translates_torch_cuda_header(self):
from torchada.utils.cpp_extension import _narrow_cuda_header_mapping, _replace_porting_line

rules = _narrow_cuda_header_mapping([("cuda.h", "musa.h")])

assert (
_replace_porting_line("#include <torch/cuda.h>\n", rules) == "#include <torch/musa.h>\n"
)
assert (
_replace_porting_line('#include "torch/cuda.h"\n', rules) == '#include "torch/musa.h"\n'
)

project_include = '#include "project/decode_jpegs_cuda.h"\n'
assert _replace_porting_line(project_include, rules) == project_include


class TestMusaPatches:
"""Test patches applied to torch_musa for extension building."""

Expand Down
2 changes: 1 addition & 1 deletion tests/test_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_get_version(self):

version = torchada.get_version()
assert version == torchada.__version__
assert version == "0.1.75"
assert version == "0.1.76"
assert isinstance(version, str)

def test_project_version_matches_runtime_version(self):
Expand Down