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

add support for batched inference #818

Closed
promptboom opened this issue Oct 13, 2023 · 6 comments
Closed

add support for batched inference #818

promptboom opened this issue Oct 13, 2023 · 6 comments

Comments

@promptboom
Copy link

as llama.cpp supports batched inference in 8.26, can llama-cpp-python supports for batched inference? I just tried the latest version 0.2.11 and found that it is not possible to make multiple requests simultaneously.

image

@yourbuddyconner
Copy link

Also, looks like easy integration here is potentially contingent on this issue: ggerganov/llama.cpp#3478

@akx
Copy link

akx commented Oct 24, 2023

See #771 – it's one of the pinned issues in this repo.

@abetlen abetlen closed this as completed Nov 8, 2023
@yugaljain1999
Copy link

yugaljain1999 commented Aug 8, 2024

@abetlen How to run batch inference of T5 model with llama-cpp-python?
Can you pls share correct code snippet to do that?

As per docs, if i run following code,


model= Llama(
      model_path="../madlad400-3b-mt.gguf",
      n_gpu_layers=-1, # Uncomment to use GPU acceleration
      # seed=1337, # Uncomment to set a specific seed
      # n_ctx=2048, # Uncomment to increase the context window
)


prompt = ["<2en> Wie kannst du es wagen, so mit mir zu reden, Bruder?", "<2en> Wie kannst du es wagen, so mit mir zu reden, Bruder?"]
prompt_tokenized = model.tokenize(prompt[0].encode())
print("Prompt tokenized", prompt_tokenized)


output_tokens = model.generate(
      prompt_tokenized, # encoded and tokenized prompt
      ) # Generate a completion, can also call create_completion

print("Output tokens", output_tokens)


for token in output_tokens:                     # -> Here I get error while iterating generator object.
    detokenized_tokens = model.detokenize([token])

This error -
GGML_ASSERT(n_outputs_enc > 0 && "call llama_encode() first") failed

@SylvainVerdy
Copy link

SylvainVerdy commented Nov 19, 2024

Did you find any solutions? @yugaljain1999

@yugaljain1999
Copy link

@SylvainVerdy Not yet, so I started using ctranslate2 for batch inference.

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

No branches or pull requests

6 participants