radiance 1.10.0

LoRA for image and video generators:
- civitai and Hugging Face adapter files as published: kohya, ComfyUI and diffusers/PEFT key names;
  LoRA, LoCon, LoHa, LoKr and full-weight diffs; DoRA, OFT and Tucker are refused by name
- stacked per request with a strength each, through the `loras` field or <lora:name:strength> tags
  in the prompt; --lora-dir serves every file in a directory, GET /v1/loras lists them, and
  --max-loras / --max-lora-rank size the slots on the card (generators default to rank 64)
- Krea 2, Qwen-Image 2.1, FLUX.3 [klein], MiniMax H3, LTX-2.5, Anima and SDXL

New models:
- Anima (base, aesthetic and turbo): Cosmos-Predict2 DiT with the Qwen3-0.6B text encoder and the
  Qwen-Image VAE, on one card
- Stable Diffusion XL and its single-file finetunes (Illustrious, NoobAI including V-Pred, Pony),
  read as civitai ships them, with the Euler, Euler a and DPM++ 2M samplers

Recipes:
- q38-27b-mxfp4-df2: any bf16 Qwen3.8-27B or finetune at MXFP4 with the DFlash2 drafter
- Krea 2 finetunes from civitai: scripts/krea2_native.py reads Krea's own key names, and
  krea-2-fp8-unscaled keeps a plain-fp8 file's codes exactly

Changes: --max-num-batched-tokens defaults to 2048 (was 8192). Plugin ABI 25: out-of-tree plugins
must be rebuilt.
This commit is contained in:
Deadcode committed 2026-10-20 21:05:16 +02:00
1 parent 685ec5bd85
commit 4246a1dd04
124 files changed
+14326 -387

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
# Built in radiance's tree, or standalone against an installed radiance
# (`cmake -S arch/anima -B build -DCMAKE_PREFIX_PATH=<radiance prefix>`); see cmake/RadAddPlugin.cmake.
if(NOT COMMAND rad_add_plugin)
cmake_minimum_required(VERSION 3.21)
project(anima LANGUAGES CXX)
find_package(radiance REQUIRED)
rad_plugin_defaults()
endif()
rad_add_plugin(anima architectures SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/anima.cpp)
+1367
View File
File diff suppressed because it is too large. Load diff
+22
View File
@@ -432,6 +432,28 @@ inline int map_rows(RadBuilder* b, const char* declared, std::initializer_list<R
return rad_decl_name_map(b, &m);
}
/* How adapter files name a generator's modules (rad_lora_root, rad_lora_alias): one network
* under the checkpoint prefix `native`, the prefixes adapter keys use for it, and the module paths
* that differ, '#' standing for a block index. */
struct LoraName {
std::string from, to;
int64_t from_lo = 0, from_hi = 0, to_lo = 0;
};
inline int lora_names(RadBuilder* b, const char* native, const char* spellings,
const std::vector<LoraName>& names) {
const int s = rad_lora_root(b, native, spellings);
if (s < 0) return s;
for (const LoraName& n : names) {
const int a = rad_lora_alias(b, native, n.from.c_str(), n.to.c_str(), n.from_lo, n.from_hi,
n.to_lo);
if (a < 0) return a;
}
return RAD_OK;
}
/* The prefixes ComfyUI, kohya and bare-key adapter files put before a diffusion model's modules. */
inline const char* kLoraDiffusionSpellings = "diffusion_model. model.diffusion_model. lora_unet_ "
"base_model.model. -";
/* A weight-normalised checkpoint tensor folded into its plain weight (RAD_MAP_WNORM). */
inline int map_wnorm(RadBuilder* b, const char* declared, const char* g, const char* v) {
RadNameMap m = map_base(declared, RAD_MAP_WNORM);
+26
View File
@@ -937,6 +937,32 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
m.b_mask = decl_b(b, nm.f("lat_mask"), RAD_F32, { lane_rows, 1 }, RAD_BUF_PERSIST);
m.b_store = decl_b(b, nm.f("cond_store"), RAD_BF16,
{ 2 * (int64_t)kMaxLanes * cond_rows(), gd.n_embd }, RAD_BUF_PERSIST);
/* ---- adapter key names. LoRA files name the blocks by Black Forest Labs' modules, as
* ComfyUI loads them (comfy/ldm/flux3): `single_blocks.N.q_proj` or a fused `qkv`,
* `attn_out`, `mlp_in`, `mlp_out`, and the mode blocks under `content_mode_blocks`. */
{
const int64_t Q = gd.n_head_all * gd.head_dim;
std::vector<LoraName> n;
static const char* const kBlocks[][2] = {
{ "single_blocks.#.", "single_transformer_blocks.#." },
{ "txt_mode_blocks.#.", "txt_mode_blocks.#." },
{ "content_mode_blocks.image.#.", "mode_blocks.image.#." },
{ "content_mode_blocks.image_cond.#.", "mode_blocks.image_cond.#." },
};
for (const auto& bl : kBlocks) {
const std::string f = bl[0], t = bl[1];
n.push_back({ f + "q_proj", t + "attn.to_q" });
n.push_back({ f + "k_proj", t + "attn.to_k" });
n.push_back({ f + "v_proj", t + "attn.to_v" });
n.push_back({ f + "qkv", t + "attn.to_q", 0, Q, 0 });
n.push_back({ f + "qkv", t + "attn.to_k", Q, 2 * Q, 0 });
n.push_back({ f + "qkv", t + "attn.to_v", 2 * Q, 3 * Q, 0 });
n.push_back({ f + "attn_out", t + "attn.to_out.0" });
n.push_back({ f + "mlp_in", t + "ff.linear_in" });
n.push_back({ f + "mlp_out", t + "ff.linear_out" });
}
RAD_ARCH_TRY(lora_names(b, "transformer.", kLoraDiffusionSpellings, n));
}
RAD_ARCH_TRY(declare_te(b, meta, m));
RAD_ARCH_TRY(declare_encoder(b, meta, m));
RAD_ARCH_TRY(declare_dit(b, meta, m));
+31
View File
@@ -297,6 +297,36 @@ static int check_format(const RadModelMeta* meta) {
return RAD_OK;
}
/* ================================================================== adapter key names */
/* LoRA files for Krea 2 name the DiT and the text fusion by the reference code's modules
* (krea-ai/krea-2 mmdit.py): `blocks.N.attn.wq`, `txtfusion.refiner_blocks.N.mlp.up`, `tproj.1`;
* the container keeps diffusers' names. The language model takes no adapters. */
static int declare_lora_names(RadBuilder* b) {
std::vector<LoraName> n;
static const char* const kInner[][2] = {
{ "attn.wq", "attn.to_q" }, { "attn.wk", "attn.to_k" }, { "attn.wv", "attn.to_v" },
{ "attn.wo", "attn.to_out.0" }, { "attn.gate", "attn.to_gate" },
{ "mlp.gate", "ff.gate" }, { "mlp.up", "ff.up" }, { "mlp.down", "ff.down" },
};
static const char* const kBlocks[][2] = {
{ "blocks.#.", "transformer_blocks.#." },
{ "txtfusion.layerwise_blocks.#.", "text_fusion.layerwise_blocks.#." },
{ "txtfusion.refiner_blocks.#.", "text_fusion.refiner_blocks.#." },
};
for (const auto& bl : kBlocks)
for (const auto& in : kInner)
n.push_back({ std::string(bl[0]) + in[0], std::string(bl[1]) + in[1] });
n.push_back({ "txtfusion.projector", "text_fusion.projector" });
n.push_back({ "txtmlp.1", "txt_in.linear_1" });
n.push_back({ "txtmlp.3", "txt_in.linear_2" });
n.push_back({ "first", "img_in" });
n.push_back({ "last_linear", "final_layer.linear" });
n.push_back({ "tmlp.0", "time_embed.linear_1" });
n.push_back({ "tmlp.2", "time_embed.linear_2" });
n.push_back({ "tproj.1", "time_mod_proj" });
return lora_names(b, "transformer.", kLoraDiffusionSpellings, n);
}
/* ================================================================== declare */
static int declare_te(RadBuilder* b, const RadModelMeta* meta, Model& m) {
Geom& g = m.gt;
@@ -1059,6 +1089,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
m.b_prev = decl_b(b, nm.f("lat_preview"), RAD_BF16, { lane_rows, m.C }, RAD_BUF_PERSIST);
m.b_store = decl_b(b, nm.f("cond_store"), RAD_BF16,
{ 2 * (int64_t)kMaxLanes * kCondRows, gd.n_embd }, RAD_BUF_PERSIST);
RAD_ARCH_TRY(declare_lora_names(b));
RAD_ARCH_TRY(declare_te(b, meta, m));
RAD_ARCH_TRY(declare_fusion(b, meta, m));
RAD_ARCH_TRY(declare_dit(b, meta, m));
+3
View File
@@ -3240,6 +3240,9 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
/* ---- in issue order: the conditioning pass, the step, the frames, the soundtrack, the
* upscale */
/* LoRA files for LTX-2.5 name the DiT's modules as the checkpoint does (`transformer_blocks.N.
* attn1.to_q`, `ff.net.0.proj`), behind ComfyUI's or kohya's prefix. */
RAD_ARCH_TRY(lora_names(b, "transformer.", kLoraDiffusionSpellings, {}));
RAD_ARCH_TRY(declare_te(b, meta, m));
{
const int64_t wz = std::max<int64_t>(rad_meta_geti(meta, "connectors.video_hidden_dim", 0),
+36
View File
@@ -705,6 +705,41 @@ static int declare_te(RadBuilder* b, const RadModelMeta* meta, Model& m) {
return m.op_embed ? RAD_OK : RAD_E_INVAL;
}
/* ================================================================== adapter key names */
/* LoRA files for H3 name the DiT by ComfyUI's modules (comfy/ldm/minimax): one fused
* `attn.qkv_proj` (q, k, v), `attn.out_proj`, and `mlp.fc1` with the SwiGLU's gate half first,
* where the checkpoint keeps the value half first in `ff.net.0.proj`. */
static int declare_lora_names(RadBuilder* b, const Model& m) {
std::vector<LoraName> n;
const int64_t Q = m.gd.n_head_all * m.gd.head_dim, KV = m.gd.n_head_kv_all * m.gd.head_dim;
const int64_t F = m.gd.n_ff_all;
static const char* const kBlocks[][2] = {
{ "blocks.#.", "transformer_blocks.#." },
{ "token_refiner.blocks.#.", "token_refiner.refiner_blocks.#." },
};
for (const auto& bl : kBlocks) {
const std::string f = bl[0], t = bl[1];
n.push_back({ f + "attn.qkv_proj", t + "attn.to_q", 0, Q, 0 });
n.push_back({ f + "attn.qkv_proj", t + "attn.to_k", Q, Q + KV, 0 });
n.push_back({ f + "attn.qkv_proj", t + "attn.to_v", Q + KV, Q + 2 * KV, 0 });
n.push_back({ f + "attn.out_proj", t + "attn.to_out.0" });
n.push_back({ f + "attn.to_gate_compress", t + "attn.to_gate_compress" });
n.push_back({ f + "mlp.fc1", t + "ff.net.0.proj", 0, F, F });
n.push_back({ f + "mlp.fc1", t + "ff.net.0.proj", F, 2 * F, 0 });
n.push_back({ f + "mlp.fc2", t + "ff.net.2" });
}
n.push_back({ "blocks.#.adaln_proj.linear", "transformer_blocks.#.adaln_proj.linear" });
n.push_back({ "video_patch_proj", "proj_in" });
n.push_back({ "audio_patch_proj", "audio_proj_in" });
n.push_back({ "condition_proj", "context_embedder" });
n.push_back({ "time_embedder.proj_in", "time_embedder.linear_1" });
n.push_back({ "time_embedder.proj_out", "time_embedder.linear_2" });
n.push_back({ "final_layer.video_out", "proj_out" });
n.push_back({ "final_layer.audio_out", "audio_proj_out" });
n.push_back({ "final_layer.adaln_proj.linear", "norm_out.linear" });
return lora_names(b, "transformer.", kLoraDiffusionSpellings, n);
}
/* ================================================================== the token refiner */
/* `context_embedder` (5120 -> 5376, bf16, replicated), two plain blocks with full attention over
* the prompt and no rotary, and the final RMSNorm into the lane's prompt rows. The feed-forward is
@@ -1924,6 +1959,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
/* ---- in issue order: the conditioning pass, the step, the soundtrack, the frames */
m.b_text = decl_b(b, nm.f("lane.text"), RAD_BF16, { (int64_t)kMaxLanes * kMaxText, m.D },
RAD_BUF_PERSIST);
RAD_ARCH_TRY(declare_lora_names(b, m));
RAD_ARCH_TRY(declare_te(b, meta, m));
RAD_ARCH_TRY(declare_refiner(b, meta, m));
RAD_ARCH_TRY(declare_tables(b, meta, m));
+11
View File
@@ -911,6 +911,17 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
* (Vae says why the order matters.) */
m.media = VisionTower::present(meta) && ctx->max_enc_patches > 0;
if (m.media) RAD_ARCH_TRY(m.vit.declare(b, meta, ctx, nm, m.gt.n_embd, kGrpVision, true));
/* ---- adapter key names. The DiT's LoRA files use the checkpoint's own names, or
* ComfyUI's, which join the SwiGLU's gate and up projections as `img_mlp.gate_up` [gate; up]
* (comfy/ldm/qwen_image21). */
{
const int64_t F = gd.n_ff_all;
RAD_ARCH_TRY(lora_names(b, "transformer.", kLoraDiffusionSpellings,
{ { "transformer_blocks.#.img_mlp.gate_up",
"transformer_blocks.#.img_mlp.gate_layer", 0, F, 0 },
{ "transformer_blocks.#.img_mlp.gate_up",
"transformer_blocks.#.img_mlp.proj", F, 2 * F, 0 } }));
}
RAD_ARCH_TRY(declare_te(b, meta, m));
RAD_ARCH_TRY(declare_encoder(b, meta, m));
RAD_ARCH_TRY(declare_dit(b, meta, m));
+10
View File
@@ -0,0 +1,10 @@
# Built in radiance's tree, or standalone against an installed radiance
# (`cmake -S arch/sdxl -B build -DCMAKE_PREFIX_PATH=<radiance prefix>`); see cmake/RadAddPlugin.cmake.
if(NOT COMMAND rad_add_plugin)
cmake_minimum_required(VERSION 3.21)
project(sdxl LANGUAGES CXX)
find_package(radiance REQUIRED)
rad_plugin_defaults()
endif()
rad_add_plugin(sdxl architectures SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sdxl.cpp)
+1236
View File
File diff suppressed because it is too large. Load diff