2022-10-08 04:30:12 -06:00
|
|
|
[tool.poetry]
|
2023-03-07 10:52:22 -07:00
|
|
|
name = "text-generation-server"
|
2024-05-24 07:36:13 -06:00
|
|
|
version = "2.0.5-dev0"
|
2023-02-03 04:43:37 -07:00
|
|
|
description = "Text Generation Inference Python gRPC Server"
|
2022-10-08 04:30:12 -06:00
|
|
|
authors = ["Olivier Dehaene <olivier@huggingface.co>"]
|
|
|
|
|
2022-10-17 06:59:00 -06:00
|
|
|
[tool.poetry.scripts]
|
2023-03-07 10:52:22 -07:00
|
|
|
text-generation-server = 'text_generation_server.cli:app'
|
2022-10-17 06:59:00 -06:00
|
|
|
|
2022-10-08 04:30:12 -06:00
|
|
|
[tool.poetry.dependencies]
|
2023-08-03 15:00:59 -06:00
|
|
|
python = ">=3.9,<3.13"
|
2024-06-04 11:38:46 -06:00
|
|
|
protobuf = "^4.25.3"
|
2023-01-05 04:01:23 -07:00
|
|
|
grpcio = "^1.51.1"
|
|
|
|
grpcio-status = "^1.51.1"
|
|
|
|
grpcio-reflection = "^1.51.1"
|
|
|
|
grpc-interceptor = "^0.15.0"
|
2022-10-08 04:30:12 -06:00
|
|
|
typer = "^0.6.1"
|
2024-04-11 02:37:35 -06:00
|
|
|
accelerate = { version = "^0.29.1", optional = true }
|
2024-03-15 06:23:26 -06:00
|
|
|
bitsandbytes = { version = "^0.43.0", optional = true }
|
2024-03-22 10:59:25 -06:00
|
|
|
safetensors = "^0.4"
|
2023-01-05 04:01:23 -07:00
|
|
|
loguru = "^0.6.0"
|
2024-06-04 11:38:46 -06:00
|
|
|
opentelemetry-api = "^1.25.0"
|
|
|
|
opentelemetry-exporter-otlp = "^1.25.0"
|
|
|
|
opentelemetry-instrumentation-grpc = "^0.46b0"
|
2023-03-03 03:26:27 -07:00
|
|
|
hf-transfer = "^0.1.2"
|
2024-10-02 03:22:13 -06:00
|
|
|
sentencepiece = "^0.2"
|
|
|
|
tokenizers = "^0.20"
|
Pali gemma modeling (#1895)
This PR adds paligemma modeling code
Blog post: https://huggingface.co/blog/paligemma
Transformers PR: https://github.com/huggingface/transformers/pull/30814
install the latest changes and run with
```bash
# get the weights
# text-generation-server download-weights gv-hf/PaliGemma-base-224px-hf
# run TGI
text-generation-launcher --model-id gv-hf/PaliGemma-base-224px-hf
```
basic example sending various requests
```python
from huggingface_hub import InferenceClient
client = InferenceClient("http://127.0.0.1:3000")
images = [
"https://huggingface.co/datasets/hf-internal-testing/fixtures-captioning/resolve/main/cow_beach_1.png",
"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/rabbit.png",
]
prompts = [
"What animal is in this image?",
"Name three colors in this image.",
"What are 10 colors in this image?",
"Where is the cow standing?",
"answer en Where is the cow standing?",
"Is there a bird in the image?",
"Is ther a cow in the image?",
"Is there a rabbit in the image?",
"how many birds are in the image?",
"how many rabbits are in the image?",
]
for img in images:
print(f"\nImage: {img.split('/')[-1]}")
for prompt in prompts:
inputs = f"![]({img}){prompt}\n"
json_data = {
"inputs": inputs,
"parameters": {
"max_new_tokens": 30,
"do_sample": False,
},
}
generated_output = client.text_generation(prompt, max_new_tokens=30, stream=False)
print([f"{prompt}\n{generated_output}"])
```
---------
Co-authored-by: Nicolas Patry <patry.nicolas@protonmail.com>
2024-05-15 22:58:47 -06:00
|
|
|
huggingface-hub = "^0.23"
|
2024-10-02 03:22:13 -06:00
|
|
|
transformers = "^4.45"
|
2023-07-03 05:01:46 -06:00
|
|
|
einops = "^0.6.1"
|
2023-07-27 06:50:45 -06:00
|
|
|
texttable = { version = "^1.6.7", optional = true }
|
|
|
|
datasets = { version = "^2.14.0", optional = true }
|
2024-04-11 02:37:35 -06:00
|
|
|
peft = { version = "^0.10", optional = true }
|
2024-07-23 14:39:43 -06:00
|
|
|
torch = { version = "^2.4.0", optional = true }
|
2023-08-03 15:00:59 -06:00
|
|
|
scipy = "^1.11.1"
|
2023-08-17 06:38:49 -06:00
|
|
|
pillow = "^10.0.0"
|
2024-06-04 11:38:46 -06:00
|
|
|
outlines= { version = "^0.0.34", optional = true }
|
2024-04-30 10:15:35 -06:00
|
|
|
prometheus-client = "^0.20.0"
|
|
|
|
py-cpuinfo = "^9.0.0"
|
2024-07-23 09:53:19 -06:00
|
|
|
# Remove later, temporary workaround for outlines.
|
|
|
|
numpy = "^1.26"
|
2022-10-08 04:30:12 -06:00
|
|
|
|
2024-07-29 07:37:10 -06:00
|
|
|
marlin-kernels = [
|
2024-10-25 08:40:47 -06:00
|
|
|
{ url = "https://github.com/danieldk/marlin-kernels/releases/download/v0.3.1/marlin_kernels-0.3.1+cu123torch2.4-cp39-cp39-linux_x86_64.whl", python = "~3.9", optional = true },
|
|
|
|
{ url = "https://github.com/danieldk/marlin-kernels/releases/download/v0.3.1/marlin_kernels-0.3.1+cu123torch2.4-cp310-cp310-linux_x86_64.whl", python = "~3.10", optional = true },
|
|
|
|
{ url = "https://github.com/danieldk/marlin-kernels/releases/download/v0.3.1/marlin_kernels-0.3.1+cu123torch2.4-cp311-cp311-linux_x86_64.whl", python = "~3.11", optional = true },
|
|
|
|
{ url = "https://github.com/danieldk/marlin-kernels/releases/download/v0.3.1/marlin_kernels-0.3.1+cu123torch2.4-cp312-cp312-linux_x86_64.whl", python = "~3.12", optional = true },
|
2024-07-29 07:37:10 -06:00
|
|
|
]
|
2024-09-17 10:08:58 -06:00
|
|
|
moe-kernels = [
|
2024-10-08 03:56:41 -06:00
|
|
|
{ url = "https://github.com/danieldk/moe-kernels/releases/download/v0.6.0/moe_kernels-0.6.0+cu123torch2.4-cp39-cp39-linux_x86_64.whl", python = "~3.9", optional = true },
|
|
|
|
{ url = "https://github.com/danieldk/moe-kernels/releases/download/v0.6.0/moe_kernels-0.6.0+cu123torch2.4-cp310-cp310-linux_x86_64.whl", python = "~3.10", optional = true },
|
|
|
|
{ url = "https://github.com/danieldk/moe-kernels/releases/download/v0.6.0/moe_kernels-0.6.0+cu123torch2.4-cp311-cp311-linux_x86_64.whl", python = "~3.11", optional = true },
|
|
|
|
{ url = "https://github.com/danieldk/moe-kernels/releases/download/v0.6.0/moe_kernels-0.6.0+cu123torch2.4-cp312-cp312-linux_x86_64.whl", python = "~3.12", optional = true },
|
2024-09-17 10:08:58 -06:00
|
|
|
]
|
2024-08-15 03:12:51 -06:00
|
|
|
rich = "^13.7.1"
|
2024-07-29 07:37:10 -06:00
|
|
|
|
2022-10-28 11:24:00 -06:00
|
|
|
[tool.poetry.extras]
|
2023-11-23 05:38:50 -07:00
|
|
|
torch = ["torch"]
|
2023-04-19 11:39:31 -06:00
|
|
|
accelerate = ["accelerate"]
|
2022-10-28 11:24:00 -06:00
|
|
|
bnb = ["bitsandbytes"]
|
2024-07-29 07:37:10 -06:00
|
|
|
marlin = ["marlin-kernels"]
|
2024-09-17 10:08:58 -06:00
|
|
|
moe = ["moe-kernels"]
|
2023-11-23 05:38:50 -07:00
|
|
|
peft = ["peft"]
|
2023-07-27 06:50:45 -06:00
|
|
|
quantize = ["texttable", "datasets", "accelerate"]
|
2024-02-16 09:50:57 -07:00
|
|
|
outlines = ["outlines"]
|
2022-10-28 11:24:00 -06:00
|
|
|
|
2022-10-08 04:30:12 -06:00
|
|
|
[tool.poetry.group.dev.dependencies]
|
2023-02-13 05:02:45 -07:00
|
|
|
grpcio-tools = "^1.51.1"
|
2023-04-13 04:43:05 -06:00
|
|
|
pytest = "^7.3.0"
|
2022-10-08 04:30:12 -06:00
|
|
|
|
2023-08-03 13:54:39 -06:00
|
|
|
|
|
|
|
[[tool.poetry.source]]
|
|
|
|
name = "pytorch-gpu-src"
|
2023-11-23 05:38:50 -07:00
|
|
|
url = "https://download.pytorch.org/whl/cu121"
|
2023-08-03 13:54:39 -06:00
|
|
|
priority = "explicit"
|
|
|
|
|
2023-05-22 07:05:32 -06:00
|
|
|
[tool.pytest.ini_options]
|
|
|
|
markers = ["private: marks tests as requiring an admin hf token (deselect with '-m \"not private\"')"]
|
|
|
|
|
2022-10-08 04:30:12 -06:00
|
|
|
[build-system]
|
Add AWQ quantization inference support (#1019) (#1054)
# Add AWQ quantization inference support
Fixes
https://github.com/huggingface/text-generation-inference/issues/781
This PR (partially) adds support for AWQ quantization for inference.
More information on AWQ [here](https://arxiv.org/abs/2306.00978). In
general, AWQ is faster and more accurate than GPTQ, which is currently
supported by TGI.
This PR installs 4-bit GEMM custom CUDA kernels released by AWQ authors
(in `requirements.txt`, just one line change).
Quick way to test this PR would be bring up TGI as follows:
```
text-generation-server download-weights abhinavkulkarni/codellama-CodeLlama-7b-Python-hf-w4-g128-awq
text-generation-launcher \
--huggingface-hub-cache ~/.cache/huggingface/hub/ \
--model-id abhinavkulkarni/codellama-CodeLlama-7b-Python-hf-w4-g128-awq \
--trust-remote-code --port 8080 \
--max-input-length 2048 --max-total-tokens 4096 --max-batch-prefill-tokens 4096 \
--quantize awq
```
Please note:
* This PR was tested with FlashAttention v2 and vLLM.
* This PR adds support for AWQ inference, not quantizing the models.
That needs to be done outside of TGI, instructions
[here](https://github.com/mit-han-lab/llm-awq/tree/f084f40bd996f3cf3a0633c1ad7d9d476c318aaa).
* This PR only adds support for `FlashLlama` models for now.
* Multi-GPU setup has not been tested.
* No integration tests have been added so far, will add later if
maintainers are interested in this change.
* This PR can be tested on any of the models released
[here](https://huggingface.co/abhinavkulkarni?sort_models=downloads#models).
Please refer to the linked issue for benchmarks for
[abhinavkulkarni/meta-llama-Llama-2-7b-chat-hf-w4-g128-awq](https://huggingface.co/abhinavkulkarni/meta-llama-Llama-2-7b-chat-hf-w4-g128-awq)
vs
[TheBloke/Llama-2-7b-Chat-GPTQ](https://huggingface.co/TheBloke/Llama-2-7b-Chat-GPTQ).
Please note, AWQ has released faster (and in case of Llama, fused)
kernels for 4-bit GEMM, currently at the top of the `main` branch at
https://github.com/mit-han-lab/llm-awq, but this PR uses an older commit
that has been tested to work. We can switch to latest commit later on.
## Who can review?
@OlivierDehaene OR @Narsil
---------
# What does this PR do?
<!--
Congratulations! You've made it this far! You're not quite done yet
though.
Once merged, your PR is going to appear in the release notes with the
title you set, so make sure it's a great title that fully reflects the
extent of your awesome contribution.
Then, please replace this with a description of the change and which
issue is fixed (if applicable). Please also include relevant motivation
and context. List any dependencies (if any) that are required for this
change.
Once you're done, someone will review your PR shortly (see the section
"Who can review?" below to tag some potential reviewers). They may
suggest changes to make the code even better. If no one reviewed your PR
after a week has passed, don't hesitate to post a new comment
@-mentioning the same persons---sometimes notifications get lost.
-->
<!-- Remove if not applicable -->
Fixes # (issue)
## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the
other checks if that's the case).
- [ ] Did you read the [contributor
guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the
[forum](https://discuss.huggingface.co/)? Please add a link
to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes?
Here are the
[documentation
guidelines](https://github.com/huggingface/transformers/tree/main/docs),
and
[here are tips on formatting
docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?
## Who can review?
Anyone in the community is free to review the PR once the tests have
passed. Feel free to tag
members/contributors who may be interested in your PR.
<!-- Your PR will be replied to more quickly if you can figure out the
right person to tag with @
@OlivierDehaene OR @Narsil
-->
---------
Co-authored-by: Abhinav M Kulkarni <abhinavkulkarni@gmail.com>
Co-authored-by: Abhinav Kulkarni <abhinav@concentric.ai>
2023-09-25 07:31:27 -06:00
|
|
|
requires = [
|
|
|
|
"poetry-core>=1.0.0",
|
|
|
|
]
|
2022-10-08 04:30:12 -06:00
|
|
|
build-backend = "poetry.core.masonry.api"
|
2024-10-09 03:08:02 -06:00
|
|
|
|
|
|
|
[tool.isort]
|
|
|
|
profile = "black"
|