Skip to content

Commit a4e850c

Browse files
ngxsonam17an
authored andcommitted
mtmd: fix miscounting n_tokens (#24656)
1 parent f3bd832 commit a4e850c

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

tools/mtmd/mtmd.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,15 @@ struct mtmd_image_tokens {
9696
// [BOI] [row0 tokens + newline] ... [row(ny-1) tokens + newline] [EOI]
9797
return (nx + 1) * ny + 2;
9898
}
99-
// [QWEN_VIDEO] this logic is quite ugly, it's mostly to make qwen-vl temporal merge work, can be improved in the future
100-
if (batch_f32.entries.size() == 1 || n_temporal_merge == 1) {
101-
return nx * ny;
102-
}
10399
uint32_t nz = batch_f32.entries.size();
104-
// TODO: simplify this by repeating the last frame until it fits the temporal merge
105-
if (nz % n_temporal_merge != 0) {
106-
nz = nz / n_temporal_merge + 1;
107-
} else {
108-
nz = nz / n_temporal_merge;
100+
if (n_temporal_merge > 1) {
101+
// [QWEN_VIDEO] this logic is quite ugly, it's mostly to make qwen-vl temporal merge work, can be improved in the future
102+
// TODO: simplify this by repeating the last frame until it fits the temporal merge
103+
if (nz % n_temporal_merge != 0) {
104+
nz = nz / n_temporal_merge + 1;
105+
} else {
106+
nz = nz / n_temporal_merge;
107+
}
109108
}
110109
return nx * ny * nz;
111110
}

0 commit comments

Comments
 (0)