unlimitedocr: tiled/base e2e parity, per-segment tower layout, n-gram whitelist

The pass packer now keeps a view and its one-cell separator in one pass, and
RadBatch carries each segment's grid host-side (enc_seg_h/enc_seg_w) so the
DeepEncoder no longer reads device coordinates to pick a geometry. The tower
lays out a line of n tiles as kMap rows of n*kMap features plus one newline
cell, accepts an earlier chunk of a longer line, and emits the learned
view_seperator for an explicit 4x4 separator rather than any square segment.

The device sam_attn resamples a rel_pos table that is not 2*tile-1 rows on
read (the 127-row global tables serve a 40-grid block as 79), matching
libref/libavx. The n-gram ban gains the reference's optional whitelist
(5th operand, OAI keys, generation_config alias) with range/dtype checks.

Gates: tiled e2e stage cosines 0.9994-1.0, det/text 0.9901 with every
coordinate within 1 px; two-page 0.9917 within 2 px; device selftest
sam_attn (incl. 127->79) and ngram whitelist (1344 columns) 0 mismatches.
This commit is contained in:
Juup committed 2026-10-20 07:04:01 +00:00
1 parent fad4ba7f1a
commit 52637ec186
37 files changed
+401566 -778

No files matched your search

+8 -4
View File
@@ -2,10 +2,14 @@
* activations.
*
* Scope (aijuus/plans/UNLIMITED-OCR-PLUGIN.md): the text trunk (P1) plus the DeepEncoder vision
* tower (P2, arch/common/rad_block_sam.h: SAM ViT-B/16 at 1024 -> 16x16x1024 map -> CLIP ViT-L/14
* -> the projector -> the 273-row layout, declared with rad_declare_encoder(RAD_MM_IMAGE),
* patch_dim 768 = 3*16*16, merge 16, n_embd 1280). The tower's weights are mapped always; its ops
* and the encoder pass are declared only when SAM's `sam_attn` op resolves, because no existing op
* tower (P2, arch/common/rad_block_sam.h: SAM ViT-B/16 -> map -> CLIP ViT-L/14 -> the projector
* -> the 273-row layout of a 1024 view / 110 rows of a 640 tile, declared with
* rad_declare_encoder(RAD_MM_IMAGE), patch_dim 768 = 3*16*16, merge 16, n_embd 1280). The tower
* serves both view geometries the processor stages -- the gundam mode's 640 tiles and global
* view, and the base mode's pages -- as two op sets over the same weights, the 40 grid's absolute
* position tables bicubic+antialias resamples of the checkpoint's (arch/common/rad_resample.h).
* The tower's weights are mapped always; its ops and the encoder pass are declared only when
* SAM's `sam_attn` op resolves, because no existing op
* can carry the decomposed rel_pos_h/rel_pos_w attention bias (rad_block_sam.h's header states the
* op and why). Without it this plugin is the P1 text-only trunk and refuses images by name. The
* decoder's KV is one RAD_KV_RING group with the checkpoint's `sliding_window_size` (128), the