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
@@ -16,11 +16,23 @@
|
||||
{%- set ns.at = loop.index0 -%}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- if ns.last is not none and ns.last['content'] is string -%}
|
||||
{%- for piece in ns.last['content'].split('<__media__>') -%}
|
||||
{%- if not loop.last -%}{%- set ns.media = ns.media + 1 -%}{%- endif -%}
|
||||
{%- if ((piece | replace('', '')) | trim) != '' -%}{%- set ns.text = true -%}{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- if ns.last is not none -%}
|
||||
{%- if ns.last['content'] is string -%}
|
||||
{%- for piece in ns.last['content'].split('<__media__>') -%}
|
||||
{%- if not loop.last -%}{%- set ns.media = ns.media + 1 -%}{%- endif -%}
|
||||
{%- if ((piece | replace('', '')) | trim) != '' -%}{%- set ns.text = true -%}{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- else -%}
|
||||
{#- The OpenAI parts form counts the same way: media from the marker parts, text from any
|
||||
non-empty text part (a client's U+FFFC object placeholder is whitespace). -#}
|
||||
{%- for part in ns.last['content'] -%}
|
||||
{%- if part['type'] == 'media_marker' -%}
|
||||
{%- set ns.media = ns.media + 1 -%}
|
||||
{%- elif part['type'] == 'text' and ((part['text'] | default('', true) | replace('', '')) | trim) != '' -%}
|
||||
{%- set ns.text = true -%}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- for message in messages -%}
|
||||
{%- set mi = loop.index0 -%}
|
||||
@@ -41,7 +53,11 @@
|
||||
{%- endfor -%}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- if ns.last is not none and ns.last['content'] is string and not ns.text -%}
|
||||
{#- The instruction block serves both content forms: ns.media/ns.text above scanned the final
|
||||
turn whichever it was. Output is whitespace-tight: every tag trims, the newline after
|
||||
"Multi page parsing." is eaten by the next tag's `{%-`, and the rendered prompt ends with
|
||||
the instruction verbatim -- keep the trims when reformatting this block. -#}
|
||||
{%- if ns.last is not none and not ns.text -%}
|
||||
{%- if ns.media > 1 -%}Multi page parsing.
|
||||
{%- elif ns.media == 1 -%}document parsing.
|
||||
{%- endif -%}
|
||||
|
||||
Reference in new issue
Block a user