engine: --resident-experts with a layer split runs as --mmap-experts with a warning (#364 #384)

The low-RAM mode's resident variant has no layer split yet, and the engine refused the pair.  When the residency
comes only from setup's soft --resident-experts (no --resident-cpu-experts, no --resident-budget-gib, no remote
caches), it now prints a WARNING - the experts the GPUs do not hold are read through the OS file cache and RAM may
fill up during long prompts - and continues exactly as --mmap-experts: the resident flags are cleared before
anything reads them, so the source, the placement and the per-stage caches are the mapped mode's (#364's hand-edited
config).  An explicit --resident-cpu-experts, a budget, or remote caches are still refused.

The explicit --expert-cache reduced under a layer split is now a WARNING that names --vram-reserve-mib.
This commit is contained in:
Niko1221 committed 2026-10-01 21:00:49 +02:00
1 parent 152f7198b9
commit 7349d9112b
1 file changed
+21 -7
+21 -7
View File
@@ -272,6 +272,7 @@ struct Options {
bool resident_pin = false;
uint64_t resident_headroom = 8ull << 30;
bool resident_soft = false;
bool resident_cpu_explicit = false; ///< #384: --resident-cpu-experts given by itself (not only implied)
/// CS-T `--resident-budget-gib N`: the resident mode with a RAM budget - the N GiB of experts the GPU cache does
/// not hold that the expert profile ranks hottest are copied into RAM, the rest are read from the files in place
/// (the GGUF shards when the pack has no experts.bin). 0 = the whole complement (--resident-experts).
@@ -1212,7 +1213,7 @@ int main(int argc, char** argv) {
else if (a == "--gpu-stages") o.gpu_stages = true;
else if (a == "--mmap-experts") o.mmap_experts = true;
else if (a == "--shared-expert-arena") o.shared_expert_arena = next("--shared-expert-arena");
else if (a == "--resident-cpu-experts") o.resident_cpu_experts = true;
else if (a == "--resident-cpu-experts") o.resident_cpu_experts = o.resident_cpu_explicit = true;
else if (a == "--resident-experts") {
o.mmap_experts = o.resident_cpu_experts = o.resident_pin = o.resident_soft = true;
o.resident_headroom = 4ull << 30;
@@ -1320,9 +1321,20 @@ int main(int argc, char** argv) {
std::fprintf(stderr, "strata generate: --resident-cpu-experts requires --mmap-experts and a static --expert-profile\n");
return 2;
}
if (o.resident_cpu_experts &&
(!o.layer_split.empty() || o.expert_cache_remote[0] > 0 || o.expert_cache_remote[1] > 0 ||
o.expert_cache_remote[2] > 0)) {
const bool remote_caches = o.expert_cache_remote[0] > 0 || o.expert_cache_remote[1] > 0 ||
o.expert_cache_remote[2] > 0;
if (o.resident_cpu_experts && !o.layer_split.empty() && !remote_caches && o.resident_soft &&
!o.resident_cpu_explicit && o.resident_budget == 0) {
// #364 #384: setup's --resident-experts with a layer split (--gpus at start, or a config edited by hand) runs
// as the plain mmap mode - the placement those users measured 1.3-1.6x faster than one GPU - instead of
// refusing. Exactly --mmap-experts: nothing else reads these flags (the headroom only sizes the copy).
std::fprintf(stderr, "strata generate: WARNING: the resident RAM mode (--resident-experts) does not support a "
"layer split yet: the experts the GPUs do not hold are read through the OS file cache "
"(--mmap-experts), and RAM may fill up during long prompts\n");
o.resident_cpu_experts = o.resident_pin = o.resident_soft = false;
o.resident_headroom = 8ull << 30;
}
if (o.resident_cpu_experts && (!o.layer_split.empty() || remote_caches)) {
std::fprintf(stderr, "strata generate: --resident-cpu-experts does not support layer splits or remote expert caches\n");
return 2;
}
@@ -2682,9 +2694,11 @@ int main(int argc, char** argv) {
const int64_t reserve = ((int64_t) o.vram_reserve_mib + prefill_mib) << 20;
const int64_t fit = std::max<int64_t>(((int64_t) free_b - reserve) / (int64_t) strata::kernels::cpu::expert_layout().max_blob, 0);
if (o.expert_cache > fit) {
std::fprintf(stderr, "strata generate: layer split: --expert-cache %d leaves no room for the prompt path's "
"buffers (%lld MiB) on CUDA0: %lld slots\n", o.expert_cache, (long long) prefill_mib,
(long long) fit);
// a WARNING that names the knob: the user asked for this size, and gets fewer slots
std::fprintf(stderr, "strata generate: WARNING: layer split: --expert-cache %d leaves no room for the "
"prompt path's buffers (%lld MiB) and the %d MiB reserve on CUDA0: %lld slots instead "
"(a smaller --vram-reserve-mib leaves more of them)\n", o.expert_cache,
(long long) prefill_mib, o.vram_reserve_mib, (long long) fit);
o.expert_cache = (int) fit;
}
}