New models. Thinking Machines' Inkling 2 Mini by gostar (#584-#586): its text backbone and loop, the release's NVFP4 and MXFP8 checkpoint read by the converter, an int8 trunk, the vision tower, tensor parallelism, tool calls (with Warzuponus) and an image processor that matches transformers bit for bit (millaguie). Inkling's routed experts are served in IQR-V4's four-bit trellis (moe_gemm_iqr), fitted by GPTQ against Hessians the plugin now records (`--calib-dir`), its token embedding in int8 (read in place by embed_lookup), and incoai's DFlash2 drafter in four bits in place of the release's DSpark. That container, 14.4 GiB with the vision tower, decodes 190 / 427 / 658 tokens a second at 1 / 4 / 8 streams at tp 2 on two R9700 with `draft-window: adaptive` (code 240 / 550 / 790, step-by-step arithmetic 358 / 811 / 1116): 19-43% ahead of the same target with the release's DSpark drafter and 45-83% ahead of the all-int8 container (26.1 GiB, 124 / 263 / 386), at a mean KL of 0.0066 against the release's weights (int8: 0.0042). DeepSeek-V4.1-Flash on 2.x by baKon (#583), with its vision tower, its IQ1_S and IQ2_XXS containers and linears and experts served in llama.cpp's own blocks; parts ported from mikoskinen/r9700-exact-serving by Dad_Vibes' fork. GLM-5.3-Flash on 2.x with its IQR / IQ8R container, an int8 latent cache and four-card serving by AnimusNull (#566). Gemma 4 dense on EXL3-V3 by keptn42 (#537), on the EXL3 dense rows and qwen35_exl3 tensor parallelism by Hero422. NVIDIA's 2-bit Nemotron-3.5-Bolt-74B-A9B on one card by keptn42 (#477). Wan 2.2 TI2V-5B text-to-video and first-frame video by rkcth (#535). LFM3-1.7B on RDNA3 iGPUs by DokterSmol (#578). Qwen3.8-27B in bf16 with the DFlash2 drafter, and bf16x12, bf16 weights packed losslessly in 12.25 bits, by eddie168 (#577). Int8 experts for drama-3 by morevgalex (#598). Speculative decoding. Draft trees for Qwen3.8-27B's DFlash2 drafts by Kezi (#450, opt-in): one card, +17% at one stream and +14% at two. --draft-max-lanes and --draft-min-accept, two gates on a block drafter, and --draft-window-ckpt, its window KV kept in the checkpoint slots, by rkcth (#600-#602). `draft-window: adaptive` verifies each sequence's drafts up to the first one unlikely to be kept. A verify's rows share each K and V tile in Inkling's attention by gostar (#608): 93 to 118 tokens a second at a 70k-token prompt on one card. Generation. Krea 2 instruction edits with one or two references and registered outfill, LoRA on the image generators with bias deltas and row-mixer adapters applied per request, and MiniMax-H3's model-declared sparse attention profiles, by rkcth (#534, #542, #543, #605-#609). MiniMax-H3's audio reference guide pinned from a frame by 1beb (#595). LTX-2's chunk ceiling raised to 40 by Itoash (#570). Fleets and memory. memory.queue-reserve, the hardware queues a card keeps ready, by kevinjd (#589). memory.pinned-numa-node by Foundry (#580). memory.card-headroom-mib on single-model tensor-parallel budgets by zihaomu (#624). Parked weights rebuilt on the CPU, memory ownership kept across a failed handoff and quiescent callbacks serialised, by rkcth (#557-#561). A warm load may unload a parked model (#592); the first card listed chooses the architecture (#458). Kernels. libr3d's packed dense IQR GEMM and routed IQR expert rows on gfx1100, and libhalo's GEMV decode for Qwen3.8-Flash-Next's MoE down, by zihaomu (#562, #620, #622). GGML IQ2_XXS and IQ3_XXS packed on the card by baKon. Dashboard. KV cache in tokens (in use, capacity now and with all flexible space), live figures through long prefill steps, step / decode / prefill / acceptance lines without holes, and expert hit rates only on tiered models. Seven tile and history defects fixed by Noblistic (#597), vision encoder and per-card hardware figures by davetha (#574), per-LoRA attribution by dowjames (#552). Fixed. return_tokens / return_token_ids on the OpenAI endpoints (#571). reasoning_effort "none" and "minimal" reach a template that takes them as levels, by millaguie (#608). Misaligned loads in the windowed paged attention over an int8 cache (#540). A retired 27B head refused by name (#541). rad-convert's GPU trellis jobs kept fed, and --reuse-only, by gostar (#575). jinja's tojson takes sort_keys by Warzuponus (#582). hfget measures file sizes with stat, by kepler_62f (#623). The tested C++ compiler is stated in the build guide by lowell80 (#551). The codebase was cleaned up: shared helpers instead of repeated blocks, and the int8 linear, activation and GEMM code no longer named after the retired fp8 formats. Inkling 2 Mini is served in one form: IQR-V4 experts with the DFlash2 drafter (StillDeadcode/inkling-2-mini-iq4r-v4 on Hugging Face, or data/recipes/inkling2-mini-iq4r-v4.recipe). A container with the release's DSpark drafter, or with NVFP4, int8 or 4-bit experts, is refused by name and needs converting again. Plugin ABI 44: out-of-tree plugins need to be rebuilt. Thanks to @gostar, @baKon, @Dad_Vibes, @AnimusNull, @keptn42, @Hero422, @rkcth, @DokterSmol, @eddie168, @morevgalex, @Kezi, @1beb, @Itoash, @kevinjd, @Foundry, @zihaomu, @Noblistic, @davetha, @dowjames, @Warzuponus, @millaguie, @kepler_62f, @lowell80 and @Code000.
791 lines
38 KiB
C++
791 lines
38 KiB
C++
/* engine_lora.cpp -- runtime LoRA on the engine side: which modules adapters may target (fixed
|
|
* before declare), and loading an adapter into a slot of every rank's pools.
|
|
*
|
|
* A load packs the adapter for each rank (lora::load_adapter, host only), refuses a module no rank
|
|
* placed, copies each rank's bytes into the slot on a stream of its own, waits, and only then
|
|
* publishes the name. A request can name the adapter only after the publish, so no step reads a
|
|
* slot while it is written.
|
|
*
|
|
* A generator keeps its adapter files in a library instead (--lora, --lora-dir, the load
|
|
* endpoint), and a slot holds one combination of them at given strengths, named by the
|
|
* combination: the first request that asks for it composes it (lora/adapter.h) into a free slot,
|
|
* or the least recently used one no request holds, and later ones find it there. */
|
|
#include "engine_priv.h"
|
|
#include "engine_hostmem.h"
|
|
#include "lora/lora.h"
|
|
#include "rad_plugin.h"
|
|
|
|
#include "util/json.h"
|
|
|
|
#include <algorithm>
|
|
#include <chrono>
|
|
#include <cmath>
|
|
#include <cstring>
|
|
#include <dirent.h>
|
|
#include <fstream>
|
|
#include <filesystem>
|
|
#include <sstream>
|
|
#include <sys/stat.h>
|
|
#include <thread>
|
|
|
|
namespace rad {
|
|
|
|
namespace {
|
|
|
|
/* adapter_config.json's target_modules as leaf names. PEFT also accepts a regex string and
|
|
* "all-linear"; neither names leaves this engine can check before declare, so both are refused
|
|
* with the flag that does. */
|
|
int read_targets(const std::string& dir, std::set<std::string>* out, std::string* err) {
|
|
const std::string path = dir + "/adapter_config.json";
|
|
std::ifstream f(path);
|
|
if (!f) { *err = "cannot read " + path; return RAD_E_NOTFOUND; }
|
|
Json j;
|
|
try { f >> j; } catch (const std::exception& e) {
|
|
*err = path + ": " + e.what();
|
|
return RAD_E_INVAL;
|
|
}
|
|
const auto it = j.find("target_modules");
|
|
if (it == j.end() || it->is_null()) { *err = path + " names no target_modules"; return RAD_E_INVAL; }
|
|
if (it->is_string()) {
|
|
*err = path + ": target_modules is '" + it->get<std::string>() +
|
|
"', not a list of module names; give them with --lora-target-modules";
|
|
return RAD_E_UNSUPPORTED;
|
|
}
|
|
if (!it->is_array()) { *err = path + ": target_modules is not a list"; return RAD_E_INVAL; }
|
|
for (const auto& m : *it) {
|
|
if (!m.is_string()) { *err = path + ": a target_modules entry is not a string"; return RAD_E_INVAL; }
|
|
std::string s = m.get<std::string>();
|
|
const size_t dot = s.rfind('.');
|
|
if (dot != std::string::npos) s = s.substr(dot + 1);
|
|
if (!s.empty()) out->insert(s);
|
|
}
|
|
return RAD_OK;
|
|
}
|
|
|
|
/* A generator's adapter name: a file stem under --lora-dir, possibly in a subdirectory, never
|
|
* leaving it. */
|
|
bool valid_name(const std::string& n) {
|
|
if (n.empty() || n.size() > 200 || n[0] == '/' || n[0] == '.') return false;
|
|
if (n.find("..") != std::string::npos || n.find("//") != std::string::npos) return false;
|
|
for (char c : n)
|
|
if (!(std::isalnum((unsigned char)c) || c == '_' || c == '-' || c == '.' || c == '/' ||
|
|
c == ' ' || c == '(' || c == ')' || c == '+' || c == ','))
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
bool is_file(const std::string& p) {
|
|
struct stat sb{};
|
|
return stat(p.c_str(), &sb) == 0 && S_ISREG(sb.st_mode);
|
|
}
|
|
|
|
/* Discovered adapters must stay inside the configured local library. */
|
|
std::string discovered_path(const std::string& dir, const std::string& name) {
|
|
if (dir.empty() || !valid_name(name)) return {};
|
|
std::error_code ec;
|
|
const auto root = std::filesystem::canonical(dir, ec);
|
|
if (ec) return {};
|
|
const auto file = std::filesystem::canonical(root / (name + ".safetensors"), ec);
|
|
if (ec || !std::filesystem::is_regular_file(file, ec)) return {};
|
|
const auto relative = file.lexically_relative(root);
|
|
if (relative.empty() || *relative.begin() == "..") return {};
|
|
return file.string();
|
|
}
|
|
|
|
std::set<std::string> discovered_adapters(const std::string& directory) {
|
|
std::set<std::string> n;
|
|
if (!directory.empty()) {
|
|
/* Two levels: the directory and its subdirectories, as a UI's lora folder is laid out. */
|
|
std::vector<std::string> dirs{ "" };
|
|
for (size_t i = 0; i < dirs.size(); ++i) {
|
|
const std::string rel = dirs[i];
|
|
DIR* d = opendir((directory + "/" + rel).c_str());
|
|
if (!d) continue;
|
|
while (dirent* e = readdir(d)) {
|
|
const std::string fn = e->d_name;
|
|
if (fn.empty() || fn[0] == '.') continue;
|
|
const std::string p = rel + fn;
|
|
struct stat sb{};
|
|
if (stat((directory + "/" + p).c_str(), &sb) != 0) continue;
|
|
if (S_ISDIR(sb.st_mode)) { if (rel.empty()) dirs.push_back(p + "/"); continue; }
|
|
const size_t k = fn.size();
|
|
if (k > 12 && fn.compare(k - 12, 12, ".safetensors") == 0) {
|
|
const std::string stem = p.substr(0, p.size() - 12);
|
|
if (!discovered_path(directory, stem).empty()) n.insert(stem);
|
|
}
|
|
}
|
|
closedir(d);
|
|
}
|
|
}
|
|
return n;
|
|
}
|
|
|
|
/* '|' is excluded from adapter names and never appears in a printed strength. */
|
|
std::string combo_key(const std::vector<Engine::LoraUse>& uses,
|
|
const std::vector<std::string>& versions) {
|
|
std::string k;
|
|
for (size_t i = 0; i < uses.size(); ++i) {
|
|
const auto& u = uses[i];
|
|
k += fmt("%s%s*%.17g", k.empty() ? "" : "|", u.name.c_str(), u.weight);
|
|
k += "@" + versions[i];
|
|
}
|
|
return k;
|
|
}
|
|
|
|
|
|
} /* namespace */
|
|
|
|
int Engine::lora_targets() {
|
|
if (!cfg_.lora.enabled()) return RAD_OK;
|
|
lora_targets_ = std::set<std::string>(cfg_.lora.targets.begin(), cfg_.lora.targets.end());
|
|
if (lora_targets_.empty()) {
|
|
/* A PEFT directory names its targets; an adapter file (a generator's) and a directory of
|
|
* them do not, and a generator's default is every plain GEMM under its declared roots. A
|
|
* text model refuses "*" at declare. */
|
|
for (const auto& [name, dir] : cfg_.lora.adapters) {
|
|
if (is_file(dir)) { lora_targets_.insert("*"); continue; }
|
|
std::string err;
|
|
const int s = read_targets(dir, &lora_targets_, &err);
|
|
if (s < 0) {
|
|
RAD_ERR("lora: adapter '%s': %s", name.c_str(), err.c_str());
|
|
return s;
|
|
}
|
|
}
|
|
if (cfg_.lora.adapters.empty()) lora_targets_.insert("*");
|
|
}
|
|
lora_table_.reset(cfg_.lora.slots(), &lora_epoch_);
|
|
return RAD_OK;
|
|
}
|
|
|
|
int Engine::lora_start() {
|
|
if (!cfg_.lora.enabled()) return RAD_OK;
|
|
lora_gen_ = ranks_[0]->program.is_pass_driven();
|
|
if (!lora_gen_ && cfg_.lora.slots() < (int)cfg_.lora.adapters.size()) {
|
|
RAD_ERR("lora: --max-loras %d holds fewer adapters than the %zu that --lora names",
|
|
cfg_.lora.slots(), cfg_.lora.adapters.size());
|
|
return RAD_E_INVAL;
|
|
}
|
|
size_t n_sites = 0;
|
|
for (const auto& r : ranks_) n_sites += r->program.lora_sites.size();
|
|
if (n_sites == 0) {
|
|
std::string t;
|
|
for (const std::string& x : lora_targets_) t += (t.empty() ? "" : ",") + x;
|
|
RAD_ERR("lora: no GEMM of this model multiplies a weight of the targeted modules (%s)",
|
|
t.c_str());
|
|
return RAD_E_UNSUPPORTED;
|
|
}
|
|
/* Every target is a module some rank carries adapters on. A leaf the model lacks, or holds
|
|
* only outside the trunk (embedding, lm_head, a tower, the drafter), would target nothing. */
|
|
if (!lora_targets_.count("*")) {
|
|
std::set<std::string> carried;
|
|
for (const auto& r : ranks_)
|
|
for (const lora::Site& site : r->lora_sites)
|
|
for (const lora::SiteSource& src : site.sources)
|
|
if (src.targeted) carried.insert(src.module.substr(src.module.rfind('.') + 1));
|
|
for (const std::string& x : lora_targets_)
|
|
if (!carried.count(x)) {
|
|
RAD_ERR("lora: the target module '%s' is no trunk linear of this model, so no "
|
|
"adapter could land on it; leave it out of --lora-target-modules (or of "
|
|
"the adapters' target_modules)", x.c_str());
|
|
return RAD_E_UNSUPPORTED;
|
|
}
|
|
}
|
|
/* The adapter ops run in their GEMM's domain and read the pools on the card, so a targeted
|
|
* GEMM placed on the host could serve no adapter request. On the host backend every op and
|
|
* the pools are in host memory. */
|
|
if (!device_is_host())
|
|
for (const auto& r : ranks_)
|
|
for (const LoraIssueSite& site : r->program.lora_sites)
|
|
if (r->ctx.op_domain((rad_op)site.gemm) != RAD_DOMAIN_DEVICE) {
|
|
RAD_ERR("lora: rank %d: the GEMM over '%s' is placed on the host, and its "
|
|
"adapter ops read pools on the card; keep the targeted weights in "
|
|
"VRAM or leave the module out of --lora-target-modules", r->index,
|
|
r->program.lora_pools[(size_t)site.pool].weight.c_str());
|
|
return RAD_E_UNSUPPORTED;
|
|
}
|
|
{
|
|
const Program& P = ranks_[0]->program;
|
|
int64_t slot_bytes = 0;
|
|
for (const LoraPool& p : P.lora_pools) slot_bytes += 2 * p.R * p.K + 2 * p.N * p.R + 4 * p.N;
|
|
std::string t;
|
|
for (const std::string& x : lora_targets_) t += (t.empty() ? "" : ",") + x;
|
|
RAD_INFO("lora: %zu GEMMs over %zu weights carry adapters on rank 0 (%s); %d slots of rank "
|
|
"%d, %s a slot, %s on the card", P.lora_sites.size(), P.lora_pools.size(), t.c_str(),
|
|
cfg_.lora.slots(), cfg_.lora.rank(lora_gen_), humanb(slot_bytes).c_str(),
|
|
humanb(slot_bytes * cfg_.lora.slots()).c_str());
|
|
}
|
|
if (lora_gen_) return gen_lora_start();
|
|
for (const auto& [name, dir] : cfg_.lora.adapters) {
|
|
std::string err;
|
|
const int s = lora_load(name, dir, &err);
|
|
if (s < 0) {
|
|
RAD_ERR("lora: adapter '%s' (%s): %s", name.c_str(), dir.c_str(), err.c_str());
|
|
return s;
|
|
}
|
|
}
|
|
return RAD_OK;
|
|
}
|
|
|
|
int Engine::lora_load(const std::string& name, const std::string& dir, std::string* err) {
|
|
std::lock_guard<std::mutex> lk(lora_mu_);
|
|
if (!cfg_.lora.enabled()) { *err = "the engine was started without adapters"; return RAD_E_STATE; }
|
|
if (name.empty()) { *err = "an adapter needs a name"; return RAD_E_INVAL; }
|
|
if (lora_gen_) {
|
|
/* A generator's adapter goes into the library; a slot takes it when a request asks. */
|
|
if (!valid_name(name)) { *err = "'" + name + "' is not an adapter name"; return RAD_E_INVAL; }
|
|
{
|
|
std::lock_guard<std::mutex> lk2(lora_lib_mu_);
|
|
if (lora_lib_.count(name)) { *err = "an adapter named '" + name + "' is already loaded"; return RAD_E_INVAL; }
|
|
}
|
|
std::shared_ptr<const lora::AdapterFile> f;
|
|
RAD_TRY(snapshot_gen_adapter(dir, &f, err));
|
|
int placed = 0, rank = 0;
|
|
std::string first;
|
|
for (const lora::FileModule& m : f->modules()) {
|
|
std::string why;
|
|
if (!lora_keys_->resolve(m.key, &why).empty()) { ++placed; continue; }
|
|
if (first.empty()) first = m.key + ": " + why;
|
|
}
|
|
for (const lora::FileModule& m : f->modules())
|
|
if (m.kind == lora::FileModule::LORA && m.t[0]) rank = std::max(rank, (int)m.t[0]->shape[0]);
|
|
std::vector<std::string> skipped_biases;
|
|
std::map<std::string, std::vector<float>> bias_deltas;
|
|
RAD_TRY(lora::compose_biases(*lora_keys_, {{name, f, 1.0}}, gen_bias_modules_,
|
|
&skipped_biases, &bias_deltas, err));
|
|
if (first.empty() && !skipped_biases.empty()) first = skipped_biases.front();
|
|
if (placed == 0 && bias_deltas.empty()) {
|
|
*err = fmt("none of its %zu modules is a module of this model (%s)", f->modules().size(),
|
|
first.c_str());
|
|
return RAD_E_NOTFOUND;
|
|
}
|
|
RAD_INFO("lora: '%s' -- %s, %d of %zu modules on this model%s%s%s", name.c_str(),
|
|
f->kind_name(), placed, f->modules().size(),
|
|
rank ? fmt(", rank %d", rank).c_str() : "", first.empty() ? "" : "; not placed: ",
|
|
first.c_str());
|
|
std::lock_guard<std::mutex> lk2(lora_lib_mu_);
|
|
lora_lib_[name] = { dir, {}, f, next_adapter_version_++ };
|
|
unloaded_gen_adapters_.erase(name);
|
|
return RAD_OK;
|
|
}
|
|
/* A slot that is still cooling (lora/slots.h) is waited for here rather than answered with a
|
|
* retry: the step loop goes round idle or busy, so the wait is milliseconds, and a hot swap
|
|
* (unload, then load at once) would otherwise fail under traffic. Only other loads wait on
|
|
* lora_mu_ meanwhile; requests and unloads use the table alone. */
|
|
const auto give_up = std::chrono::steady_clock::now() + std::chrono::seconds(2);
|
|
int slot = -1;
|
|
for (;;) {
|
|
bool cooling = false;
|
|
const int s = lora_table_.reserve(name, &slot, &cooling, err);
|
|
if (s >= 0) break;
|
|
if (s != RAD_E_FULL || !cooling || stopping_.load(std::memory_order_acquire) ||
|
|
std::chrono::steady_clock::now() >= give_up)
|
|
return s;
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(2));
|
|
}
|
|
|
|
/* ---- pack, per rank (host only) */
|
|
std::vector<lora::AdapterInfo> infos(ranks_.size());
|
|
std::vector<std::vector<lora::PackedSite>> packed(ranks_.size());
|
|
for (size_t ri = 0; ri < ranks_.size(); ++ri) {
|
|
const int s = lora::load_adapter(dir, ranks_[ri]->lora_sites, cfg_.lora.rank(false), &infos[ri],
|
|
&packed[ri], err);
|
|
if (s < 0) {
|
|
if (ranks_.size() > 1) *err = fmt("rank %zu: ", ri) + *err;
|
|
return s;
|
|
}
|
|
}
|
|
{
|
|
const int s = lora::check_placed(infos, err, &ranks_[0]->program, &lora_targets_);
|
|
if (s < 0) return s;
|
|
}
|
|
|
|
RAD_TRY(lora_copy(slot, packed, err));
|
|
|
|
lora_table_.publish(slot, name, dir);
|
|
const lora::AdapterInfo& a = infos[0];
|
|
RAD_INFO("lora: '%s' in slot %d -- %zu modules, rank %lld, alpha %g%s, base %s", name.c_str(),
|
|
slot, a.modules.size(), (long long)a.max_module_rank, a.alpha, a.rslora ? " (rsLoRA)" : "",
|
|
a.base_model.empty() ? "(unnamed)" : a.base_model.c_str());
|
|
return RAD_OK;
|
|
}
|
|
|
|
int Engine::lora_copy(int slot, const std::vector<std::vector<lora::PackedSite>>& packed,
|
|
std::string* err, const LoraReplacements* replacements) {
|
|
/* Each rank on a stream of its own: the compute stream may be recording a pass. */
|
|
for (size_t ri = 0; ri < ranks_.size(); ++ri) {
|
|
Rank& r = *ranks_[ri];
|
|
const Program& P = r.program;
|
|
if (packed[ri].size() != P.lora_pools.size()) {
|
|
*err = fmt("rank %zu: the adapter was packed for %zu pools, the program has %zu", ri,
|
|
packed[ri].size(), P.lora_pools.size());
|
|
return RAD_E_STATE;
|
|
}
|
|
if (rad_dev_set(r.device) < 0) { *err = fmt("rank %zu: cannot bind its device", ri); return RAD_E_DEVICE; }
|
|
RadStream st{};
|
|
if (rad_stream_create(&st, 0) < 0) { *err = fmt("rank %zu: no copy stream", ri); return RAD_E_DEVICE; }
|
|
int rc = RAD_OK;
|
|
for (size_t p = 0; p < P.lora_pools.size() && rc >= 0; ++p) {
|
|
const LoraPool& lp = P.lora_pools[p];
|
|
const lora::PackedSite& ps = packed[ri][p];
|
|
const int64_t ab = 2 * lp.R * lp.K, bb = 2 * lp.N * lp.R, sb = 4 * lp.N;
|
|
char* da = (char*)P.buffers[lp.a].ptr;
|
|
char* db = (char*)P.buffers[lp.b].ptr;
|
|
char* ds = (char*)P.buffers[lp.scale].ptr;
|
|
if (!da || !db || !ds) {
|
|
rc = RAD_E_STATE;
|
|
*err = "the adapter pool of '" + lp.weight + "' has no buffer address";
|
|
break;
|
|
}
|
|
da += (int64_t)slot * ab; db += (int64_t)slot * bb; ds += (int64_t)slot * sb;
|
|
/* A pool this adapter does not touch is zeroed, not left as it was: the bytes are what
|
|
* the slot's last adapter or the arena held, and a scale of 0 times a NaN is a NaN. */
|
|
if (ps.empty) {
|
|
if (rad_memset_async(da, 0, ab, st) < 0 || rad_memset_async(db, 0, bb, st) < 0 ||
|
|
rad_memset_async(ds, 0, sb, st) < 0)
|
|
rc = RAD_E_DEVICE;
|
|
continue;
|
|
}
|
|
if ((int64_t)ps.a.size() * 2 != ab || (int64_t)ps.b.size() * 2 != bb ||
|
|
(int64_t)ps.scale.size() * 4 != sb) {
|
|
*err = fmt("rank %zu: pool '%s' was packed as %zu/%zu/%zu elements, its slot holds "
|
|
"%lld/%lld/%lld", ri, lp.weight.c_str(), ps.a.size(), ps.b.size(),
|
|
ps.scale.size(), (long long)(ab / 2), (long long)(bb / 2), (long long)(sb / 4));
|
|
rc = RAD_E_STATE;
|
|
break;
|
|
}
|
|
if (rad_memcpy_async(da, ps.a.data(), ab, st) < 0 ||
|
|
rad_memcpy_async(db, ps.b.data(), bb, st) < 0 ||
|
|
rad_memcpy_async(ds, ps.scale.data(), sb, st) < 0)
|
|
rc = RAD_E_DEVICE;
|
|
}
|
|
if (replacements && rc >= 0) {
|
|
for (const auto& [buffer, values] : (*replacements)[ri]) {
|
|
auto* dst = static_cast<uint16_t*>(r.ctx.buf_ptr(buffer));
|
|
if (!dst) { rc = RAD_E_STATE; break; }
|
|
rc = rad_memcpy_async(dst + slot * values.size(), values.data(),
|
|
values.size() * sizeof(uint16_t), st);
|
|
if (rc < 0) break;
|
|
}
|
|
}
|
|
const int sy = rad_stream_sync(st);
|
|
rad_stream_destroy(st);
|
|
if (rc >= 0 && sy < 0) rc = RAD_E_DEVICE;
|
|
if (rc < 0) {
|
|
if (err->empty()) *err = fmt("rank %zu: the copy into slot %d failed", ri, slot);
|
|
return rc;
|
|
}
|
|
}
|
|
return RAD_OK;
|
|
}
|
|
|
|
int Engine::lora_acquire(const std::string& name, int32_t* slot, uint64_t* uid,
|
|
std::shared_ptr<void>* hold) {
|
|
return lora_table_.acquire(name, slot, uid, hold);
|
|
}
|
|
|
|
int Engine::lora_unload(const std::string& name, std::string* err, int* in_flight) {
|
|
if (!lora_gen_) return lora_table_.unload(name, in_flight, err);
|
|
const std::lock_guard composition_lock(lora_mu_);
|
|
/* A generator's adapter leaves the library, and every combination holding it its slot (at
|
|
* once when idle, after its requests otherwise). */
|
|
{
|
|
std::lock_guard<std::mutex> lk(lora_lib_mu_);
|
|
if (unloaded_gen_adapters_.count(name) ||
|
|
(!lora_lib_.erase(name) && discovered_path(cfg_.lora.dir, name).empty())) {
|
|
*err = "no adapter named '" + name + "' is loaded";
|
|
return RAD_E_NOTFOUND;
|
|
}
|
|
unloaded_gen_adapters_.insert(name);
|
|
}
|
|
*in_flight = 0;
|
|
for (const std::string& k : lora_table_.names()) {
|
|
bool uses = false;
|
|
size_t at = 0;
|
|
while (at <= k.size()) {
|
|
const size_t plus = std::min(k.find('|', at), k.size());
|
|
const std::string part = k.substr(at, plus - at);
|
|
if (part.substr(0, part.rfind('*')) == name) uses = true;
|
|
at = plus + 1;
|
|
}
|
|
if (!uses) continue;
|
|
int n = 0;
|
|
std::string e;
|
|
lora_table_.unload(k, &n, &e);
|
|
*in_flight += n;
|
|
}
|
|
return RAD_OK;
|
|
}
|
|
|
|
std::vector<std::string> Engine::lora_names() const {
|
|
return lora_gen_ ? gen_lora_names() : lora_table_.names();
|
|
}
|
|
|
|
/* ================================================================== generator adapters */
|
|
int Engine::gen_lora_start() {
|
|
/* Every slot's run of the slot-row table holds its own index (Program::lora_rows). */
|
|
std::map<std::string, size_t> bias_rank_count;
|
|
std::map<std::string, size_t> mixer_rank_count;
|
|
for (auto& rp : ranks_) {
|
|
Rank& r = *rp;
|
|
Program& P = r.program;
|
|
// Replacement slots live on the device. A weight used by a host op must keep its
|
|
// original pointer, even if a device op also reads that weight.
|
|
if (!device_is_host()) {
|
|
for (size_t op = 1; op < P.ops.size(); ++op)
|
|
if (r.ctx.op_domain((rad_op)op) == RAD_DOMAIN_HOST)
|
|
for (rad_weight weight : P.ops[op].weights) {
|
|
const auto replacement = P.lora_replacements.find(weight);
|
|
if (replacement != P.lora_replacements.end() && replacement->second.row_mixer)
|
|
P.lora_placement_issues.try_emplace(replacement->second.module,
|
|
"row-mixer replacement is unavailable to a host reader");
|
|
P.lora_replacements.erase(weight);
|
|
}
|
|
}
|
|
std::set<std::string> rank_biases;
|
|
for (const auto& [weight, replacement] : P.lora_replacements)
|
|
if (!replacement.row_mixer) rank_biases.insert(replacement.module);
|
|
for (const auto& name : rank_biases) ++bias_rank_count[name];
|
|
std::set<std::string> rank_mixers;
|
|
for (const auto& [weight, replacement] : P.lora_replacements)
|
|
if (replacement.row_mixer) rank_mixers.insert(replacement.module);
|
|
for (const auto& name : rank_mixers) ++mixer_rank_count[name];
|
|
RAD_TRY(rad_dev_set(r.device));
|
|
for (const auto& [weight, bias] : P.lora_replacements) {
|
|
auto& base = r.lora_base_weights[weight];
|
|
base.resize((size_t)bias.rows);
|
|
const void* src = r.ctx.weight_ptr(weight);
|
|
if (!src) return RAD_E_STATE;
|
|
RAD_TRY(rad_memcpy_async(base.data(), src, bias.rows * 2, r.ctx.stream()));
|
|
RAD_TRY(rad_stream_sync(r.ctx.stream()));
|
|
}
|
|
if (!P.lora_rows || P.lora_rows_n <= 0) continue;
|
|
RAD_TRY(rad_dev_set(r.device));
|
|
const int S = cfg_.lora.slots();
|
|
std::vector<int32_t> v((size_t)(S * P.lora_rows_n));
|
|
for (int s = 0; s < S; ++s)
|
|
std::fill(v.begin() + (int64_t)s * P.lora_rows_n, v.begin() + (int64_t)(s + 1) * P.lora_rows_n, s);
|
|
void* d = P.buffers[P.lora_rows].ptr;
|
|
if (!d || rad_dev_set(r.device) < 0) {
|
|
RAD_ERR("lora: rank %d: the slot-row table has no address", r.index);
|
|
return RAD_E_STATE;
|
|
}
|
|
RadStream st{};
|
|
if (rad_stream_create(&st, 0) < 0) return RAD_E_DEVICE;
|
|
const int rc = rad_memcpy_async(d, v.data(), (int64_t)v.size() * 4, st);
|
|
const int sy = rad_stream_sync(st);
|
|
rad_stream_destroy(st);
|
|
if (rc < 0 || sy < 0) return RAD_E_DEVICE;
|
|
}
|
|
// A projector adapter must reach every rank that serves the model.
|
|
for (auto& rank : ranks_) {
|
|
auto& replacements = rank->program.lora_replacements;
|
|
for (auto it = replacements.begin(); it != replacements.end();) {
|
|
if (it->second.row_mixer && mixer_rank_count[it->second.module] != ranks_.size()) {
|
|
rank->program.lora_placement_issues.try_emplace(it->second.module,
|
|
"row-mixer replacement is not eligible on every rank");
|
|
rank->lora_base_weights.erase(it->first);
|
|
it = replacements.erase(it);
|
|
} else {
|
|
++it;
|
|
}
|
|
}
|
|
}
|
|
for (const auto& [name, count] : bias_rank_count)
|
|
if (count == ranks_.size()) gen_bias_modules_.insert(name);
|
|
lora_keys_ = std::make_unique<lora::KeyMap>(ranks_[0]->program, ranks_[0]->lora_sites);
|
|
for (const auto& [name, path] : cfg_.lora.adapters) {
|
|
std::string err;
|
|
const int s = lora_load(name, path, &err);
|
|
if (s < 0) {
|
|
RAD_ERR("lora: adapter '%s' (%s): %s", name.c_str(), path.c_str(), err.c_str());
|
|
return s;
|
|
}
|
|
}
|
|
if (!cfg_.lora.dir.empty())
|
|
RAD_INFO("lora: requests may name the %zu adapter files under %s", gen_lora_names().size(),
|
|
cfg_.lora.dir.c_str());
|
|
return RAD_OK;
|
|
}
|
|
|
|
int Engine::gen_lora_prepare_replacements(
|
|
const std::map<std::string, lora::Composite>& modules,
|
|
const std::map<std::string, std::vector<float>>& deltas,
|
|
LoraReplacements* replacements, std::string* err) const {
|
|
replacements->resize(ranks_.size());
|
|
for (size_t i = 0; i < ranks_.size(); ++i) {
|
|
const auto& r = *ranks_[i];
|
|
std::set<std::string> matched;
|
|
for (const auto& [weight, bias] : r.program.lora_replacements) {
|
|
auto data = r.lora_base_weights.at(weight);
|
|
const auto delta = deltas.find(bias.module);
|
|
if (bias.row_mixer) {
|
|
if (const auto it = modules.find(bias.module); it != modules.end()) {
|
|
const auto& factors = it->second;
|
|
if (factors.rows != 1 || factors.K != bias.rows) {
|
|
*err = "adapter shape disagrees with row mixer " + bias.module;
|
|
return RAD_E_SHAPE;
|
|
}
|
|
for (int64_t i = 0; i < bias.rows; ++i) {
|
|
float adjustment = 0;
|
|
for (int64_t j = 0; j < factors.r; ++j)
|
|
adjustment += factors.B[(size_t)j] * factors.A[(size_t)(j * factors.K + i)];
|
|
data[(size_t)i] = rad_f32_to_bf16(rad_bf16_to_f32(data[(size_t)i]) + adjustment);
|
|
}
|
|
}
|
|
} else if (delta != deltas.end()) {
|
|
const int status = lora::apply_bias_delta(delta->second, bias.source_rows, &data, err);
|
|
if (status < 0) {
|
|
*err = bias.module + ": " + *err;
|
|
return status;
|
|
}
|
|
matched.insert(delta->first);
|
|
}
|
|
(*replacements)[i].push_back({bias.slots, std::move(data)});
|
|
}
|
|
if (matched.size() != deltas.size()) {
|
|
for (const auto& delta : deltas) {
|
|
if (!matched.count(delta.first)) {
|
|
*err = "no supported bias operand for " + delta.first;
|
|
return RAD_E_UNSUPPORTED;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return RAD_OK;
|
|
}
|
|
|
|
// A published slot owns its packed weights. Only explicitly loaded adapters
|
|
// keep source bytes between requests. A cache hit needs just a revision check.
|
|
int Engine::resolve_gen_adapter(const std::string& name, AdapterEntry* entry, std::string* err) {
|
|
const std::lock_guard lock(lora_lib_mu_);
|
|
if (unloaded_gen_adapters_.count(name)) {
|
|
*err = "adapter '" + name + "' was unloaded; load it before using it again";
|
|
return RAD_E_NOTFOUND;
|
|
}
|
|
auto it = lora_lib_.find(name);
|
|
if (it != lora_lib_.end() && it->second.file) {
|
|
*entry = it->second;
|
|
return RAD_OK;
|
|
}
|
|
const std::string path = discovered_path(cfg_.lora.dir, name);
|
|
FileRevision revision;
|
|
if (read_file_revision(path, &revision) < 0) {
|
|
*err = "no local adapter named '" + name + "'";
|
|
return RAD_E_NOTFOUND;
|
|
}
|
|
if (it == lora_lib_.end() || it->second.path != path || it->second.revision != revision)
|
|
lora_lib_[name] = {path, revision, nullptr, next_adapter_version_++};
|
|
*entry = lora_lib_.at(name);
|
|
return RAD_OK;
|
|
}
|
|
|
|
int Engine::snapshot_gen_adapter(const std::string& path,
|
|
std::shared_ptr<const lora::AdapterFile>* file,
|
|
std::string* err, const FileRevision* expected) const {
|
|
FileRevision revision;
|
|
if (read_file_revision(path, &revision) < 0 || revision.bytes < 8) {
|
|
*err = "adapter source is missing or incomplete";
|
|
return RAD_E_IO;
|
|
}
|
|
if (!lockable_room(static_cast<int64_t>(revision.bytes), 0, host_margin_bytes(), false, err)) return RAD_E_NOMEM;
|
|
auto source = std::make_shared<lora::AdapterFile>();
|
|
const int status = source->open_snapshot(path, revision.bytes, err, expected);
|
|
if (status == RAD_E_FULL) return RAD_E_STATE; // File grew after stat, no slot wait can help.
|
|
if (status < 0) return status;
|
|
*file = std::move(source);
|
|
return RAD_OK;
|
|
}
|
|
|
|
std::vector<std::string> Engine::gen_lora_names() const {
|
|
auto n = discovered_adapters(cfg_.lora.dir);
|
|
const std::lock_guard lock(lora_lib_mu_);
|
|
for (const auto& [name, entry] : lora_lib_)
|
|
if (!entry.revision) n.insert(name);
|
|
for (const auto& name : unloaded_gen_adapters_) n.erase(name);
|
|
return std::vector<std::string>(n.begin(), n.end());
|
|
}
|
|
|
|
int Engine::gen_lora_acquire(const std::vector<LoraUse>& uses_in, int32_t* slot,
|
|
std::shared_ptr<void>* hold, std::string* note, std::string* err) {
|
|
return gen_lora_request(uses_in, slot, hold, note, err, false);
|
|
}
|
|
|
|
int Engine::gen_lora_validate(const std::vector<LoraUse>& uses, std::string* err) {
|
|
int32_t slot;
|
|
std::shared_ptr<void> hold;
|
|
return gen_lora_request(uses, &slot, &hold, nullptr, err, true);
|
|
}
|
|
|
|
int Engine::gen_lora_request(const std::vector<LoraUse>& uses_in, int32_t* slot,
|
|
std::shared_ptr<void>* hold, std::string* note, std::string* err,
|
|
bool validate_only) {
|
|
*slot = -1;
|
|
hold->reset();
|
|
if (note) note->clear();
|
|
if (!lora_gen_) { *err = "this model takes no adapters (start it with --lora or --lora-dir)"; return RAD_E_STATE; }
|
|
/* One entry per adapter, strengths of a repeated name summed; strength 0 is no adapter. */
|
|
std::map<std::string, double> by;
|
|
for (const LoraUse& u : uses_in) {
|
|
if (!std::isfinite(u.weight) || std::fabs(u.weight) > 16.0) {
|
|
*err = fmt("adapter '%s': strength %g is outside [-16, 16]", u.name.c_str(), u.weight);
|
|
return RAD_E_INVAL;
|
|
}
|
|
by[u.name] += u.weight;
|
|
}
|
|
std::vector<LoraUse> uses;
|
|
for (const auto& [n, w] : by) if (w != 0.0) uses.push_back({ n, w });
|
|
if (uses.empty()) {
|
|
if (!validate_only) return RAD_OK;
|
|
*err = "expected a nonzero adapter combination";
|
|
return RAD_E_INVAL;
|
|
}
|
|
if (uses.size() > 16) { *err = fmt("%zu adapters in one request; at most 16", uses.size()); return RAD_E_INVAL; }
|
|
uint64_t uid = 0;
|
|
std::vector<AdapterEntry> sources(uses.size());
|
|
std::string key;
|
|
auto resolve_sources = [&]() -> int {
|
|
std::vector<std::string> versions;
|
|
for (size_t i = 0; i < uses.size(); ++i) {
|
|
RAD_TRY(resolve_gen_adapter(uses[i].name, &sources[i], err));
|
|
versions.push_back(std::to_string(sources[i].version));
|
|
}
|
|
key = combo_key(uses, versions);
|
|
return RAD_OK;
|
|
};
|
|
RAD_TRY(resolve_sources());
|
|
// An already packed revision does not wait behind unrelated expensive composition.
|
|
bool all_held = false;
|
|
if (!validate_only && lora_table_.acquire(key, slot, &uid, hold, &all_held) == RAD_OK) return RAD_OK;
|
|
if (!validate_only && all_held) { *err = "all adapter slots are in use"; return RAD_E_FULL; }
|
|
std::lock_guard<std::mutex> lk(lora_mu_);
|
|
// A load, unload or replacement may have happened while waiting for the composer.
|
|
RAD_TRY(resolve_sources());
|
|
if (!validate_only && lora_table_.acquire(key, slot, &uid, hold) == RAD_OK) return RAD_OK;
|
|
const auto t0 = std::chrono::steady_clock::now();
|
|
/* A slot: free, or freed from the least recently used combination no request holds. */
|
|
const auto give_up = std::chrono::steady_clock::now() + std::chrono::seconds(2);
|
|
int sl = -1;
|
|
if (!validate_only) {
|
|
for (;;) {
|
|
bool cooling = false;
|
|
const int s = lora_table_.reserve(key, &sl, &cooling, err);
|
|
if (s >= 0) break;
|
|
if (s == RAD_E_FULL && !cooling) {
|
|
std::string ev;
|
|
if (lora_table_.evict_idle(&ev) == RAD_OK) continue;
|
|
*err = fmt("all %d adapter slots are held by running requests with other adapters "
|
|
"(--max-loras); retry when one finishes", cfg_.lora.slots());
|
|
return RAD_E_FULL;
|
|
}
|
|
if (s != RAD_E_FULL || stopping_.load(std::memory_order_acquire) ||
|
|
std::chrono::steady_clock::now() >= give_up)
|
|
return s;
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(2));
|
|
}
|
|
}
|
|
// reserve() only selects a free UID-zero slot under lora_mu_. Until publish(), any
|
|
// snapshot/compose/copy failure leaves it unpublished and available to the next load.
|
|
std::vector<lora::Strength> ss;
|
|
for (size_t i = 0; i < uses.size(); ++i) {
|
|
auto& source = sources[i];
|
|
if (!source.file) {
|
|
const FileRevision* expected = source.revision ? &*source.revision : nullptr;
|
|
RAD_TRY(snapshot_gen_adapter(source.path, &source.file, err, expected));
|
|
}
|
|
ss.push_back({uses[i].name, source.file, uses[i].weight});
|
|
}
|
|
const int rank = cfg_.lora.rank(true);
|
|
std::map<std::string, lora::Composite> comp;
|
|
lora::ComposeReport rep;
|
|
RAD_TRY(lora::compose(*lora_keys_, ss, rank, &comp, &rep, err));
|
|
std::map<std::string, std::vector<float>> biases;
|
|
RAD_TRY(lora::compose_biases(*lora_keys_, ss, gen_bias_modules_, &rep.skipped, &biases, err));
|
|
if (validate_only && (!rep.unplaced.empty() || !rep.skipped.empty())) {
|
|
*err = "adapter combination is incompatible: " +
|
|
(!rep.unplaced.empty() ? rep.unplaced.front() : rep.skipped.front());
|
|
return RAD_E_INVAL;
|
|
}
|
|
if (rep.modules == 0 && biases.empty()) {
|
|
*err = "none of the adapters' modules is a module of this model" +
|
|
(rep.unplaced.empty() ? std::string() : " (" + rep.unplaced[0] + ")");
|
|
return RAD_E_NOTFOUND;
|
|
}
|
|
const std::map<std::string, lora::AdModule> mods = lora::as_modules(comp, *lora_keys_);
|
|
std::vector<std::vector<lora::PackedSite>> packed(ranks_.size());
|
|
std::vector<lora::AdapterInfo> placement(ranks_.size());
|
|
for (size_t ri = 0; ri < ranks_.size(); ++ri) {
|
|
const int s = lora::pack_modules(ranks_[ri]->lora_sites, rank, mods, &placement[ri], &packed[ri], err,
|
|
/*compact=*/true);
|
|
if (s < 0) {
|
|
if (ranks_.size() > 1) *err = fmt("rank %zu: ", ri) + *err;
|
|
return s;
|
|
}
|
|
/* Pools past the last one a site names hold nothing (lora_declare's dropped GEMMs). */
|
|
packed[ri].resize(ranks_[ri]->program.lora_pools.size());
|
|
}
|
|
LoraReplacements replacements;
|
|
RAD_TRY(gen_lora_prepare_replacements(comp, biases, &replacements, err));
|
|
if (validate_only) {
|
|
std::vector<std::map<std::string, std::string>> issues;
|
|
std::vector<std::set<std::string>> required_slices(ranks_.size());
|
|
std::set<std::string> mixers;
|
|
for (size_t i = 0; i < ranks_.size(); ++i) {
|
|
const auto& program = ranks_[i]->program;
|
|
issues.push_back(program.lora_placement_issues);
|
|
for (const auto& site : ranks_[i]->lora_sites) {
|
|
if (!site.gemm || site.gemm >= program.ops.size() ||
|
|
program.ops[site.gemm].lora_site < 0) continue;
|
|
for (const auto& source : site.sources)
|
|
if (source.targeted) required_slices[i].insert(source.module);
|
|
}
|
|
std::set<std::string> local;
|
|
for (const auto& [weight, replacement] : program.lora_replacements)
|
|
if (replacement.row_mixer) local.insert(replacement.module);
|
|
if (i == 0) mixers = std::move(local);
|
|
else std::erase_if(mixers, [&](const auto& name) { return !local.count(name); });
|
|
}
|
|
RAD_TRY(lora::check_generator_placement(placement, issues, mixers, err, required_slices));
|
|
if (!rep.unplaced.empty() || !rep.skipped.empty() || !rep.over_rank.empty() || rep.exact != rep.modules) {
|
|
*err = "adapter combination is not exact: " +
|
|
(!rep.unplaced.empty() ? rep.unplaced.front() :
|
|
!rep.skipped.empty() ? rep.skipped.front() : !rep.over_rank.empty() ? rep.over_rank + " has a structural rank upper bound above the slot capacity" :
|
|
rep.worst_module + " was approximated");
|
|
return RAD_E_INVAL;
|
|
}
|
|
return RAD_OK;
|
|
}
|
|
RAD_TRY(lora_copy(sl, packed, err, &replacements));
|
|
/* The ranks each pool takes in this slot, before a pass can name the slot (the publish). */
|
|
for (size_t ri = 0; ri < ranks_.size(); ++ri) {
|
|
Program& P = ranks_[ri]->program;
|
|
const size_t S = (size_t)cfg_.lora.slots();
|
|
for (size_t p = 0; p < P.lora_pools.size() && p < packed[ri].size(); ++p)
|
|
if (p * S + (size_t)sl < P.lora_rused.size())
|
|
P.lora_rused[p * S + (size_t)sl] = packed[ri][p].empty ? 0 : (int32_t)packed[ri][p].r_used;
|
|
}
|
|
lora_table_.publish(sl, key, "");
|
|
const double ms = std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - t0).count();
|
|
std::string n;
|
|
if (!rep.unplaced.empty())
|
|
n += fmt("%zu adapter module%s not on this model (%s)", rep.unplaced.size(),
|
|
rep.unplaced.size() == 1 ? "" : "s", rep.unplaced[0].c_str());
|
|
if (!rep.skipped.empty())
|
|
n += fmt("%s%zu skipped adapter tensor(s) (%s)", n.empty() ? "" : "; ",
|
|
rep.skipped.size(), rep.skipped.front().c_str());
|
|
if (rep.exact < rep.modules)
|
|
n += fmt("%s%lld module%s past rank %d were truncated to it, keeping at worst %.1f%% of the "
|
|
"delta (%s)", n.empty() ? "" : "; ", (long long)(rep.modules - rep.exact),
|
|
rep.modules - rep.exact == 1 ? "" : "s", rank, 100.0 * rep.worst_kept,
|
|
rep.worst_module.c_str());
|
|
RAD_INFO("lora: slot %d <- %s: %lld modules (%lld exact) in %.0f ms%s%s", sl, key.c_str(),
|
|
(long long)rep.modules, (long long)rep.exact, ms, n.empty() ? "" : "; ", n.c_str());
|
|
if (note) *note = n;
|
|
if (lora_table_.acquire(key, slot, &uid, hold) != RAD_OK) {
|
|
*err = "the combination's slot was taken back before the request could hold it; retry";
|
|
return RAD_E_STATE;
|
|
}
|
|
return RAD_OK;
|
|
}
|
|
|
|
} /* namespace rad */
|