Archived
review: apply the Unlimited-OCR code-review findings
The 2a1ca01..f308216 range's 45 review findings (12 performance, 33 quality) are applied: ABI 23 for the RadBatch append, the fused q|k|v projection, the batched patch-embed GEMM and pitched layout copies, the sam_attn w-dot hoist with an alignment-gated vector row path and NaN poisoning for malformed segments, the fused quick_gelu act, and the R-SWA/scheduler/drafting gates. Quality items: stale comments corrected, env reads hoisted, the ngram_window negative refusal, the parts-form chat template instruction, the whitelist fallback warning, and the segmented R-SWA refusal of the fixed/runtime window mix. The 3.2 MB generated resample header becomes a 9.6 MB little-endian blob (tests/data/golden/uocr_resample_golden.bin) read by a small loader; resample_golden.py emits and round-trip-verifies it. One perf-med item (AVX2 bicubic passes/LUT patch staging in the processor) is left as the follow-up the review itself recommends; the code says why. Verified: ninja -C build-review -k 0; host ctest 89/89; GPU r4d_selftest 0 failures, kbench/kbench_moe and the card tests pass.
This commit is contained in:
1 parent
1f661bf2e0
commit
859efc7208
35 files changed
+799
-399093
No files matched your search
+11
-6
@@ -82,18 +82,19 @@ int Engine::run_encodes() {
|
||||
ip->embd.assign((size_t)(ip->n_rows() * e.n_embd), 0);
|
||||
/* Diagnostic: RADIANCE_DEBUG_MM_ROWS=<raw bf16 file> substitutes a reference encoder's
|
||||
* rows for the tower's, to tell a tower difference from a language-model one. */
|
||||
if (const char* rp = std::getenv("RADIANCE_DEBUG_MM_ROWS")) {
|
||||
if (FILE* rf = std::fopen(rp, "rb")) {
|
||||
static const char* const rows_ref = std::getenv("RADIANCE_DEBUG_MM_ROWS");
|
||||
if (rows_ref) {
|
||||
if (FILE* rf = std::fopen(rows_ref, "rb")) {
|
||||
const size_t want = ip->embd.size() * sizeof(uint16_t);
|
||||
const size_t got = std::fread(ip->embd.data(), 1, want, rf);
|
||||
std::fclose(rf);
|
||||
if (got == want) {
|
||||
ip->encoded = true;
|
||||
RAD_INFO("encoder: %zu row(s) taken from %s instead of the tower",
|
||||
(size_t)ip->n_rows(), rp);
|
||||
RAD_INFO("encoder: %zu row(s) taken from %s instead of the tower",
|
||||
(size_t)ip->n_rows(), rows_ref);
|
||||
continue;
|
||||
}
|
||||
RAD_ERR("encoder: %s holds %zu bytes, wanted %zu", rp, got, want);
|
||||
RAD_ERR("encoder: %s holds %zu bytes, wanted %zu", rows_ref, got, want);
|
||||
}
|
||||
}
|
||||
if (dump_dir && *dump_dir) dump(*ip, ".pix.bf16", ip->pixels.data(), ip->pixels.size());
|
||||
@@ -146,7 +147,11 @@ int Engine::run_encodes() {
|
||||
if (!sep) seg_grid = g;
|
||||
}
|
||||
if (seg == first) {
|
||||
if (seg_grid == 0) seg_grid = it.seg_h(seg); /* a lone oversized segment */
|
||||
/* Nothing of this item packed into the pass: its first segment did not fit
|
||||
* a pass that already has content (a segment larger than the whole pass was
|
||||
* refused above). `seg` addresses a real segment only below `it.n_seg`;
|
||||
* a degenerate zero-segment item leaves seg_grid alone. */
|
||||
if (seg_grid == 0 && seg < it.n_seg) seg_grid = it.seg_h(seg);
|
||||
break;
|
||||
}
|
||||
parts.push_back({ &it, first, seg - first });
|
||||
|
||||
Reference in new issue
Block a user