abetlen / abetlen/llama-cpp-python

Reload the model for each inference

Đang mở
#745 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
10.6k
Fork
1.4k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

# Prerequisites

Please answer the following questions for yourself before submitting an issue.

- [ YES ] I am running the latest code. Development is very rapid so there are no tagged versions as of now.
- [ YES ] I carefully followed the [README.md](https://github.com/abetlen/llama-cpp-python/blob/main/README.md).
- [ YES ] I [searched using keywords relevant to my issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/filtering-and-searching-issues-and-pull-requests) to make sure that I am creating a new issue that is not already open (or closed).
- [ YES ] I reviewed the [Discussions](https://github.com/abetlen/llama-cpp-python/discussions), and have a new bug or useful enhancement to share.

# Expected Behavior

After loading the model, use a loop to perform inference on the model.

```
for _ in range(num_tests):
prompt = SOME_PROMPT
output = llm(prompt, max_tokens=num_outputs, stop=[], echo=True)
```

Expect not to reload the model every time inference.

# Current Behavior

The model is reloaded for each inference, resulting in slow speed.

```
llama_print_timings: load time = 17250.71 ms
llama_print_timings: sample time = 201.88 ms / 252 runs ( 0.80 ms per token, 1248.27 tokens per second)
llama_print_timings: prompt eval time = 30952.42 ms / 866 tokens ( 35.74 ms per token, 27.98 tokens per second)
llama_print_timings: eval time = 25540.01 ms / 251 runs ( 101.75 ms per token, 9.83 tokens per second)
llama_print_timings: total time = 57510.74 ms
41%|██████████████████████████████████████████████████████████████████▋ | 409/1000 [4:48:55<8:00:45, 48.81s/it]Llama.generate: prefix-match hit

llama_print_timings: load time = 17250.71 ms
llama_print_timings: sample time = 92.96 ms / 117 runs ( 0.79 ms per token, 1258.59 tokens per second)
llama_print_timings: prompt eval time = 30846.49 ms / 863 tokens ( 35.74 ms per token, 27.98 tokens per second)
llama_print_timings: eval time = 11540.79 ms / 116 runs ( 99.49 ms per token, 10.05 tokens per second)
llama_print_timings: total time = 42844.49 ms
41%|██████████████████████████████████████████████████████████████████▊ | 410/1000 [4:49:38<7:42:21, 47.02s/it]Llama.generate: prefix-match hit

llama_print_timings: load time = 17250.71 ms
llama_print_timings: sample time = 61.98 ms / 78 runs ( 0.79 ms per token, 1258.39 tokens per second)
llama_print_timings: prompt eval time = 3552.11 ms / 108 tokens ( 32.89 ms per token, 30.40 tokens per second)
llama_print_timings: eval time = 6513.85 ms / 77 runs ( 84.60 ms per token, 11.82 tokens per second)
llama_print_timings: total time = 10364.52 ms
41%|██████████████████████████████████████████████████████████████████▉ | 411/1000 [4:49:49<5:53:38, 36.02s/it]Llama.generate: prefix-match hit

llama_print_timings: load time = 17250.71 ms
llama_print_timings: sample time = 27.72 ms / 35 runs ( 0.79 ms per token, 1262.44 tokens per second)
llama_print_timings: prompt eval time = 6006.41 ms / 184 tokens ( 32.64 ms per token, 30.63 tokens per second)
llama_print_timings: eval time = 4535.59 ms / 34 runs ( 133.40 ms per token, 7.50 tokens per second)
llama_print_timings: total time = 10676.09 ms
41%|███████████████████████████████████████████████████████████████████▏ | 412/1000 [4:49:59<4:38:31, 28.42s/it]Llama.generate: prefix-match hit

llama_print_timings: load time = 17250.71 ms
llama_print_timings: sample time = 109.43 ms / 135 runs ( 0.81 ms per token, 1233.62 tokens per second)
llama_print_timings: prompt eval time = 17706.92 ms / 522 tokens ( 33.92 ms per token, 29.48 tokens per second)
llama_print_timings: eval time = 11811.50 ms / 134 runs ( 88.15 ms per token, 11.34 tokens per second)
llama_print_timings: total time = 30063.79 ms
41%|███████████████████████████████████████████████████████████████████▎ | 413/1000 [4:50:29<4:42:52, 28.91s/it]Llama.generate: prefix-match hit

llama_print_timings: load time = 17250.71 ms
llama_print_timings: sample time = 69.98 ms / 88 runs ( 0.80 ms per token, 1257.52 tokens per second)
llama_print_timings: prompt eval time = 46134.09 ms / 1268 tokens ( 36.38 ms per token, 27.49 tokens per second)
llama_print_timings: eval time = 8670.88 ms / 87 runs ( 99.67 ms per token, 10.03 tokens per second)
llama_print_timings: total time = 55154.51 ms
41%|███████████████████████████████████████████████████████████████████▍ | 414/1000 [4:51:24<5:59:17, 36.79s/it]Llama.generate: prefix-match hit

llama_print_timings: load time = 17250.71 ms
llama_print_timings: sample time = 115.67 ms / 143 runs ( 0.81 ms per token, 1236.24 tokens per second)
llama_print_timings: prompt eval time = 40741.50 ms / 1124 tokens ( 36.25 ms per token, 27.59 tokens per second)
llama_print_timings: eval time = 13751.92 ms / 142 runs ( 96.84 ms per token, 10.33 tokens per second)
llama_print_timings: total time = 55070.64 ms
42%|███████████████████████████████████████████████████████████████████▋ | 415/1000 [4:52:20<6:52:09, 42.27s/it]
```

# Environment and Context

Please provide detailed information about your computer setup. This is important in case the issue is not reproducible except for under certain specific conditions.

* Physical (or virtual) hardware you are using, e.g. for Linux: Ubuntu 18.04 LTS

`$ lscpu`

* Operating System, e.g. for Linux:

`$ uname -a`

* SDK version, e.g. for Linux:

```
$ python3 --version
$ make --version
$ g++ --version
```

# Failure Information (for bugs)

Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.

# Steps to Reproduce

Please provide detailed steps for reproducing the issue. We are not sitting in front of your screen, so the more detail the better.

1. step 1
2. step 2
3. step 3
4. etc.

**Note: Many issues seem to be regarding functional or performance issues / differences with `llama.cpp`. In these cases we need to confirm that you're comparing against the version of `llama.cpp` that was built with your python package, and which parameters you're passing to the context.**

Try the following:

1. `git clone https://github.com/abetlen/llama-cpp-python`
2. `cd llama-cpp-python`
3. `rm -rf _skbuild/` # delete any old builds
4. `python setup.py develop`
5. `cd ./vendor/llama.cpp`
6. Follow [llama.cpp's instructions](https://github.com/ggerganov/llama.cpp#build) to `cmake` llama.cpp
7. Run llama.cpp's `./main` with the same arguments you previously passed to llama-cpp-python and see if you can reproduce the issue. If you can, [log an issue with llama.cpp](https://github.com/ggerganov/llama.cpp/issues)

# Failure Logs

Please include any relevant log snippets or files. If it works under one configuration but not under another, please provide logs for both configurations and their corresponding outputs so it is easy to see where behavior changes.

Also, please try to **avoid using screenshots** if at all possible. Instead, copy/paste the console output and use [Github's markdown](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) to cleanly format your logs for easy readability.

Example environment info:
```
llama-cpp-python$ git log | head -1
commit 47b0aa6e957b93dbe2c29d53af16fbae2dd628f2

llama-cpp-python$ python3 --version
Python 3.10.10

llama-cpp-python$ pip list | egrep "uvicorn|fastapi|sse-starlette|numpy"
fastapi 0.95.0
numpy 1.24.3
sse-starlette 1.3.3
uvicorn 0.21.1

llama-cpp-python/vendor/llama.cpp$ git log | head -3
commit 66874d4fbcc7866377246efbcee938e8cc9c7d76
Author: Kerfuffle <44031344+KerfuffleV2@users.noreply.github.com>
Date: Thu May 25 20:18:01 2023 -0600
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.