setup on macOS: Unsloth UD-Q4/Q5/Q6_K_XL (not offered until their expert kernels land); the stream rule by size

setup_mac.py: the Unsloth files by name and SHA-256 (setup.py's pinned revision), repacked into one GGUF for the GPU
with every tensor verified, the n-gram table found by name, --native-dense-gguf the repacked file; setup writes
STRATA_METAL_STREAM to the config so the engine follows its choice. UD-* are behind 'missing' (the Metal expert
kernels for Q4_K/Q5_K/Q6_K/Q5_1 are in progress) and only reachable with --model.

stream.cpp: auto streams when the mapped weights + 12 GiB do not fit the GPU working set (was: experts > 60% of
it, which would have streamed UD-Q4_K_XL on the 128 GB M5 Max). M5 Max: Q2_0 stays resident (same tokens and speed);
M4 32 GB: Q2_0 streams as before.
This commit is contained in:
Niko1221 committed 2026-10-12 22:49:27 +02:00
1 parent a57fa9990e
commit 1269d5fa97
2 files changed
+90 -11

No files matched your search

+6 -3
View File
@@ -30,10 +30,13 @@ bool ExpertStream::wanted(const gguf::File& f, const mtl::Context& cx) {
const char* e = std::getenv("STRATA_METAL_STREAM");
if (e && std::string(e) == "1") return true;
if (e && std::string(e) == "0") return false;
uint64_t exp = 0;
// auto: stream when the mapped weights (experts and dense) and ~12 GiB beside them (the prompt buffers, KV, the
// draft layer, macOS) do not fit the GPU working set. M5 Max (115.4 GB): GSQ packs, IQ3_S and UD-Q4_K_XL stay
// resident, UD-Q5/Q6_K_XL stream; M4 32 GB (26.8 GB): every pack streams.
uint64_t all = 0;
for (const auto& kv : f.tensors)
if (kv.first.find("_exps") != std::string::npos) exp += kv.second.bytes;
return (double) exp > 0.6 * (double) cx.recommended_working_set();
if (kv.first != "per_layer_token_embd.weight") all += kv.second.bytes;
return (double) all + 12.0 * (1ull << 30) > (double) cx.recommended_working_set();
}
ExpertStream::~ExpertStream() {