Archived
radiance 2.0.0
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.
This commit is contained in:
1 parent
b4c04b6042
commit
ddcb9c69bb
696 files changed
+120770
-56596
No files matched your search
+105
-41
@@ -13,6 +13,8 @@
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
|
||||
namespace rad {
|
||||
|
||||
@@ -28,6 +30,44 @@ Registry& rad_tools_registry() {
|
||||
return *r;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ engines in one process */
|
||||
|
||||
namespace {
|
||||
std::mutex g_claim_mu;
|
||||
bool g_slot_held[RAD_MAX_SLOTS] = {};
|
||||
std::map<std::string, int> g_arch_engines; /* arch plugin -> engines holding it */
|
||||
} // namespace
|
||||
|
||||
int rad_engine_claim(const std::string& arch_plugin, int n_ranks, int* slot_base) {
|
||||
std::lock_guard<std::mutex> lk(g_claim_mu);
|
||||
const Plugin* ap = rad_tools_registry().plugin(arch_plugin);
|
||||
if (ap && !ap->arch_multi_instance && g_arch_engines[arch_plugin] > 0) {
|
||||
RAD_ERR("architecture plugin '%s' keeps one model's state per process and already backs "
|
||||
"a running model; it does not export rad_arch_multi_instance, so a second model on "
|
||||
"it cannot run beside the first", arch_plugin.c_str());
|
||||
return RAD_E_STATE;
|
||||
}
|
||||
for (int base = 0; base + n_ranks <= RAD_MAX_SLOTS; ++base) {
|
||||
bool free = true;
|
||||
for (int i = 0; i < n_ranks && free; ++i) free = !g_slot_held[base + i];
|
||||
if (!free) continue;
|
||||
for (int i = 0; i < n_ranks; ++i) g_slot_held[base + i] = true;
|
||||
++g_arch_engines[arch_plugin];
|
||||
*slot_base = base;
|
||||
return RAD_OK;
|
||||
}
|
||||
RAD_ERR("no %d free instance slot(s) in a row: the process holds at most %d ranks across its "
|
||||
"models (RAD_MAX_SLOTS)", n_ranks, RAD_MAX_SLOTS);
|
||||
return RAD_E_FULL;
|
||||
}
|
||||
|
||||
void rad_engine_release(const std::string& arch_plugin, int slot_base, int n_ranks) {
|
||||
std::lock_guard<std::mutex> lk(g_claim_mu);
|
||||
for (int i = 0; i < n_ranks && slot_base + i < RAD_MAX_SLOTS; ++i) g_slot_held[slot_base + i] = false;
|
||||
auto it = g_arch_engines.find(arch_plugin);
|
||||
if (it != g_arch_engines.end() && --it->second <= 0) g_arch_engines.erase(it);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ the reference-kernel gate */
|
||||
|
||||
/* An op is "on the reference" when no band in any domain offers a non-reference kernel
|
||||
@@ -119,46 +159,10 @@ static std::vector<std::string> home_subdirs(const std::string& home, const char
|
||||
return out;
|
||||
}
|
||||
|
||||
int rad_tools_load_plugins(const std::string& home, const std::vector<std::string>& hierarchy,
|
||||
const std::string& arch_id, const std::string& quant,
|
||||
LoadedPlugins* out, bool imported) {
|
||||
if (!out) return RAD_E_INVAL;
|
||||
*out = LoadedPlugins{};
|
||||
|
||||
Registry& r = rad_tools_registry();
|
||||
|
||||
/* Kernels first, in hierarchy order, then architectures (unordered: no two may claim the same
|
||||
* id). A home need not have every directory, but kernels/ and architectures/ must each exist
|
||||
* somewhere on the path, or the scan reports the first home's as missing. */
|
||||
const std::string first = rad_home_dirs(home).front();
|
||||
std::vector<std::string> kdirs = home_subdirs(home, "kernels");
|
||||
if (kdirs.empty()) kdirs.push_back(first + "/kernels");
|
||||
int s = r.load_dirs(kdirs, hierarchy);
|
||||
if (s < 0) return s;
|
||||
|
||||
std::vector<std::string> adirs = home_subdirs(home, "architectures");
|
||||
if (adirs.empty()) adirs.push_back(first + "/architectures");
|
||||
s = r.load_dirs(adirs, {});
|
||||
if (s < 0) return s;
|
||||
|
||||
/* Quantisers: rad-convert drives them, and the oracle decodes through them for schemes the
|
||||
* core does not define. Optional. */
|
||||
const std::vector<std::string> qdirs = home_subdirs(home, "quantizers");
|
||||
if (!qdirs.empty()) {
|
||||
s = r.load_dirs(qdirs, {});
|
||||
if (s < 0) return s;
|
||||
}
|
||||
|
||||
RAD_TRY(r.check_complete());
|
||||
|
||||
/* The tuning cache, once the kernel set is known. A missing file leaves every shape on its
|
||||
* plugin's first variant. Logged when it has rows; --debug-graph shows the per-shape
|
||||
* source. */
|
||||
const std::string tune = rad_home_file(home, TuneCache::rel_path(rad_machine_key()));
|
||||
const std::string tune_home = tune.substr(0, tune.size() - TuneCache::rel_path(rad_machine_key()).size() - 1);
|
||||
const int n_tuned = r.load_tune(tune_home);
|
||||
if (n_tuned > 0) RAD_INFO("tune cache: %d row(s) from %s", n_tuned, tune.c_str());
|
||||
|
||||
/* The architecture plugin for (arch_id, quant) among a loaded set, and the kernel libraries it
|
||||
* selects from, into *out. */
|
||||
static int pick_arch(Registry& r, const std::string& home, const std::string& arch_id,
|
||||
const std::string& quant, LoadedPlugins* out, bool imported) {
|
||||
/* The selection key is the (arch_id, quant) pair (spec §2.4), matched exactly with no
|
||||
* fallback; a mismatched plugin would only fail later at the name map with a worse message. */
|
||||
for (const Plugin& p : r.plugins()) {
|
||||
@@ -240,6 +244,66 @@ int rad_tools_load_plugins(const std::string& home, const std::vector<std::strin
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
int rad_tools_load_plugins(const std::string& home, const std::vector<std::string>& hierarchy,
|
||||
const std::string& arch_id, const std::string& quant,
|
||||
LoadedPlugins* out, bool imported) {
|
||||
if (!out) return RAD_E_INVAL;
|
||||
*out = LoadedPlugins{};
|
||||
|
||||
Registry& r = rad_tools_registry();
|
||||
|
||||
/* One plugin set serves every engine in the process (registry.h, Sharing): the first load
|
||||
* reads the homes, a later one finds the set loaded and only picks its architecture. The home
|
||||
* and the hierarchy are server-level settings, so every engine asks for the same set; a
|
||||
* different one is refused rather than served from the wrong libraries. */
|
||||
static std::string loaded_home;
|
||||
static std::vector<std::string> loaded_hierarchy;
|
||||
if (!r.plugins().empty()) {
|
||||
if (home != loaded_home || hierarchy != loaded_hierarchy) {
|
||||
RAD_ERR("the plugin set is already loaded from %s; every model in a process uses the "
|
||||
"same radiance-home and kernels", loaded_home.c_str());
|
||||
return RAD_E_STATE;
|
||||
}
|
||||
return pick_arch(r, home, arch_id, quant, out, imported);
|
||||
}
|
||||
loaded_home = home;
|
||||
loaded_hierarchy = hierarchy;
|
||||
|
||||
/* Kernels first, in hierarchy order, then architectures (unordered: no two may claim the same
|
||||
* id). A home need not have every directory, but kernels/ and architectures/ must each exist
|
||||
* somewhere on the path, or the scan reports the first home's as missing. */
|
||||
const std::string first = rad_home_dirs(home).front();
|
||||
std::vector<std::string> kdirs = home_subdirs(home, "kernels");
|
||||
if (kdirs.empty()) kdirs.push_back(first + "/kernels");
|
||||
int s = r.load_dirs(kdirs, hierarchy);
|
||||
if (s < 0) return s;
|
||||
|
||||
std::vector<std::string> adirs = home_subdirs(home, "architectures");
|
||||
if (adirs.empty()) adirs.push_back(first + "/architectures");
|
||||
s = r.load_dirs(adirs, {});
|
||||
if (s < 0) return s;
|
||||
|
||||
/* Quantisers: rad-convert drives them, and the oracle decodes through them for schemes the
|
||||
* core does not define. Optional. */
|
||||
const std::vector<std::string> qdirs = home_subdirs(home, "quantizers");
|
||||
if (!qdirs.empty()) {
|
||||
s = r.load_dirs(qdirs, {});
|
||||
if (s < 0) return s;
|
||||
}
|
||||
|
||||
RAD_TRY(r.check_complete());
|
||||
|
||||
/* The tuning cache, once the kernel set is known. A missing file leaves every shape on its
|
||||
* plugin's first variant. Logged when it has rows; --debug-graph shows the per-shape
|
||||
* source. */
|
||||
const std::string tune = rad_home_file(home, TuneCache::rel_path(rad_machine_key()));
|
||||
const std::string tune_home = tune.substr(0, tune.size() - TuneCache::rel_path(rad_machine_key()).size() - 1);
|
||||
const int n_tuned = r.load_tune(tune_home);
|
||||
if (n_tuned > 0) RAD_INFO("tune cache: %d row(s) from %s", n_tuned, tune.c_str());
|
||||
|
||||
return pick_arch(r, home, arch_id, quant, out, imported);
|
||||
}
|
||||
|
||||
/* Optional export. Without it, or on failure, every field is zero and the caller uses its own
|
||||
* defaults. A failed probe is not an error: the plugin can still refuse in declare, where it has
|
||||
* the whole configuration and can say why. */
|
||||
@@ -398,7 +462,7 @@ int rad_tools_declare(const LoadedPlugins& lp, const RadModelMeta& meta, const R
|
||||
const LoraDeclare* lora) {
|
||||
if (!out) return RAD_E_INVAL;
|
||||
|
||||
Registry& r = rad_tools_registry();
|
||||
Registry& r = lp.registry ? *lp.registry : rad_tools_registry();
|
||||
const Plugin* ap = r.plugin(lp.arch_plugin);
|
||||
if (!ap || !ap->arch_declare) {
|
||||
RAD_ERR("architecture plugin '%s' is not loaded or exports no rad_arch_declare",
|
||||
|
||||
Reference in new issue
Block a user