]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
mtmd-helper : bug fix to token batching in mtmd (#13650)
authorl3utterfly <redacted>
Tue, 20 May 2025 16:55:30 +0000 (00:55 +0800)
committerGitHub <redacted>
Tue, 20 May 2025 16:55:30 +0000 (18:55 +0200)
* Update mtmd-helper.cpp

* Update tools/mtmd/mtmd-helper.cpp

Co-authored-by: Xuan-Son Nguyen <redacted>
---------

Co-authored-by: Xuan-Son Nguyen <redacted>
tools/mtmd/mtmd-helper.cpp

index 7a3288672d447cb6474d0c57902556335cdedb3f..bb20db150faf4bd186ad5766c7ec092ce19ff9b4 100644 (file)
@@ -231,12 +231,14 @@ int32_t mtmd_helper_eval_chunk_single(mtmd_context * ctx,
         while (i < n_tokens) { // split into batches
             text_batch.n_tokens = 0; // clear the batch
             for (; i < n_tokens && text_batch.n_tokens < n_batch; i++) {
+                int32_t j = text_batch.n_tokens;
+                text_batch.token   [j]    = tokens[i];
+                text_batch.pos     [j]    = n_past++;
+                text_batch.n_seq_id[j]    = 1;
+                text_batch.seq_id  [j][0] = seq_id;
+                text_batch.logits  [j]    = false;
+
                 text_batch.n_tokens++;
-                text_batch.token   [i]    = tokens[i];
-                text_batch.pos     [i]    = n_past++;
-                text_batch.n_seq_id[i]    = 1;
-                text_batch.seq_id  [i][0] = seq_id;
-                text_batch.logits  [i]    = false;
             }
             bool is_last_token = (i == n_tokens);
             if (logits_last && is_last_token) {