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:
Deadcode committed 2026-11-14 22:32:28 +01:00
1 parent b4c04b6042
commit ddcb9c69bb
696 files changed
+120770 -56596

No files matched your search

+63 -36
View File
@@ -107,7 +107,7 @@ void Registry::err_(const char* f, ...) {
va_start(ap, f);
vsnprintf(msg, sizeof msg, f, ap);
va_end(ap);
load_errors_.emplace_back(msg);
set_->load_errors.emplace_back(msg);
RAD_ERR("%s", msg);
}
@@ -185,7 +185,7 @@ void Registry::unstage_(Staged& s) {
/* ------------------------------------------------------------------ registration */
int Registry::commit_(Staged& s, int order) {
for (const Plugin& p : plugins_) {
for (const Plugin& p : set_->plugins) {
if (p.name == s.name) {
err_("two plugins claim the name '%s': %s and %s -- refusing the second",
s.name.c_str(), p.path.c_str(), s.path.c_str());
@@ -206,6 +206,7 @@ int Registry::commit_(Staged& s, int order) {
p.order = order;
p.handle = s.handle;
p.close = dl_fn<RadPluginCloseFn>(s.handle, "rad_plugin_close");
p.freed = dl_fn<RadPluginFreedFn>(s.handle, "rad_plugin_freed");
std::vector<const RadOpSchema*> staged_schemas;
std::vector<std::pair<const RadKernelInfo*, int>> staged_rows; /* the row and its index */
@@ -238,6 +239,9 @@ int Registry::commit_(Staged& s, int order) {
/* Optional: absent means the plugin may serve an imported quantisation (startup.h). */
if (auto i_fn = dl_fn<int (*)(void)>(s.handle, "rad_arch_serves_imports"))
p.arch_serves_imports = i_fn() != 0;
/* Optional: absent means one engine at a time (rad_engine_claim). */
if (auto m_fn = dl_fn<int (*)(void)>(s.handle, "rad_arch_multi_instance"))
p.arch_multi_instance = m_fn() != 0;
/* Optional: answers what the core needs before it builds the RadBuildCtx for declare.
* Absent means every answer is zero (rad_builder.h). */
@@ -265,7 +269,7 @@ int Registry::commit_(Staged& s, int order) {
/* The (architecture id, quantisation) pair selects the plugin, so no two plugins may claim
* the same pair (§2.4). Sharing an id at different quantisations is normal (qwen35_bf16
* and qwen35_fp8). */
for (const Plugin& q : plugins_) {
for (const Plugin& q : set_->plugins) {
if (q.arch_id == p.arch_id && q.arch_quant == p.arch_quant) {
err_("architecture id '%s' at quantisation '%s' is claimed by both '%s' and '%s' "
"-- refusing the second", p.arch_id.c_str(),
@@ -320,8 +324,8 @@ int Registry::commit_(Staged& s, int order) {
}
}
std::string diff;
auto it = schemas_.find(sch->op);
if (it != schemas_.end()) {
auto it = set_->schemas.find(sch->op);
if (it != set_->schemas.end()) {
if (!schema_same(*it->second.schema, *sch, &diff)) {
/* Disagreeing positional schemas would silently change a call's meaning
* (§2.3). The whole plugin is refused, not just the op: it was built against
@@ -424,7 +428,7 @@ int Registry::commit_(Staged& s, int order) {
int n_device = 0;
for (const auto& r : staged_rows) n_device += r.first->domain == RAD_DOMAIN_DEVICE;
std::string why;
if (no_device_code_)
if (set_->no_device_code)
why = "no card is visible, so this process runs on the host backend and no GPU code "
"object runs here";
/* The code range decides only the per-card test: on the host backend the rows go even when
@@ -432,15 +436,15 @@ int Registry::commit_(Staged& s, int order) {
* mapped by another registry). */
const bool no_code_here =
n_device > 0 &&
(no_device_code_ ||
(set_->no_device_code ||
(s.code_to > s.code_from &&
rad::dev_code_runs(s.code_from, s.code_to, code_device_, &why) == 0));
rad::dev_code_runs(s.code_from, s.code_to, set_->code_device, &why) == 0));
if (no_code_here) {
std::vector<std::pair<const RadKernelInfo*, int>> keep;
for (const auto& r : staged_rows)
if (r.first->domain != RAD_DOMAIN_DEVICE) keep.push_back(r);
RAD_WARN("kernel plugin '%s' has no device code for device %d: %s. Its %d device "
"kernel(s) are left out of selection here%s.", p.name.c_str(), code_device_,
"kernel(s) are left out of selection here%s.", p.name.c_str(), set_->code_device,
why.c_str(), n_device,
keep.empty() ? "" : fmt(" and its %zu host kernel(s) stay", keep.size()).c_str());
staged_rows.swap(keep);
@@ -467,7 +471,7 @@ int Registry::commit_(Staged& s, int order) {
/* Quantiser names are unique, so a recipe means the same thing whatever the load
* order. */
auto clash = [&](const char* other) { return std::strcmp(other, q->name) == 0; };
for (const QuantRow& r : quants_)
for (const QuantRow& r : set_->quants)
if (clash(r.info->name)) {
err_("quantiser '%s' is offered by both '%s' and '%s' -- refusing '%s'",
q->name, r.plugin.c_str(), p.name.c_str(), p.name.c_str());
@@ -511,9 +515,9 @@ int Registry::commit_(Staged& s, int order) {
* answers which plugin fixed an op. */
p.n_schemas = n_declared_schemas;
p.n_kernels = (int)staged_rows.size();
for (const RadOpSchema* sch : staged_schemas) schemas_[sch->op] = SchemaEntry{sch, p.name};
for (const RadOpSchema* sch : staged_schemas) set_->schemas[sch->op] = SchemaEntry{sch, p.name};
for (const RadQuantizerInfo* q : staged_quants) {
quants_.push_back(QuantRow{ q, p.name });
set_->quants.push_back(QuantRow{ q, p.name });
/* Register its decoder so every weight reader can decode its schemes. */
if (q->decode) enc_add_decoder(q->decode);
}
@@ -535,7 +539,7 @@ int Registry::commit_(Staged& s, int order) {
row.releases_link = coll == 2;
row.reference = kern_ref ? kern_ref(sr.second) != 0 : p.reference;
row.chain = chainable && chainable(sr.second) != 0;
rows_.push_back(row);
set_->rows.push_back(row);
}
/* A library built for another card fails at every launch with an unhelpful driver error;
@@ -545,7 +549,7 @@ int Registry::commit_(Staged& s, int order) {
if (p.kind == RAD_PLUGIN_KERNEL && s.code_to == s.code_from && !p.build_target.empty() &&
p.build_target != "host") {
RadDeviceProps dp{};
if (rad_dev_count() > code_device_ && rad_dev_props(code_device_, &dp) == RAD_OK &&
if (rad_dev_count() > set_->code_device && rad_dev_props(set_->code_device, &dp) == RAD_OK &&
dp.arch[0] && !target_covers(p.build_target, dp.arch))
RAD_WARN("kernel plugin '%s' declares it was built for %s and this machine reports %s. "
"Its kernels will fail to launch; build it for %s, or leave it out with "
@@ -556,7 +560,8 @@ int Registry::commit_(Staged& s, int order) {
RAD_DEBUG("plugin %d: %s %s (%s) -- %d kernels, %d schemas, %zu fat binaries, %s", order,
p.name.c_str(), p.version.c_str(), p.path.c_str(), p.n_kernels, p.n_schemas,
s.code_to - s.code_from, p.build_target.empty() ? "portable" : p.build_target.c_str());
plugins_.push_back(std::move(p));
if (p.freed) rad_dev_on_free(p.freed);
set_->plugins.push_back(std::move(p));
index_rows_();
s.handle = nullptr; /* the Plugin owns it now */
return RAD_OK;
@@ -565,9 +570,9 @@ int Registry::commit_(Staged& s, int order) {
/* The per-op index select() walks, in (hierarchy order, declaration order). Rebuilt whole on
* every registration; there are only hundreds of rows, at startup. */
void Registry::index_rows_() {
by_op_.clear();
for (const KernelRow& r : rows_) by_op_[r.info->op].push_back(&r);
for (auto& kv : by_op_) {
set_->by_op.clear();
for (const KernelRow& r : set_->rows) set_->by_op[r.info->op].push_back(&r);
for (auto& kv : set_->by_op) {
std::stable_sort(kv.second.begin(), kv.second.end(),
[](const KernelRow* a, const KernelRow* b) {
if (a->plugin_order != b->plugin_order)
@@ -578,7 +583,17 @@ void Registry::index_rows_() {
}
/* ------------------------------------------------------------------ the public loading API */
Registry::Registry() : set_(std::make_shared<Set>()) {}
std::unique_ptr<Registry> Registry::share() const {
return std::unique_ptr<Registry>(new Registry(set_));
}
int Registry::load_plugin(const std::string& path, int order) {
if (shared()) {
err_("%s: the plugin set is shared by a running engine; it is loaded once, before the first", path.c_str());
return RAD_E_STATE;
}
Staged s;
int st = stage_(path, &s);
if (st < 0) return st;
@@ -591,6 +606,10 @@ int Registry::load_dir(const std::string& dir, const std::vector<std::string>& h
int Registry::load_dirs(const std::vector<std::string>& dirs,
const std::vector<std::string>& hierarchy) {
if (shared()) {
err_("the plugin set is shared by a running engine; it is loaded once, before the first");
return RAD_E_STATE;
}
int first_error = RAD_OK;
/* Directories in the given order, files in filename order, so an unconfigured set loads
@@ -706,7 +725,7 @@ int Registry::load_dirs(const std::vector<std::string>& dirs,
/* Continue from what is already loaded, so loading kernels/ then architectures/ does not put
* two plugins at position 0. */
int order = 0;
for (const Plugin& p : plugins_) order = std::max(order, p.order + 1);
for (const Plugin& p : set_->plugins) order = std::max(order, p.order + 1);
for (size_t i : idx) {
int st = commit_(staged[i], order);
@@ -726,11 +745,11 @@ int Registry::load_dirs(const std::vector<std::string>& dirs,
/* ------------------------------------------------------------------ the tuning cache (§15) */
int Registry::load_tune(const std::string& radiance_home, const std::string& machine) {
const std::string key = machine.empty() ? rad_machine_key() : machine;
const int s = tune_.load(radiance_home, key);
const int s = set_->tune.load(radiance_home, key);
if (s < 0) return s;
/* `load` refuses a file whose machine key (line 2, tunecache.h) is another machine's, so
* these rows are this machine's. */
return (int)tune_.rows().size();
return (int)set_->tune.rows().size();
}
/* A row whose op has no schema in the loaded set cannot have its parameters checked, so a typo
@@ -738,8 +757,8 @@ int Registry::load_tune(const std::string& radiance_home, const std::string& mac
* rely on the schema of a plugin below it, which loads later. */
int Registry::check_complete() {
int st = RAD_OK;
for (const KernelRow& r : rows_) {
if (schemas_.find(r.info->op) == schemas_.end()) {
for (const KernelRow& r : set_->rows) {
if (set_->schemas.find(r.info->op) == set_->schemas.end()) {
err_("kernel '%s' in plugin '%s' implements op '%s', which no loaded plugin declares a "
"schema for", r.info->name, r.plugin.c_str(), r.info->op);
st = RAD_E_NOSCHEMA;
@@ -750,38 +769,46 @@ int Registry::check_complete() {
/* ------------------------------------------------------------------ lookup and teardown */
const Plugin* Registry::plugin(std::string_view name) const {
for (const Plugin& p : plugins_)
for (const Plugin& p : set_->plugins)
if (p.name == name || p.file == name) return &p;
return nullptr;
}
const Registry::QuantRow* Registry::quantizer(std::string_view name) const {
for (const QuantRow& q : quants_)
for (const QuantRow& q : set_->quants)
if (name == q.info->name) return &q;
return nullptr;
}
const std::vector<const KernelRow*>* Registry::rows_for(std::string_view op) const {
auto it = by_op_.find(std::string(op));
return it == by_op_.end() ? nullptr : &it->second;
auto it = set_->by_op.find(std::string(op));
return it == set_->by_op.end() ? nullptr : &it->second;
}
void Registry::close() {
fini_instances();
for (const QuantRow& q : quants_)
clear_selections();
device_facts_ = Geometry{};
/* Another registry still selects from the set: leave it loaded and take an empty one. Engines
* are created and destroyed by one thread (the fleet), so the count cannot race a share(). */
if (shared()) {
set_ = std::make_shared<Set>();
return;
}
for (const QuantRow& q : set_->quants)
if (q.info && q.info->decode) enc_remove_decoder(q.info->decode);
/* Reverse load order: a later plugin may depend on state an earlier one established. */
for (auto it = plugins_.rbegin(); it != plugins_.rend(); ++it) {
for (auto it = set_->plugins.rbegin(); it != set_->plugins.rend(); ++it) {
if (it->freed) rad_dev_off_free(it->freed);
if (it->close) it->close();
if (it->handle) dlclose(it->handle);
}
plugins_.clear();
rows_.clear();
quants_.clear();
by_op_.clear();
schemas_.clear();
load_errors_.clear();
clear_selections();
set_->plugins.clear();
set_->rows.clear();
set_->quants.clear();
set_->by_op.clear();
set_->schemas.clear();
set_->load_errors.clear();
}
Registry::~Registry() { close(); }
+54 -21
View File
@@ -27,8 +27,15 @@
* is keyed on the declaration, never on a name, so bundled libraries load like third-party ones.
*
* Lifetime: a Resolved, a Band and a KernelRow point into a plugin's static tables and are valid
* only as long as the Registry that loaded them; close() dlcloses. The core keeps one Registry for
* the process; a tool that loads two kernel sets in turn must finish with the first.
* only as long as the plugin set that holds them; the last close() of a set dlcloses it. The core
* keeps one Registry for the process (rad_tools_registry); a tool that loads two kernel sets in
* turn must finish with the first.
*
* Sharing: several engines in one process (docs/MULTIMODEL.md §3.3) select from one loaded set,
* because a plugin's .so can be loaded once per process and its rows and schemas are the same for
* every model. What differs per engine is held per Registry object: the facts its cards report
* (P2P), its selection table and the kernel instances it initialised. share() makes such an object
* over the same set; its close() finis only its own instances and leaves the set to the others.
*
* Threading: loading is single-threaded, before the rank threads exist. select() and
* init_instance() run on every rank thread during declare, so the selection log and instance list
@@ -42,6 +49,7 @@
#include <deque>
#include <mutex>
#include <functional>
#include <memory>
#include <string>
#include <string_view>
#include <unordered_map>
@@ -98,12 +106,16 @@ struct Plugin {
/* Optional (rad_builder.h, rad_arch_serves_imports); absent is true. False keeps the plugin
* out of the pick for an imported checkpoint (startup.h). */
bool arch_serves_imports = true;
/* Optional (rad_builder.h, rad_arch_multi_instance); absent is false: the plugin backs one
* engine at a time (rad_engine_claim). */
bool arch_multi_instance = false;
/* A video generator's reference conditioning (rad_builder.h); null for one without. */
int64_t (*arch_video_pack)(const RadVideoGeom*, const int32_t*, int32_t*, int32_t*, int32_t*,
int32_t*, float*, int64_t) = nullptr;
int64_t (*arch_encode_geom)(int32_t, const int64_t*, int32_t*, int64_t) = nullptr;
RadPluginCloseFn close = nullptr;
RadPluginFreedFn freed = nullptr; /* rad_plugin_freed, optional */
};
/* ------------------------------------------------------------------ one selection question */
@@ -146,8 +158,15 @@ struct SelectionTrace {
/* ------------------------------------------------------------------ the registry */
class Registry {
public:
Registry() = default;
Registry();
~Registry();
/* A registry over this one's loaded set, with its own device facts, selection table and
* instances (see Sharing above). The set stays loaded while any registry sharing it lives.
* Loading into a set that is shared is refused, so every sharer sees the same plugins. */
std::unique_ptr<Registry> share() const;
/* True while another registry shares this one's set. */
bool shared() const { return set_.use_count() > 1; }
Registry(const Registry&) = delete;
Registry& operator=(const Registry&) = delete;
@@ -179,23 +198,25 @@ public:
/* The device a kernel library's device code is checked against at load: the first card the
* caller will run on. Default 0; the engine sets it after choosing its cards, before loading. */
void set_code_device(int device) { code_device_ = device; }
void set_code_device(int device) { set_->code_device = device; }
/* Set by the engine when serving on the host backend, where no GPU code object runs: device
* rows are left out at load and every op takes its host kernel. Only the engine sets it; tools
* that select without serving (rad-convert's recipe check, rad-kbench, constraint tests) see
* every row, as on the serving machine. */
void set_no_device_code(bool v) { no_device_code_ = v; }
void set_no_device_code(bool v) { set_->no_device_code = v; }
/* Measured facts about the ranks' devices, for constraints on "device." keys (rad_types.h).
* Set before the first selection by whoever chose the devices; without a fact, a kernel
* constrained on it is not selected. */
void set_device_fact(std::string_view key, long long v) { device_facts_.set_i(key, v); }
void close(); /* fini instances, close hooks, dlclose, forget everything */
/* Fini this registry's instances and forget its selections. The last registry holding the
* set also runs the plugins' close hooks, dlcloses them and forgets everything. */
void close();
const std::vector<Plugin>& plugins() const { return plugins_; }
const std::vector<Plugin>& plugins() const { return set_->plugins; }
const Plugin* plugin(std::string_view name) const;
const std::vector<std::string>& load_errors() const { return load_errors_; }
const std::vector<std::string>& load_errors() const { return set_->load_errors; }
/* Every quantiser the loaded quantiser plugins offer, in load order. Names are unique (a
* duplicate is refused at load); quantizer() is null when nothing offers the name. */
@@ -203,11 +224,11 @@ public:
const RadQuantizerInfo* info = nullptr;
std::string plugin;
};
const std::deque<QuantRow>& quantizers() const { return quants_; }
const std::deque<QuantRow>& quantizers() const { return set_->quants; }
const QuantRow* quantizer(std::string_view name) const;
/* Every kernel row, in (hierarchy order, declaration order). rad-info prints this. */
const std::deque<KernelRow>& rows() const { return rows_; }
const std::deque<KernelRow>& rows() const { return set_->rows; }
/* The rows implementing one op, in the order select() considers them. Empty if none. */
const std::vector<const KernelRow*>* rows_for(std::string_view op) const;
@@ -232,7 +253,7 @@ public:
*
* Returns the number of rows loaded, or a negative status. */
int load_tune(const std::string& radiance_home, const std::string& machine = std::string());
const TuneCache& tune() const { return tune_; }
const TuneCache& tune() const { return set_->tune; }
/* ---------------------------------------------------------- selection (§2.1) */
/* The first plugin in hierarchy order with any matching row supplies the kernel; within that
@@ -292,6 +313,11 @@ public:
* rank and world size, off the hot path: e.g. libr4d's all-reduce sets up peer signal buffers
* and IPC handles here. A negative return aborts startup; the caller names the kernel. */
int init_instance(Resolved& r, int rank, int world_size);
/* The tensor-parallel group this registry's engine is (its first instance slot,
* rad_engine_claim). Set, init_instance hands it to every kernel's init as the `tp_group`
* parameter, so a collective's ranks rendezvous only with their own engine's; unset (-1), as
* for the tools, no parameter is added. */
void set_tp_group(long long g) { tp_group_ = g; }
void fini_instances();
size_t n_instances() const;
@@ -328,10 +354,23 @@ private:
long long count = 1;
};
int code_device_ = 0;
bool no_device_code_ = false;
/* What loading produced: shared by every registry made with share(). */
struct Set {
int code_device = 0;
bool no_device_code = false;
TuneCache tune;
std::vector<Plugin> plugins;
std::deque<KernelRow> rows; /* deque: KernelRow* handed out must stay valid */
std::deque<QuantRow> quants;
std::unordered_map<std::string, std::vector<const KernelRow*>> by_op;
std::unordered_map<std::string, SchemaEntry> schemas;
std::vector<std::string> load_errors;
};
explicit Registry(std::shared_ptr<Set> set) : set_(std::move(set)) {}
std::shared_ptr<Set> set_;
Geometry device_facts_;
TuneCache tune_;
long long tp_group_ = -1;
int stage_(const std::string& path, Staged* out);
int commit_(Staged& s, int order);
@@ -340,17 +379,11 @@ private:
void record_(const std::string& op, int domain, const Geometry& g, const SelectionTrace& t);
void err_(const char* fmt, ...) __attribute__((format(printf, 2, 3)));
std::vector<Plugin> plugins_;
std::deque<KernelRow> rows_; /* deque: KernelRow* handed out must stay valid */
std::deque<QuantRow> quants_;
std::unordered_map<std::string, std::vector<const KernelRow*>> by_op_;
std::unordered_map<std::string, SchemaEntry> schemas_;
std::vector<std::string> load_errors_;
mutable std::mutex mu_;
std::vector<SelectionRecord> log_;
std::unordered_map<std::string, size_t> log_at_; /* SelectionRecord::key -> index in log_ */
std::vector<std::pair<const RadKernelInfo*, void*>> instances_;
std::deque<Geometry> init_geoms_; /* deque: init may keep pointers into an entry */
};
/* The value a kernel's own constraints place on one key, e.g. the paged block size the resolved
+10 -10
View File
@@ -62,23 +62,23 @@ const char* param_kind_name(int kind) {
}
const RadOpSchema* Registry::schema(std::string_view op) const {
auto it = schemas_.find(std::string(op));
return it == schemas_.end() ? nullptr : it->second.schema;
auto it = set_->schemas.find(std::string(op));
return it == set_->schemas.end() ? nullptr : it->second.schema;
}
const Plugin* Registry::schema_owner(std::string_view op) const {
auto it = schemas_.find(std::string(op));
return it == schemas_.end() ? nullptr : plugin(it->second.plugin);
auto it = set_->schemas.find(std::string(op));
return it == set_->schemas.end() ? nullptr : plugin(it->second.plugin);
}
std::vector<std::string> Registry::op_names() const {
std::vector<std::string> out;
out.reserve(schemas_.size());
for (const auto& kv : schemas_) out.push_back(kv.first);
out.reserve(set_->schemas.size());
for (const auto& kv : set_->schemas) out.push_back(kv.first);
/* Include ops that have rows but no schema (check_complete() reports those), so a near-miss
* search can still name them. */
for (const KernelRow& r : rows_)
if (schemas_.find(r.info->op) == schemas_.end()) out.emplace_back(r.info->op);
for (const KernelRow& r : set_->rows)
if (set_->schemas.find(r.info->op) == set_->schemas.end()) out.emplace_back(r.info->op);
std::sort(out.begin(), out.end());
out.erase(std::unique(out.begin(), out.end()), out.end());
return out;
@@ -94,8 +94,8 @@ int Registry::validate(std::string_view op, const RadParam* p, int n_p, std::str
err->clear();
const std::string name(op);
auto it = schemas_.find(name);
if (it == schemas_.end()) {
auto it = set_->schemas.find(name);
if (it == set_->schemas.end()) {
const std::string did = near_miss(op);
*err = fmt("no loaded kernel plugin declares op '%s'%s", name.c_str(),
did.empty() ? "" : fmt("; did you mean '%s'?", did.c_str()).c_str());
+15 -3
View File
@@ -328,8 +328,8 @@ Resolved Registry::resolve(std::string_view op, const Geometry& g, int domain, S
chosen.emplace_back(ki->tunables[i].key, ki->tunables[i].deflt);
r.tune_source = "axis defaults";
if (!tune_.empty()) {
if (const TuneRow* tr = tune_.find(ki->name, r.row->plugin, r.geom_key)) {
if (!set_->tune.empty()) {
if (const TuneRow* tr = set_->tune.find(ki->name, r.row->plugin, r.geom_key)) {
bool took = false;
for (const auto& kv : TuneCache::parse_choice(tr->choice))
for (int i = 0; i < ki->n_tunables; ++i)
@@ -470,7 +470,17 @@ int Registry::init_instance(Resolved& r, int rank, int world_size) {
if (!k->init) { r.instance = nullptr; return RAD_OK; }
void* inst = nullptr;
const int st = k->init(r.geom.params(), r.geom.n_params(), rank, world_size, &inst);
/* The parameters init reads: the frozen geometry, plus the engine's tensor-parallel group when
* one is set. The extended copy lives as long as the instance, as the frozen geometry does,
* since an init may keep pointers into what it was handed. */
const Geometry* g = &r.geom;
if (tp_group_ >= 0) {
std::lock_guard<std::mutex> lk(mu_);
init_geoms_.push_back(r.geom);
init_geoms_.back().set_i("tp_group", tp_group_);
g = &init_geoms_.back();
}
const int st = k->init(g->params(), g->n_params(), rank, world_size, &inst);
if (st < 0) {
/* A negative init aborts startup rather than launching a kernel whose setup failed. */
RAD_ERR("kernel '%s' (%s) failed to initialise for %s: %s", k->name, r.row->plugin.c_str(),
@@ -492,6 +502,8 @@ void Registry::fini_instances() {
}
for (auto it = take.rbegin(); it != take.rend(); ++it)
if (it->first->fini) it->first->fini(it->second);
std::lock_guard<std::mutex> lk(mu_);
init_geoms_.clear();
}
size_t Registry::n_instances() const {