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

+1 -1
View File
@@ -17,7 +17,7 @@ extern "C" {
* kind of plugin reports it, and a plugin that does not report exactly this version is refused at
* load with both versions printed. A new optional export (e.g. rad_plugin_reference) is not a
* change of shape: a plugin without it gets the default. */
#define RAD_ABI_VERSION 24u
#define RAD_ABI_VERSION 25u
/* ================================================================== plugin identity */
/* One value per plugin, not flags (QUANT is 3). RAD_PLUGIN_QUANT is a quantiser plugin:
+106 -5
View File
@@ -429,7 +429,7 @@ int rad_op_declared(RadBuilder* b, const char* op);
* convert-time fusions (q/k/v into one qkv, gate and up into gate_up). It is the only component
* that knows both sides, and rad-convert reads the map from it (spec §2.4). */
enum { RAD_MAP_COPY = 0, RAD_MAP_CONCAT = 1, RAD_MAP_WNORM = 2, RAD_MAP_ROWS = 3,
RAD_MAP_TRANSPOSE = 4, RAD_MAP_EMA = 5, RAD_MAP_TAP = 6 };
RAD_MAP_TRANSPOSE = 4, RAD_MAP_EMA = 5, RAD_MAP_TAP = 6, RAD_MAP_COLS = 7 };
typedef struct RadNameMap {
const char* declared; /* the name given to rad_decl_weight */
@@ -445,7 +445,8 @@ typedef struct RadNameMap {
int src_index[8];
/* RAD_MAP_ROWS only: piece i is rows [src_index[i], src_index[i] + src_rows[i]) of the 2-D (or
* higher, rows along dim 0) tensor src[i]; the pieces join along dim 0. */
* higher, rows along dim 0) tensor src[i]; the pieces join along dim 0. RAD_MAP_COLS: columns
* [src_index[0], src_index[0] + src_rows[0]) of src[0]'s last dimension. */
int64_t src_rows[8];
} RadNameMap;
@@ -463,7 +464,13 @@ typedef struct RadNameMap {
*
* RAD_MAP_ROWS keeps only row ranges of its sources (see src_rows), joined: a head read over a
* fraction of a vocabulary (an audio model's codes, a few rows of a text model's 200K) stores that
* fraction rather than the whole table.
* fraction rather than the whole table. Successive ROWS maps for one name extend it in call order,
* as CONCAT maps do, so a weight may take more than eight pieces (an output projection whose rows
* are permuted, one piece a row).
*
* RAD_MAP_COLS keeps one column range of src[0] (see src_rows): a linear whose input carries
* channels the runtime never feeds (Cosmos's padding-mask channel, always zero) is read over the
* columns it is fed.
*
* RAD_MAP_TRANSPOSE swaps the last two dimensions of src[0] in each leading slice, [.., a, b] to
* [.., b, a]: a linear a checkpoint keeps as (in, out), where the GEMMs read (out, in).
@@ -478,7 +485,7 @@ typedef struct RadNameMap {
* run on a single frame reads only its last temporal tap, so [cout, cin, kt, kh, kw] read at tap -1
* of dimension 2 is the 2-D convolution it then is.
*
* TRANSPOSE, EMA and TAP are computed at convert in f32, like WNORM, and stored as the recipe
* TRANSPOSE, EMA, TAP and COLS are computed at convert in f32, like WNORM, and stored as the recipe
* says. */
int rad_decl_name_map(RadBuilder* b, const RadNameMap* m);
@@ -714,7 +721,8 @@ typedef struct RadGeneratorDecl {
/* The sampler: flow matching, Euler steps from sigma 1 towards 0.
* A fixed schedule: `n_sigmas` values, the terminal 0 implied; a request may not change the
* step count. Otherwise `default_steps` sigmas from 1 to 1/steps, shifted:
* step count. Otherwise `default_steps` sigmas from 1 to 1/steps (or off `sigma_grid`'s
* table), shifted:
* dyn_shift 0 sigma' = shift * s / (1 + (shift - 1) * s)
* dyn_shift 1 mu linear in the image's token count, 256 -> base_shift .. max_seq ->
* max_shift; shift_exp 1: exp(mu) / (exp(mu) + (1/s - 1)), 0: mu / (mu + ...)
@@ -755,10 +763,103 @@ typedef struct RadGeneratorDecl {
/* 1: a reference picture is shrunk to `ref_area` only when larger and cut to `size_multiple`
* by a centred crop; 0: resized to `ref_area` at its own aspect. */
int32_t ref_shrink_only;
/* ---- appended in ABI 25 (Anima, SDXL) */
/* `aux_tokens` nonzero: the conditioning also reads the user's prompt through the container's
* second tokenizer (rad-convert --tokenizer2), as that tokenizer encodes it alone, special
* tokens included, and the COND pass carries the ids (RadGenBatch::aux_ids). A prompt whose
* second tokenisation is longer than `aux_max_tokens` is refused. */
int64_t aux_max_tokens;
/* The unshifted sigmas of a schedule that is not fixed: 0 is diffusers' linspace(1, 1 / steps,
* steps); N > 0 picks them off a table of N timesteps as ComfyUI's `simple` scheduler does,
* step i at (N - floor(i N / steps)) / N, each an f32 quotient of the table's own. */
int32_t sigma_grid;
/* A prompt shorter than this many tokens after `drop_prefix` is padded with `pad_token` up to
* it, the padding read as prompt (a reference tokenizer's minimum length: an empty prompt is
* one padding token, and stays empty rather than becoming " "). 0: no minimum. */
int32_t min_tokens;
int32_t aux_tokens;
/* ---- a discrete-time denoiser (train_steps 0: the flow-matching sampler above)
* A model trained on `train_steps` timesteps of a variance-preserving schedule, betas from
* `beta_start` to `beta_end` (RAD_GEN_BETAS_*), sampled as k-diffusion samples it (Stable
* Diffusion's family). Its schedule is in sigmas, sigma_t = sqrt((1 - abar_t) / abar_t) for
* the cumulative product abar of 1 - beta; `zero_snr` rescales it to a zero terminal SNR
* (the last abar 4.8973451890853435e-08, as ComfyUI does). A request names a sampler
* (RAD_GEN_SAMPLER_*, one of those `samplers` holds as 1 << id, which the plugin's step
* serves) and a scheduler (RAD_GEN_SCHED_*), which places the request's steps between the
* table's largest and smallest sigma, 0 last. A DENOISE pass carries each entry's sigma,
* next and previous sigma in these units, the timestep the denoiser is conditioned on, the
* sampler and the step (RadGenBatch). n_sigmas, shift and the dynamic shift are unused. */
double beta_start, beta_end;
int32_t train_steps;
int32_t beta_schedule;
int32_t zero_snr;
uint32_t samplers;
int32_t default_sampler;
int32_t default_scheduler;
/* ---- the prompt in windows (a CLIP text encoder's fixed context)
* Nonzero: the prompt's tokens after `drop_prefix` are cut into runs of at most
* `chunk_tokens`, each laid out as `chunk_bos`, the run, `chunk_eos`, then `pad_token` up to
* chunk_tokens + 2 rows, the windows end to end; a prompt with no tokens is one window of
* the two markers and padding. The JOINT_STEP layout only, with `pad_multiple` 0, and
* `cond_rows` a whole number of windows. */
int32_t chunk_tokens;
int32_t chunk_bos, chunk_eos;
} RadGeneratorDecl;
/* RadGeneratorDecl::beta_schedule: betas linear in sqrt(beta) (Stable Diffusion's
* "scaled_linear"), or linear in beta. */
enum { RAD_GEN_BETAS_SCALED_LINEAR = 0, RAD_GEN_BETAS_LINEAR = 1 };
/* A discrete-time model's samplers, as k-diffusion (and ComfyUI) name and define them. */
enum {
RAD_GEN_SAMPLER_EULER = 0, /* "euler" */
RAD_GEN_SAMPLER_EULER_ANCESTRAL = 1, /* "euler_ancestral", eta 1 */
RAD_GEN_SAMPLER_DPMPP_2M = 2, /* "dpmpp_2m" */
RAD_GEN_SAMPLER_COUNT = 3
};
/* ... and its schedulers, ComfyUI's: "normal" (timesteps evenly spaced, the last at the smallest
* sigma), "karras" (rho 7), "exponential", "sgm_uniform" (normal without its last point) and
* "simple" (the table read at even strides). */
enum {
RAD_GEN_SCHED_NORMAL = 0,
RAD_GEN_SCHED_KARRAS = 1,
RAD_GEN_SCHED_EXPONENTIAL = 2,
RAD_GEN_SCHED_SGM_UNIFORM = 3,
RAD_GEN_SCHED_SIMPLE = 4,
RAD_GEN_SCHED_COUNT = 5
};
int rad_declare_generator(RadBuilder* b, const RadGeneratorDecl* d);
/* ================================================================== adapter key names */
/* How LoRA files written for this model name its linears, for an image or video generator served
* with runtime adapters (--lora, --lora-dir, --max-loras; core/lora/). Adapter files from training
* tools and UIs name a module by the model's original code, not by the checkpoint the container
* was converted from, and wrap it in a prefix of their own: `diffusion_model.blocks.3.attn.wq`,
* kohya's `lora_unet_blocks_3_attn_wq`, a bare `blocks.3.attn.wq`. Both calls are optional,
* made before the GEMMs they cover are declared, and only a program that declares a root carries
* adapters at all. Additive exports; RAD_ABI_VERSION does not move.
*
* rad_lora_root declares one network the adapters may reach (the denoiser, a text encoder): every
* LoRA-capable GEMM over a checkpoint tensor whose name starts with `native` gets an adapter path.
* `spellings` lists, space separated, the prefixes adapter keys of this network start with in
* place of `native`; one ending in '_' is kohya's form, in which the rest of the key is the module
* path with every '.' written '_'. `native` itself is always accepted, and "-" stands for a key
* with no prefix at all. A key is tried against the longest matching spelling first.
*
* rad_lora_alias maps an adapter module that the checkpoint names differently. `from` and `to`
* are module paths relative to the root's prefixes (no ".weight"), '#' standing for a decimal
* index that `to` repeats in the same order. Rows [from_lo, from_hi) of the adapter module's
* output (its lora_B rows; from_hi 0 = all of them) land at rows from `to_lo` of the checkpoint
* module `to`. Several aliases with one `from` split a fused adapter module over separate
* checkpoint tensors (a `qkv` over `to_q`, `to_k`, `to_v`); several `from` into one `to` at
* different `to_lo` place separate adapter modules into one fused tensor. A module path that is
* the checkpoint's own needs no alias. */
int rad_lora_root(RadBuilder* b, const char* native, const char* spellings);
int rad_lora_alias(RadBuilder* b, const char* native, const char* from, const char* to,
int64_t from_lo, int64_t from_hi, int64_t to_lo);
/* ================================================================== the audio generator */
/* A program that makes audio from text: an autoregressive language model writes the piece frame by
* frame, with classifier-free guidance (each request runs a conditional and an unconditional
+15
View File
@@ -56,9 +56,16 @@ typedef struct RadFileHeader {
uint64_t prof_off, prof_count; /* RadFileProfile[] -- expert popularity */
uint64_t data_off, data_bytes; /* the blob; RAD_ALIGN_POOL-aligned */
/* reserved[RAD_HDR_AUX_VOCAB_OFF] and reserved[RAD_HDR_AUX_VOCAB_BYTES] place a second vocab
* section, laid out as the first (RadVocabHeader + its payload, its strings in the one string
* blob): a tokenizer a generator reads its prompt through beside the model's own
* (RadGeneratorDecl::aux_tokens). Both zero when there is none, as in a file written before
* the section existed; the rest are zero. */
uint64_t reserved[8];
} RadFileHeader;
enum { RAD_HDR_AUX_VOCAB_OFF = 0, RAD_HDR_AUX_VOCAB_BYTES = 1 };
/* ------------------------------------------------------------------ metadata */
typedef struct RadFileKV {
rad_stroff key;
@@ -124,9 +131,17 @@ enum { RAD_TOK_BPE = 1, RAD_TOK_UNIGRAM = 2, RAD_TOK_WORDPIECE = 3, RAD_TOK_RWKV
enum {
RAD_NORM_NFC = 1, RAD_NORM_NFKC = 2, RAD_NORM_NFD = 3, RAD_NORM_NFKD = 4,
RAD_NORM_LOWERCASE = 5, RAD_NORM_STRIP = 6, RAD_NORM_REPLACE = 7, RAD_NORM_PREPEND = 8,
RAD_NORM_PRECOMPILED = 9,
RAD_PRE_BYTELEVEL = 32, RAD_PRE_SPLIT = 33, RAD_PRE_METASPACE = 34,
RAD_PRE_WHITESPACE = 35, RAD_PRE_PUNCTUATION = 36, RAD_PRE_DIGITS = 37,
RAD_PRE_BYTE_FALLBACK = 38,
/* BPE's end-of-word suffix (arg0, CLIP's "</w>"): a word's last symbol carries it, so the
* merges and the vocabulary tell a word's end from its middle. */
RAD_PRE_END_OF_WORD = 39,
/* An added token matched in the normalised text rather than the raw one (tokenizers'
* `normalized`): arg0 its spelling, iarg its id. Cut out after the normalisers and before
* the other pre-tokenisers. */
RAD_PRE_ADDED_NORMALIZED = 40,
RAD_DEC_BYTELEVEL = 64, RAD_DEC_METASPACE = 65, RAD_DEC_REPLACE = 66,
RAD_DEC_STRIP = 67, RAD_DEC_FUSE = 68, RAD_DEC_BYTE_FALLBACK = 69
};
+26
View File
@@ -352,6 +352,32 @@ typedef struct RadGenBatch {
const int32_t* mode_ccu;
const int64_t* n_mode_h;
const float* mode_rope_f;
/* ---- appended in ABI 25 (Anima, SDXL) */
/* COND, for a generator that reads its prompt through a second tokenizer
* (RadGeneratorDecl::aux_tokens): the user's prompt as that tokenizer encodes it, `n_aux` ids
* on the device, and `aux_cu` {0, n_aux} on the device. 0 and null otherwise. */
int64_t n_aux;
const int32_t* aux_ids;
const int32_t* aux_cu;
/* ---- a discrete-time denoiser (RadGeneratorDecl::train_steps), DENOISE, one value per
* entry: the schedule's sigma before `sigma` (0 on an image's first step), `sigma` on the
* model's trained clock (the nearest of its timesteps, as ComfyUI conditions it), the
* request's sampler (RAD_GEN_SAMPLER_*) and the image's step, from 0. */
const float* sigma_prev;
const float* timestep;
const int32_t* sampler;
const int32_t* step;
/* DENOISE: [n_seq, 2] each entry's image height and width in pixels, f32 (a model
* conditioned on its size); `entry_h` [n_seq, 4] the same entries on the host: the
* conditioning's rows (JOINT_STEP), the height and width in pixels, and the branch (0 the
* prompt, 1 the negative prompt), for a plugin whose ops take an image's geometry from their
* operands and so issue each entry on its own. */
const float* size_px;
const int32_t* entry_h;
/* COND: the pass's token ids on the host ([n_tok]), for a plugin whose issue depends on
* where a window's end-of-text marker sits. */
const int32_t* tokens_h;
} RadGenBatch;
/* An entry's flags on a DENOISE pass. */