Archived
DeepEncoder (arch/common/rad_block_sam.h): the checkpoint's SAM ViT-B/16, neck and CLIP ViT-L/14 producing its 16x17+1 row layout, with a new `sam_attn` op for the windowed, zero-padded SAM attention and its decomposed relative-position bias (libref oracle, libavx kernel, libr4d kernel and selftest). The plugin declares the tower when the container records `radiance.encoder`, and splices its rows over the placeholders after embed_lookup. BOS: the chat path adds BOS when the rendered template does not already start with it. This checkpoint's template is a bare concatenation and its tokenizer states add_bos_token, so without it every position was off by one and the det boxes came out wrong. A media run's placeholders shift with it. R-SWA: RAD_KV_RING, paged like a window group but with a per-sequence floor armed at admission. adv_groups now computes the same clamped seqused and modulo ring slots the builder stages; the mismatch read the block table's -1 padding and faulted the card. Prefill stays causal; prefix cache, checkpoints and speculation are off for the group. Sampling: sample_ngram_ban in libref/libavx/libr4d and the host chain, the request knobs, and the container's generation config (35 over 128). Processor: the checkpoint's grid/mode selection, its tall-last tie order, Pillow's bicubic pass order, and goldens generated from its own code. Tools: --mm-max-patches auto-detection accepts a tower stated as per-width tables under vision_config.image_size, and rad-convert records radiance.encoder. Verified: tower stages match the checkpoint's code (rows cos 0.9998), the device sam_attn selftest is within tolerance, the R-SWA device repro returns text, a GPU e2e reproduces the reference's first det block, and the host suite is 88/89 (known webp decode baseline).
139 lines
5.0 KiB
C++
139 lines
5.0 KiB
C++
/* uocr_golden.h -- GENERATED by mkuocrgolden.py from the checkpoint's remote code; do not edit. */
|
|
#pragma once
|
|
#include <cstdint>
|
|
|
|
static const int32_t kUocrPatch = 16, kUocrDownsample = 4;
|
|
static const int32_t kUocrBaseSize = 1024, kUocrTile = 640;
|
|
static const int32_t kUocrMinTiles = 2, kUocrMaxTiles = 32;
|
|
static const bool kUocrCropMode = true;
|
|
static const int32_t kUocrImageToken = 128815;
|
|
|
|
struct GoldUocrGrid { int64_t h, w; int32_t cols, rows; };
|
|
static const GoldUocrGrid kUocrGrid[] = {
|
|
{ 1, 1, 1, 1 },
|
|
{ 40, 30, 1, 1 },
|
|
{ 100, 100, 1, 1 },
|
|
{ 300, 500, 1, 1 },
|
|
{ 500, 300, 1, 1 },
|
|
{ 640, 640, 1, 1 },
|
|
{ 641, 641, 2, 2 },
|
|
{ 500, 700, 4, 3 },
|
|
{ 700, 500, 3, 4 },
|
|
{ 800, 1000, 5, 4 },
|
|
{ 1000, 800, 4, 5 },
|
|
{ 1024, 1024, 2, 2 },
|
|
{ 1280, 1024, 4, 5 },
|
|
{ 1024, 1280, 5, 4 },
|
|
{ 900, 1400, 3, 2 },
|
|
{ 1400, 900, 2, 3 },
|
|
{ 2000, 600, 3, 10 },
|
|
{ 600, 2000, 10, 3 },
|
|
{ 2400, 400, 1, 6 },
|
|
{ 400, 2400, 6, 1 },
|
|
{ 1080, 1920, 7, 4 },
|
|
{ 1920, 1080, 4, 7 },
|
|
{ 515, 1031, 2, 1 },
|
|
{ 1031, 515, 1, 2 },
|
|
{ 100, 5000, 32, 1 },
|
|
{ 5000, 100, 1, 32 },
|
|
{ 3000, 3000, 5, 5 },
|
|
{ 720, 1280, 7, 4 },
|
|
{ 800, 640, 4, 5 },
|
|
{ 640, 800, 5, 4 },
|
|
{ 960, 720, 3, 4 },
|
|
{ 720, 960, 4, 3 },
|
|
{ 1600, 1200, 3, 4 },
|
|
{ 1200, 1600, 4, 3 },
|
|
{ 33, 4096, 32, 1 },
|
|
{ 4096, 33, 1, 32 },
|
|
};
|
|
|
|
struct GoldUocrPic { int32_t f, h, w, mode; int32_t cols, rows, n_ids; int32_t n_seg, seg0; uint64_t global_fnv, local_fnv; };
|
|
static const GoldUocrPic kUocrPictures[] = {
|
|
{ 0, 300, 500, 1, 1, 1, 273, 2, 0, 0xabc7f1eabc334430ull, 0x0000000000000000ull },
|
|
{ 1, 900, 1400, 1, 3, 2, 893, 4, 2, 0xb068ca82d7ec14c3ull, 0x93a9d30576e60c3eull },
|
|
{ 2, 2400, 400, 1, 1, 6, 933, 8, 6, 0x92636385d3bfb221ull, 0x2df135a4207447b6ull },
|
|
{ 3, 500, 700, 1, 4, 3, 1503, 5, 14, 0x2feb196ccb92c0feull, 0x2627954c4ca5bc98ull },
|
|
{ 4, 64, 48, 1, 1, 1, 273, 2, 19, 0x406b72ef3c95b8b6ull, 0x0000000000000000ull },
|
|
{ 5, 800, 1000, 1, 5, 4, 2313, 6, 21, 0xa449cce59a03d7dcull, 0x36b9d429ad266a50ull },
|
|
{ 0, 300, 500, 2, 1, 1, 273, 2, 27, 0xabc7f1eabc334430ull, 0x0000000000000000ull },
|
|
{ 1, 900, 1400, 2, 1, 1, 273, 2, 29, 0xb068ca82d7ec14c3ull, 0x0000000000000000ull },
|
|
{ 2, 2400, 400, 2, 1, 1, 273, 2, 31, 0x92636385d3bfb221ull, 0x0000000000000000ull },
|
|
{ 3, 500, 700, 2, 1, 1, 273, 2, 33, 0x2feb196ccb92c0feull, 0x0000000000000000ull },
|
|
{ 4, 64, 48, 2, 1, 1, 273, 2, 35, 0x406b72ef3c95b8b6ull, 0x0000000000000000ull },
|
|
{ 5, 800, 1000, 2, 1, 1, 273, 2, 37, 0xa449cce59a03d7dcull, 0x0000000000000000ull },
|
|
{ 1, 900, 1400, 3, 1, 1, 111, 2, 39, 0x45321be8ce76d69dull, 0x0000000000000000ull },
|
|
{ 3, 500, 700, 3, 1, 1, 111, 2, 41, 0xde290af82e82620full, 0x0000000000000000ull },
|
|
};
|
|
struct GoldUocrSeg { int32_t h, w, real; };
|
|
static const GoldUocrSeg kUocrSegs[] = {
|
|
{ 64, 68, 64 },
|
|
{ 4, 4, 0 },
|
|
{ 40, 124, 120 },
|
|
{ 40, 124, 120 },
|
|
{ 64, 68, 64 },
|
|
{ 4, 4, 0 },
|
|
{ 40, 44, 40 },
|
|
{ 40, 44, 40 },
|
|
{ 40, 44, 40 },
|
|
{ 40, 44, 40 },
|
|
{ 40, 44, 40 },
|
|
{ 40, 44, 40 },
|
|
{ 64, 68, 64 },
|
|
{ 4, 4, 0 },
|
|
{ 40, 164, 160 },
|
|
{ 40, 164, 160 },
|
|
{ 40, 164, 160 },
|
|
{ 64, 68, 64 },
|
|
{ 4, 4, 0 },
|
|
{ 64, 68, 64 },
|
|
{ 4, 4, 0 },
|
|
{ 40, 204, 200 },
|
|
{ 40, 204, 200 },
|
|
{ 40, 204, 200 },
|
|
{ 40, 204, 200 },
|
|
{ 64, 68, 64 },
|
|
{ 4, 4, 0 },
|
|
{ 64, 68, 64 },
|
|
{ 4, 4, 0 },
|
|
{ 64, 68, 64 },
|
|
{ 4, 4, 0 },
|
|
{ 64, 68, 64 },
|
|
{ 4, 4, 0 },
|
|
{ 64, 68, 64 },
|
|
{ 4, 4, 0 },
|
|
{ 64, 68, 64 },
|
|
{ 4, 4, 0 },
|
|
{ 64, 68, 64 },
|
|
{ 4, 4, 0 },
|
|
{ 40, 44, 40 },
|
|
{ 4, 4, 0 },
|
|
{ 40, 44, 40 },
|
|
{ 4, 4, 0 },
|
|
};
|
|
|
|
/* Pillow's Image.resize(BICUBIC) of a splitmix picture: its two-pass order is part of the
|
|
* function (the intermediate rounds to eight bits). */
|
|
struct GoldUocrResize { int32_t sh, sw, dh, dw; uint64_t fnv; };
|
|
static const GoldUocrResize kUocrResize[] = {
|
|
{ 2400, 400, 1024, 171, 0xbccdeb5e050ce815ull },
|
|
{ 300, 300, 90, 100, 0xac4b3e6526dfbbb5ull },
|
|
{ 400, 300, 171, 1024, 0x799a058e681618b5ull },
|
|
{ 300, 400, 1024, 171, 0x82e65a0a71c6ee00ull },
|
|
{ 400, 1000, 200, 500, 0x7ef049c0990c00f6ull },
|
|
{ 1000, 400, 200, 300, 0x5a8d982164d9ff27ull },
|
|
{ 700, 500, 650, 470, 0x4697cb390555b911ull },
|
|
{ 500, 700, 640, 650, 0x90a6214f04fe8c0bull },
|
|
{ 320, 480, 320, 480, 0x8ce46502c9f58463ull },
|
|
{ 240, 320, 160, 320, 0x8ba4f63a78cc06bdull },
|
|
{ 240, 320, 240, 200, 0x9210b76889ecfbceull },
|
|
{ 64, 48, 1024, 1024, 0x3ccf3b8e768cfcd2ull },
|
|
};
|
|
|
|
/* The transposed pairs whose tall side the reference's set visits last. */
|
|
struct GoldUocrTie { int32_t c, r; };
|
|
static const GoldUocrTie kUocrTallLast[] = {
|
|
{1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 9}, {1, 13}, {1, 14}, {1, 16}, {1, 18}, {1, 20}, {1, 22}, {1, 27}, {1, 29}, {2, 3}, {2, 4}, {2, 5}, {2, 6}, {2, 7}, {2, 8}, {2, 9}, {2, 14}, {2, 15}, {2, 16}, {3, 5}, {3, 7}, {3, 9}, {4, 5}, {4, 6}, {4, 7}, {4, 8},
|
|
};
|
|
static const int32_t kUocrNTallLast = 31;
|