MCPcopy Create free account
hub / github.com/Niko1221/Strata / wanted

Method wanted

engine/metal/src/engine/stream.cpp:37–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35} // namespace
36
37bool ExpertStream::wanted(const gguf::File& f, const mtl::Context& cx) {
38 const char* e = std::getenv("STRATA_METAL_STREAM");
39 if (e && std::string(e) == "1") return true;
40 if (e && std::string(e) == "0") return false;
41 // auto: stream when the mapped weights (experts and dense) and ~12 GiB beside them (the prompt buffers, KV, the
42 // draft layer, macOS) do not fit the resident footprint cap: the GPU working set, or on a big Mac the RAM less the
43 // 30% macOS and its file cache keep (arena_budget.h: footprint_cap).
44 uint64_t all = 0;
45 for (const auto& kv : f.tensors)
46 if (kv.first != "per_layer_token_embd.weight") all += kv.second.bytes;
47 uint64_t phys = 0;
48 size_t len = sizeof phys;
49 sysctlbyname("hw.memsize", &phys, &len, nullptr, 0);
50 return !resident_fits((double) phys, (double) cx.recommended_working_set(), (double) all, 12.0 * (1ull << 30));
51}
52
53ExpertStream::~ExpertStream() {
54 {

Calls 2

resident_fitsFunction · 0.85
stringFunction · 0.50