Merge branch 'f-142-small' into f-142
This commit is contained in:
commit
f5aa356f14
34 files changed
+1257
-63
No files matched your search
@@ -596,6 +596,10 @@ struct Options {
|
||||
int64_t conversation_cache_mib = 0; // opt-in host RAM for independent conversations
|
||||
int conversation_cache_slots = 4;
|
||||
int64_t conversation_cache_min_free_mib = 2560;
|
||||
/// --serve: park only conversations of at least this many tokens. Every parked conversation costs one of
|
||||
/// conversation_cache_slots whatever its length, so without it a client that interleaves short side requests
|
||||
/// with one long conversation evicts the long one (oldest first). 0 = park every conversation.
|
||||
int64_t conversation_cache_min_tokens = 0;
|
||||
/// --serve SAVE: disk space a session file must leave free where it is written (MiB; 0 = no check)
|
||||
int64_t session_min_free_mib = 4096;
|
||||
/// --serve: also keep a checkpoint every N freshly read prompt tokens (0 = only at the last turn boundary)
|
||||
@@ -740,6 +744,8 @@ void usage() {
|
||||
" --conversation-cache-slots N --serve: at most N parked conversations (default 4)\n"
|
||||
" --conversation-cache-min-free-mib N --serve: physical RAM floor when parking or restoring a\n"
|
||||
" session file (default 2560)\n"
|
||||
" --conversation-cache-min-tokens N --serve: park only conversations of at least N tokens, so\n"
|
||||
" short side requests do not take the slots a long one needs (default 0 = park any)\n"
|
||||
" --session-min-free-mib N --serve: disk space a SAVE must leave free (default 4096; 0 = no check)\n"
|
||||
" --vram-elastic --serve (#533, opt-in, NVIDIA): the expert cache in segments (--vram-segment-mib,\n"
|
||||
" default 512), so the command `VRAM <reserve_mib>` (the server's POST /v1/vram) can\n"
|
||||
@@ -1835,17 +1841,20 @@ int main(int argc, char** argv) {
|
||||
else if (a == "--vision") o.vision = true;
|
||||
else if (a == "--prompt-cache") o.prompt_cache = std::max(0, std::atoi(next("--prompt-cache")));
|
||||
else if (a == "--conversation-cache-mib" || a == "--conversation-cache-slots" ||
|
||||
a == "--conversation-cache-min-free-mib" || a == "--session-min-free-mib") {
|
||||
a == "--conversation-cache-min-free-mib" || a == "--conversation-cache-min-tokens" ||
|
||||
a == "--session-min-free-mib") {
|
||||
const std::string value = next(a.c_str());
|
||||
int64_t number = 0;
|
||||
const auto result = std::from_chars(value.data(), value.data() + value.size(), number);
|
||||
const int64_t limit = a == "--conversation-cache-slots" ? INT32_MAX : INT64_MAX / (1024 * 1024);
|
||||
const int64_t limit = (a == "--conversation-cache-slots" || a == "--conversation-cache-min-tokens")
|
||||
? INT32_MAX : INT64_MAX / (1024 * 1024);
|
||||
if (result.ec != std::errc{} || result.ptr != value.data() + value.size() || number < 0 || number > limit) {
|
||||
std::fprintf(stderr, "%s needs a nonnegative integer within range\n", a.c_str());
|
||||
return 2;
|
||||
}
|
||||
if (a == "--conversation-cache-mib") o.conversation_cache_mib = number;
|
||||
else if (a == "--conversation-cache-min-free-mib") o.conversation_cache_min_free_mib = number;
|
||||
else if (a == "--conversation-cache-min-tokens") o.conversation_cache_min_tokens = number;
|
||||
else if (a == "--session-min-free-mib") o.session_min_free_mib = number;
|
||||
else o.conversation_cache_slots = (int) number;
|
||||
}
|
||||
@@ -7050,7 +7059,7 @@ int main(int argc, char** argv) {
|
||||
// (the snapshots accept a null draft)
|
||||
strata::core::ConversationCache conversations(
|
||||
o.prompt_cache > 0 ? (size_t) o.conversation_cache_mib * 1024 * 1024 : 0,
|
||||
(size_t) o.conversation_cache_slots);
|
||||
(size_t) o.conversation_cache_slots, o.conversation_cache_min_tokens);
|
||||
// Disk sessions: what a session file is bound to. The model fingerprint samples every model input this
|
||||
// engine loaded, by role (conversation_file.hpp), once; the config fingerprint covers the RESOLVED settings
|
||||
// that change what the saved bytes mean - the rope (K is cached post-RoPE), the loaded control vector, the
|
||||
@@ -7129,6 +7138,16 @@ int main(int argc, char** argv) {
|
||||
// addresses change: all parked images live in ordinary host vectors.
|
||||
auto park_current_body = [&](size_t held) -> bool {
|
||||
if (!conversations.enabled() || !live_ok || live.empty()) return true;
|
||||
// --conversation-cache-min-tokens: a short conversation is not worth one of the slots. Parking is a
|
||||
// switch-time decision, so a client's small side requests would otherwise park themselves and, once the
|
||||
// cache is full, evict the long conversation they were interleaved with (oldest first) - the reuse it
|
||||
// wanted. Returning true is the same non-error skip the byte-budget and RAM-floor paths below take.
|
||||
if (!conversations.wants((int64_t) live.size())) {
|
||||
std::fprintf(stderr, "strata serve: conversation cache: skip parking (%zu tokens, below the %lld "
|
||||
"minimum; parked=%zu)\n",
|
||||
live.size(), (long long) o.conversation_cache_min_tokens, conversations.size());
|
||||
return true;
|
||||
}
|
||||
// #342: before make_room evicts oldest-first, the copies of this conversation a turn back go (they hold
|
||||
// nothing the outgoing chain does not, apart from the tail this conversation rewrote)
|
||||
if (const size_t dropped = conversations.drop_superseded(live, live_imgs, checks, cvec_cached))
|
||||
@@ -8127,7 +8146,8 @@ int main(int argc, char** argv) {
|
||||
"expert_slots_primary=%lld expert_cache_primary_mib=%lld spec=%d "
|
||||
"mtp_max=%d lookup=%d vram_free_mib=%lld cvec=%s arena_mib=%lld pool_workers=%d pcie_frac=%.2f "
|
||||
"spec_min_p=%.2f conversation_cache_mib=%lld conversation_cache_slots=%d "
|
||||
"conversation_cache_min_free_mib=%lld tail_role_token=%lld vram_elastic=%d%s engine=" STRATA_VERSION "\n",
|
||||
"conversation_cache_min_free_mib=%lld conversation_cache_min_tokens=%lld "
|
||||
"tail_role_token=%lld vram_elastic=%d%s engine=" STRATA_VERSION "\n",
|
||||
(long long) o.max_context, o.kv.c_str(),
|
||||
(long long) (g.n_qsa_layers() > 0 && ss.qsa_states[ss.qsa_primary()].kv_mode == 1
|
||||
? ss.qsa_states[ss.qsa_primary()].n_slots * 4 : 0),
|
||||
@@ -8138,7 +8158,8 @@ int main(int argc, char** argv) {
|
||||
(long long) ((o.mmap_experts ? src.resident_bytes() : strata::kernels::cpu::expert_layout().total) >> 20),
|
||||
pool.workers(), o.pcie_frac,
|
||||
o.spec_min_p, (long long) o.conversation_cache_mib, o.conversation_cache_slots,
|
||||
(long long) o.conversation_cache_min_free_mib, (long long) o.tail_role_token, xcache.segmented() ? 1 : 0,
|
||||
(long long) o.conversation_cache_min_free_mib, (long long) o.conversation_cache_min_tokens,
|
||||
(long long) o.tail_role_token, xcache.segmented() ? 1 : 0,
|
||||
o.batch > 0 ? (" batch_slots=" + std::to_string(o.batch) +
|
||||
" slot_cache=" + std::to_string(o.prompt_cache > 0 ? 1 : 0) +
|
||||
" batch_groups=" + std::to_string(o.batch_groups)).c_str() : "");
|
||||
|
||||
Reference in new issue
Block a user