Port CUDA sources to MUSA in place#87
Conversation
torch_musa's SimplePorting is driven in place (destination == source) with an identity extension map, so ported .cu/.cuh sources keep their names and locations. Original #include and source paths resolve as-is: no per-file include rewriting, and no second source tree that could cause cross-tree #pragma once ODR. In-place content substitution is restricted to compiled C/C++/CUDA sources and headers, so build scripts, templates, and docs in a ported directory are left byte-for-byte unchanged. Each source's parent directory is ported alongside the include roots. The headeronly->c10 header rewrites live in the data-type mappings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
🤖 Augment PR SummarySummary: This PR switches torchada’s CUDA→MUSA extension porting to run in place (no Changes:
Technical Notes: In-place compilation relies on the patched 🤖 Was this summary useful? React with 👍 or 👎 |
Use os.rmdir (not shutil.rmtree) for the leftover <dir>_musa so a non-empty directory is never force-deleted. Check the full _PORTABLE_SOURCE_EXTS set in the port gate so a directory of only .cc/.cpp sources is ported, not skipped. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
On-device verification caught a runtime regression — root-caused and fixed in The first in-place build passed build + import (rc=0) but produced degenerate garbage output ( Root cause. In-place porting walks every file under a ported include root ( Ruled out along the way: mcc codegen is byte-identical for Fix ( Verified on-device (S5000, native mp_31, image |
In-place porting walks every file under a ported include root and applied the CUDA->MUSA content substitution to hand-written MUSA-native .mu/.muh sources as well. The asm-volatile neutralization rule -- which guards un-assemblable CUDA PTX with if(0) -- then disabled valid MUSA inline asm (e.g. vec_utils.muh's vectorized 16-byte load), leaving the result uninitialized and producing garbage kernel output while still building cleanly. Gate content substitution to CUDA/C++ extensions only and leave .mu/.muh byte-identical: they are already MUSA and need no porting. Add _MUSA_NATIVE_EXTS alongside _PORTABLE_SOURCE_EXTS and skip substitution for it in modify_file. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
test_build_mixed_sources_extension still asserted the old <dir>_musa mirror and .cu->.mu rename, contradicting its own docstring and the in-place porter. Assert instead that no csrc_musa mirror is created and that sources keep their original names and locations, matching test_cu_and_mu_coexist_in_place. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
e8f7086 to
90a43e7
Compare
Bump the torchada>= install-pin examples in README.md / README_CN.md and the benchmark_history baseline version label to 0.1.70. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Version correction applied in
|
What
Port CUDA sources to MUSA in place as the single default path of the setuptools build:
torch_musa'sSimplePortingwithmusa_dir_path == cuda_dir_pathand an identity extension map, so ported.cu/.cuhsources keep their original names and locations — no<dir>_musamirror, no.cuto.mu/.cuhto.muhrename.#includeand source paths therefore resolve as-is: no per-file include rewriting, and no second source tree that could cause cross-tree#pragma onceODR..mu/.muhfiles byte-for-byte unchanged.torch/headeronly/util/*toc10/util/*header rewrites into the data-type mappings.torchada 0.1.70. No 0.1.70 artifact was published before this PR, so this remains the final release identity.Why
Consumers that drive this build (vLLM-MUSA, SGLang
sgl-kernel) otherwise carry hand-maintained patches whose only job is to rewrite#includedirectives so mirrored and renamed ported sources resolve. Porting in place removes that class of downstream patch.MUSA-native
.mu/.muhfiles must not undergo CUDA-to-MUSA substitutions: they are already MUSA source, and rewriting their inline assembly caused the runtime regression found during on-device verification. A native MUSA source that includes a ported third-party header should use its real.cuhname;.muhremains reserved for MUSA-native headers.Verification
83 passed, 4 build-gated skipped.10 passed; changed-file Black and isort checks passed.torchada-0.1.70-py3-none-any.whlsuccessfully and verified its wheel metadata reports version 0.1.70.SimplePortingcontainer check:.cu/.cuh/.hported in place; non-source and MUSA-native files remained byte-identical; no<dir>_musamirror was created.Cross-repository consumer: MooreThreads/vllm-musa#95.