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
+24
-12
@@ -40,10 +40,10 @@ using namespace ref;
|
||||
|
||||
namespace {
|
||||
|
||||
/* The largest head this reference accumulates in one stack frame. MLA's 576 is the widest head in
|
||||
* circulation and libr4d's widest is 256, so 1024 is headroom rather than a limit anyone will
|
||||
* meet; above it the op says RAD_E_UNSUPPORTED by name instead of overflowing a frame. */
|
||||
enum { REF_HD_MAX = 1024 };
|
||||
/* The largest head this reference accumulates in one stack frame. The widest in circulation is an
|
||||
* image VAE's single-head mid-block attention at 1152 (Qwen-Image 2.1), so 2048 is headroom; above
|
||||
* it the op says RAD_E_UNSUPPORTED by name instead of overflowing a frame. */
|
||||
enum { REF_HD_MAX = 2048 };
|
||||
|
||||
struct KVView {
|
||||
const RadTensor* t;
|
||||
@@ -564,10 +564,15 @@ int ref_qk_norm_rope(const RadArgs* a, RadStream) {
|
||||
const float rscale = p_f32(a, "scale", 1.0f);
|
||||
const float wadd = p_f32(a, "wadd", 0.0f);
|
||||
const int v_norm = (int)p_int(a, "v_norm", 0);
|
||||
static const char* kModes[] = { "neox", "gptj", "blocks" };
|
||||
const int mode = p_enum(a, "mode", kModes, 3, 0);
|
||||
/* `gptj_blocks` is `blocks` with each section's pairs ADJACENT -- (start + 2j, start + 2j + 1),
|
||||
* the complex-number form a 3-axis image rotary takes (Qwen-Image's). `imrope` is `rope`'s
|
||||
* interleaved M-RoPE over NeoX pairs, after the norm (Qwen3-VL's text attention). */
|
||||
static const char* kModes[] = { "neox", "gptj", "blocks", "gptj_blocks", "imrope" };
|
||||
const int mode = p_enum(a, "mode", kModes, 5, 0);
|
||||
if (mode < 0) return RAD_E_UNSUPPORTED;
|
||||
const bool blocks = mode == 2;
|
||||
const bool blocks = mode == 2 || mode == 3;
|
||||
const bool adjacent = mode == 3;
|
||||
const bool im = mode == 4;
|
||||
int64_t rot = p_int(a, "rotary_dim", head_dim);
|
||||
if (head_dim <= 0 || n_head <= 0 || rot <= 0 || rot > head_dim || (rot & 1)) return RAD_E_SHAPE;
|
||||
if (numel(qw) < head_dim || numel(kw) < head_dim) return RAD_E_SHAPE;
|
||||
@@ -578,6 +583,10 @@ int ref_qk_norm_rope(const RadArgs* a, RadStream) {
|
||||
* fill the rotated prefix exactly. Positions are [C, M], component-major. */
|
||||
int64_t sec[8] = {}, comp[8] = {};
|
||||
int n_sec = 0;
|
||||
if (im) {
|
||||
n_sec = rope_sections(a, sec);
|
||||
if (n_sec < 3) return RAD_E_SHAPE;
|
||||
}
|
||||
if (blocks) {
|
||||
n_sec = rope_sections(a, sec);
|
||||
if (n_sec <= 0) return RAD_E_SHAPE;
|
||||
@@ -599,8 +608,9 @@ int ref_qk_norm_rope(const RadArgs* a, RadStream) {
|
||||
const bool multi = pos->rank >= 2;
|
||||
const int64_t n_comp = multi ? pos->shape[0] : 1;
|
||||
const int64_t M = multi ? pos->shape[1] : numel(pos);
|
||||
if (multi && !blocks) return RAD_E_SHAPE;
|
||||
for (int c = 0; c < n_sec; ++c)
|
||||
if (multi && !blocks && !im) return RAD_E_SHAPE;
|
||||
if (multi && im && n_comp < 3) return RAD_E_SHAPE;
|
||||
for (int c = 0; blocks && c < n_sec; ++c)
|
||||
if (comp[c] < 0 || comp[c] >= n_comp) return RAD_E_SHAPE;
|
||||
const int64_t pcs = multi ? pos->stride[0] : 0, pms = multi ? pos->stride[1] : 0;
|
||||
|
||||
@@ -610,7 +620,8 @@ int ref_qk_norm_rope(const RadArgs* a, RadStream) {
|
||||
const int64_t ds = laststride(qkv);
|
||||
RopeFreq f;
|
||||
/* No `ladder` on this row yet: the fused norm+rope measures by `rot`, as it always has. */
|
||||
RAD_REF_TRY(rope_freqs(mode, rot, rot, theta, nullptr, 0, &f));
|
||||
if (im) RAD_REF_TRY(rope_freqs(ROPE_IMROPE, rot, rot, theta, sec, multi ? n_sec : 0, &f));
|
||||
else RAD_REF_TRY(rope_freqs(blocks ? 0 : mode, rot, rot, theta, nullptr, 0, &f));
|
||||
|
||||
|
||||
#pragma omp parallel for schedule(static)
|
||||
@@ -637,7 +648,7 @@ int ref_qk_norm_rope(const RadArgs* a, RadStream) {
|
||||
for (int64_t d = 0; d < head_dim; ++d)
|
||||
stt(qkv, base + d * ds, ldt(qkv, base + d * ds) * sc * (ldt(w, d * ws) + wadd));
|
||||
if (!blocks) {
|
||||
rope_head(qkv, base, ds, rot, mode, f, p);
|
||||
rope_head(qkv, base, ds, rot, im ? ROPE_IMROPE : mode, f, p);
|
||||
continue;
|
||||
}
|
||||
int64_t start = 0;
|
||||
@@ -646,7 +657,8 @@ int ref_qk_norm_rope(const RadArgs* a, RadStream) {
|
||||
const float inv = 1.0f / std::pow(theta, (float)j / (float)sec[c]);
|
||||
const float ang = p[comp[c]] * inv;
|
||||
const float cs = std::cos(ang), sn = std::sin(ang);
|
||||
const int64_t i0 = start + j, i1 = start + sec[c] + j;
|
||||
const int64_t i0 = adjacent ? start + 2 * j : start + j;
|
||||
const int64_t i1 = adjacent ? start + 2 * j + 1 : start + sec[c] + j;
|
||||
const float x0 = ldt(qkv, base + i0 * ds), x1 = ldt(qkv, base + i1 * ds);
|
||||
stt(qkv, base + i0 * ds, x0 * cs - x1 * sn);
|
||||
stt(qkv, base + i1 * ds, x0 * sn + x1 * cs);
|
||||
|
||||
Reference in new issue
Block a user