metal: the engine runs on the M5 Max - the shared host loop over a Metal decode window (C3, first greedy answers)
The Metal build of `strata` is the shared host code (src/, unchanged except preprocessor-only Metal/arm64 branches) over two Metal-only parts in metal/src/engine: - window.cpp: the decode window, the one backend hook (Verifier::init/run/commit/copy_logits under STRATA_GPU_METAL). It is mac-kern's chain on the model GGUF itself (shard 1 mmapped and wrapped no-copy, every weight read in place: no upload, no expert cache): HC reads, GDN/QSA mixers with their own state (recurrence, conv history ping-pong, int8 K/V, indexer), router + plan, routed and shared experts, combine, the final mixer, the LM head and the greedy pick, encoded as one dependency graph. The embedding is dequantized on the CPU into the shared buffer; the PLE rows come from the shared table reader, their projections run on the GPU and the block's norms / gate / conv on the CPU between two command buffers. One-token windows (--mtp-max-t 1) for now. - host helpers copied from the CUDA kernel files the host code reads while it starts (format tables, sizes, path switches, the RoPE table/config); every other kernel entry point is a generated stub that stops with its name (stubs.cpp, tools/gen_stubs.py, from clang's AST of our headers). Shared host code, all inside #if STRATA_GPU_METAL / __APPLE__ / __aarch64__ (the PC objects do not change): - verify.hpp/.cpp: the hook (an opaque window pointer; init/run/commit/wait_commit/copy_logits hand over) - generate.cpp: no x86 ISA refusal; a native pack without --prefill reads its prompt through one-token windows; the model shard handed to the window - device.cu: the poison fill through the allocation's CPU view; pool_affinity_linux.hpp: a macOS branch (no pinning); expert_layout.cpp: no xgetbv asm on arm64 metal/include/metal_compat: cpuid.h (all zero on arm64), linux/mman.h (no hugetlb/THP: the fallback taken). M5 Max, Q2_0, greedy, "What is the capital of France?": "The capital of France is Paris." - the same 36 first tokens as the HIP engine (R9700, same flags) on that prompt and 39 on a story prompt, then near-tie flips (margins 0.08-0.41 when following the HIP tokens); decode 74-75 tok/s.
This commit is contained in:
1 parent
7f3bed34ea
commit
5d76056a4a
18 files changed
+1752
-1
No files matched your search
@@ -60,7 +60,9 @@ bool cpu_avx512_ok() {
|
||||
const unsigned long long xcr0 = _xgetbv(0);
|
||||
#else
|
||||
unsigned lo = 0, hi = 0;
|
||||
#if !defined(__aarch64__) // arm64 (the Metal build): no XCR0; cpuid reads zero there, so this is never reached
|
||||
__asm__ volatile("xgetbv" : "=a"(lo), "=d"(hi) : "c"(0));
|
||||
#endif
|
||||
const unsigned long long xcr0 = ((unsigned long long) hi << 32) | lo;
|
||||
#endif
|
||||
if ((xcr0 & 0xE6) != 0xE6) return false; // the OS saves the AVX-512 state
|
||||
@@ -92,7 +94,9 @@ bool cpu_avx512bw_ok() {
|
||||
const unsigned long long xcr0 = _xgetbv(0);
|
||||
#else
|
||||
unsigned lo = 0, hi = 0;
|
||||
#if !defined(__aarch64__) // arm64 (the Metal build): no XCR0; cpuid reads zero there, so this is never reached
|
||||
__asm__ volatile("xgetbv" : "=a"(lo), "=d"(hi) : "c"(0));
|
||||
#endif
|
||||
const unsigned long long xcr0 = ((unsigned long long) hi << 32) | lo;
|
||||
#endif
|
||||
if ((xcr0 & 0xE6) != 0xE6) return false; // the OS saves the AVX-512 state
|
||||
@@ -126,7 +130,9 @@ bool cpu_avx2_ok() {
|
||||
const unsigned long long xcr0 = _xgetbv(0);
|
||||
#else
|
||||
unsigned lo = 0, hi = 0;
|
||||
#if !defined(__aarch64__) // arm64 (the Metal build): no XCR0; cpuid reads zero there, so this is never reached
|
||||
__asm__ volatile("xgetbv" : "=a"(lo), "=d"(hi) : "c"(0));
|
||||
#endif
|
||||
const unsigned long long xcr0 = ((unsigned long long) hi << 32) | lo;
|
||||
#endif
|
||||
if ((xcr0 & 0x6) != 0x6) return false; // the OS saves the SSE and AVX state
|
||||
@@ -154,7 +160,9 @@ bool cpu_avx1_ok() {
|
||||
const unsigned long long xcr0 = _xgetbv(0);
|
||||
#else
|
||||
unsigned lo = 0, hi = 0;
|
||||
#if !defined(__aarch64__) // arm64 (the Metal build): no XCR0; cpuid reads zero there, so this is never reached
|
||||
__asm__ volatile("xgetbv" : "=a"(lo), "=d"(hi) : "c"(0));
|
||||
#endif
|
||||
const unsigned long long xcr0 = ((unsigned long long) hi << 32) | lo;
|
||||
#endif
|
||||
return (xcr0 & 0x6) == 0x6;
|
||||
|
||||
Reference in new issue
Block a user