okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-0271-macds (DeepSeek on the Mac) into 0.2.7.1: setup.py keeps the Mac sentence and adds the DGX Spark one for Linux ARM649258e4086

main
1.7 KiB38 linesraw
1// mma.h - the wmma surface on Metal: the names parse, and using one stops the run.
2//
3// The DeepSeek token path does not use tensor cores.  The prompt path has an MMA variant written for CUDA/HIP warp matrices;
4// Metal's equivalent is the simdgroup matrix API, which is a different shape, so that variant is a later piece of the port.
5// These aliases exist so the shared sources compile (which is how the rest of the API surface is enumerated), and every
6// operation aborts with a message naming this file - an accidental call cannot return plausible garbage.
7#pragma once
8
9#include <cstdio>
10#include <cstdlib>
11
12namespace nvcuda {
13namespace wmma {
14
15// CUDA 12 spells these as tags: fragment<accumulator, 16, 16, 16, float>
16struct matrix_a {};
17struct matrix_b {};
18struct accumulator {};
19struct row_major {};
20struct col_major {};
21enum layout_t { mem_row_major, mem_col_major };
22
23template <typename Use, int M, int N, int K, typename T, typename Layout = void> struct fragment {
24    T x[M * N];
25};
26
27[[noreturn]] inline void strata_metal_wmma_missing(const char* what) {
28    std::fprintf(stderr, "strata metal: wmma::%s has no Metal implementation (simdgroup matrices are the equivalent)\n", what);
29    std::abort();
30}
31
32template <typename... A> inline void fill_fragment(A&&...) { strata_metal_wmma_missing("fill_fragment"); }
33template <typename... A> inline void load_matrix_sync(A&&...) { strata_metal_wmma_missing("load_matrix_sync"); }
34template <typename... A> inline void mma_sync(A&&...) { strata_metal_wmma_missing("mma_sync"); }   // variadic: the engine passes four fragments of different types
35template <typename... A> inline void store_matrix_sync(A&&...) { strata_metal_wmma_missing("store_matrix_sync"); }
36
37}   // namespace wmma
38}   // namespace nvcuda