You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0acefcf
Browse filesBrowse the repository at this point in the historyBrowse files
FLASHNEXT_LOAD_LIMIT_GB covers the prompt cache too: the automatic budget is what the sessions leave under it, up to the 16 GiB default
The slot checks reserved a given cache against the selected limit while the cache plan still read 70% of RAM, so an automatic cache could take the server past the limit and a raised limit did not raise a given cache's own gate. cache_fit.budgetUnder plans the cache under the same ceiling (fitUnder; budget, budgetBeside and fit keep 70% for the other hosts), and the automatic budget still stops at DEFAULT_CEILING. A test covers the automatic and the given budget under a limit. The recipe doc, the limit's comment and the OverMemoryLimit message name the contract.
conststreams=if (later>0) trystd.fmt.allocPrint(a, " and {d:.1} GiB its streams take on first use", .{gibs(later)}) else"";
72
-
constf=fit(total, ready, gib, over) catch|e| {
73
-
constleft= (fit(total, ready, null, false) catchunreachable).room; // without a given budget it never refuses
74
-
why.*=trystd.fmt.allocPrint(a, "--prompt-cache-gib {d} would take this server past 70% of this Mac's memory: it holds {d:.1} GiB once loaded{s}, 70% of {d:.0} GiB is {d:.1} GiB, and {d} GiB stays free for prompt buffers, so {d:.1} GiB is left for kept prompt states. Pass a smaller one{s}, leave --prompt-cache-gib out for the default {d:.1} GiB, or add --prompt-cache-over-cap to keep {d} GiB anyway.", .{ gib.?, gibs(loaded), streams, gibs(total), gibs(total/100*SHARE_PERCENT), MARGIN>>30, gibs(left), if (later>0) ", serve a smaller --parallel"else"", gibs(@min(left, DEFAULT_CEILING)), gib.? });
81
+
constcap=limitorelsetotal/100*SHARE_PERCENT;
82
+
constf=fitUnder(cap, ready, gib, over) catch|e| {
83
+
constleft= (fitUnder(cap, ready, null, false) catchunreachable).room; // without a given budget it never refuses
84
+
if (limit!=null) {
85
+
why.*=trystd.fmt.allocPrint(a, "--prompt-cache-gib {d} would take this server past its load limit: it holds {d:.1} GiB once loaded{s}, the limit is {d:.1} GiB, and {d} GiB stays free for prompt buffers, so {d:.1} GiB is left for kept prompt states. Pass a smaller one{s}, leave --prompt-cache-gib out for the default {d:.1} GiB, raise the limit, or add --prompt-cache-over-cap to keep {d} GiB anyway.", .{ gib.?, gibs(loaded), streams, gibs(cap), MARGIN>>30, gibs(left), if (later>0) ", serve a smaller --parallel"else"", gibs(@min(left, DEFAULT_CEILING)), gib.? });
86
+
} elsewhy.*=trystd.fmt.allocPrint(a, "--prompt-cache-gib {d} would take this server past 70% of this Mac's memory: it holds {d:.1} GiB once loaded{s}, 70% of {d:.0} GiB is {d:.1} GiB, and {d} GiB stays free for prompt buffers, so {d:.1} GiB is left for kept prompt states. Pass a smaller one{s}, leave --prompt-cache-gib out for the default {d:.1} GiB, or add --prompt-cache-over-cap to keep {d} GiB anyway.", .{ gib.?, gibs(loaded), streams, gibs(total), gibs(cap), MARGIN>>30, gibs(left), if (later>0) ", serve a smaller --parallel"else"", gibs(@min(left, DEFAULT_CEILING)), gib.? });
75
87
returne;
76
88
};
77
89
constby_default=if (gib==nullandf.room>f.budget) std.fmt.comptimePrint("; {d} GiB by default: --prompt-cache-gib takes more, up to what is free", .{DEFAULT_CEILING>>30}) else"";
78
-
std.log.info("prompt cache: {d:.1} GiB from {d:.1} GiB free under the 70% cap ({d:.1} GiB in use once loaded{s}, {d:.0} GiB of RAM, {d} GiB kept for prompt buffers){s}{s}{s}", .{ gibs(f.budget), gibs(f.room), gibs(loaded), streams, gibs(total), MARGIN>>30, if (f.budget>f.room) ", past the cap by --prompt-cache-over-cap"else"", rank, by_default });
90
+
std.log.info("prompt cache: {d:.1} GiB from {d:.1} GiB free under the {s} ({d:.1} GiB in use once loaded{s}, {d:.0} GiB of RAM, {d} GiB kept for prompt buffers){s}{s}{s}", .{ gibs(f.budget), gibs(f.room), if (limit!=null) "load limit"else"70% cap", gibs(loaded), streams, gibs(total), MARGIN>>30, if (f.budget>f.room) ", past the cap by --prompt-cache-over-cap"else"", rank, by_default });
79
91
return .{
80
92
.source=.physical_footprint,
81
93
.budget_bytes=f.budget,
@@ -116,6 +128,25 @@ test "the default stops at 16 GiB, a given budget takes up to the room, and 0 tu
std.log.err("flash next: FLASHNEXT_LOAD_LIMIT_GB={s} is not a load limit: give a number of GB above 0, or unset it for 70% of RAM", .{text.?});
30
30
returnerr;
31
31
};
32
32
if (c.capped) std.log.info("flash next: FLASHNEXT_LOAD_LIMIT_GB={s} passes this GPU's recommended working set; the limit is {d:.1} GB", .{ text.?, fit.gibs(c.bytes) *1.073741824 });
33
-
if (c.bytes>c.default) std.log.warn("flash next: FLASHNEXT_LOAD_LIMIT_GB lets the sessions take this Mac to {d:.1} GiB, past the default {d:.1} GiB (70% of RAM): a load that wires most of the RAM can stall macOS until its watchdog kills the server", .{ fit.gibs(c.bytes), fit.gibs(c.default) });
33
+
if (c.bytes>c.default) std.log.warn("flash next: FLASHNEXT_LOAD_LIMIT_GB lets the server (sessions and prompt cache) take this Mac to {d:.1} GiB, past the default {d:.1} GiB (70% of RAM): a load that wires most of the RAM can stall macOS until its watchdog kills the server", .{ fit.gibs(c.bytes), fit.gibs(c.default) });
return@import("flashnext_batch_host.zig").open(gpa, io, o.dir, dump, if (window>0) @min(window, tf.flashnext_replay.CAP-tf.flashnext_engine.MARGIN) elsetf.flashnext_replay.CAP-tf.flashnext_engine.MARGIN, o.lanes, o.prompt_cache_gib, o.prompt_cache_over_cap, a, &why) catch|err| {
324
-
problem.*=if (err==error.CacheOverCap) whyelseif (err==error.BadLoadLimit) "FLASHNEXT_LOAD_LIMIT_GB is not a load limit: give a number of GB above 0, or unset it for 70% of RAM"elseif (err==error.OverMemoryLimit) "the native Flash Next batching engine cannot open (OverMemoryLimit): the sessions do not fit under 70% of RAMpast the loaded model; fewer streams, a smaller --context, or FLASHNEXT_LOAD_LIMIT_GB past the share"elsetrystd.fmt.allocPrint(a, "the native Flash Next batching engine cannot open ({s})", .{@errorName(err)});
324
+
problem.*=if (err==error.CacheOverCap) whyelseif (err==error.BadLoadLimit) "FLASHNEXT_LOAD_LIMIT_GB is not a load limit: give a number of GB above 0, or unset it for 70% of RAM"elseif (err==error.OverMemoryLimit) "the native Flash Next batching engine cannot open (OverMemoryLimit): the sessions and the given prompt cache do not fit under the load limit (70% of RAM, or FLASHNEXT_LOAD_LIMIT_GB) past the loaded model; fewer streams, a smaller --context or --prompt-cache-gib, or a higher FLASHNEXT_LOAD_LIMIT_GB"elsetrystd.fmt.allocPrint(a, "the native Flash Next batching engine cannot open ({s})", .{@errorName(err)});
0 commit comments