Archived
- 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
50 lines
2.2 KiB
C
50 lines
2.2 KiB
C
#ifndef RAD_PHILOX_H
|
|
#define RAD_PHILOX_H
|
|
|
|
/* Counter-based Gaussian noise, the one definition every kernel library computes it by, so an
|
|
* image's starting latent is a function of its seed and of nothing else: not the batch it shares a
|
|
* pass with, not the rank count, not the order its rows are visited in.
|
|
*
|
|
* Element e of a seed's stream is Philox4x32-10 at counter (e / 4, 0) keyed by the 64-bit seed,
|
|
* its four words made uniform in (0, 1) as ((w >> 8) + 0.5) * 2^-24 and paired by Box-Muller --
|
|
* words 0 and 1 give elements 4g and 4g+1 (r cos t, r sin t), words 2 and 3 give 4g+2 and 4g+3.
|
|
* f32 throughout. A library's libm may differ from another's in the last place of log, cos and
|
|
* sin, so two libraries agree to a tolerance and each agrees with itself exactly. */
|
|
#include <stdint.h>
|
|
#include <math.h>
|
|
|
|
#if defined(__HIPCC__)
|
|
#define RAD_PHILOX_HD __host__ __device__ __forceinline__
|
|
#else
|
|
#define RAD_PHILOX_HD static inline
|
|
#endif
|
|
|
|
RAD_PHILOX_HD void rad_philox4x32_10(uint32_t c[4], uint32_t k0, uint32_t k1) {
|
|
const uint32_t M0 = 0xD2511F53u, M1 = 0xCD9E8D57u, W0 = 0x9E3779B9u, W1 = 0xBB67AE85u;
|
|
for (int r = 0; r < 10; ++r) {
|
|
const uint64_t p0 = (uint64_t)M0 * c[0], p1 = (uint64_t)M1 * c[2];
|
|
const uint32_t hi0 = (uint32_t)(p0 >> 32), lo0 = (uint32_t)p0;
|
|
const uint32_t hi1 = (uint32_t)(p1 >> 32), lo1 = (uint32_t)p1;
|
|
const uint32_t n0 = hi1 ^ c[1] ^ k0, n2 = hi0 ^ c[3] ^ k1;
|
|
c[0] = n0; c[1] = lo1; c[2] = n2; c[3] = lo0;
|
|
k0 += W0;
|
|
k1 += W1;
|
|
}
|
|
}
|
|
|
|
/* Element `e` of the standard-normal stream of `seed`. */
|
|
RAD_PHILOX_HD float rad_philox_normal(uint64_t seed, uint64_t e) {
|
|
const uint64_t g = e >> 2;
|
|
uint32_t c[4] = { (uint32_t)g, (uint32_t)(g >> 32), 0u, 0u };
|
|
rad_philox4x32_10(c, (uint32_t)seed, (uint32_t)(seed >> 32));
|
|
const int j = (int)(e & 3u);
|
|
const uint32_t wa = c[(j >> 1) * 2], wb = c[(j >> 1) * 2 + 1];
|
|
const float ua = ((float)(wa >> 8) + 0.5f) * (1.0f / 16777216.0f);
|
|
const float ub = ((float)(wb >> 8) + 0.5f) * (1.0f / 16777216.0f);
|
|
const float r = sqrtf(-2.0f * logf(ua));
|
|
const float t = 6.28318530717958647692f * ub;
|
|
return (j & 1) ? r * sinf(t) : r * cosf(t);
|
|
}
|
|
|
|
#endif /* RAD_PHILOX_H */
|