Archived
review: apply the Unlimited-OCR code-review findings
The 2a1ca01..f308216 range's 45 review findings (12 performance, 33 quality) are applied: ABI 23 for the RadBatch append, the fused q|k|v projection, the batched patch-embed GEMM and pitched layout copies, the sam_attn w-dot hoist with an alignment-gated vector row path and NaN poisoning for malformed segments, the fused quick_gelu act, and the R-SWA/scheduler/drafting gates. Quality items: stale comments corrected, env reads hoisted, the ngram_window negative refusal, the parts-form chat template instruction, the whitelist fallback warning, and the segmented R-SWA refusal of the fixed/runtime window mix. The 3.2 MB generated resample header becomes a 9.6 MB little-endian blob (tests/data/golden/uocr_resample_golden.bin) read by a small loader; resample_golden.py emits and round-trip-verifies it. One perf-med item (AVX2 bicubic passes/LUT patch staging in the processor) is left as the follow-up the review itself recommends; the code says why. Verified: ninja -C build-review -k 0; host ctest 89/89; GPU r4d_selftest 0 failures, kbench/kbench_moe and the card tests pass.
This commit is contained in:
1 parent
1f661bf2e0
commit
859efc7208
35 files changed
+799
-399093
No files matched your search
+14
-12
@@ -6,6 +6,7 @@
|
||||
#include "device/device.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
@@ -689,6 +690,11 @@ int BatchBuilder::build_groups(const StepPlan& plan, const IKVManager& kv, Set&
|
||||
}
|
||||
|
||||
int64_t t = 0;
|
||||
/* The group's ring block count, read off the first armed sequence: declare_runtime_window
|
||||
* fixes one W per group, so every armed sequence computes the same count. Collected here,
|
||||
* with the table walk that already opens each window, so the group header below needs no
|
||||
* second pass over the plan. */
|
||||
int32_t ring_blocks = 0;
|
||||
for (int64_t i = 0; i < n_seq; ++i) {
|
||||
const StepEntry& e = plan.e[(size_t)i];
|
||||
|
||||
@@ -703,6 +709,10 @@ int BatchBuilder::build_groups(const StepPlan& plan, const IKVManager& kv, Set&
|
||||
const std::vector<int32_t>& bt = kv.block_table(e.seq, (int32_t)gi);
|
||||
first = kv.first_block_pos(e.seq, (int32_t)gi);
|
||||
has_win = kv.runtime_window(e.seq, (int32_t)gi, &win);
|
||||
if (has_win) {
|
||||
assert(!ring_blocks || ring_blocks == (int32_t)win.ring_blocks);
|
||||
ring_blocks = (int32_t)win.ring_blocks;
|
||||
}
|
||||
bt_len = (int64_t)bt.size();
|
||||
table_end = bt_len * L.block_size;
|
||||
for (int32_t j = 0; j < e.n_tokens; ++j) {
|
||||
@@ -803,20 +813,12 @@ int BatchBuilder::build_groups(const StepPlan& plan, const IKVManager& kv, Set&
|
||||
/* The runtime window (KVManager::set_window): the advance runs after this build and
|
||||
* overwrites `used` and the slots, so it must reproduce the ring's mapping rather
|
||||
* than the linear one (advance_impl.h). The floor and table length are per sequence
|
||||
* (s.h_rpos / s.h_tlen), the ring's block count is the group's W. */
|
||||
a.ring = 0;
|
||||
a.ring_blocks = 0;
|
||||
* (s.h_rpos / s.h_tlen), the ring's block count is the group's W, collected with the
|
||||
* table walk above. */
|
||||
a.ring = ring_blocks ? 1 : 0;
|
||||
a.ring_blocks = ring_blocks;
|
||||
a.rpos_off = (const char*)s.d_rpos - d0;
|
||||
a.tlen_off = (const char*)s.d_tlen - d0;
|
||||
for (int64_t i = 0; i < n_seq; ++i) {
|
||||
const StepEntry& e = plan.e[(size_t)i];
|
||||
SeqWindow w;
|
||||
if (kv.runtime_window(e.seq, (int32_t)gi, &w)) {
|
||||
a.ring = 1;
|
||||
a.ring_blocks = (int32_t)w.ring_blocks;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t r = 0; r < ranks_.size(); ++r) {
|
||||
|
||||
Reference in new issue
Block a user