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.
26 lines
1.3 KiB
C++
26 lines
1.3 KiB
C++
// metal/tools/gguf_list.cpp - tensor directory and scalar metadata of a GGUF (name type shape offset), for the
|
|
// Metal window's wiring. clang++ -std=c++20 -I include metal/tools/gguf_list.cpp -o gguf_list
|
|
#include "strata/artifact/gguf_reader.hpp"
|
|
|
|
#include <cstdio>
|
|
#include <string>
|
|
|
|
int main(int argc, char** argv) {
|
|
if (argc < 2) { std::printf("usage: gguf_list <file.gguf> [substring]\n"); return 2; }
|
|
strata::GgufFile g(argv[1]);
|
|
const std::string f = argc > 2 ? argv[2] : "";
|
|
for (const auto& [k, v] : g.metadata()) {
|
|
if (!f.empty() && k.find(f) == std::string::npos) continue;
|
|
if (v.is_num()) std::printf("META %s = %g\n", k.c_str(), v.num());
|
|
else if (v.type == strata::MetaType::STRING) std::printf("META %s = %s\n", k.c_str(), v.s.substr(0, 80).c_str());
|
|
else std::printf("META %s = [%llu items]\n", k.c_str(), (unsigned long long) v.count);
|
|
}
|
|
for (const auto& t : g.tensors()) {
|
|
if (!f.empty() && t.name.find(f) == std::string::npos) continue;
|
|
std::printf("%s %s [", t.name.c_str(), t.type_name());
|
|
for (size_t i = 0; i < t.shape.size(); ++i) std::printf(i ? ",%llu" : "%llu", (unsigned long long) t.shape[i]);
|
|
std::printf("] off %llu\n", (unsigned long long) t.offset);
|
|
}
|
|
return 0;
|
|
}
|