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

+11 -2
View File
@@ -181,9 +181,14 @@ void host_xtc(CandidateSet& s, float probability, float threshold, size_t min_ke
* SlidingWindowNoRepeatNgramProcessor): a candidate whose token would complete an `n`-gram the
* last `window` tokens of `history` already contain gets -infinity. `n` <= 0 is off, `window` <= 0
* is the whole history. It runs after the penalties and DRY and before every cut, so the greedy
* path sees it too. */
* path sees it too.
*
* `whitelist` is the reference's whitelist (a SET bit means exempt from the ban, the same plane
* form as host_mask's, word w bit b covering token 32w + b): ids removed from the banned set
* before anything is written, as `banned.difference_update(self.whitelist)` does. Null or zero
* words is off -- the reference's empty whitelist, the default serving form. */
void host_ngram_ban(CandidateSet& s, const int32_t* history, int64_t n_history, int32_t n,
int32_t window);
int32_t window, const uint32_t* whitelist = nullptr, int64_t wl_words = 0);
/* The grammar mask. One bit per token, set means admissible; a cleared bit sets the logit to -inf
* instead of removing the candidate, so nothing downstream is renumbered. `n_words` is
@@ -224,6 +229,10 @@ struct HostRefInput {
int64_t total_context = 0; /* DRY's clamp; 0 means use n_history */
const uint32_t* bitmask = nullptr; /* grammar mask, or null */
int64_t n_words = 0;
/* The n-gram ban's whitelist bitmask (a SET bit exempts a token, host_ngram_ban), null =
* no exemptions. */
const uint32_t* ngram_whitelist = nullptr;
int64_t ngram_whitelist_words = 0;
uint64_t pos = 0; /* output position: the RNG's second coordinate */
const DryBreakers* dry_breakers = nullptr; /* null runs DRY with no breakers */
/* The chain's candidate width (SamplerConfig::max_candidates): top-k narrows every row to