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

+12 -2
View File
@@ -48,7 +48,8 @@
* sample_penalties M(range) n_vocab vocab_off? logits, params, history -> logits (inout)
* sample_dry M(range) n_vocab vocab_off? logits, params, history, breakers?
* -> logits (inout)
* sample_ngram_ban M(range) n_vocab vocab_off? logits, params, history, ngram
* sample_ngram_ban M(range) n_vocab vocab_off? logits, params, history, ngram,
* whitelist?
* -> logits (inout)
* sample_temp M(range) n_vocab logits, params -> logits (inout)
* sample_mask M(range) n_vocab logits, params, bitmask -> logits (inout)
@@ -67,7 +68,9 @@
* a verify. `params` is [M] DeviceSampleParams rows. `history` is [M, max_hist] int32 global
* token ids, row m addressed by its hist_off/hist_len. `breakers` is [M, max_hist] uint8 beside
* it, nonzero where that token is a whole DRY sequence breaker. `bitmask` is [M, mask_words]
* uint32, addressed by the row's mask_row. `vocab_off` is this rank's first vocabulary row,
* uint32, addressed by the row's mask_row. The ban's `whitelist` is a [M, mask_words] uint32
* bitmask (a SET bit exempts that column from the ban) addressed by the row itself, absent when
* no staged row carries one. `vocab_off` is this rank's first vocabulary row,
* declared only when the vocabulary is split; the three ops that map between token ids and this
* rank's logit columns use it. Every op has a libref implementation, which is both its fallback
* and its oracle (spec §17).
@@ -259,6 +262,9 @@ private:
rad_buf buf_hist_ = RAD_NULL_HANDLE;
rad_buf buf_brk_ = RAD_NULL_HANDLE; /* DRY's single-token breaker marks, beside history */
rad_buf buf_ngram_ = RAD_NULL_HANDLE; /* the n-gram ban's {n, window} pair a row */
/* The ban's whitelist bitmask, [rows, mask_words] like the grammar mask plane: a SET bit
* exempts that column from the ban. Uploaded with the ban, only when a staged row has one. */
rad_buf buf_ngram_wl_ = RAD_NULL_HANDLE;
rad_buf buf_mask_ = RAD_NULL_HANDLE;
rad_buf buf_cand_i_ = RAD_NULL_HANDLE;
rad_buf buf_cand_v_ = RAD_NULL_HANDLE;
@@ -283,6 +289,7 @@ private:
int32_t* hist_stage_ = nullptr;
uint8_t* brk_stage_ = nullptr;
int32_t* ngram_stage_ = nullptr; /* [rows][2]: n-gram length, window */
uint32_t* ngram_wl_stage_ = nullptr; /* [rows][mask_words] exemption bitmask */
uint32_t* mask_stage_ = nullptr;
int64_t mask_words_ = 0; /* words for this rank's shard; what the mask op indexes */
@@ -293,6 +300,9 @@ private:
/* Whether any row this step runs the n-gram ban. Its history is the plane the penalties use,
* so this only decides whether that plane is uploaded and the op issued. */
bool any_ngram_ = false;
/* Whether any banned row this step whitelists a column of this rank's shard; only then is
* the exemption plane uploaded and passed to sample_ngram_ban. */
bool any_ngram_wl_ = false;
/* The whole-vocabulary mask the grammar fills, from which this rank's shard is cut. Used
* only when the head is sharded; see declare(). */