radiance 1.6.0

- Qwen-Image 2.1 and 2.1 Turbo: text to image and image edits over OpenAI's images API,
  /v1/images/generations and /v1/images/edits. An edit takes up to ten pictures and an optional
  mask, outside which the picture comes back exactly as it was; `background: transparent`, png,
  jpeg and webp output, `n` pictures from one prompt, streamed previews (`partial_images`), and
  vLLM-Omni's seed, negative_prompt with true_cfg_scale, num_inference_steps, width and height.
  arch/qwenimage21 serves the diffusers pipeline directory, converted with
  data/recipes/qwen-image-2.1-fp8.recipe (block fp8) or qwen-image-2.1-bf16.recipe.
  deploy/compose/qwen-image-2.1.yaml and qwen-image-2.1-turbo.yaml serve the fp8 containers on
  two cards. Two R9700s make a 2048x2048 picture in 61 s at the base model's 40 steps and in
  13 s with Turbo (56 and 12 s with --tp-wire wht6), a 1024x1024 one in 6.0 and 2.6 s. The
  models are under Qwen's research license, which is non-commercial
- an image generator is a program kind of its own (core/gen): an architecture declares its
  conditioning, denoising and decoding passes, and the driver runs the schedule, the pictures of
  a batch and the conditioning cache. An image model's /v1/models entry is its generator's name
  (qwen-image-2.1, qwen-image-2.1-turbo), and its capabilities and startup banner list only the
  images endpoints
- the tiled prefill GEMMs run their tiles in groups of activation bands, 16 for fp8 and 8 for
  bf16, so an operand larger than the 64 MB cache is read once a group instead of once a band. A
  bf16 GEMM with more than 64 MB of weight runs up to twice as fast
- fixed: a second lane opened in the middle of a step started beside work lane 0 had not
  finished. Gemma 4 26B-A4B opens its lane that way, so its first step after startup could read
  rows not yet written
- startup no longer warns about --checkpoint-slots when it was not passed, nor about an expert
  floor on a model with no experts
- the image's FFmpeg writes png, jpeg and webp (libwebp)
- for out-of-tree plugins: RAD_ABI_VERSION is 16. The op vocabulary gains the image generator's
  ops (conv2d_nhwc, ln_mod, ln_mod_quant_fp8, flow_euler, attn_prefix_self and others; docs/OPS.md,
  "Image generation"), and all_reduce takes an optional `overlap`. Plugins built against 1.5.0
  must be rebuilt
This commit is contained in:
Deadcode committed 2026-10-14 14:03:59 +02:00
1 parent b93b531f63
commit b068190326
66 files changed
+9035 -87

No files matched your search

+94
View File
@@ -5,6 +5,7 @@
#include <nlohmann/json.hpp>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <fstream>
@@ -76,6 +77,7 @@ static void flatten_json(const nlohmann::json& j, const std::string& prefix, Met
if (e.is_number_integer()) s += fmt("%lld", (long long)e.get<int64_t>());
else if (e.is_number()) s += fmt("%.17g", e.get<double>());
else if (e.is_string()) s += e.get<std::string>();
else if (e.is_boolean()) s += e.get<bool>() ? "1" : "0";
else { ok = false; break; }
}
if (ok) out->kv(key, s);
@@ -480,6 +482,95 @@ int shard_list(const std::string& dir, const std::string& index, bool index_give
} /* namespace */
/* A JSON file flattened under `prefix`; absent is not an error when `optional`. */
static int meta_merge_json_file(const std::string& path, const std::string& prefix, bool optional,
MetaOwn* out) {
std::ifstream f(path);
if (!f) {
if (optional) return RAD_OK;
RAD_ERR("%s: cannot read it", path.c_str());
return RAD_E_NOTFOUND;
}
nlohmann::json j;
try { f >> j; }
catch (const std::exception& e) { RAD_ERR("%s: %s", path.c_str(), e.what()); return RAD_E_FORMAT; }
if (!j.is_object()) {
RAD_ERR("%s: not a JSON object", path.c_str());
return RAD_E_FORMAT;
}
flatten_json(j, prefix, out);
return RAD_OK;
}
static bool path_exists(const std::string& p) { std::ifstream f(p); return (bool)f; }
/* A DIFFUSERS PIPELINE: model_index.json at the top and one folder a component, each with its own
* config and weights. It is read as ONE checkpoint, because the components are one model to the
* architecture plugin that serves them:
*
* text_encoder/ its config.json is the container's model config -- the typed dimensions and
* the bare keys -- and its tensors keep their names;
* transformer/ tensors under `transformer.`, config.json under `transformer.` keys;
* vae/ tensors under `vae.`, config.json under `vae.` keys;
* scheduler/ scheduler_config.json under `scheduler.` keys;
* processor/ (or tokenizer/) the tokenizer, the chat template and the preprocessor configs.
*
* model_index.json itself goes under `pipeline.` keys, and its `_class_name` names the
* architecture: `QwenImage21Pipeline` is `qwenimage21`. A component folder may be a link to
* another pipeline's (a distilled release sharing its base's text encoder). */
int Checkpoint::open_diffusers() {
kind_ = SafeT;
RAD_TRY(meta_merge_json_file(dir_ + "/model_index.json", "pipeline", false, &meta_));
const std::string te = dir_ + "/text_encoder";
if (path_exists(te + "/config.json")) {
std::vector<std::string> shards;
std::unordered_map<std::string, std::string> owner;
RAD_TRY(shard_list(te, te + "/model.safetensors.index.json", false, &shards, &owner));
for (const auto& sh : shards) RAD_TRY(add_shard(sh, "", owner.empty() ? nullptr : &owner));
RAD_TRY(meta_from_config_json(te, &meta_));
RAD_TRY(meta_merge_generation_config(te, &meta_));
}
for (const char* comp : { "transformer", "vae" }) {
const std::string d = dir_ + "/" + comp;
if (!path_exists(d + "/config.json")) continue;
const std::string idx = d + "/diffusion_pytorch_model.safetensors.index.json";
std::vector<std::string> shards;
std::unordered_map<std::string, std::string> owner;
if (path_exists(idx)) {
RAD_TRY(shard_list(d, idx, true, &shards, &owner));
} else {
shards.push_back(d + "/diffusion_pytorch_model.safetensors");
}
for (const auto& sh : shards)
RAD_TRY(add_shard(sh, std::string(comp) + ".", owner.empty() ? nullptr : &owner));
RAD_TRY(meta_merge_json_file(d + "/config.json", comp, false, &meta_));
}
RAD_TRY(meta_merge_json_file(dir_ + "/scheduler/scheduler_config.json", "scheduler", true,
&meta_));
for (const char* sub : { "processor", "tokenizer" }) {
const std::string d = dir_ + "/" + sub;
if (!path_exists(d + "/tokenizer.json")) continue;
tok_dir_ = d;
RAD_TRY(meta_merge_preprocessor_configs(d, &meta_));
break;
}
/* The architecture is the pipeline's, whatever the text encoder calls itself. */
if (const char* cn = meta_.get("pipeline._class_name")) {
std::string a = cn;
const std::string suf = "Pipeline";
if (a.size() > suf.size() && a.compare(a.size() - suf.size(), suf.size(), suf) == 0)
a.resize(a.size() - suf.size());
for (char& ch : a) ch = (char)std::tolower((unsigned char)ch);
meta_.arch = a;
}
if (tensors_.empty()) {
RAD_ERR("%s: a diffusers pipeline with no component weights", dir_.c_str());
return RAD_E_NOTFOUND;
}
meta_.finish();
return RAD_OK;
}
int Checkpoint::open_safetensors(const std::string& path) {
kind_ = SafeT;
/* One shard, an index, or the directory holding either: one namespace whichever it is. */
@@ -488,6 +579,9 @@ int Checkpoint::open_safetensors(const std::string& path) {
const bool is_index = path.size() > 10 && path.compare(path.size() - 10, 10, "index.json") == 0;
const bool is_file = path.size() > 12 &&
path.compare(path.size() - 12, 12, ".safetensors") == 0;
if (!is_file && !is_index && path_exists(dir_ + "/model_index.json") &&
!path_exists(dir_ + "/config.json"))
return open_diffusers();
if (is_file) {
shards.push_back(path);
} else {