Skip to content

Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦

C

backend: the gated-delta reduction and memset go through the HIP shims

kreuzzelgb7ead912df63
diff --git a/c/backend_cuda.cu b/c/backend_cuda.cu
index 7222bd75..d1bd3efd 100644
--- a/c/backend_cuda.cu
+++ b/c/backend_cuda.cu
@@ -1831,7 +1831,7 @@ __global__ void dn_conv_kernel(const float *__restrict__ qkv, float *__restrict_
__device__ static double dn_block_sum(double v, double *sh) {
/* blockDim <= 1024; warp shuffle then one pass over warps */
- for (int o = 16; o > 0; o >>= 1) v += __shfl_down_sync(0xffffffffu, v, o);
+ for (int o = 16; o > 0; o >>= 1) v += f8_shfl_down(v, o); /* CUDA: __shfl_down_sync, HIP: __shfl_down (backend_gpu_compat) */
int lane = threadIdx.x & 31, wid = threadIdx.x >> 5;
__syncthreads();
if (lane == 0) sh[wid] = v;
diff --git a/c/backend_gpu_compat.h b/c/backend_gpu_compat.h
index f3a3508f..93067997 100644
--- a/c/backend_gpu_compat.h
+++ b/c/backend_gpu_compat.h
@@ -99,6 +99,7 @@ namespace nvcuda { namespace wmma = ::rocwmma; }
#define cudaMemcpyPeer hipMemcpyPeer
#define cudaMemcpyPeerAsync hipMemcpyPeerAsync
#define cudaMemsetAsync hipMemsetAsync
+#define cudaMemset hipMemset
/* Device-side kernel abort (weight_at's undecodable-format backstop,
* backend_cuda.cu). CUDA's __trap() intrinsic has no HIP name-twin; HIP
* device code aborts via abort() -- the same mapping hipify applies. NVCC