Radiance becomes a multi-model engine: one process serves several models behind one port, loads each when a request names it, parks it in host memory or restores it from its container, and shares the cards between them (docs/MULTIMODEL.md). The configuration is one YAML file; the command line flags are gone (`radiance --config FILE`, hot reload on SIGHUP). Formats. IQ8R (rotated int8) and IQR-V4 replace FP8 and MXFP4 as whole-model formats, with an int8 KV cache (`kv-cache-dtype: i8`) in place of the fp8 one. Containers whose weights are block FP8, MXFP4, M2XFP4, NVFP4 or ParoQuant are refused at startup by the name of the first such weight. Not served until they have int8 containers: GLM-5.3-Flash, Ornith-1.5, Sage-A1.5, Nemotron-3.5-Bolt-74B, Ling-3.0-flash, drama-3 and Anima's FP8 container; Nemotron-3.5-Bolt-E4B, the Gemma 4 31B DFlash containers and MiniCPM5-2B bf16 serve without their drafter. 1.17.0 serves all of them. Speed. Chained launches for Qwen3.8-27B, Gemma 4, Gemma 3 and the small bf16 models, a new Qwen3.8-Flash-Next container (IQR-V4 experts, int8 trunk) with its decode step and prefill reworked, and a reworked adaptive draft window. Deployment. deploy/compose has two fleet files, tp1.yaml and tp2.yaml, each with its configuration beside it, in place of the per-model files. `host-pool-mib` is a model's host pool in all, split among its ranks. The dashboard is rebuilt: an hour of history kept by the server, each accelerator's memory by model, model states over time. Merged since 1.17.0: Nemotron-3.5-Bolt-74B-A9B by keptn42 (#339); GLM-5.3-Flash on four cards by AnimusNull (#397); chained launches for Flash-Next's decode step (#396) and preempted requests keeping their prefix and place (#405) by mici81; --prefill-interleave auto by Code000 (#410); eight more libr3d kernels and the w4a4 reference by RikshaDriver (#403, #407, #408); libr3d large-BAR and E4M3 decode fixes by neuromanMD (#438, #439); int4/int5 decode tiles by Kezi (#426); attention for Nanbeige 4.3 33B by everplays (#417); expert_stats_report.py by baKon (#431). Fixed: #398, #402, #419, #437 (dschmitz's patch); added the metrics of #392, and multi-model serving as asked for in #367 and #109. Plugin ABI 39: out-of-tree plugins need to be rebuilt. Thanks to @keptn42, @AnimusNull, @mici81, @Code000, @RikshaDriver, @neuromanMD, @Kezi, @everplays, @baKon and @dschmitz.
89 lines
3.2 KiB
C++
89 lines
3.2 KiB
C++
/* engine_hostmem.cpp -- see engine_hostmem.h. */
|
|
#include "engine_hostmem.h"
|
|
|
|
#include <algorithm>
|
|
#include <cstdlib>
|
|
#include <fstream>
|
|
|
|
namespace rad {
|
|
|
|
bool cgroup_room(const std::string& dir, bool v2, int64_t* room) {
|
|
auto read_ll = [](const std::string& f, long long* v) {
|
|
std::ifstream in(f);
|
|
std::string t;
|
|
if (!(in >> t)) return false;
|
|
char* e = nullptr;
|
|
*v = std::strtoll(t.c_str(), &e, 10);
|
|
return e && *e == '\0';
|
|
};
|
|
auto stat_ll = [](const std::string& f, const char* key, long long* v) {
|
|
std::ifstream in(f);
|
|
std::string k;
|
|
long long x = 0;
|
|
while (in >> k >> x) if (k == key) { *v = x; return true; }
|
|
return false;
|
|
};
|
|
long long lim = 0, used = 0, file = 0;
|
|
if (v2) {
|
|
if (!read_ll(dir + "/memory.max", &lim)) return false; /* "max" fails to parse */
|
|
if (!read_ll(dir + "/memory.current", &used)) return false;
|
|
(void)stat_ll(dir + "/memory.stat", "file", &file);
|
|
} else {
|
|
if (!read_ll(dir + "/memory.limit_in_bytes", &lim) || lim >= ((long long)1 << 62))
|
|
return false;
|
|
if (!read_ll(dir + "/memory.usage_in_bytes", &used)) return false;
|
|
if (!stat_ll(dir + "/memory.stat", "total_cache", &file))
|
|
(void)stat_ll(dir + "/memory.stat", "cache", &file);
|
|
}
|
|
const long long hard = used > file ? used - file : 0;
|
|
*room = lim > hard ? (int64_t)(lim - hard) : 0;
|
|
return true;
|
|
}
|
|
|
|
void cgroup_levels(const std::string& root, std::string path, bool v2,
|
|
const std::function<bool(const std::string& dir, int64_t room)>& visit) {
|
|
for (;;) {
|
|
const std::string dir = root + (path == "/" ? std::string() : path);
|
|
int64_t room = 0;
|
|
if (cgroup_room(dir, v2, &room) && !visit(dir, room)) return;
|
|
if (path.empty() || path == "/") break;
|
|
const size_t up = path.find_last_of('/');
|
|
path = up == 0 || up == std::string::npos ? "/" : path.substr(0, up);
|
|
}
|
|
}
|
|
|
|
void memory_cgroups(const std::function<bool(const std::string&, int64_t)>& visit) {
|
|
std::ifstream f("/proc/self/cgroup");
|
|
std::string line;
|
|
bool go = true;
|
|
while (go && std::getline(f, line)) {
|
|
const size_t a = line.find(':'), b = a == std::string::npos ? a : line.find(':', a + 1);
|
|
if (b == std::string::npos) continue;
|
|
const std::string ctrl = line.substr(a + 1, b - a - 1);
|
|
std::string path = line.substr(b + 1);
|
|
const bool v2 = ctrl.empty();
|
|
bool memory = v2;
|
|
for (size_t i = 0; !memory && i < ctrl.size();) {
|
|
const size_t j = std::min(ctrl.find(',', i), ctrl.size());
|
|
memory = ctrl.compare(i, j - i, "memory") == 0;
|
|
i = j + 1;
|
|
}
|
|
if (!memory) continue;
|
|
const std::string root = v2 ? "/sys/fs/cgroup" : "/sys/fs/cgroup/memory";
|
|
cgroup_levels(root, path, v2, [&](const std::string& dir, int64_t room) {
|
|
return go = visit(dir, room);
|
|
});
|
|
}
|
|
}
|
|
|
|
int64_t cgroup_least_room() {
|
|
int64_t least = INT64_MAX;
|
|
memory_cgroups([&](const std::string&, int64_t room) {
|
|
least = std::min(least, room);
|
|
return true;
|
|
});
|
|
return least;
|
|
}
|
|
|
|
} /* namespace rad */
|