Archived
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:
1 parent
fad4ba7f1a
commit
52637ec186
37 files changed
+401566
-778
No files matched your search
@@ -528,7 +528,7 @@ int32_t host_argmax(const float* logits, int64_t n_vocab) {
|
||||
}
|
||||
|
||||
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, int64_t wl_words) {
|
||||
if (n <= 0 || !history || n_history < (int64_t)n) return;
|
||||
const int64_t len = n_history;
|
||||
const int64_t win = (window > 0 && window < len) ? window : len;
|
||||
@@ -547,6 +547,21 @@ void host_ngram_ban(CandidateSet& s, const int32_t* history, int64_t n_history,
|
||||
}
|
||||
if (match) banned.insert(history[idx + plen]);
|
||||
}
|
||||
|
||||
/* The reference's `banned.difference_update(self.whitelist)`, before any -inf: a token whose
|
||||
* whitelist bit is set is never banned. A bit past the plane is not set, so a token outside
|
||||
* it stays banned, as an id the reference's set does not contain. */
|
||||
if (whitelist && wl_words > 0) {
|
||||
for (auto it = banned.begin(); it != banned.end();) {
|
||||
const int64_t id = *it;
|
||||
if (id >= 0 && (id >> 5) < wl_words &&
|
||||
(whitelist[(size_t)(id >> 5)] >> ((uint32_t)id & 31u)) & 1u)
|
||||
it = banned.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
if (banned.empty()) return;
|
||||
s.sorted = false; /* a -infinity candidate belongs after every finite one */
|
||||
for (Candidate& c : s.c)
|
||||
@@ -575,7 +590,8 @@ int32_t host_sample_into(CandidateSet& s, const SamplingParams& sp, const HostRe
|
||||
|
||||
/* The n-gram ban, after the penalties and before the greedy split: the device chain issues it
|
||||
* there, so a greedy request sees the same masked distribution. Off at ngram_ban_n 0. */
|
||||
host_ngram_ban(s, in.history, in.n_history, sp.ngram_ban_n, sp.ngram_window);
|
||||
host_ngram_ban(s, in.history, in.n_history, sp.ngram_ban_n, sp.ngram_window,
|
||||
in.ngram_whitelist, in.ngram_whitelist_words);
|
||||
|
||||
/* Greedy skips the chain: penalties -> mask -> argmax. Temperature 0 collapses every other
|
||||
* logit to -inf, so a mask applied after it could leave nothing. */
|
||||
|
||||
Reference in new issue
Block a user