metal: the dsv41 host side compiles - ds4_model.cu goes from 20 errors to 0
The last layer of the compat surface: the CUDA function-space qualifiers (__host__/__device__/__global__/__shared__/ __constant__/__forceinline__/__launch_bounds__), cpu_set_t's CPU_ZERO/CPU_SET for the macOS branch of ds4_os.hpp, CUBLAS_GEMM_DEFAULT_TENSOR_OP, a cudaMemcpy2D that reports failure rather than copying nothing, and a cublasGemmEx that takes any argument list (the engine passes cuBLAS's full 19-argument spelling) and aborts naming kernels/dense_mm.metal. With that, src/dsv41/ds4_model.cu - 8,232 lines, host only - compiles against metal/include/metal_compat on the M5 Max. The four kernel sources are one error each, and the kernel work itself (MSL bodies for 27 + 76 + 33 device functions, plus the dense GEMM and a pitched copy at the runtime) is what remains before a first token.
This commit is contained in:
1 parent
bb60de0e8e
commit
a798d03858
3 files changed
+44
-4
No files matched your search
@@ -19,6 +19,7 @@ enum cublasStatus_t { CUBLAS_STATUS_SUCCESS = 0, CUBLAS_STATUS_NOT_INITIALIZED =
|
||||
CUBLAS_STATUS_INVALID_VALUE = 7, CUBLAS_STATUS_ARCH_MISMATCH = 8, CUBLAS_STATUS_NOT_SUPPORTED = 14 };
|
||||
enum cublasOperation_t { CUBLAS_OP_N = 0, CUBLAS_OP_T = 1, CUBLAS_OP_C = 2 };
|
||||
enum cublasComputeType_t { CUBLAS_COMPUTE_16F = 64, CUBLAS_COMPUTE_32F = 68, CUBLAS_COMPUTE_32F_FAST_16F = 74 };
|
||||
enum cublasGemmAlgo_t { CUBLAS_GEMM_DEFAULT = -1, CUBLAS_GEMM_DEFAULT_TENSOR_OP = 99 };
|
||||
enum cudaDataType_t { CUDA_R_32F = 0, CUDA_R_16F = 2, CUDA_R_16BF = 14, CUDA_R_8F_E4M3 = 28 };
|
||||
|
||||
static inline cublasStatus_t cublasCreate(cublasHandle_t* h) {
|
||||
@@ -43,9 +44,9 @@ static inline cublasStatus_t cublasSgemm(cublasHandle_t, cublasOperation_t, cubl
|
||||
strata_metal_dense_gemm_missing("cublasSgemm");
|
||||
}
|
||||
|
||||
// the mixed-precision form: the engine passes a compute type and a scale; on Metal the kernels read A/B by their own type
|
||||
static inline cublasStatus_t cublasGemmEx(cublasHandle_t, cublasOperation_t, cublasOperation_t, int, int, int,
|
||||
const void*, const void*, cudaDataType_t, int, const void*, cudaDataType_t, int,
|
||||
const void*, void*, cudaDataType_t, cublasComputeType_t, int) {
|
||||
// the mixed-precision form: any argument list, because the engine passes cuBLAS's full 19-argument spelling; the body
|
||||
// names kernels/dense_mm.metal, which is where the real implementation goes.
|
||||
template <typename... A>
|
||||
static inline cublasStatus_t cublasGemmEx(A...) {
|
||||
strata_metal_dense_gemm_missing("cublasGemmEx");
|
||||
}
|
||||
@@ -1,3 +1,31 @@
|
||||
// The CUDA function-space qualifiers and the few launch/kernel spellings the shared sources use. On Metal they say
|
||||
// nothing: a "kernel" here is an MSL function compiled at run time and dispatched by the host runtime, so the qualifiers
|
||||
// are empty and __forceinline__ is plain inline. Part of the metal_compat layer (M5 Max, 2026-10-23).
|
||||
#ifndef __host__
|
||||
#define __host__
|
||||
#endif
|
||||
#ifndef __device__
|
||||
#define __device__
|
||||
#endif
|
||||
#ifndef __global__
|
||||
#define __global__
|
||||
#endif
|
||||
#ifndef __shared__
|
||||
#define __shared__
|
||||
#endif
|
||||
#ifndef __constant__
|
||||
#define __constant__
|
||||
#endif
|
||||
#ifndef __forceinline__
|
||||
#define __forceinline__ inline
|
||||
#endif
|
||||
#ifndef __launch_bounds__
|
||||
#define __launch_bounds__(...)
|
||||
#endif
|
||||
#ifndef __restrict__
|
||||
#define __restrict__
|
||||
#endif
|
||||
|
||||
// metal/include/metal_compat/cuda_runtime.h - the CUDA runtime names the host files use, on Metal.
|
||||
//
|
||||
// The HIP build's approach (include/strata/hip_compat/cuda_runtime.h maps every cudaX the host code calls to hipX),
|
||||
@@ -141,3 +169,10 @@ inline cudaError_t cudaGraphLaunch(cudaGraphExec_t x, cudaStream_t s) { return s
|
||||
inline cudaError_t cudaGraphUpload(cudaGraphExec_t x, cudaStream_t s) { return strata::gpu::graph_upload(x, s); }
|
||||
inline cudaError_t cudaGraphDestroy(cudaGraph_t g) { return strata::gpu::graph_destroy(g); }
|
||||
inline cudaError_t cudaGraphExecDestroy(cudaGraphExec_t x) { return strata::gpu::graph_exec_destroy(x); }
|
||||
|
||||
// cudaMemcpy2D(dst, dpitch, src, spitch, width, height, kind): a strided copy, used by the vision tower's patch rows and
|
||||
// the Engram tables' column slices. The Metal runtime has no pitched copy yet, so this reports failure rather than
|
||||
// copying nothing silently.
|
||||
inline strata::gpu::Error cudaMemcpy2D(void*, size_t, const void*, size_t, size_t, size_t, strata::gpu::CopyKind) {
|
||||
return strata::gpu::kErrorUnsupported; // cudaMemcpy2D_unimplemented_marker
|
||||
}
|
||||
@@ -46,6 +46,10 @@ static inline long syscall(long, ...) { return -1; }
|
||||
|
||||
// CPU affinity: macOS schedules on its own; the engine only uses this to pin the token thread. No-op, reported as success.
|
||||
typedef struct { unsigned long __bits[16]; } cpu_set_t;
|
||||
#ifndef CPU_ZERO
|
||||
#define CPU_ZERO(set) ((void) (set))
|
||||
#define CPU_SET(cpu, set) ((void) (set))
|
||||
#endif
|
||||
static inline int sched_setaffinity(pid_t, size_t, const cpu_set_t*) { return 0; }
|
||||
static inline int pthread_setaffinity_np(pthread_t, size_t, const cpu_set_t*) { return 0; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user