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.
186 lines
8.4 KiB
C++
186 lines
8.4 KiB
C++
/* Public Engine API over a tiny synthetic generator on the host backend. No GPU or downloads. */
|
|
#include "rad_test.h"
|
|
#include "tiny_model.h"
|
|
#include "engine.h"
|
|
|
|
#include <algorithm>
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <sys/stat.h>
|
|
#include <utility>
|
|
|
|
namespace {
|
|
|
|
// The plugin registry is process-wide. Both tests use one isolated home, kept alive until exit,
|
|
// so unrelated stale plugins are excluded without changing the registry's identity between cases.
|
|
const std::string& generator_test_home() {
|
|
static tiny::TempDir directory("generator-lora-home");
|
|
static const std::string home = [&]() -> std::string {
|
|
if (!directory.ok()) return {};
|
|
const std::string path = directory / "home";
|
|
std::error_code error;
|
|
for (const char* sub : {"kernels", "architectures", "quantizers"}) {
|
|
std::filesystem::create_directories(path + "/" + sub, error);
|
|
if (error) return {};
|
|
}
|
|
for (const char* file : {"kernels/libref.so", "architectures/qwenimage21.so", "quantizers/libquant.so"}) {
|
|
if (!std::filesystem::copy_file(std::string(RAD_E2E_HOME) + "/" + file,
|
|
path + "/" + file, error) || error) return {};
|
|
}
|
|
return path;
|
|
}();
|
|
return home;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
TEST(discovered_replacements_and_explicit_reload_keep_in_flight_combinations) {
|
|
tiny::TempDir dir("generator-lora-engine");
|
|
REQUIRE(dir.ok());
|
|
const std::string pipeline = dir / "pipeline", library = dir / "loras";
|
|
REQUIRE_EQ(::mkdir(pipeline.c_str(), 0700), 0);
|
|
REQUIRE_EQ(::mkdir(library.c_str(), 0700), 0);
|
|
const std::string home = generator_test_home();
|
|
REQUIRE(!home.empty());
|
|
tiny::QwenImage shape;
|
|
shape.te_hidden = 128;
|
|
shape.te_head_dim = 32;
|
|
shape.te_ffn = 256;
|
|
REQUIRE(tiny::write_qwen_image(pipeline, shape));
|
|
const std::string model = dir / "tiny.rad";
|
|
std::string conversion_log;
|
|
const int conversion_status = tiny::run({RAD_E2E_CONVERT, pipeline, "-o", model, "--kernels", "libref"},
|
|
{std::string("RADIANCE_HOME=") + home, "ROCR_VISIBLE_DEVICES=99"},
|
|
&conversion_log, 60);
|
|
if (conversion_status != 0) std::fprintf(stderr, "conversion failed (%d):\n%s\n", conversion_status, conversion_log.c_str());
|
|
REQUIRE_EQ(conversion_status, 0);
|
|
const std::string path = library + "/local.safetensors", replacement = library + "/replacement";
|
|
auto write_adapter = [&](const std::string& to, float gain) {
|
|
tiny::Rng random(1);
|
|
const std::string key = "transformer.transformer_blocks.0.attn.to_q";
|
|
return tiny::write_safetensors(to, {
|
|
tiny::noise(key + ".lora_A.weight", {1, 128}, random, 0, gain, "F32"),
|
|
tiny::noise(key + ".lora_B.weight", {128, 1}, random, 0, 1, "F32")});
|
|
};
|
|
REQUIRE(write_adapter(path, 1));
|
|
rad::Config config;
|
|
config.model = model;
|
|
config.radiance_home = home;
|
|
config.kernel_hierarchy = {"libref"};
|
|
config.accept_reference_kernels = true;
|
|
config.max_seqs = 2;
|
|
config.max_ctx = 2048;
|
|
config.image_gen_max_pixels = 64 * 64;
|
|
config.prefix_cache = false;
|
|
config.lora.dir = library;
|
|
config.lora.max_rank = 2;
|
|
config.lora.max_loras = 3; // Each held revision remains live; no synthetic epoch advance.
|
|
rad::Engine engine(std::move(config));
|
|
REQUIRE_EQ(engine.start(), RAD_OK);
|
|
int32_t first_slot = -1, second_slot = -1, reloaded_slot = -1;
|
|
std::shared_ptr<void> first_hold, second_hold, reloaded_hold;
|
|
std::string note, why;
|
|
const std::vector<rad::Engine::LoraUse> uses = {{"local", 1.0}};
|
|
REQUIRE_EQ(engine.gen_lora_acquire(uses, &first_slot, &first_hold, ¬e, &why), RAD_OK);
|
|
REQUIRE(first_slot >= 0);
|
|
REQUIRE(first_hold.use_count() > 0);
|
|
REQUIRE(write_adapter(replacement, 2));
|
|
REQUIRE_EQ(::rename(replacement.c_str(), path.c_str()), 0);
|
|
REQUIRE_EQ(engine.gen_lora_acquire(uses, &second_slot, &second_hold, ¬e, &why), RAD_OK);
|
|
CHECK(second_slot != first_slot);
|
|
CHECK(first_hold.use_count() > 0);
|
|
int held = 0;
|
|
REQUIRE_EQ(engine.lora_unload("local", &why, &held), RAD_OK);
|
|
CHECK_EQ(held, 2);
|
|
auto names = engine.gen_lora_names();
|
|
CHECK(std::find(names.begin(), names.end(), "local") == names.end());
|
|
std::shared_ptr<void> rejected;
|
|
int32_t rejected_slot = -1;
|
|
CHECK_EQ(engine.gen_lora_acquire(uses, &rejected_slot, &rejected, ¬e, &why), RAD_E_NOTFOUND);
|
|
REQUIRE_EQ(engine.lora_load("local", path, &why), RAD_OK);
|
|
REQUIRE_EQ(engine.gen_lora_acquire(uses, &reloaded_slot, &reloaded_hold, ¬e, &why), RAD_OK);
|
|
CHECK(reloaded_slot != first_slot);
|
|
CHECK(reloaded_slot != second_slot);
|
|
names = engine.gen_lora_names();
|
|
CHECK(std::find(names.begin(), names.end(), "local") != names.end());
|
|
CHECK(first_hold.use_count() > 0);
|
|
CHECK(second_hold.use_count() > 0);
|
|
}
|
|
|
|
TEST(validation_keeps_the_only_held_slot_and_rejects_present_incompatible_files) {
|
|
tiny::TempDir dir("generator-lora-engine");
|
|
REQUIRE(dir.ok());
|
|
const std::string pipeline = dir / "pipeline", library = dir / "loras";
|
|
REQUIRE_EQ(::mkdir(pipeline.c_str(), 0700), 0);
|
|
REQUIRE_EQ(::mkdir(library.c_str(), 0700), 0);
|
|
const std::string home = generator_test_home();
|
|
REQUIRE(!home.empty());
|
|
tiny::QwenImage shape;
|
|
shape.te_hidden = 128;
|
|
shape.te_head_dim = 32;
|
|
shape.te_ffn = 256;
|
|
REQUIRE(tiny::write_qwen_image(pipeline, shape));
|
|
const std::string model = dir / "tiny.rad";
|
|
std::string conversion_log;
|
|
const int conversion_status = tiny::run({RAD_E2E_CONVERT, pipeline, "-o", model, "--kernels", "libref"},
|
|
{std::string("RADIANCE_HOME=") + home, "ROCR_VISIBLE_DEVICES=99"},
|
|
&conversion_log, 60);
|
|
if (conversion_status != 0) std::fprintf(stderr, "conversion failed (%d):\n%s\n", conversion_status, conversion_log.c_str());
|
|
REQUIRE_EQ(conversion_status, 0);
|
|
const std::string path = library + "/local.safetensors", replacement = library + "/replacement";
|
|
auto write_adapter = [&](const std::string& to, float gain) {
|
|
tiny::Rng random(1);
|
|
const std::string key = "transformer.transformer_blocks.0.attn.to_q";
|
|
return tiny::write_safetensors(to, {
|
|
tiny::noise(key + ".lora_A.weight", {1, 128}, random, 0, gain, "F32"),
|
|
tiny::noise(key + ".lora_B.weight", {128, 1}, random, 0, 1, "F32")});
|
|
};
|
|
REQUIRE(write_adapter(path, 1));
|
|
rad::Config config;
|
|
config.model = model;
|
|
config.radiance_home = home;
|
|
config.kernel_hierarchy = {"libref"};
|
|
config.accept_reference_kernels = true;
|
|
config.max_seqs = 2;
|
|
config.max_ctx = 2048;
|
|
config.image_gen_max_pixels = 64 * 64;
|
|
config.prefix_cache = false;
|
|
config.lora.dir = library;
|
|
config.lora.max_rank = 2;
|
|
config.lora.max_loras = 1;
|
|
rad::Engine engine(std::move(config));
|
|
REQUIRE_EQ(engine.start(), RAD_OK);
|
|
const std::string other = library + "/other.safetensors";
|
|
REQUIRE(write_adapter(other, 2));
|
|
const std::string incompatible = library + "/bias.safetensors";
|
|
tiny::Rng bias_random(9);
|
|
REQUIRE(tiny::write_safetensors(incompatible, {
|
|
tiny::noise("transformer.not_a_module.diff_b", {1}, bias_random, 0, 1, "F32")}));
|
|
int32_t first_slot = -1;
|
|
std::shared_ptr<void> first_hold;
|
|
std::string note, why;
|
|
const std::vector<rad::Engine::LoraUse> first = {{"local", 1.0}};
|
|
REQUIRE_EQ(engine.gen_lora_acquire(first, &first_slot, &first_hold, ¬e, &why), RAD_OK);
|
|
REQUIRE(first_slot >= 0);
|
|
REQUIRE(first_hold.use_count() > 0);
|
|
CHECK_EQ(engine.gen_lora_validate({{"other", 1.0}}, &why), RAD_OK);
|
|
CHECK(first_hold.use_count() > 0);
|
|
CHECK_EQ(engine.gen_lora_validate({{"bias", 1.0}}, &why), RAD_E_INVAL);
|
|
CHECK(why.find("unsupported bias target") != std::string::npos);
|
|
CHECK_EQ(engine.gen_lora_validate({{"missing", 1.0}}, &why), RAD_E_NOTFOUND);
|
|
std::shared_ptr<void> reacquired, rejected;
|
|
int32_t same_slot = -1, rejected_slot = -1;
|
|
REQUIRE_EQ(engine.gen_lora_acquire(first, &same_slot, &reacquired, ¬e, &why), RAD_OK);
|
|
CHECK_EQ(same_slot, first_slot);
|
|
CHECK_EQ(engine.gen_lora_acquire({{"other", 1.0}}, &rejected_slot, &rejected, ¬e, &why), RAD_E_FULL);
|
|
CHECK(!rejected);
|
|
CHECK(first_hold.use_count() > 0);
|
|
}
|
|
|
|
int main(int argc, char** argv) {
|
|
::setenv("ROCR_VISIBLE_DEVICES", "99", 1);
|
|
::setenv("RADIANCE_HOST_VRAM_MIB", "2048", 1);
|
|
::setenv("OMP_NUM_THREADS", "2", 1);
|
|
return radtest::run_all(argc, argv);
|
|
}
|