Skip to content

embedding: adjust n_ubatch value, print error on insufficient n_batch value#6296

Merged
ggerganov merged 5 commits intoggml-org:masterfrom
mscheong01:embedding-assign-`n_ubatch`-value,-print-error-on-`n_batch`-overflow
Mar 26, 2024
Merged

embedding: adjust n_ubatch value, print error on insufficient n_batch value#6296
ggerganov merged 5 commits intoggml-org:masterfrom
mscheong01:embedding-assign-`n_ubatch`-value,-print-error-on-`n_batch`-overflow

Conversation

@mscheong01
Copy link
Copy Markdown
Collaborator

updates to the embedding example based on discussion from #6193

  • assign n_batch value to u_batch
  • output error on insufficient batch size

Comment thread examples/embedding/embedding.cpp Outdated
if (inp.size() > n_batch) {
inp.resize(n_batch);
fprintf(stderr, "%s: error: number of tokens in input line (%lld) exceeds batch size (%lld), increase batch size and re-run\n",
__func__, (long long int) inp.size(), (long long int) n_batch);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you can use %ld instead of %lld, no need to cast the type then

Suggested change
__func__, (long long int) inp.size(), (long long int) n_batch);
__func__, inp.size(), n_batch);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied & rolled back due to build failure.
IIRC, this is why I used %lld with casting in #6193. Although I tried your suggestion just in case 😉.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We normally use PRIu64 / PRId64 to print 64-bit integers. Alternatively, in this case just %d and cast to (int) is fine

mscheong01 and others added 4 commits March 26, 2024 09:25
Co-authored-by: Xuan Son Nguyen <thichthat@gmail.com>
…tch`-overflow' of github.com:mscheong01/llama.cpp into embedding-assign-`n_ubatch`-value,-print-error-on-`n_batch`-overflow
@ggerganov ggerganov merged commit deb7240 into ggml-org:master Mar 26, 2024
hodlen pushed a commit to hodlen/llama.cpp that referenced this pull request Apr 3, 2024
* embedding: assign `n_ubatch` value, print error on `n_batch` overflow

* Update examples/embedding/embedding.cpp

Co-authored-by: Xuan Son Nguyen <thichthat@gmail.com>

* use %ld instead of %lld

* Revert "use %ld instead of %lld"

This reverts commit ea753ed.

---------

Co-authored-by: Xuan Son Nguyen <thichthat@gmail.com>
Seunghhon pushed a commit to Seunghhon/llama.cpp that referenced this pull request Apr 26, 2026
* embedding: assign `n_ubatch` value, print error on `n_batch` overflow

* Update examples/embedding/embedding.cpp

Co-authored-by: Xuan Son Nguyen <thichthat@gmail.com>

* use %ld instead of %lld

* Revert "use %ld instead of %lld"

This reverts commit ea753ed.

---------

Co-authored-by: Xuan Son Nguyen <thichthat@gmail.com>
phuongncn pushed a commit to phuongncn/llama.cpp-gx10-dgx-sparks-deepseekv4 that referenced this pull request Apr 28, 2026
* embedding: assign `n_ubatch` value, print error on `n_batch` overflow

* Update examples/embedding/embedding.cpp

Co-authored-by: Xuan Son Nguyen <thichthat@gmail.com>

* use %ld instead of %lld

* Revert "use %ld instead of %lld"

This reverts commit ea753ed.

---------

Co-authored-by: Xuan Son Nguyen <thichthat@gmail.com>
ljubomirj pushed a commit to ljubomirj/llama.cpp that referenced this pull request May 6, 2026
* embedding: assign `n_ubatch` value, print error on `n_batch` overflow

* Update examples/embedding/embedding.cpp

Co-authored-by: Xuan Son Nguyen <thichthat@gmail.com>

* use %ld instead of %lld

* Revert "use %ld instead of %lld"

This reverts commit ea753ed.

---------

Co-authored-by: Xuan Son Nguyen <thichthat@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants