radiance 1.9.0

New models:
- LTX-2.5 (base and distilled): video with a stereo soundtrack from text or from text and a first
  frame, on one card, with its duration head, tiled VAE decoding, the diffusion decoder and the x2
  latent upsampler
- Krea 2 Raw and Turbo, and FLUX.3 [klein] and its base: text to image, and for FLUX.3 edits from up
  to ten reference pictures, on one card
- GLM-5.3-Flash from AMD's Quark MXFP4 export, on eight cards (John McDonough, Nunze)
- Gemma 3 / TranslateGemma 27B with an optional DFlash2 drafter (mici81)

Engine:
- --kv-cache-dtype fp8_v4 and k6_v4 for Gemma 3 and Qwen3.8-Flash-Next (mici81)
- the rotated int8 trunk (i8a8h) for Qwen3.8-27B (eddie168168)
- eight-rank all-reduce bands, weighted shards and pieces (Nunze); --host-headroom-mib (sfjes)
- the dashboard shows the single-stream decode floor and its most recent window (Memoria)

Fixes: prefix-cache reservations kept until their save lands (baKon), tool calls in Responses
namespaces (#119), system messages merged when a template refuses several (#137), a prefill
continued with no open step (#127), calibration of a Gram accumulation (#122), JSON Schema patterns
read unanchored (davetha), GLM-style tool calls, the KV floor counting every sequence's state.
Plugin ABI 24.
This commit is contained in:
Deadcode committed 2026-10-19 21:58:07 +02:00
1 parent 778cbf315e
commit 685ec5bd85
136 files changed
+18917 -3821

No files matched your search

+92 -31
View File
@@ -9,8 +9,10 @@
* repainted where the mask is transparent; the rest is restored exactly after decoding.
*
* Extensions, under vLLM-Omni's names: `seed`, `negative_prompt` with `true_cfg_scale`
* (guidance), `num_inference_steps`, and `width` / `height` instead of `size`. A fixed-schedule
* (distilled) model accepts only its own step count.
* (guidance, in the model card's terms; `guidance_scale` is the same field under diffusers' name),
* `num_inference_steps`, and `width` / `height` instead of `size`. A fixed-schedule (distilled)
* model accepts only its own step count. A model whose card guides by default does so with its
* own negative prompt unless the request names one or turns guidance off.
*
* Refused: `response_format: url`, since no image is stored to serve later; only b64_json.
*
@@ -77,7 +79,7 @@ json form_value(const std::string& key, const std::string& v) {
if (e && *e == 0 && !v.empty()) return json(x);
return json(v);
}
if (key == "true_cfg_scale") {
if (key == "true_cfg_scale" || key == "guidance_scale") {
char* e = nullptr;
const double x = std::strtod(v.c_str(), &e);
if (e && *e == 0 && !v.empty()) return json(x);
@@ -107,18 +109,34 @@ std::string replace_all(std::string s, const std::string& what, const std::strin
}
/* A picture as the generator's encoder reads it: each channel u -> 2 * (u / 255) - 1 in f32, then
* bf16 (VaeImageProcessor's preprocess, cast to the VAE's dtype). */
gen::Pixels to_pixels(const mm::FrameRGBA& f) {
* bf16 (VaeImageProcessor's preprocess, cast to the VAE's dtype). An RGB model reads the colour
* channels and not the alpha, as PIL's convert("RGB") drops it. */
gen::Pixels to_pixels(const mm::FrameRGBA& f, int ch) {
gen::Pixels p;
p.w = f.w;
p.h = f.h;
p.ch = 4;
p.bf16.resize(f.rgba.size());
for (size_t i = 0; i < f.rgba.size(); ++i)
p.bf16[i] = rad_f32_to_bf16(2.0f * ((float)f.rgba[i] / 255.0f) - 1.0f);
p.ch = ch;
p.bf16.resize((size_t)f.w * f.h * ch);
for (size_t px = 0; px < (size_t)f.w * f.h; ++px)
for (int c = 0; c < ch; ++c)
p.bf16[px * ch + c] =
rad_f32_to_bf16(2.0f * ((float)f.rgba[px * 4 + c] / 255.0f) - 1.0f);
return p;
}
/* The centred w x h window of a picture (diffusers' resize_mode "crop" after its resize). */
mm::FrameRGBA crop_centre(const mm::FrameRGBA& f, int32_t w, int32_t h) {
mm::FrameRGBA o;
o.w = w;
o.h = h;
o.rgba.resize((size_t)w * h * 4);
const int32_t x0 = (f.w - w) / 2, y0 = (f.h - h) / 2;
for (int32_t y = 0; y < h; ++y)
std::memcpy(&o.rgba[(size_t)y * w * 4], &f.rgba[((size_t)(y0 + y) * f.w + x0) * 4],
(size_t)w * 4);
return o;
}
/* The decoded RGBA flattened on white (no alpha), for a jpeg or an opaque background. */
std::vector<uint8_t> on_white(const std::vector<uint8_t>& rgba, int32_t w, int32_t h) {
mm::FrameRGBA f;
@@ -216,6 +234,7 @@ HttpResponse Server::handle_images(const HttpRequest& req, bool edit) {
"prompt", "model", "n", "size", "quality", "background", "output_format",
"output_compression", "response_format", "stream", "partial_images", "moderation",
"style", "user", "input_fidelity", "seed", "negative_prompt", "true_cfg_scale",
"guidance_scale",
"num_inference_steps", "width", "height",
};
for (auto it = body.begin(); it != body.end(); ++it) {
@@ -274,6 +293,8 @@ HttpResponse Server::handle_images(const HttpRequest& req, bool edit) {
if (r.background == "transparent" && r.format == "jpeg")
return error_response(err_bad("background", "jpeg has no transparency; ask for png or "
"webp"), req.peer);
if (r.background == "transparent" && info.pixel_channels < 4)
return error_response(err_bad("background", "this model makes opaque images"), req.peer);
if (num("output_compression", 0, 100, &v) < 0)
return error_response(err_bad("output_compression", "expected an integer in 0..100"),
req.peer);
@@ -323,21 +344,35 @@ HttpResponse Server::handle_images(const HttpRequest& req, bool edit) {
}
if (str("negative_prompt", &r.negative) < 0)
return error_response(err_bad("negative_prompt", "expected a string"), req.peer);
if (body.contains("true_cfg_scale") && !body["true_cfg_scale"].is_null()) {
if (!body["true_cfg_scale"].is_number())
return error_response(err_bad("true_cfg_scale", "expected a number"), req.peer);
r.cfg = body["true_cfg_scale"].get<double>();
if (!(r.cfg >= 1.0 && r.cfg <= 30.0))
return error_response(err_bad("true_cfg_scale", "expected a number in 1..30"),
req.peer);
/* The scale in the model card's terms: off at 0 for a card that states it as
* cond + s (cond - uncond), at 1 for uncond + s (cond - uncond). */
const double cfg_off = info.cfg_original ? 0.0 : 1.0;
const char* cfg_key = body.contains("guidance_scale") && !body["guidance_scale"].is_null()
? "guidance_scale" : "true_cfg_scale";
const bool cfg_given = body.contains(cfg_key) && !body[cfg_key].is_null();
if (cfg_given && body.contains("true_cfg_scale") && body.contains("guidance_scale") &&
!body["true_cfg_scale"].is_null())
return error_response(err_bad("guidance_scale", "true_cfg_scale and guidance_scale are "
"the same field; name one"), req.peer);
r.cfg = info.default_cfg;
if (cfg_given) {
if (!body[cfg_key].is_number())
return error_response(err_bad(cfg_key, "expected a number"), req.peer);
r.cfg = body[cfg_key].get<double>();
if (!(r.cfg >= cfg_off && r.cfg <= 30.0))
return error_response(err_bad(cfg_key, "expected a number in " +
std::string(cfg_off > 0 ? "1" : "0") +
"..30"), req.peer);
}
/* Guidance needs a scale above one and a negative prompt (empty becomes " "), as in the
* reference pipeline. */
r.has_neg = r.cfg > 1.0 && body.contains("negative_prompt");
if (r.has_neg && r.negative.empty()) r.negative = " ";
if (r.cfg > 1.0 && !r.has_neg)
return error_response(err_bad("true_cfg_scale", "guidance needs a negative_prompt"),
req.peer);
/* Guidance needs a scale past its off value and a negative prompt: the request's (empty
* becomes " ", as in the reference pipeline), or the model's own. */
const bool guided = r.cfg > cfg_off;
const bool named_neg = body.contains("negative_prompt") && !body["negative_prompt"].is_null();
r.has_neg = guided && (named_neg || info.has_default_negative);
if (r.has_neg && !named_neg) r.negative = info.default_negative;
else if (r.has_neg && r.negative.empty()) r.negative = " ";
if (guided && !r.has_neg)
return error_response(err_bad(cfg_key, "guidance needs a negative_prompt"), req.peer);
/* ---- the pictures */
if (edit) {
@@ -372,7 +407,7 @@ HttpResponse Server::handle_images(const HttpRequest& req, bool edit) {
* image generated without transparency has only decoder noise in its alpha. */
if (r.background == "auto") {
bool alpha = false;
if (r.format != "jpeg")
if (r.format != "jpeg" && info.pixel_channels >= 4)
for (const mm::FrameRGBA& f : r.images)
for (size_t i = 3; i < f.rgba.size() && !alpha; i += 4)
alpha = f.rgba[i] < kTransparentBelow;
@@ -437,17 +472,40 @@ HttpResponse Server::handle_images(const HttpRequest& req, bool edit) {
g->steps = r.steps;
g->seed = r.seed;
g->previews = r.previews;
g->cfg = (float)r.cfg;
/* The driver guides as uncond + cfg (cond - uncond); a card's cond + s (cond - uncond) is
* that at s + 1. */
g->cfg = (float)(info.cfg_original ? r.cfg + 1.0 : r.cfg);
g->has_neg = r.has_neg;
g->ticket = std::make_shared<gen::Ticket>();
std::vector<std::shared_ptr<mm::Item>> items;
const int pch = (int)info.pixel_channels;
for (const mm::FrameRGBA& f : r.images) {
int32_t rw = 0, rh = 0;
dims_for((double)info.ref_area, (double)f.w / (double)f.h, mult, &rw, &rh);
mm::FrameRGBA rs;
mm::resize_lanczos_rgba(f, rw, rh, &rs);
g->refs.push_back(to_pixels(rs));
if (info.ref_shrink_only) {
/* Shrunk to the reference area only when larger, then cut to the size multiple. */
const double area = (double)f.w * f.h;
if (area > (double)info.ref_area) {
const double k = std::sqrt((double)info.ref_area / area);
rw = std::max<int32_t>(1, (int32_t)(f.w * k));
rh = std::max<int32_t>(1, (int32_t)(f.h * k));
mm::resize_lanczos_rgba(f, rw, rh, &rs);
} else {
rs = f;
}
const int32_t cw = rs.w / mult * mult, ch = rs.h / mult * mult;
if (cw <= 0 || ch <= 0)
return error_response(err_bad("image", "a picture must be at least " +
std::to_string(mult) + " pixels a side"),
req.peer);
if (cw != rs.w || ch != rs.h) rs = crop_centre(rs, cw, ch);
} else {
dims_for((double)info.ref_area, (double)f.w / (double)f.h, mult, &rw, &rh);
mm::resize_lanczos_rgba(f, rw, rh, &rs);
}
g->refs.push_back(to_pixels(rs, pch));
if (info.refs_encoder_only) continue;
mm::Frame rgb;
mm::composite_white(rs, &rgb);
std::shared_ptr<mm::Item> it;
@@ -465,7 +523,7 @@ HttpResponse Server::handle_images(const HttpRequest& req, bool edit) {
mm::resize_lanczos_rgba(r.images[0], r.w, r.h, &src);
mm::resize_lanczos_rgba(r.mask, r.w, r.h, &msk);
g->inpaint = true;
g->inp_src = to_pixels(src);
g->inp_src = to_pixels(src, pch);
const int32_t lw = r.w / (int32_t)ls, lh = r.h / (int32_t)ls;
g->inp_mask.assign((size_t)lw * lh, 0.0f);
keep_px.assign((size_t)r.w * r.h, 0);
@@ -567,12 +625,15 @@ HttpResponse Server::handle_images(const HttpRequest& req, bool edit) {
auto encode = [fmt, comp, keep_px, src_px, flatten](gen::Image& im, std::string* b64,
std::string* why) -> int {
std::vector<uint8_t>& px = im.px;
const size_t ch = (size_t)im.ch;
if (!keep_px.empty() && !im.preview)
for (size_t i = 0; i < keep_px.size(); ++i)
if (keep_px[i]) std::memcpy(&px[i * 4], &src_px[i * 4], 4);
if (keep_px[i]) std::memcpy(&px[i * ch], &src_px[i * 4], ch);
std::vector<uint8_t> file;
int s;
if (flatten) {
if (ch == 3) {
s = mm::encode_image(px.data(), im.w, im.h, 3, fmt, comp, &file, why);
} else if (flatten) {
const std::vector<uint8_t> rgb = on_white(px, im.w, im.h);
s = mm::encode_image(rgb.data(), im.w, im.h, 3, fmt, comp, &file, why);
} else {