CUDA backend (DGX-Spark) — refactored into modular .cuh files mirroring ROCm structure#398
Open
gundemirbas wants to merge 1 commit into
Open
CUDA backend (DGX-Spark) — refactored into modular .cuh files mirroring ROCm structure#398gundemirbas wants to merge 1 commit into
gundemirbas wants to merge 1 commit into
Conversation
CUDA backend refactored into modular .cuh files under /cuda/ mirroring ROCm structure. Includes ds4_cuda_runtime.cuh, attention, moe, matmul, norm/rope, fp8_kv, compressor, hc, indexer, router, q8_K, embedding, misc kernels. Makefile: CUDA target selection shell.nix: ROCm + CUDA dev environment
|
@gundemirbas could you rebase codes on this #402, since my change is more lite. I am not sure you have added functions (quantization) and UVA prefetch cache for cuda backend. But hope you have some tests to verify it . Could you post some snapshot and logs (to make sure critical path work as expected) ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a full CUDA backend for NVIDIA GPU support (targeting DGX Spark / NVIDIA Grace Blackwell), refactored into modular
.cuhfiles under a newcuda/directory, mirroring the existing ROCm backend structure. The monolithicds4_cuda.cuis replaced with a thin dispatcher that includes the appropriate.cuhmodules.Changes
New
cuda/directory — 18 modular.cuhfilesds4_cuda_runtime.cuhds4_cuda_common.cuhds4_cuda_attention.cuh/ds4_cuda_attention_launch.cuhds4_cuda_moe.cuh/ds4_cuda_moe_launch.cuhds4_cuda_matmul.cuhds4_cuda_norm_rope.cuhds4_cuda_fp8_kv.cuhds4_cuda_compressor.cuhds4_cuda_hc.cuh/ds4_cuda_hc_output_launch.cuhds4_cuda_indexer.cuhds4_cuda_router.cuhds4_cuda_q8_K.cuhds4_cuda_embedding.cuh/ds4_cuda_embedding_launch.cuhds4_cuda_misc.cuhRefactored
ds4_cuda.cu.cuhfiles.ds4_rocm.cu→rocm/*.cuh.MakefileCUDAtarget:make CUDA=1builds the CUDA backend.DS4_CUDApreprocessor define.shell.nixMotivation
The DGX Spark (NVIDIA Grace Blackwell) is a compact AI workstation with 128 GB unified memory and a Blackwell GPU. Adding a first-class CUDA backend enables ds4 to run on this platform without the ROCm compatibility layer. The modular structure mirrors the existing ROCm backend (
rocm/*.cuh), making future cross-backend maintenance straightforward.Design Decisions
.cuhfiles — each kernel family lives in its own file, matching the ROCm layout. This makes it easy to compare CUDA and ROCm implementations side by side.ds4_cuda_runtime.cuh— contains all CUDA-specific runtime code (streams, events, memory management, device queries), analogous tods4_rocm_runtime.cuh.DS4_CUDA/DS4_ROCMdefines.Testing