CUDA compiler and runtime for Apple Silicon
173
stars
482
commits
C++
primary language
Sep 8, 2026
updated
CuMetal recompiles a tested subset of CUDA C++ and PTX for Apple Metal and provides a clean-room CUDA compatibility runtime for Apple Silicon. It is experimental: supported paths run real Metal kernels, while unsupported paths should fail explicitly.
brew install lulzx/tap/cumetal
cumetal doctor
The tap installs the recommended Release/source-first configuration and keeps
the optional libcuda.dylib alias off.
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j"$(sysctl -n hw.ncpu)"
bash scripts/ci_report.sh build --exclude-regex '^bench_'
build/cumetalc samples/vectorAdd/vectorAdd.cu -o vectorAdd
./vectorAdd
That linked source path embeds a typed metallib and uses CuMetal's versioned native registration ABI, including constant/device symbol metadata; it does not ship PTX or perform first-launch JIT.
Requirements are macOS 14 or newer on Apple Silicon, CMake, LLVM 18+ libraries,
a CUDA-capable Clang 21-23 frontend, LZ4/Zstd libraries, and Apple's public
metal and metallib tools. See the
build and installation guide before packaging or installing.
For a staged GPU demonstration:
bash demos/apollo/run.sh
Apollo requires numerical checks and device=apple_gpu provenance at every
stage. Other bounded demonstrations are indexed in the demos guide.
CuMetal is source-first:
CUDA C++ -> Clang/NVVM -> typed CuMetal IR -> MSL -> Apple tools -> metallib
PTX -------------------> legacy or typed lowering --------------------^
.cu compilation is the primary path and defaults to typed CuMetal IR..cu --cuda-device default to the broader legacy compatibility
backend while typed PTX migration remains incomplete.libcuda.dylib alias accepts only supported binary-registration
and embedded-PTX forms. It is disabled in Release builds unless explicitly
enabled. SASS execution is unsupported.runtime/metal_backend/; CUDA-facing headers are clean-room; no private Apple
API is used.The canonical requirements are indexed by the specification. Current compiler paths and their selection policy are in compiler architecture.
printf metadata without first-launch PTX
JIT.cuda-samples gate is 83/83 pass, with zero
waivers and zero nonpassing entries on the 2026-08-30 rerun. Its cooperative
CG case now gates both device residual and the independent host equation
error, so a partial-warp false positive cannot count as a pass..cu through typed CuMetal IR, 25/25 for typed PTX,
and 25/25 for the legacy PTX backend. These are compile results, not
numerical runtime proof.printf, typed direct
constant/device symbols,
shared memory, warp operations, streams, and events have focused numerical
Apple-GPU tests.VF64-metal is pinned and its fast48, wide48, and ieee64 integration
validation passes on the recorded Apple M4 Pro system. Each mode has different
precision semantics; this is not native Metal FP64.Exact commands, tolerances, device provenance, and third-party boundaries are
in verified results. The executable source/sample
matrix is tests/cuda_projects/backend_matrix_manifest.txt.
multiProcessorCount is conservatively
1 because public Metal has no per-kernel residency query.fast48, wide48, or software ieee64; observable IEEE exception
status is not fully integrated.See known gaps for the maintained classification and the closure roadmap for prioritized work.
# Inspect compiler stages
build/cumetalc kernel.cu --emit=cumetal-ir -o kernel.cmir
build/cumetalc kernel.cu --emit=msl -o kernel.metal
build/cumetalc kernel.cu --emit=metallib -o kernel.metallib
# Enable the optional binary alias in an explicit build
cmake -B build-shim -DCMAKE_BUILD_TYPE=Release \
-DCUMETAL_ENABLE_BINARY_SHIM=ON
cmake --build build-shim
# Validate both source-first and no-shim configurations
ctest --test-dir build --output-on-failure
cmake -B build-noshim -DCMAKE_BUILD_TYPE=Debug \
-DCUMETAL_ENABLE_BINARY_SHIM=OFF
cmake --build build-noshim
ctest --test-dir build-noshim --output-on-failure
cumetal doctor checks an installed toolchain. cumetal run only scopes this
installation's runtime library path to a child process; it cannot make an
unsupported binary portable.
The full documentation map is docs/README.md. Primary entries:
If documentation conflicts, spec.md wins, followed by AGENTS.md. Status and
README material may lag and must not override the specification.
482 commits
C++
79.6%
Shell
5.2%
Cuda
4.5%
C
3.7%
CMake
3.0%
Objective-C++
2.6%
CUDA compiler and runtime for Apple Silicon
173
stars
482
commits
C++
primary language
Sep 8, 2026
updated
CuMetal recompiles a tested subset of CUDA C++ and PTX for Apple Metal and provides a clean-room CUDA compatibility runtime for Apple Silicon. It is experimental: supported paths run real Metal kernels, while unsupported paths should fail explicitly.
brew install lulzx/tap/cumetal
cumetal doctor
The tap installs the recommended Release/source-first configuration and keeps
the optional libcuda.dylib alias off.
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j"$(sysctl -n hw.ncpu)"
bash scripts/ci_report.sh build --exclude-regex '^bench_'
build/cumetalc samples/vectorAdd/vectorAdd.cu -o vectorAdd
./vectorAdd
That linked source path embeds a typed metallib and uses CuMetal's versioned native registration ABI, including constant/device symbol metadata; it does not ship PTX or perform first-launch JIT.
Requirements are macOS 14 or newer on Apple Silicon, CMake, LLVM 18+ libraries,
a CUDA-capable Clang 21-23 frontend, LZ4/Zstd libraries, and Apple's public
metal and metallib tools. See the
build and installation guide before packaging or installing.
For a staged GPU demonstration:
bash demos/apollo/run.sh
Apollo requires numerical checks and device=apple_gpu provenance at every
stage. Other bounded demonstrations are indexed in the demos guide.
CuMetal is source-first:
CUDA C++ -> Clang/NVVM -> typed CuMetal IR -> MSL -> Apple tools -> metallib
PTX -------------------> legacy or typed lowering --------------------^
.cu compilation is the primary path and defaults to typed CuMetal IR..cu --cuda-device default to the broader legacy compatibility
backend while typed PTX migration remains incomplete.libcuda.dylib alias accepts only supported binary-registration
and embedded-PTX forms. It is disabled in Release builds unless explicitly
enabled. SASS execution is unsupported.runtime/metal_backend/; CUDA-facing headers are clean-room; no private Apple
API is used.The canonical requirements are indexed by the specification. Current compiler paths and their selection policy are in compiler architecture.
printf metadata without first-launch PTX
JIT.cuda-samples gate is 83/83 pass, with zero
waivers and zero nonpassing entries on the 2026-08-30 rerun. Its cooperative
CG case now gates both device residual and the independent host equation
error, so a partial-warp false positive cannot count as a pass..cu through typed CuMetal IR, 25/25 for typed PTX,
and 25/25 for the legacy PTX backend. These are compile results, not
numerical runtime proof.printf, typed direct
constant/device symbols,
shared memory, warp operations, streams, and events have focused numerical
Apple-GPU tests.VF64-metal is pinned and its fast48, wide48, and ieee64 integration
validation passes on the recorded Apple M4 Pro system. Each mode has different
precision semantics; this is not native Metal FP64.Exact commands, tolerances, device provenance, and third-party boundaries are
in verified results. The executable source/sample
matrix is tests/cuda_projects/backend_matrix_manifest.txt.
multiProcessorCount is conservatively
1 because public Metal has no per-kernel residency query.fast48, wide48, or software ieee64; observable IEEE exception
status is not fully integrated.See known gaps for the maintained classification and the closure roadmap for prioritized work.
# Inspect compiler stages
build/cumetalc kernel.cu --emit=cumetal-ir -o kernel.cmir
build/cumetalc kernel.cu --emit=msl -o kernel.metal
build/cumetalc kernel.cu --emit=metallib -o kernel.metallib
# Enable the optional binary alias in an explicit build
cmake -B build-shim -DCMAKE_BUILD_TYPE=Release \
-DCUMETAL_ENABLE_BINARY_SHIM=ON
cmake --build build-shim
# Validate both source-first and no-shim configurations
ctest --test-dir build --output-on-failure
cmake -B build-noshim -DCMAKE_BUILD_TYPE=Debug \
-DCUMETAL_ENABLE_BINARY_SHIM=OFF
cmake --build build-noshim
ctest --test-dir build-noshim --output-on-failure
cumetal doctor checks an installed toolchain. cumetal run only scopes this
installation's runtime library path to a child process; it cannot make an
unsupported binary portable.
The full documentation map is docs/README.md. Primary entries:
If documentation conflicts, spec.md wins, followed by AGENTS.md. Status and
README material may lag and must not override the specification.
482 commits
C++
79.6%
Shell
5.2%
Cuda
4.5%
C
3.7%
CMake
3.0%
Objective-C++
2.6%