Repository navigation
npu: minicpm_image_probe gains --dump, --chunk and --rows-argmax, the options that bisected #2149 (engine#1788) - #2155
Conversation
… three options that bisected #2149 (engine#1788) --dump writes the ids, the three position planes and the tower's rows the text model is about to get; --chunk N sends the prompt in calls of N rows as the served route does; --rows-argmax prints the model's next-token choice at every row of a text prompt. Together with a reference run of the same prompt they told inputs from layers and position from uniform error when a sliced image was described wrongly. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
ready for review at e63aa27 |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at e63aa27: READY
Reviewed head e63aa27 (refs #1788). A diagnostic-only change to minicpm_image_probe (+67/−6) plus a docs paragraph. This is the first verdict.
Checked
git merge-treeonto main: no conflicts.tools/copyright.py --check: rc 0.file_create_check: clean. CIbuildsucceeded (waited for it before posting); CodeQL green.- Without the new options the probe is unchanged.
chunk = 0takes the original singlestep_batch_embeds(embeds, 0, logits, in)call;--dumpand--rows-argmaxdefault off. --chunk Nis the served route's shape. Each call takes rows[off, off+take)of the embeddings and of all three position planes (t|h|w, concatenated per chunk as the forward expects), and starts at cache slotoff.--chunk< 0 is refused.--rows-argmaxis refused without--none, as documented, becausestep_batch_all()takes ids, not image rows. It resets the forward before its teacher-forced pass, and the prefill that follows starts at slot 0.
Nits, not blocking
- The dumps bypass #2057's opener.
--dumpwrites throughstd::ofstream, whichfile_create_checkdoes not look for, so the files are created with the default mode and through a symlink. That is what #2057 just removed for every other dump.onebit_fopen_private_wb+fwritewould keep the dumps consistent with the rest of the tree. - The chunk path builds its own
HybridInputs. Each chunk gets a freshHybridInputs ciwith onlyposition_idsset. That is equivalent today, because the probe never setsdeepstack/image_lo/image_hi(minicpm_image_probe.cpp:266). But if a later pack routes deepstack through this probe, the chunked path will silently drop it while the single call keeps it. Copyinginand replacingposition_ids(and offsetting the image span) would make the two paths agree by construction.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
Refs #1788 (F6, MiniCPM-V 4.7). Small: three options on
minicpm_image_probe(#2132). The issue stays open.Why
A sliced image was described wrongly through the probe, the same on the host arm and on the device. Finding out why took three things the probe could not do, which I added locally and which led to #2149 (the forward was running this pack without q/k normalisation). They are worth keeping, because the next wrong answer on this path will need the same three cuts.
What
--dump <dir>writes what the text model is about to be given, inhybrid_prompt_probe's file forms:ids.i32,positions.i32(the t, h and w planes),pooled.f32(the tower's rows). In the npu: q/k norm is read from the container, so a qwen3_5 text model under another name is normalised (engine#1788) #2149 hunt these matched a reference pipeline's exactly (ids and positions identical, rows within 1e-5), which put the fault past the inputs.--chunk Nsends the prompt in calls of at most N rows, as the served route sends a prefill;0(default) is one call. There, 64, 128 and one call gave the same wrong answer, which ruled out the batched body and a row-count edge.--rows-argmax(text-only, with--none) prints the model's own next-token choice at every prompt row from one teacher-forced pass. Against the reference's per-row choices it showed 65 % agreement, flat across positions: an error in the layers, not at a position.No change to what the probe does without these options.
Checked on this box (main at this head, host arm, MiniCPM-V-4.7-1B-NPU2)
The pack loads on main now that #2026 has merged. The measurements that used these options are in #2149 and on the issue; I did not repeat them for this PR.
Not in this PR
The reference side (transformers with the model's original weights, and the script that compares per-row choices). It needs transformers and a 3.1 GB download, lives in my lane scratch, and is described in #2149.
No ctest row, as for the probe itself: it needs a pack, a kernel set and the forward library.
Docs:
docs/npu.md, the probe's paragraph.🤖 Generated with Claude Code