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

+131
View File
@@ -67,6 +67,16 @@ std::vector<float> schedule(const RadGeneratorDecl& d, const std::vector<double>
std::vector<float> s;
if (!fixed.empty()) {
for (double v : fixed) s.push_back((float)v);
} else if (d.sigma_grid > 0) {
/* ComfyUI's `simple` scheduler: the model's table holds t = k / N for k = 1..N (an f32
* quotient), and step i reads entry N - 1 - floor(i N / n), the floor of a Python float. */
const int32_t n = steps > 0 ? steps : (int32_t)d.default_steps;
const int64_t N = d.sigma_grid;
const double ss = (double)N / (double)n;
for (int32_t i = 0; i < n; ++i) {
const int64_t k = N - (int64_t)((double)i * ss);
s.push_back((float)k / (float)N);
}
} else {
const int32_t n = steps > 0 ? steps : (int32_t)d.default_steps;
/* np.linspace(1.0, 1 / n, n) in f64, then astype(f32). */
@@ -94,6 +104,127 @@ std::vector<float> schedule(const RadGeneratorDecl& d, const std::vector<double>
return s;
}
/* ================================================================== a discrete-time schedule */
float DiscreteTable::sigma_at(double t) const {
const double hi = (double)(log_sigmas.size() - 1);
t = t < 0.0 ? 0.0 : t > hi ? hi : t;
const size_t lo = (size_t)std::floor(t), up = (size_t)std::ceil(t);
const float w = (float)(t - std::floor(t));
return std::exp((1.0f - w) * log_sigmas[lo] + w * log_sigmas[up]);
}
int32_t DiscreteTable::timestep(float sigma) const {
const float l = std::log(sigma);
int32_t best = 0;
float bd = std::fabs(l - log_sigmas[0]);
for (size_t i = 1; i < log_sigmas.size(); ++i) {
const float d = std::fabs(l - log_sigmas[i]);
if (d < bd) { bd = d; best = (int32_t)i; }
}
return best;
}
int discrete_table(const RadGeneratorDecl& d, DiscreteTable* out, std::string* why) {
const int32_t n = d.train_steps;
if (n < 2 || !(d.beta_start > 0) || !(d.beta_end > d.beta_start) || d.beta_end >= 1 ||
(d.beta_schedule != RAD_GEN_BETAS_SCALED_LINEAR && d.beta_schedule != RAD_GEN_BETAS_LINEAR)) {
if (why) *why = "the discrete schedule needs two or more timesteps and betas rising in (0, 1)";
return RAD_E_INVAL;
}
std::vector<double> sig((size_t)n);
double abar = 1.0;
const bool sq = d.beta_schedule == RAD_GEN_BETAS_SCALED_LINEAR;
const double a = sq ? std::sqrt(d.beta_start) : d.beta_start;
const double b = sq ? std::sqrt(d.beta_end) : d.beta_end;
for (int32_t i = 0; i < n; ++i) {
const double v = a + (b - a) * (double)i / (double)(n - 1);
abar *= 1.0 - (sq ? v * v : v);
sig[(size_t)i] = std::sqrt((1.0 - abar) / abar);
}
if (d.zero_snr) {
/* ComfyUI's rescale_zero_terminal_snr_sigmas: sqrt(abar) shifted to end at 0 and scaled
* to keep its start, the last abar then set to a small positive value. */
std::vector<double> s((size_t)n);
for (int32_t i = 0; i < n; ++i) s[(size_t)i] = std::sqrt(1.0 / (sig[(size_t)i] * sig[(size_t)i] + 1.0));
const double s0 = s.front(), sT = s.back();
for (int32_t i = 0; i < n; ++i) {
double v = (s[(size_t)i] - sT) * (s0 / (s0 - sT));
double ab = v * v;
if (i == n - 1) ab = 4.8973451890853435e-08;
sig[(size_t)i] = std::sqrt((1.0 - ab) / ab);
}
}
out->sigmas.resize((size_t)n);
out->log_sigmas.resize((size_t)n);
for (int32_t i = 0; i < n; ++i) {
out->sigmas[(size_t)i] = (float)sig[(size_t)i];
out->log_sigmas[(size_t)i] = (float)std::log(sig[(size_t)i]);
}
return RAD_OK;
}
std::vector<float> schedule_discrete(const RadGeneratorDecl& d, const DiscreteTable& t,
int32_t scheduler, int32_t steps) {
const int32_t n = steps > 0 ? steps : (int32_t)d.default_steps;
std::vector<float> s;
const double smin = t.sigma_min(), smax = t.sigma_max();
/* A point i of n evenly spaced from `a` to `b`, both ends included. */
auto lin = [](double a, double b, int32_t i, int32_t cnt) {
return cnt <= 1 ? a : a + (b - a) * (double)i / (double)(cnt - 1);
};
switch (scheduler) {
case RAD_GEN_SCHED_KARRAS: {
const double rho = 7.0, lo = std::pow(smin, 1.0 / rho), hi = std::pow(smax, 1.0 / rho);
for (int32_t i = 0; i < n; ++i) s.push_back((float)std::pow(lin(hi, lo, i, n), rho));
break;
}
case RAD_GEN_SCHED_EXPONENTIAL:
for (int32_t i = 0; i < n; ++i)
s.push_back((float)std::exp(lin(std::log(smax), std::log(smin), i, n)));
break;
case RAD_GEN_SCHED_SIMPLE: {
const double stride = (double)t.sigmas.size() / (double)n;
for (int32_t i = 0; i < n; ++i)
s.push_back(t.sigmas[t.sigmas.size() - 1 - (size_t)((double)i * stride)]);
break;
}
case RAD_GEN_SCHED_SGM_UNIFORM:
case RAD_GEN_SCHED_NORMAL:
default: {
/* Timesteps from the largest sigma's to the smallest's, evenly spaced; sgm_uniform
* spaces n + 1 and drops the last. The model's clock ends at 0. */
const double a = (double)t.timestep(t.sigma_max()), b = (double)t.timestep(t.sigma_min());
const bool sgm = scheduler == RAD_GEN_SCHED_SGM_UNIFORM;
const int32_t cnt = sgm ? n + 1 : n;
for (int32_t i = 0; i < n; ++i) s.push_back(t.sigma_at(lin(a, b, i, cnt)));
break;
}
}
s.push_back(0.0f);
return s;
}
namespace {
const char* const kSamplers[RAD_GEN_SAMPLER_COUNT] = { "euler", "euler_ancestral", "dpmpp_2m" };
const char* const kScheds[RAD_GEN_SCHED_COUNT] = { "normal", "karras", "exponential",
"sgm_uniform", "simple" };
} /* namespace */
const char* sampler_name(int32_t id) {
return id >= 0 && id < RAD_GEN_SAMPLER_COUNT ? kSamplers[id] : "";
}
const char* scheduler_name(int32_t id) {
return id >= 0 && id < RAD_GEN_SCHED_COUNT ? kScheds[id] : "";
}
int32_t sampler_id(const std::string& name) {
for (int32_t i = 0; i < RAD_GEN_SAMPLER_COUNT; ++i) if (name == kSamplers[i]) return i;
return -1;
}
int32_t scheduler_id(const std::string& name) {
for (int32_t i = 0; i < RAD_GEN_SCHED_COUNT; ++i) if (name == kScheds[i]) return i;
return -1;
}
/* ================================================================== the sequence */
void image_rope(int32_t pos, int32_t h, int32_t w, int32_t* planes, int64_t n_total) {
const int32_t h0 = -(h - h / 2), w0 = -(w - w / 2);