merge origin/main: the upstream LoRA-runtime refactor beneath the ref2va port

Merges upstream 1.10.0 (152 commits: the LoRA acquire/runtime refactor, the
form-1 LTX-2 scheduler family, guidance terms + negative prompts, decoder
selection, input_reference, new architectures) into the ref2va port branch.
Resolution rule throughout: keep BOTH feature sets; ABI numbering follows
upstream (RAD_ABI_VERSION 26, RAD_FORMAT_VER 2), with the port's video fields
unioned into RadVideoGenBatch/RadVideoGenDecl and abi_layout_table.h
regenerated from the live table.

Notable reconciliations:
  * videos.cpp: the task grammars are disjoint by capability -- keyframe tasks
    (i2va/l2va/flash-attn l2va/fl2va) are recognized only when decl.encodes,
    so upstream models keep refusing them as unknown tasks; input_reference,
    the LoRA tag/field pipeline, and the guidance/negative_prompt rendering
    coexist with refs/ref2va; the prompt put() helper hoisted to block scope
    for the media branch.
  * video_schedule(): upstream's (steps, video_tokens, refine) keeps its
    positional slots; the port's shift_video/shift_audio overrides move to the
    tail so upstream's schedule tests call unchanged.
  * r4d_selftest conv3d cases: the port's sp/st/causal/down/refl geometry and
    upstream's tpad/tpre fold into one reference (ft = causal ? 2 : tpad==2 ?
    2+tpre : 1); rms_mod rows keep the port's i8/fp8 quant modes alongside
    upstream's wadd/norm_once/norm parameters.
  * tests/oot_plugins.sh: the per-plugin cmake --install gains a --prefix
    staging dir -- plugin .so files still land in the absolute
    RAD_PLUGIN_INSTALL_HOME, but libr4d now also installs r4d_selftest to a
    relative bin/, which needs no root.

Host ctest: 112/113 (mm_test's webp gap pre-exists this merge); r4d_selftest,
engine_e2e, oot_plugins, abi_layout, all LoRA tests green.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
gearwave00001andClaude committed 2026-10-22 18:38:04 -05:00
commit a1a75da7e9
415 files changed
+78837 -5310

No files matched your search

+193 -57
View File
@@ -5,6 +5,7 @@
* Separate from engine.cpp (the hot step loop), with which it shares only the Engine's fields.
*/
#include "engine_priv.h"
#include "rad_internal.h"
#include "engine_hostmem.h"
#include "gen/driver.h"
#include "gen/audio_driver.h"
@@ -275,10 +276,11 @@ static void report_pool_refusal(int rank, int device, const Pools& pools, const
}
/* ------------------------------------------------------------------ locked host memory */
/* Host memory left free beside a table locked whole: the process's unpooled allocations, the
* load's staging windows, and the page cache holding the container's hot pages. Without it the
* kernel reclaims the files the engine reads, then the OOM killer runs. */
static const int64_t kLockMargin = (int64_t)4 << 30;
/* The margin (--host-headroom-mib, Engine::host_headroom_bytes): host memory left free beside a
* table locked whole -- the process's unpooled allocations, the load's staging windows, and the
* page cache holding the container's hot pages. Without it the kernel reclaims the files the
* engine reads, then the OOM killer runs. It is dead RAM by design; a host that can reclaim
* cheaply trades it for pool, cache or slots. */
/* Every level of every memory cgroup the process is in, leaf first: `visit(dir, room)` until it
* returns false (cgroup_levels). /proc/self/cgroup reads "0::/path" on v2 and "N:memory:/path"
@@ -309,12 +311,13 @@ static void memory_cgroups(const std::function<bool(const std::string&, int64_t)
}
/* Whether `need` more bytes fit in host memory after `still` more this process will allocate
* first, or why not. Checks MemAvailable; every memory cgroup from the process's own up to the
* visible root (Docker's --memory, enforced by the OOM killer); and, for an mlock()ed copy
* (`mlocks`), RLIMIT_MEMLOCK unless the process has CAP_IPC_LOCK. Pinned memory a card reads is a
* driver userptr mapping, which RLIMIT_MEMLOCK does not count. An unreadable limit is ignored,
* never guessed. */
static bool lockable_room(int64_t need, int64_t still, bool mlocks, std::string* why) {
* first and `margin` (--host-headroom-mib) stays free, or why not. Checks MemAvailable; every
* memory cgroup from the process's own up to the visible root (Docker's --memory, enforced by
* the OOM killer); and, for an mlock()ed copy (`mlocks`), RLIMIT_MEMLOCK unless the process has
* CAP_IPC_LOCK. Pinned memory a card reads is a driver userptr mapping, which RLIMIT_MEMLOCK
* does not count. An unreadable limit is ignored, never guessed. */
static bool lockable_room(int64_t need, int64_t still, int64_t margin, bool mlocks,
std::string* why) {
long long locked_kb = 0;
unsigned long long caps = 0;
{
@@ -334,43 +337,44 @@ static bool lockable_room(int64_t need, int64_t still, bool mlocks, std::string*
return false;
}
if (const int64_t avail = meminfo_bytes("MemAvailable");
avail >= 0 && avail - still - kLockMargin < need) {
avail >= 0 && avail - still - margin < need) {
*why = fmt("%s of memory is available, %s more is still to be allocated (the pinned host "
"pools, the prefix cache's host tier, the checkpoint slots and the host "
"activation arenas), and this wants %s with %s to spare",
"activation arenas), and this wants %s with %s to spare "
"(--host-headroom-mib)",
humanb(avail).c_str(), humanb(still).c_str(), humanb(need).c_str(),
humanb(kLockMargin).c_str());
humanb(margin).c_str());
return false;
}
bool fits = true;
memory_cgroups([&](const std::string& dir, int64_t room) {
if (room - still - kLockMargin >= need) return true;
if (room - still - margin >= need) return true;
*why = fmt("the memory cgroup at %s leaves %s, %s more is still to be allocated, "
"and this wants %s with %s to spare", dir.c_str(),
"and this wants %s with %s to spare (--host-headroom-mib)", dir.c_str(),
humanb(room).c_str(), humanb(still).c_str(), humanb(need).c_str(),
humanb(kLockMargin).c_str());
humanb(margin).c_str());
fits = false;
return false;
});
return fits;
}
/* The most lockable_room(need, still, false) admits, and in `limit` the bound that decides it.
* INT64_MAX when no limit can be read. */
static int64_t lockable_bytes(int64_t still, std::string* limit) {
/* The most lockable_room(need, still, margin, false) admits, and in `limit` the bound that
* decides it. INT64_MAX when no limit can be read. */
static int64_t lockable_bytes(int64_t still, int64_t margin, std::string* limit) {
int64_t most = INT64_MAX;
*limit = "no readable memory limit";
if (const int64_t avail = meminfo_bytes("MemAvailable"); avail >= 0) {
most = avail - still - kLockMargin;
most = avail - still - margin;
*limit = fmt("%s of memory available, less %s still to be allocated and %s to spare",
humanb(avail).c_str(), humanb(still).c_str(), humanb(kLockMargin).c_str());
humanb(avail).c_str(), humanb(still).c_str(), humanb(margin).c_str());
}
memory_cgroups([&](const std::string& dir, int64_t room) {
if (room - still - kLockMargin < most) {
most = room - still - kLockMargin;
if (room - still - margin < most) {
most = room - still - margin;
*limit = fmt("the memory cgroup at %s, which leaves %s, less %s still to be allocated "
"and %s to spare", dir.c_str(), humanb(room).c_str(),
humanb(still).c_str(), humanb(kLockMargin).c_str());
humanb(still).c_str(), humanb(margin).c_str());
}
return true;
});
@@ -470,7 +474,9 @@ int Engine::resolve_table_placement(const std::vector<VramFacts>& facts,
const int64_t pools_still = (int64_t)cfg_.tp * cfg_.host_pool_mib * MiB +
cfg_.prefix_cache_mib * MiB + host_late;
std::string emb_room_why;
auto emb_room = [&]() { return lockable_room(emb_pin, pools_still, false, &emb_room_why); };
auto emb_room = [&]() {
return lockable_room(emb_pin, pools_still, host_headroom_bytes(), false, &emb_room_why);
};
if (emb_max == 0) {
if (emb == TablePlacement::Ram && emb_asked) {
RAD_ERR("--embedding-placement ram: this model has no token embedding table that only "
@@ -525,7 +531,7 @@ int Engine::resolve_table_placement(const std::vector<VramFacts>& facts,
std::string why;
const int64_t pin = (int64_t)cfg_.tp * align_up(tower_max, (int64_t)MiB);
if (!lockable_room(pin, pools_still + (int64_t)cfg_.tp * cfg_.embedding_host_mib * MiB,
false, &why)) {
host_headroom_bytes(), false, &why)) {
RAD_ERR("--vision-tower-placement ram: the encoder towers (%s a rank, pinned on every "
"rank) cannot be held in host memory: %s. Use vram.", humanb(tower_max).c_str(),
why.c_str());
@@ -609,7 +615,8 @@ int Engine::resolve_table_placement(const std::vector<VramFacts>& facts,
} else {
std::string card_why, ram_why;
const bool card = ng == TablePlacement::Auto && ngram_device && card_holds(&card_why);
const bool room = !card && lockable_room(need, still, !ngram_device, &ram_why);
const bool room =
!card && lockable_room(need, still, host_headroom_bytes(), !ngram_device, &ram_why);
if (ng == TablePlacement::Ram) {
if (!room) {
RAD_ERR("--ngram-placement ram: the n-gram table (%s) cannot be held in memory as "
@@ -875,7 +882,9 @@ RadBuildCtx Engine::build_ctx(int rank, int64_t max_tok) const {
bc.tp_wire_lossy = cfg_.tp_wire_exact ? 0 : 1;
/* The engine always states the KV dtype. RAD_DT_INVALID (zero) remains valid in the ABI for
* other callers and means the plugin's default. */
bc.kv_dtype = cfg_.kv_cache_dtype == "fp8" ? RAD_F8E4M3 : RAD_BF16;
bc.kv_dtype = cfg_.kv_cache_dtype == "bf16" ? RAD_BF16 : RAD_F8E4M3;
bc.kv_quant = cfg_.kv_cache_dtype == "fp8_v4" ? RAD_KVQ_V4
: cfg_.kv_cache_dtype == "k6_v4" ? RAD_KVQ_K6V4 : RAD_KVQ_NONE;
bc.tp_wire_min_bytes = cfg_.tp_wire_min_kb * 1024;
bc.scope = "";
bc.max_enc_patches = cfg_.mm_max_patches > 0 ? cfg_.mm_max_patches : 0;
@@ -886,6 +895,12 @@ RadBuildCtx Engine::build_ctx(int rank, int64_t max_tok) const {
/* Under --prefill-span every step but a lone prefill is planned at the shared budget
* (Scheduler::step), so a wider step is one sequence; 0 without a span. */
bc.max_mixed_tok = cfg_.prefill_span > 1 ? std::min(max_tok, prefill_shared_tok(cfg_)) : 0;
/* The control vector, when one is loaded: this rank's view, or null. A plugin reads it at
* declare only (the direction table never changes); the per-request switch rides the derived
* mask, not this struct. */
if (cvec_.loaded() && rank >= 0 && rank < (int) cvec_views_.size() &&
cvec_views_[(size_t) rank].dir)
bc.cvec = &cvec_views_[(size_t) rank];
return bc;
}
@@ -991,6 +1006,19 @@ int Engine::declare() {
cfg_.prefix_cache = false;
}
}
/* fp8_v4 and k6_v4 are layouts only the plugin and libr4d's rows for them know. A plugin that
* does not say it serves one (RadArchProbe::kv_quant_ok) would store plain E4M3 under a name
* that promised a smaller cache, so the flag is refused rather than ignored. */
if (cfg_.kv_cache_dtype == "fp8_v4" || cfg_.kv_cache_dtype == "k6_v4") {
const int q = cfg_.kv_cache_dtype == "fp8_v4" ? RAD_KVQ_V4 : RAD_KVQ_K6V4;
RadArchProbe pb{};
(void)rad_tools_probe(plugins_, meta_, &pb);
if (!(pb.kv_quant_ok & (1 << q))) {
RAD_ERR("--kv-cache-dtype %s: the '%s' plugin does not serve it for this model "
"(fp8 does)", cfg_.kv_cache_dtype.c_str(), plugins_.arch_plugin.c_str());
return RAD_E_UNSUPPORTED;
}
}
/* Resolved here, not at argument parsing: the plugin states its drafter's depth, and it is
* selected only once the container is open. Every consumer of `n_spec` (buffer sizing, kernel
* bands, the scheduler's window) runs after this. rad_arch_probe is the core's only source of
@@ -1008,6 +1036,25 @@ int Engine::declare() {
cfg_.n_spec > 0 ? "the depth the drafter in this container states as its operating point"
: "this container carries no draft head");
}
/* Chained launches pay on some speculative steps and cost plain decode (4x R9700: the 31B
* with DFlash2 +13%, the 26B-A4B with DFlash +1%, Qwen3.8-27B with DFlash2 even; the 31B with
* no drafter -6.5%), so they are on by default only where the model's plugin measured a gain
* with its speculative drafter (RadArchProbe::chain_pays) and that drafter decodes
* speculatively. */
{
RadArchProbe pb{};
(void)rad_tools_probe(plugins_, meta_, &pb);
rad_dev_chain_infer(cfg_.n_spec > 0 && pb.chain_pays);
const char* e = std::getenv("RADIANCE_CHAIN");
const bool on = rad_dev_chain_enabled() != 0;
const char* why = e && *e && std::strcmp(e, "auto") != 0
? (on || *e == '0' ? "RADIANCE_CHAIN says so" : "the backend does not chain")
: on ? "the model's plugin measured a gain with its speculative drafter"
: "no drafter whose plugin measured a gain with them decodes "
"speculatively, or the backend does not chain";
RAD_INFO("chained launches: %s -- %s", on ? "on" : "off", why);
decide("RADIANCE_CHAIN", on ? "1" : "0", why);
}
/* The audio encoder's pass: the plugin's longest clip, when the model file carries an audio
* encoder (`radiance.encoder` names one) and the deployment is not text-only. */
if (cfg_.mm_audio_frames < 0) {
@@ -1051,6 +1098,64 @@ int Engine::declare() {
* a serial loop times out. Registry::select() and init_instance() share a mutex for this. Each
* thread binds its device first, because the current device is thread-local and the init
* allocates on it. */
/* Control vectors are resolved here, before any rank declares: the plugin reads the direction
* table from RadBuildCtx, so a table that failed validation must stop the server before a graph
* is built around it.
*
* The feature is loaded only when the deployment asks: `--control-vector off|on`. Without it
* nothing is looked for, the graph declares no projection op, and a request that asks for one
* is refused by name -- so a deployment that does not use the feature pays nothing. With the
* flag, the engine looks beside the container (or in the directory, or in
* $RADIANCE_HOME/vectors) and uses the file if it is compatible; its operation parameters come
* from the package's own JSON. A file that does not fit is reported and skipped -- a sidecar
* must never stop a server nobody pointed at it. The flag's value is the startup switch: `off`
* leaves requests off until one asks (or the dashboard flips the default), `on` starts them on. */
const std::string arch = meta_.arch_id ? meta_.arch_id : "";
if (cfg_.control_vector == "disabled") {
RAD_INFO("control vectors: not loaded (no --control-vector); a request that asks for one is "
"refused");
} else if (!arch.empty()) {
std::string proj_path, tried;
(void) control_vector_discover(cfg_.model, arch, cfg_.radiance_home, &proj_path, &tried);
if (proj_path.empty()) {
RAD_INFO("control vectors: none found (%s)", tried.c_str());
} else if (arch != "qwen4exp") {
RAD_WARN("control vectors: %s is for this family only (qwen4exp, whose gated residual "
"carries the projection op); this container is '%s' -- ignoring it",
proj_path.c_str(), arch.c_str());
} else {
std::string why;
const int rc = control_vector_load(proj_path, arch, meta_.n_embd, meta_.n_layers,
&cvec_, &why);
if (rc != RAD_OK) {
RAD_WARN("%s -- serving without it", why.c_str());
cvec_ = ControlVector{};
}
}
}
if (cvec_.loaded()) {
cvec_views_.assign(ranks_.size(), RadControlVector{});
cvec_salt_ = control_vector_salt(cvec_);
/* `--control-vector on` starts the request default on, which is also how `--kld-record`/
* `--kld-ref` score the projection itself: those modes serve no request to carry the
* switch. The switch still decides per request. */
const bool default_on = cfg_.control_vector == "on";
cvec_default_.store(default_on);
RAD_INFO("control vectors: %s: %lld directions of %lld, layers %d..%d, scale %.3f -- "
"default %s%s",
cvec_.path.c_str(), (long long) cvec_.n_dirs,
(long long) cvec_.n_embd, cvec_.first, cvec_.last, (double) cvec_.user_scale,
default_on ? "ON" : "off",
default_on ? " (--control-vector on; a request can still say false)"
: " until a request asks for it (the dashboard's switch, or a request's "
"`control_vector` field)");
decide("control vectors", cvec_.path,
"found beside the container, in its directory, or in $RADIANCE_HOME/vectors; "
"requests opt in");
} else {
cvec_default_.store(false);
}
std::vector<int> st(ranks_.size(), RAD_OK);
std::vector<std::thread> th;
th.reserve(ranks_.size());
@@ -1064,6 +1169,17 @@ int Engine::declare() {
st[(size_t)ri] = RAD_E_DEVICE;
return;
}
/* This rank's copy of the control vector's directions, on the device the thread has
* just bound. Uploaded outside the program's arena: it is not a weight (it is not in
* the container) and not an activation (it lives for the deployment). */
if (cvec_.loaded()) {
const float* d = control_vector_upload(cvec_, ri);
if (!d) {
st[(size_t)ri] = RAD_E_DEVICE;
return;
}
cvec_views_[(size_t)ri] = control_vector_view(cvec_, d);
}
const RadBuildCtx bc = build_ctx(ri, cfg_.max_tok);
LoraDeclare ld;
ld.cfg = &cfg_.lora;
@@ -1361,18 +1477,6 @@ int Engine::plan() {
ngram_bytes = std::max(ngram_bytes, wf.ngram);
ngram_device = ngram_device || wf.ngram_device;
ngram_host = ngram_host || wf.ngram_host;
/* One --max-model-len sequence's cache: the least a KV pool can hold and still serve
* every acceptable request (configure_kv warns below it). --ngram-placement auto puts
* the table on the card only if the pool stays above it. */
{
Config one = cfg_;
one.max_seqs = 1;
KVManager single;
if (single.plan_groups(r->program.kv_groups, one) == RAD_OK) {
kv_floor = std::max(kv_floor, single.ceiling(ctx));
f.kv_one = single.ceiling(ctx);
}
}
/* The staging region is sized only where the arena lends its top: without smaller
* levels nothing returns it to the slab at decode, and a deterministic plan moves
* nothing. */
@@ -1385,6 +1489,13 @@ int Engine::plan() {
ck_slot += probe.checkpoint_bytes();
f.kv_ceiling = probe.ceiling(ctx);
f.kv_fixed = probe.fixed_bytes();
/* One --max-model-len sequence's pool, as the inverse of the real plan: its
* recurrent and conv slots stay allocated with one request active, which a
* separate one-sequence plan would leave out. */
const int64_t MiB = 1ll << 20;
const int64_t need = probe.pool_mib_for_tokens(ctx, (f.kv_ceiling + MiB - 1) / MiB);
if (need >= 0) f.kv_one = need * MiB;
kv_floor = std::max(kv_floor, f.kv_one);
}
/* The step batch's device staging, reserved by the scheduler after this split: block
* tables for max_seqs sequences at max_ctx, media staging for max_tok encoder rows.
@@ -1440,6 +1551,11 @@ int Engine::plan() {
const int64_t ck_cap = INT64_MAX / 8;
const int64_t ck_store = !cfg_.prefix_cache || ck_slot <= 0 ? 0
: ck_n > ck_cap / ck_slot ? ck_cap : ck_slot * ck_n;
/* The direction table was allocated in declare(); it is not part of the program, and
* claiming its bytes back keeps a deployment that offers a vector planning against the
* same card as one that does not (VramFacts::held_out). */
const int64_t cvec_bytes = cvec_.loaded() ? (int64_t) cvec_.dir.size() * 4 : 0;
for (VramFacts& f : facts) f.held_out = cvec_bytes;
RAD_TRY(resolve_table_placement(facts, emb_bytes, wfs, kv_floor, ngram_bytes,
ngram_device, ngram_host, ck_store + host_arenas));
/* The n-gram table was counted off the card; on it, every rank holds the whole table. */
@@ -2773,7 +2889,7 @@ int Engine::size_checkpoint_store(int64_t slot, const char* what) {
int64_t still = cfg_.prefix_cache_mib * ((int64_t)1 << 20);
for (const auto& r : ranks_) still += arena_host_bytes(r->program);
std::string limit;
int64_t room = lockable_bytes(still, &limit);
int64_t room = lockable_bytes(still, host_headroom_bytes(), &limit);
if (!device_is_host()) {
bool lifted = false;
if (const int64_t cap = amdgpu_pin_cap(&lifted); cap > 0) {
@@ -2916,7 +3032,8 @@ int Engine::configure_kv() {
};
if (!sized) return refuse("no host has");
std::string why;
if (!lockable_room(slot * n, 0, false, &why)) return refuse("does not fit: " + why);
if (!lockable_room(slot * n, 0, host_headroom_bytes(), false, &why))
return refuse("does not fit: " + why);
if (ck_store_.open(slot, slot * n) != RAD_OK)
return refuse(std::string("the host did not pin: ") + rad_dev_last_error());
if (!sized_auto)
@@ -2943,21 +3060,17 @@ int Engine::configure_kv() {
{
const bool tier_asked = cfg_.prefix_cache_mib > 0;
const std::vector<int32_t>& cg = ranks_[0]->prefix.cached_groups();
/* One slot holds every rank's shard of an entry; each rank writes only its window. Shards
* can differ or be empty (uneven heads, rad_kv_group_zero), so a slot is the sum and each
* window starts where the previous ends. TierExec::sizes uses the largest rank's entry,
* since the staging ring is per rank. */
std::vector<int64_t> rank_entry(ranks_.size(), 0), entry_off(ranks_.size(), 0);
int64_t entry_bytes = 0, slot_bytes = 0;
for (size_t i = 0; i < ranks_.size(); ++i) {
for (int32_t g : cg) {
const KVGroupPlan* p = ranks_[i]->kv.plan(g);
if (p && p->paged()) rank_entry[i] += p->bytes_per_block;
}
entry_off[i] = slot_bytes;
slot_bytes += rank_entry[i];
entry_bytes = std::max(entry_bytes, rank_entry[i]);
}
/* One slot holds the whole engine's entry: the groups every rank holds alike
* (rad_kv_group_replicated) once, at the front, then every rank's own shard in its own
* window. Shards can differ or be empty (uneven heads, rad_kv_group_zero). The layout is
* TierExec's, so the arithmetic here and the copies agree; TierExec::sizes takes the
* largest rank's entry, since the staging ring is per rank. */
std::vector<const KVManager*> rank_kv;
for (auto& r : ranks_) rank_kv.push_back(&r->kv);
TierExec::SlotLayout layout;
RAD_TRY(TierExec::slot_layout(rank_kv, cg, &layout));
const std::vector<int64_t>& entry_off = layout.own_off;
const int64_t entry_bytes = layout.entry_bytes, slot_bytes = layout.slot_bytes;
/* Snapshots live in the checkpoint store (--checkpoint-slots); --prefix-cache-mib is for
* blocks only. */
@@ -2985,6 +3098,20 @@ int Engine::configure_kv() {
* fit is right after the turn. */
const int64_t held = T.arena().capacity() * tc.block_tokens;
const int64_t ctx = cfg_.max_ctx > 0 ? cfg_.max_ctx : meta_.n_ctx_train;
if (layout.rep_bytes > 0 && ranks_.size() > 1) {
/* What the slot would be with every rank's copy of the replicated groups. */
const int64_t each = slot_bytes + layout.rep_bytes * (int64_t)(ranks_.size() - 1);
std::string names;
for (const std::string& n : layout.replicated)
names += (names.empty() ? "" : ", ") + n;
RAD_INFO("kv tiers: %s (%s of each entry) is the same on every rank and held "
"once a slot: %s a slot rather than %s, so --prefix-cache-mib %lld "
"holds %lld tokens rather than %lld",
names.c_str(), humanb(layout.rep_bytes).c_str(),
humanb(slot_bytes).c_str(), humanb(each).c_str(),
(long long)cfg_.prefix_cache_mib, (long long)held,
(long long)(tc.host_cap_bytes / each * tc.block_tokens));
}
if (held < ctx)
RAD_WARN("kv tiers: --prefix-cache-mib %lld holds %lld tokens of context (%s "
"per %lld-token block), less than one --max-model-len %lld "
@@ -3112,6 +3239,7 @@ int Engine::configure_kv() {
/* ================================================================== start */
int Engine::start() {
startup_begin_ns_ = rad_mono_ns();
std::vector<int> devs;
std::string inventory;
std::string devnote;
@@ -3654,6 +3782,14 @@ int Engine::load_vocab() {
auto v = std::make_shared<Vocab>();
RAD_TRY(v->load(std::move(vb)));
vocab_ = v;
if (file_ && file_->aux_vocab()) {
VocabBuild ab;
RAD_TRY(vocab_deserialize(file_->base(), (uint64_t)file_->size(), file_->aux_vocab().h, ab));
auto av = std::make_shared<Vocab>();
RAD_TRY(av->load(std::move(ab)));
aux_vocab_ = av;
RAD_INFO("vocab: a second vocabulary of %d tokens", aux_vocab_->n_tokens());
}
auto view = std::make_unique<TokenView>();
RAD_TRY(view->init(vocab_));