Archived
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:
1 parent
b93b531f63
commit
b068190326
66 files changed
+9035
-87
No files matched your search
@@ -1067,6 +1067,11 @@ int Builder::declare_logits(rad_buf b) {
|
||||
prog_.buffers[prog_.pooled_buf].name.c_str());
|
||||
return RAD_E_STATE;
|
||||
}
|
||||
if (prog_.generator.layout != 0) {
|
||||
err(RAD_E_STATE, "declare_logits: this program already declared the image generator '%s'",
|
||||
prog_.gen_str.name.c_str());
|
||||
return RAD_E_STATE;
|
||||
}
|
||||
prog_.logits_buf = b;
|
||||
return RAD_OK;
|
||||
}
|
||||
@@ -1093,6 +1098,11 @@ int Builder::declare_pooled(rad_buf b) {
|
||||
prog_.buffers[prog_.logits_buf].name.c_str());
|
||||
return RAD_E_STATE;
|
||||
}
|
||||
if (prog_.generator.layout != 0) {
|
||||
err(RAD_E_STATE, "declare_pooled: this program already declared the image generator '%s'",
|
||||
prog_.gen_str.name.c_str());
|
||||
return RAD_E_STATE;
|
||||
}
|
||||
const RadBufDecl& d = prog_.buffers[b].decl;
|
||||
if (d.dtype != RAD_F32 || d.domain != RAD_DOMAIN_DEVICE || d.rank != 2 ||
|
||||
d.shape[0] < prog_.ctx.max_seqs || d.shape[1] <= 0) {
|
||||
@@ -1173,6 +1183,105 @@ int Builder::declare_encoder(const RadEncoderDecl* d) {
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
/* WHAT THE GENERATOR IS. Checked whole here: a generator's every request runs all three of its
|
||||
* passes, so a declaration the core cannot drive fails the first request rather than a rare one,
|
||||
* and the first request is the wrong place to learn that the plugin sized its image buffer for a
|
||||
* smaller picture than it says it makes. The strings are copied: the plugin's storage is not the
|
||||
* Program's, and the Program outlives a declare. */
|
||||
int Builder::declare_generator(const RadGeneratorDecl* d) {
|
||||
if (finished_) { err(RAD_E_STATE, "declare_generator after declare finished"); return RAD_E_STATE; }
|
||||
if (!d) { err(RAD_E_INVAL, "declare_generator: null declaration"); return RAD_E_INVAL; }
|
||||
const char* nm = d->name && *d->name ? d->name : "(unnamed)";
|
||||
if (prog_.generator.layout != 0) {
|
||||
err(RAD_E_STATE, "declare_generator: '%s' was already declared; '%s' is a second one",
|
||||
prog_.gen_str.name.c_str(), nm);
|
||||
return RAD_E_STATE;
|
||||
}
|
||||
if (prog_.logits_buf != RAD_NULL_HANDLE || prog_.pooled_buf != RAD_NULL_HANDLE) {
|
||||
err(RAD_E_STATE, "declare_generator '%s': this program already declared %s; a program "
|
||||
"generates text, embeds or makes images -- one of the three", nm,
|
||||
prog_.logits_buf != RAD_NULL_HANDLE ? "logits" : "a pooled output");
|
||||
return RAD_E_STATE;
|
||||
}
|
||||
if (d->layout != RAD_GEN_LAYOUT_JOINT_GRID) {
|
||||
err(RAD_E_INVAL, "declare_generator '%s': layout %d is not one this engine builds", nm,
|
||||
(int)d->layout);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
auto has = [](const char* t, const char* what) { return t && std::strstr(t, what); };
|
||||
if (!has(d->tmpl_text, "{prompt}") || !has(d->tmpl_edit, "{prompt}") ||
|
||||
!has(d->tmpl_edit, "{images}") || !has(d->tmpl_image, "{image}")) {
|
||||
err(RAD_E_INVAL, "declare_generator '%s': tmpl_text needs {prompt}, tmpl_edit {images} and "
|
||||
"{prompt}, and tmpl_image {image}, where the picture's tokens go", nm);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (d->latent_channels <= 0 || d->latent_scale <= 0 || d->size_multiple <= 0 ||
|
||||
d->size_multiple % d->latent_scale != 0 || d->pixel_channels <= 0 ||
|
||||
d->pixel_channels > 4 || d->slot_rows <= 0 || d->max_tokens <= 0 || d->max_refs < 0 ||
|
||||
d->ref_area <= 0 || d->default_width <= 0 || d->default_height <= 0 ||
|
||||
d->default_width % d->size_multiple != 0 || d->default_height % d->size_multiple != 0 ||
|
||||
(d->default_width / d->latent_scale) * (d->default_height / d->latent_scale) > d->max_tokens ||
|
||||
d->max_lanes <= 0) {
|
||||
err(RAD_E_INVAL, "declare_generator '%s': a geometry field is out of range (latent %lld x "
|
||||
"%lld px, multiple %lld, %lld channels, slot rows %lld, max %lld tokens, "
|
||||
"default %lldx%lld, %lld lanes)", nm, (long long)d->latent_channels,
|
||||
(long long)d->latent_scale, (long long)d->size_multiple, (long long)d->pixel_channels,
|
||||
(long long)d->slot_rows, (long long)d->max_tokens, (long long)d->default_width,
|
||||
(long long)d->default_height, (long long)d->max_lanes);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (d->n_sigmas < 0 || (d->n_sigmas > 0 && !d->sigmas) ||
|
||||
(d->n_sigmas == 0 && d->default_steps <= 0) || !(d->default_cfg >= 1.0) ||
|
||||
(d->dyn_shift && (d->max_seq <= d->base_seq || d->base_seq <= 0)) ||
|
||||
(!d->dyn_shift && !(d->shift > 0)) || d->shift_terminal < 0 || d->shift_terminal >= 1) {
|
||||
err(RAD_E_INVAL, "declare_generator '%s': the sampler is incomplete (%d fixed sigmas, %lld "
|
||||
"default steps, shift %g, dynamic %d over %lld..%lld, terminal %g, "
|
||||
"guidance %g)", nm, (int)d->n_sigmas, (long long)d->default_steps,
|
||||
d->shift, (int)d->dyn_shift, (long long)d->base_seq, (long long)d->max_seq,
|
||||
d->shift_terminal, d->default_cfg);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
for (int i = 0; i < d->n_sigmas; ++i)
|
||||
if (!(d->sigmas[i] > 0.0 && d->sigmas[i] <= 1.0) ||
|
||||
(i > 0 && !(d->sigmas[i] < d->sigmas[i - 1]))) {
|
||||
err(RAD_E_INVAL, "declare_generator '%s': fixed sigma %d (%g) is not in (0, 1] below "
|
||||
"the one before it", nm, i, d->sigmas[i]);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (d->image_out == RAD_NULL_HANDLE || (size_t)d->image_out >= prog_.buffers.size()) {
|
||||
err(RAD_E_INVAL, "declare_generator '%s': image_out %u is not a declared buffer", nm,
|
||||
(unsigned)d->image_out);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
const RadBufDecl& ob = prog_.buffers[d->image_out].decl;
|
||||
int64_t numel = 1;
|
||||
for (uint32_t i = 0; i < ob.rank; ++i) numel *= ob.shape[i];
|
||||
const int64_t px = d->max_tokens * d->latent_scale * d->latent_scale;
|
||||
if (ob.dtype != RAD_U8 || ob.domain != RAD_DOMAIN_DEVICE || numel < px * d->pixel_channels) {
|
||||
err(RAD_E_INVAL, "declare_generator '%s': image_out '%s' must be a device u8 buffer of at "
|
||||
"least %lld x %lld -- the largest image", nm,
|
||||
prog_.buffers[d->image_out].name.c_str(), (long long)px, (long long)d->pixel_channels);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
Program::GenStrings& g = prog_.gen_str;
|
||||
g.name = nm;
|
||||
g.tmpl_text = d->tmpl_text;
|
||||
g.tmpl_edit = d->tmpl_edit;
|
||||
g.tmpl_image = d->tmpl_image;
|
||||
g.tmpl_image_sep = d->tmpl_image_sep ? d->tmpl_image_sep : "";
|
||||
g.drop_prefix = d->drop_prefix ? d->drop_prefix : "";
|
||||
g.tmpl_transparent = d->tmpl_transparent ? d->tmpl_transparent : "";
|
||||
g.sigmas.assign(d->sigmas, d->sigmas + d->n_sigmas);
|
||||
prog_.generator = *d;
|
||||
/* The Program is moved after declare, and a pointer into a moved string is a pointer into the
|
||||
* old one's storage: nothing here may be read through the decl, only through gen_str. */
|
||||
RadGeneratorDecl& c = prog_.generator;
|
||||
c.name = c.tmpl_text = c.tmpl_edit = c.tmpl_image = c.tmpl_image_sep = nullptr;
|
||||
c.drop_prefix = c.tmpl_transparent = nullptr;
|
||||
c.sigmas = nullptr;
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
/* WHAT THE DRAFT HEAD IS. Every field is checked here rather than at the first draft pass: a
|
||||
* drafter is exercised only once a request is speculating, so a decl that is wrong in a way the
|
||||
* engine cannot act on would otherwise surface as acceptance that is quietly zero.
|
||||
@@ -1822,6 +1931,11 @@ int rad_declare_encoder(RadBuilder* b, const RadEncoderDecl* d) {
|
||||
return B(b)->declare_encoder(d);
|
||||
}
|
||||
|
||||
int rad_declare_generator(RadBuilder* b, const RadGeneratorDecl* d) {
|
||||
if (!b) return RAD_E_INVAL;
|
||||
return B(b)->declare_generator(d);
|
||||
}
|
||||
|
||||
void rad_note(RadBuilder* b, const char* f, ...) {
|
||||
if (!b) return;
|
||||
va_list ap;
|
||||
|
||||
Reference in new issue
Block a user