This repository has been archived on 2026-11-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
radiance-sycl/tests/uocr_resample_golden.h
T
Deadcode 9eaf10da6e radiance 1.11.0
New models:
- GLM-5.3-Flash reads pictures: its vision tower and processor (--image-tokens sets the budget),
  with decode kernels for a few rows and the DSA indexer split over the ranks
- Sage-A1.5 (fp8 and MXFP4) with its vision tower and a DFlash2 drafter
- Unlimited-OCR (bf16)
- Gemma 4 31B with z-lab's DFlash and RedHatAI's DFlash2 drafters; at four cards its all-reduces
  are fused with the junctions, overlapped with the compute and sent compressed
- Ornith-1.5-35B-A3B w4a8 compose files

Speed:
- Block drafters (DFlash, DFlash2) accept their drafts on the card, and the next step is issued
  ahead
- The four-rank all-reduce is faster for every --tp 4 model
- qwen35_w8a8: the norms and SiLU write the int8 linears' operands directly
- --attn-prefill-fp8 off|qk|pv|both: fp8 QK and PV legs for the h256 prefill attention (about +20%
  prefill on a 221K-token prompt for the 27B MXFP4 at TP2); lossy, off by default

Features:
- Control vectors: --control-vector off|on|disabled (disabled by default), a per-request switch,
  and the published Qwen3.8-Flash-Next refusal-direction vector (its license is in NOTICE)
- Krea 2: the `rebalance` request field, as ComfyUI's ConditioningKrea2Rebalance
- Cards with a small PCI BAR run, with kernel arguments kept in host memory
- Dashboard: live acceptance figures; statsdump rotates its file at a size cap
- KV caches every rank holds whole (GLM-5.3's latent and index caches) take one host-tier slot

Fixes:
- Long conversations taking turns no longer fall back to an early snapshot: a host-tier restore
  makes room as memory pressure does and waits a step for the previous turn's release (two
  conversations of 142K and 147K tokens sent back to back: 31.3 s per turn before, 2.8 s now)
- Kernels before Linux 6.16 (amdgpu below 3.64) no longer hang at startup: virtual memory
  management is turned off there, with a warning
- Gemma 4 dense scales its token embeddings as Hugging Face does (bf16), which changes its output
- The four-rank all-reduce fences prefill-sized messages, for a rare divergence after a fresh start
- GLM-5.3: every refusal names the setting and the reason; its template keeps string content
- Several pictures in one request no longer refuse processors that take one image at a time

Changes: Plugin ABI 26: out-of-tree plugins must be rebuilt. The environment switches the PRs
added are fixed rules or flags now (R4D_ATTN_FP8 is --attn-prefill-fp8).
2026-10-23 11:57:52 +02:00

122 lines
4.4 KiB
C++

/* uocr_resample_golden.h -- loader for tests/data/golden/uocr_resample_golden.bin, the golden
* data resample_golden.py generates (torch CPU, seed 20261019) from F.interpolate(bicubic,
* antialias=True) and the Unlimited-OCR checkpoint. The data is a checked-in little-endian blob
* read at test time, not C arrays: 40 MB of literals would add ~10 s of compile per TU.
*
* Blob layout (little-endian, no padding):
* u32 magic 'UOCR', u32 version=1, u32 n_cases, u32 pad
* n_cases * { i32 ih, iw, oh, ow; i64 in_n, out_n } (32 B each)
* per case: f32 in[in_n], f32 out[out_n]
* u16 sam_src[64*64*768], sam_out[40*40*768], clip_src[257*1024], clip_out[101*1024]
*
* The bf16 payloads are stored as u16 bit patterns. */
#pragma once
#include <array>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <string>
#include <utility>
#include <vector>
#include "rad_test.h"
namespace uocr_golden {
struct Golden {
int n_cases = 0;
std::vector<std::array<int, 4>> geo; /* in_h, in_w, out_h, out_w; C=3 */
std::vector<std::vector<float>> in, out;
std::vector<uint16_t> sam_src, sam_out, clip_src, clip_out;
};
/* Reads the blob from RAD_GOLDEN_FIXTURES (tests/CMakeLists.txt). Returns false, reporting in
* `err`, on a missing, truncated, or mismatched blob; the caller skips via ARTIFACT_MISSING. */
inline bool load(Golden* g, std::string* err) {
#ifdef RAD_GOLDEN_FIXTURES
const std::string path = std::string(RAD_GOLDEN_FIXTURES) + "/uocr_resample_golden.bin";
#else
const std::string path = "uocr_resample_golden.bin";
#endif
std::ifstream f(path, std::ios::binary);
if (!f) {
*err = "cannot open " + path;
return false;
}
std::vector<char> raw((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
const auto u32 = [&raw](size_t o) {
uint32_t v;
std::memcpy(&v, raw.data() + o, 4);
return v;
};
const auto i64 = [&raw](size_t o) {
int64_t v;
std::memcpy(&v, raw.data() + o, 8);
return v;
};
const auto f32 = [&raw](size_t o) {
float v;
std::memcpy(&v, raw.data() + o, 4);
return v;
};
const auto u16 = [&raw](size_t o) {
uint16_t v;
std::memcpy(&v, raw.data() + o, 2);
return v;
};
if (raw.size() < 16 || u32(0) != 0x52434F55u || u32(4) != 1u) {
*err = path + ": not a uocr golden blob (magic/version)";
return false;
}
const uint32_t n = u32(8);
size_t off = 16;
if (raw.size() < off + (size_t)n * 32) {
*err = path + ": truncated case table";
return false;
}
g->n_cases = (int)n;
g->geo.assign(n, {});
g->in.assign(n, {});
g->out.assign(n, {});
std::vector<std::pair<int64_t, int64_t>> ns(n);
for (uint32_t k = 0; k < n; ++k) {
g->geo[k] = { (int)(int32_t)u32(off), (int)(int32_t)u32(off + 4),
(int)(int32_t)u32(off + 8), (int)(int32_t)u32(off + 12) };
ns[k] = { i64(off + 16), i64(off + 24) };
off += 32;
}
for (uint32_t k = 0; k < n; ++k) {
for (int which = 0; which < 2; ++which) {
const int64_t cnt = which ? ns[k].second : ns[k].first;
std::vector<float>& dst = which ? g->out[k] : g->in[k];
if (cnt < 0 || raw.size() < off + (size_t)cnt * 4) {
*err = path + ": truncated fp32 payload";
return false;
}
dst.resize((size_t)cnt);
for (int64_t i = 0; i < cnt; ++i) dst[(size_t)i] = f32(off + (size_t)i * 4);
off += (size_t)cnt * 4;
}
}
const size_t need = (size_t)(64 * 64 * 768 + 40 * 40 * 768 + 257 * 1024 + 101 * 1024) * 2;
if (raw.size() != off + need) {
*err = path + ": size mismatch (expected " + std::to_string(off + need) +
" B, got " + std::to_string(raw.size()) + " B)";
return false;
}
size_t p = 0;
for (std::vector<uint16_t>* v : { &g->sam_src, &g->sam_out, &g->clip_src, &g->clip_out }) {
const size_t cnt = v == &g->sam_src ? (size_t)64 * 64 * 768
: v == &g->sam_out ? (size_t)40 * 40 * 768
: v == &g->clip_src ? (size_t)257 * 1024
: (size_t)101 * 1024;
v->resize(cnt);
for (size_t i = 0; i < cnt; ++i) (*v)[i] = u16(off + (p + i) * 2);
p += cnt;
}
return true;
}
} // namespace uocr_golden