Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Conversation

mscheong01
Copy link
Collaborator

updates to the embedding example based on discussion from #6193

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

examples/embedding/embedding.cpp Outdated Show resolved Hide resolved
@@ -114,7 +116,9 @@ int main(int argc, char ** argv) {
for (const auto & prompt : prompts) {
auto inp = ::llama_tokenize(ctx, prompt, true, false);
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
Collaborator

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
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
Owner

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
…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 ggerganov:master Mar 26, 2024
55 of 56 checks passed
hodlen pushed a commit to hodlen/llama.cpp that referenced this pull request Apr 1, 2024
* embedding: assign `n_ubatch` value, print error on `n_batch` overflow

* Update examples/embedding/embedding.cpp

Co-authored-by: Xuan Son Nguyen <[email protected]>

* use %ld instead of %lld

* Revert "use %ld instead of %lld"

This reverts commit ea753ed.

---------

Co-authored-by: Xuan Son Nguyen <[email protected]>
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 <[email protected]>

* use %ld instead of %lld

* Revert "use %ld instead of %lld"

This reverts commit ea753ed.

---------

Co-authored-by: Xuan Son Nguyen <[email protected]>
tybalex pushed a commit to tybalex/function.cpp that referenced this pull request Apr 17, 2024
* embedding: assign `n_ubatch` value, print error on `n_batch` overflow

* Update examples/embedding/embedding.cpp

Co-authored-by: Xuan Son Nguyen <[email protected]>

* use %ld instead of %lld

* Revert "use %ld instead of %lld"

This reverts commit ea753ed.

---------

Co-authored-by: Xuan Son Nguyen <[email protected]>
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.

None yet

3 participants