radiance 1.2.4

- EmbeddingGemma 2 (google/embeddinggemma-2): text, image, video and audio embeddings on the
  card (libr4d) and on the CPU (libavx); prompt_name, Matryoshka dimensions, image budgets,
  mixed content parts and the messages form on /v1/embeddings
- #43: on serves that lend the activation arena to the experts (Qwen3.8-Flash-Next with
  expert_tiered), every image after the first read its rows from the wrong place -- garbage
  replies, or an earlier request's image. Fixed
- the Qwen vision towers' attention resolves on the card again (broken on main after 1.2.3,
  never released)
- #42: a warning at startup when amdgpu cwsr_enable is 0, and a stalled queue is reported as
  slow or stuck; the guide covers the GPU-hang-and-reset chain
This commit is contained in:
Deadcode committed 2026-10-07 22:42:45 +02:00
1 parent 05af4db458
commit 7d840861af
76 files changed
+8324 -467

No files matched your search

+28 -19
View File
@@ -495,21 +495,27 @@ int BatchBuilder::layout(Program& prog, const Config& cfg) {
: a.conv_grp < b.conv_grp;
});
mm_on_ = prog.encoder.modalities != 0;
mm_on_ = prog.encoder.modalities != 0 || prog.audio_encoder.modalities != 0;
return RAD_OK;
}
/* ------------------------------------------------------------------ media staging */
BatchBuilder::MediaBytes BatchBuilder::media_bytes() {
const RadEncoderDecl& e = prog_->encoder;
n_embd_ = e.n_embd;
enc_patches_ = e.max_patches;
enc_dim_ = e.patch_dim;
/* The most segments one pass can hold: a segment is at least one output row, `merge` patches. */
enc_segs_ = e.max_patches / (e.merge > 0 ? e.merge : 1) + 1;
/* The larger of the two encoders' passes, field by field: they run one at a time. Both write
* rows of the model's embedding width. */
enc_patches_ = enc_pix_elems_ = enc_segs_ = 0;
n_embd_ = 0;
for (const RadEncoderDecl* e : { &prog_->encoder, &prog_->audio_encoder }) {
if (e->modalities == 0) continue;
n_embd_ = std::max<int64_t>(n_embd_, e->n_embd);
enc_patches_ = std::max<int64_t>(enc_patches_, e->max_patches);
enc_pix_elems_ = std::max<int64_t>(enc_pix_elems_, e->max_patches * e->patch_dim);
/* The most segments one pass can hold: a segment is at least one output row. */
enc_segs_ = std::max<int64_t>(enc_segs_, e->max_patches / (e->merge > 0 ? e->merge : 1) + 1);
}
MediaBytes m;
m.mm = max_tok_ * n_embd_ * (int64_t)sizeof(uint16_t);
m.pix = enc_patches_ * enc_dim_ * (int64_t)sizeof(uint16_t);
m.pix = enc_pix_elems_ * (int64_t)sizeof(uint16_t);
m.crd = 4 * enc_patches_ * (int64_t)sizeof(int32_t);
m.cu = (enc_segs_ + 1) * (int64_t)sizeof(int32_t);
return m;
@@ -546,7 +552,7 @@ int BatchBuilder::alloc_media() {
}
if (rad_event_create_as(&mm_ev_, RAD_EVENT_LOCAL | RAD_EVENT_HOST_WAIT) < 0) return RAD_E_DEVICE;
RAD_INFO("media staging: %s a rank for a step's encoder rows and %s for an encoder pass of "
"%lld patches", humanb(mm_bytes).c_str(),
"up to %lld patches", humanb(mm_bytes).c_str(),
humanb(pix_bytes + crd_bytes + cu_bytes).c_str(), (long long)enc_patches_);
return RAD_OK;
}
@@ -1272,24 +1278,27 @@ AdvanceArgs BatchBuilder::advance_args(int rank) const {
}
/* ------------------------------------------------------------------ the encoder pass */
const RadBatch* BatchBuilder::build_encoder(const std::vector<EncoderPart>& parts, int step) {
if (!mm_on_ || parts.empty()) return nullptr;
const RadBatch* BatchBuilder::build_encoder(const std::vector<EncoderPart>& parts, int step,
const RadEncoderDecl& enc) {
if (!mm_on_ || parts.empty() || enc.modalities == 0) return nullptr;
const int64_t enc_dim = enc.patch_dim;
const int64_t max_segs = enc.max_patches / (enc.merge > 0 ? enc.merge : 1) + 1;
int64_t n_patch = 0, n_seg = 0, max_seg = 0;
enc_cu_host_[0] = 0;
for (const EncoderPart& p : parts) {
const mm::Item& it = *p.item;
const int64_t seg_p = (int64_t)it.grid_h * it.grid_w;
const int64_t np = seg_p * p.n_seg;
if (it.patch_dim != enc_dim_ || n_patch + np > enc_patches_ ||
n_seg + p.n_seg > enc_segs_ || p.seg0 + p.n_seg > it.n_seg) {
if (it.patch_dim != enc_dim || n_patch + np > enc.max_patches ||
n_seg + p.n_seg > max_segs || p.seg0 + p.n_seg > it.n_seg) {
RAD_ERR("encoder pass: %lld patches in %lld segments do not fit the declared pass of "
"%lld patches of %lld elements", (long long)(n_patch + np),
(long long)(n_seg + p.n_seg), (long long)enc_patches_, (long long)enc_dim_);
(long long)(n_seg + p.n_seg), (long long)enc.max_patches, (long long)enc_dim);
return nullptr;
}
std::memcpy(enc_pix_host_ + n_patch * enc_dim_,
it.pixels.data() + (int64_t)p.seg0 * seg_p * enc_dim_,
(size_t)(np * enc_dim_) * sizeof(uint16_t));
std::memcpy(enc_pix_host_ + n_patch * enc_dim,
it.pixels.data() + (int64_t)p.seg0 * seg_p * enc_dim,
(size_t)(np * enc_dim) * sizeof(uint16_t));
n_patch += np;
for (int32_t q = 0; q < p.n_seg; ++q) {
enc_cu_host_[n_seg + 1] = enc_cu_host_[n_seg] + (int32_t)seg_p;
@@ -1316,7 +1325,7 @@ const RadBatch* BatchBuilder::build_encoder(const std::vector<EncoderPart>& part
for (size_t r = 0; r < ranks_.size(); ++r) {
RadStream st = ranks_[r].stream;
if (rad_memcpy_async(enc_pix_dev_[r], enc_pix_host_,
n_patch * enc_dim_ * (int64_t)sizeof(uint16_t), st) < 0 ||
n_patch * enc_dim * (int64_t)sizeof(uint16_t), st) < 0 ||
rad_memcpy_async(enc_coord_dev_[r], enc_coord_host_,
4 * n_patch * (int64_t)sizeof(int32_t), st) < 0 ||
rad_memcpy_async(enc_cu_dev_[r], enc_cu_host_,
@@ -1333,7 +1342,7 @@ const RadBatch* BatchBuilder::build_encoder(const std::vector<EncoderPart>& part
B.step = step;
B.n_kv_groups = (int)o.kv[r].size();
B.kv = o.kv[r].data();
B.enc = 1;
B.enc = (int32_t)enc.modalities;
B.enc_n_patch = n_patch;
B.enc_pixels = enc_pix_dev_[r];
B.enc_coord = static_cast<const int32_t*>(enc_coord_dev_[r]);