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
View File
@@ -1164,6 +1164,8 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
B.enc_n_seg = 0;
B.enc_cu = nullptr;
B.enc_max_seg = 0;
B.enc_seg_h = nullptr;
B.enc_seg_w = nullptr;
B.n_checkpoints = n_ck;
B.checkpoint_tok = n_ck ? on_rank(base, b0, s.d_cktok) : nullptr;
B.checkpoint_slot = n_ck ? on_rank(base, b0, s.d_ckslot) : nullptr;
@@ -1232,6 +1234,8 @@ const RadBatch* BatchBuilder::build_encoder(const std::vector<EncoderPart>& part
const int64_t max_segs = enc.max_patches / (enc.merge > 0 ? enc.merge : 1) + 1;
int64_t n_patch = 0, n_seg = 0, max_seg = 0;
enc_cu_host_[0] = 0;
enc_seg_h_host_.clear();
enc_seg_w_host_.clear();
for (const EncoderPart& p : parts) {
const mm::Item& it = *p.item;
if (p.seg0 < 0 || p.n_seg <= 0 || p.seg0 + p.n_seg > it.n_seg) {
@@ -1254,6 +1258,8 @@ const RadBatch* BatchBuilder::build_encoder(const std::vector<EncoderPart>& part
for (int32_t q = p.seg0; q < p.seg0 + p.n_seg; ++q) {
const int64_t seg_p = it.patch_at(q + 1) - it.patch_at(q);
enc_cu_host_[n_seg + 1] = enc_cu_host_[n_seg] + (int32_t)seg_p;
enc_seg_h_host_.push_back(it.seg_h(q));
enc_seg_w_host_.push_back(it.seg_w(q));
++n_seg;
if (seg_p > max_seg) max_seg = seg_p;
}
@@ -1300,6 +1306,8 @@ const RadBatch* BatchBuilder::build_encoder(const std::vector<EncoderPart>& part
B.enc_n_seg = n_seg;
B.enc_cu = static_cast<const int32_t*>(enc_cu_dev_[r]);
B.enc_max_seg = (int32_t)max_seg;
B.enc_seg_h = enc_seg_h_host_.data();
B.enc_seg_w = enc_seg_w_host_.data();
}
out_last_ = out_next_;
out_next_ = (out_next_ + 1) % kOut;