Archived
unlimitedocr: the DeepEncoder tower, R-SWA ring KV and the n-gram ban
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).
This commit is contained in:
1 parent
543cba7416
commit
fad4ba7f1a
63 files changed
+6162
-169
No files matched your search
+27
-2
@@ -370,6 +370,31 @@ std::vector<Case> build_cases() {
|
||||
for (int kw : { 3, 4 })
|
||||
add("attn_na3d", { HI("M", 64), HI("head_dim", 64), HI("kt", 3), HI("kh", 3),
|
||||
HI("kw", kw), HS("dtype", dt) });
|
||||
/* Unlimited-OCR's SAM tower: window 14 on a 16x16 grid (padded to 2x2 windows of 14x14), the
|
||||
* same over a 14x21 grid (a partial window in both directions, and the padded rows take part in
|
||||
* the softmax), an exact 14x14 multiple, window 7 (21x21 after padding), the global form on a
|
||||
* square grid, and the global form on a non-square grid whose rel_pos tables must be resampled
|
||||
* along their row axis. Two segments where the case is multi-segment, so a wrong cu walk shows.
|
||||
* `n_seq` is not a schema parameter: libref's shape hook sizes cu from it (the harness hint
|
||||
* convention, avx_cases.cpp's gdn cases). */
|
||||
add("sam_attn", { HI("M", 256), HI("head_dim", 64), HI("n_head", 2), HI("grid_h", 16),
|
||||
HI("grid_w", 16), HI("window", 14), HF("scale", 0.125),
|
||||
HS("dtype", "bf16") });
|
||||
add("sam_attn", { HI("M", 588), HI("head_dim", 32), HI("n_head", 2), HI("grid_h", 14),
|
||||
HI("grid_w", 21), HI("window", 14), HF("scale", 0.17677669529663687),
|
||||
HS("dtype", "bf16"), HI("n_seq", 2) });
|
||||
add("sam_attn", { HI("M", 196), HI("head_dim", 64), HI("n_head", 2), HI("grid_h", 14),
|
||||
HI("grid_w", 14), HI("window", 14), HF("scale", 0.125),
|
||||
HS("dtype", "bf16") });
|
||||
add("sam_attn", { HI("M", 256), HI("head_dim", 64), HI("n_head", 2), HI("grid_h", 16),
|
||||
HI("grid_w", 16), HI("window", 7), HF("scale", 0.125),
|
||||
HS("dtype", "bf16") });
|
||||
add("sam_attn", { HI("M", 256), HI("head_dim", 16), HI("n_head", 4), HI("grid_h", 16),
|
||||
HI("grid_w", 16), HI("window", 0), HF("scale", 0.25),
|
||||
HS("dtype", "bf16") });
|
||||
add("sam_attn", { HI("M", 240), HI("head_dim", 32), HI("n_head", 2), HI("grid_h", 12),
|
||||
HI("grid_w", 20), HI("window", 0), HF("scale", 0.17677669529663687),
|
||||
HS("dtype", "bf16") });
|
||||
for (const char* dt : { "f32", "bf16" })
|
||||
add("seg_sinusoid", { HI("M", 30), HI("n", 64), HI("period", 13), HS("dtype", dt) });
|
||||
/* Gemma 4's audio attention: left 12, over segments longer than the window. */
|
||||
@@ -661,8 +686,8 @@ std::vector<Case> build_cases() {
|
||||
|
||||
/* Sampling. n_vocab 517 exceeds every vector width and is not a multiple of any; n_cand 12 is
|
||||
* a realistic candidate set after top-k. */
|
||||
for (const char* op : { "sample_penalties", "sample_dry", "sample_temp", "sample_mask",
|
||||
"sample_argmax" })
|
||||
for (const char* op : { "sample_penalties", "sample_dry", "sample_ngram_ban", "sample_temp",
|
||||
"sample_mask", "sample_argmax" })
|
||||
add(op, { HI("M", 5), HI("n_vocab", 517) });
|
||||
add("sample_topk", { HI("M", 5), HI("n_vocab", 517), HI("vocab_off", 0) });
|
||||
/* k 7 and 20 (OpenAI's top_logprobs bound) against 517 columns; the offset case checks that
|
||||
|
||||
Reference in new issue
Block a user