Creating doc automatically for supported models. (#1929)
# 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 -->
This commit is contained in:
parent
fc0eaffc81
commit
2f243a1a15
|
@ -13,11 +13,7 @@ jobs:
|
||||||
|
|
||||||
- name: Install Launcher
|
- name: Install Launcher
|
||||||
id: install-launcher
|
id: install-launcher
|
||||||
env:
|
run: cargo install --path launcher/
|
||||||
REF: ${{ github.head_ref }}
|
|
||||||
REPO: ${{ github.repository }}
|
|
||||||
run: cargo install --git "https://github.com/$REPO" --branch "$REF" text-generation-launcher
|
|
||||||
|
|
||||||
- name: Check launcher Docs are up-to-date
|
- name: Check launcher Docs are up-to-date
|
||||||
run: |
|
run: |
|
||||||
echo text-generation-launcher --help
|
echo text-generation-launcher --help
|
||||||
|
|
|
@ -1,30 +1,36 @@
|
||||||
|
|
||||||
# Supported Models and Hardware
|
# Supported Models and Hardware
|
||||||
|
|
||||||
Text Generation Inference enables serving optimized models on specific hardware for the highest performance. The following sections list which models are hardware are supported.
|
Text Generation Inference enables serving optimized models on specific hardware for the highest performance. The following sections list which models are hardware are supported.
|
||||||
|
|
||||||
## Supported Models
|
## Supported Models
|
||||||
|
|
||||||
The following models are optimized and can be served with TGI, which uses custom CUDA kernels for better inference. You can add the flag `--disable-custom-kernels` at the end of the `docker run` command if you wish to disable them.
|
- [Idefics 2](https://huggingface.co/HuggingFaceM4/idefics2-8b) (Multimodal)
|
||||||
|
- [Llava Next (1.6)](https://huggingface.co/llava-hf/llava-v1.6-vicuna-13b-hf) (Multimodal)
|
||||||
- [BLOOM](https://huggingface.co/bigscience/bloom)
|
- [Llama](https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct)
|
||||||
- [FLAN-T5](https://huggingface.co/google/flan-t5-xxl)
|
- [Phi 3](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct)
|
||||||
- [Galactica](https://huggingface.co/facebook/galactica-120b)
|
- [Gemma](https://huggingface.co/google/gemma-7b)
|
||||||
- [GPT-2](https://huggingface.co/openai-community/gpt2)
|
- [Cohere](https://huggingface.co/CohereForAI/c4ai-command-r-plus)
|
||||||
- [GPT-Neox](https://huggingface.co/EleutherAI/gpt-neox-20b)
|
- [Dbrx](https://huggingface.co/databricks/dbrx-instruct)
|
||||||
- [Llama](https://github.com/facebookresearch/llama)
|
- [Mamba](https://huggingface.co/state-spaces/mamba-2.8b-slimpj)
|
||||||
- [OPT](https://huggingface.co/facebook/opt-66b)
|
|
||||||
- [SantaCoder](https://huggingface.co/bigcode/santacoder)
|
|
||||||
- [Starcoder](https://huggingface.co/bigcode/starcoder)
|
|
||||||
- [Falcon 7B](https://huggingface.co/tiiuae/falcon-7b)
|
|
||||||
- [Falcon 40B](https://huggingface.co/tiiuae/falcon-40b)
|
|
||||||
- [MPT](https://huggingface.co/mosaicml/mpt-30b)
|
|
||||||
- [Llama V2](https://huggingface.co/meta-llama)
|
|
||||||
- [Code Llama](https://huggingface.co/codellama)
|
|
||||||
- [Mistral](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2)
|
- [Mistral](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2)
|
||||||
- [Mixtral](https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1)
|
- [Mixtral](https://huggingface.co/mistralai/Mixtral-8x22B-Instruct-v0.1)
|
||||||
- [Phi](https://huggingface.co/microsoft/phi-2)
|
- [Gpt Bigcode](https://huggingface.co/bigcode/gpt_bigcode-santacoder)
|
||||||
- [Idefics](HuggingFaceM4/idefics-9b-instruct) (Multimodal)
|
- [Phi](https://huggingface.co/microsoft/phi-1_5)
|
||||||
- [Llava-next](llava-hf/llava-v1.6-mistral-7b-hf) (Multimodal)
|
- [Baichuan](https://huggingface.co/baichuan-inc/Baichuan2-7B-Chat)
|
||||||
|
- [Falcon](https://huggingface.co/tiiuae/falcon-7b-instruct)
|
||||||
|
- [StarCoder 2](https://huggingface.co/bigcode/starcoder2-15b-instruct-v0.1)
|
||||||
|
- [Qwen 2](https://huggingface.co/bigcode/starcoder2-15b-instruct-v0.1)
|
||||||
|
- [Opt](https://huggingface.co/facebook/opt-6.7b)
|
||||||
|
- [T5](https://huggingface.co/google/flan-t5-xxl)
|
||||||
|
- [Galactica](https://huggingface.co/facebook/galactica-120b)
|
||||||
|
- [SantaCoder](https://huggingface.co/bigcode/santacoder)
|
||||||
|
- [Bloom](https://huggingface.co/bigscience/bloom-560m)
|
||||||
|
- [Mpt](https://huggingface.co/mosaicml/mpt-7b-instruct)
|
||||||
|
- [Gpt2](https://huggingface.co/openai-community/gpt2)
|
||||||
|
- [Gpt Neox](https://huggingface.co/EleutherAI/gpt-neox-20b)
|
||||||
|
- [Idefics](https://huggingface.co/HuggingFaceM4/idefics-9b) (Multimodal)
|
||||||
|
|
||||||
|
|
||||||
If the above list lacks the model you would like to serve, depending on the model's pipeline type, you can try to initialize and serve the model anyways to see how well it performs, but performance isn't guaranteed for non-optimized models:
|
If the above list lacks the model you would like to serve, depending on the model's pipeline type, you can try to initialize and serve the model anyways to see how well it performs, but performance isn't guaranteed for non-optimized models:
|
||||||
|
|
||||||
|
@ -39,4 +45,4 @@ If you wish to serve a supported model that already exists on a local folder, ju
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
text-generation-launcher --model-id <PATH-TO-LOCAL-BLOOM>
|
text-generation-launcher --model-id <PATH-TO-LOCAL-BLOOM>
|
||||||
``````
|
```
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import torch
|
import torch
|
||||||
|
import enum
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
@ -116,6 +117,142 @@ if MAMBA_AVAILABLE:
|
||||||
__all__.append(Mamba)
|
__all__.append(Mamba)
|
||||||
|
|
||||||
|
|
||||||
|
class ModelType(enum.Enum):
|
||||||
|
IDEFICS2 = {
|
||||||
|
"type": "idefics2",
|
||||||
|
"name": "Idefics 2",
|
||||||
|
"url": "https://huggingface.co/HuggingFaceM4/idefics2-8b",
|
||||||
|
"multimodal": True,
|
||||||
|
}
|
||||||
|
LLAVA_NEXT = {
|
||||||
|
"type": "llava_next",
|
||||||
|
"name": "Llava Next (1.6)",
|
||||||
|
"url": "https://huggingface.co/llava-hf/llava-v1.6-vicuna-13b-hf",
|
||||||
|
"multimodal": True,
|
||||||
|
}
|
||||||
|
LLAMA = {
|
||||||
|
"type": "llama",
|
||||||
|
"name": "Llama",
|
||||||
|
"url": "https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct",
|
||||||
|
}
|
||||||
|
PHI3 = {
|
||||||
|
"type": "phi3",
|
||||||
|
"name": "Phi 3",
|
||||||
|
"url": "https://huggingface.co/microsoft/Phi-3-mini-4k-instruct",
|
||||||
|
}
|
||||||
|
GEMMA = {
|
||||||
|
"type": "gemma",
|
||||||
|
"name": "Gemma",
|
||||||
|
"url": "https://huggingface.co/google/gemma-7b",
|
||||||
|
}
|
||||||
|
COHERE = {
|
||||||
|
"type": "cohere",
|
||||||
|
"name": "Cohere",
|
||||||
|
"url": "https://huggingface.co/CohereForAI/c4ai-command-r-plus",
|
||||||
|
}
|
||||||
|
DBRX = {
|
||||||
|
"type": "dbrx",
|
||||||
|
"name": "Dbrx",
|
||||||
|
"url": "https://huggingface.co/databricks/dbrx-instruct",
|
||||||
|
}
|
||||||
|
MAMBA = {
|
||||||
|
"type": "ssm",
|
||||||
|
"name": "Mamba",
|
||||||
|
"url": "https://huggingface.co/state-spaces/mamba-2.8b-slimpj",
|
||||||
|
}
|
||||||
|
MISTRAL = {
|
||||||
|
"type": "mistral",
|
||||||
|
"name": "Mistral",
|
||||||
|
"url": "https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2",
|
||||||
|
}
|
||||||
|
MIXTRAL = {
|
||||||
|
"type": "mixtral",
|
||||||
|
"name": "Mixtral",
|
||||||
|
"url": "https://huggingface.co/mistralai/Mixtral-8x22B-Instruct-v0.1",
|
||||||
|
}
|
||||||
|
GPT_BIGCODE = {
|
||||||
|
"type": "gpt_bigcode",
|
||||||
|
"name": "Gpt Bigcode",
|
||||||
|
"url": "https://huggingface.co/bigcode/gpt_bigcode-santacoder",
|
||||||
|
}
|
||||||
|
PHI = {
|
||||||
|
"type": "phi",
|
||||||
|
"name": "Phi",
|
||||||
|
"url": "https://huggingface.co/microsoft/phi-1_5",
|
||||||
|
}
|
||||||
|
BAICHUAN = {
|
||||||
|
"type": "baichuan",
|
||||||
|
"name": "Baichuan",
|
||||||
|
"url": "https://huggingface.co/baichuan-inc/Baichuan2-7B-Chat",
|
||||||
|
}
|
||||||
|
FALCON = {
|
||||||
|
"type": "falcon",
|
||||||
|
"name": "Falcon",
|
||||||
|
"url": "https://huggingface.co/tiiuae/falcon-7b-instruct",
|
||||||
|
}
|
||||||
|
STARCODER2 = {
|
||||||
|
"type": "starcoder2",
|
||||||
|
"name": "StarCoder 2",
|
||||||
|
"url": "https://huggingface.co/bigcode/starcoder2-15b-instruct-v0.1",
|
||||||
|
}
|
||||||
|
QWEN2 = {
|
||||||
|
"type": "qwen2",
|
||||||
|
"name": "Qwen 2",
|
||||||
|
"url": "https://huggingface.co/bigcode/starcoder2-15b-instruct-v0.1",
|
||||||
|
}
|
||||||
|
OPT = {
|
||||||
|
"type": "opt",
|
||||||
|
"name": "Opt",
|
||||||
|
"url": "https://huggingface.co/facebook/opt-6.7b",
|
||||||
|
}
|
||||||
|
T5 = {
|
||||||
|
"type": "t5",
|
||||||
|
"name": "T5",
|
||||||
|
"url": "https://huggingface.co/google/flan-t5-xxl",
|
||||||
|
}
|
||||||
|
GALACTICA = {
|
||||||
|
"type": "galactica",
|
||||||
|
"name": "Galactica",
|
||||||
|
"url": "https://huggingface.co/facebook/galactica-120b",
|
||||||
|
}
|
||||||
|
SANTACODER = {
|
||||||
|
"type": "santacoder",
|
||||||
|
"name": "SantaCoder",
|
||||||
|
"url": "https://huggingface.co/bigcode/santacoder",
|
||||||
|
}
|
||||||
|
BLOOM = {
|
||||||
|
"type": "bloom",
|
||||||
|
"name": "Bloom",
|
||||||
|
"url": "https://huggingface.co/bigscience/bloom-560m",
|
||||||
|
}
|
||||||
|
MPT = {
|
||||||
|
"type": "mpt",
|
||||||
|
"name": "Mpt",
|
||||||
|
"url": "https://huggingface.co/mosaicml/mpt-7b-instruct",
|
||||||
|
}
|
||||||
|
GPT2 = {
|
||||||
|
"type": "gpt2",
|
||||||
|
"name": "Gpt2",
|
||||||
|
"url": "https://huggingface.co/openai-community/gpt2",
|
||||||
|
}
|
||||||
|
GPT_NEOX = {
|
||||||
|
"type": "gpt_neox",
|
||||||
|
"name": "Gpt Neox",
|
||||||
|
"url": "https://huggingface.co/EleutherAI/gpt-neox-20b",
|
||||||
|
}
|
||||||
|
IDEFICS = {
|
||||||
|
"type": "idefics",
|
||||||
|
"name": "Idefics",
|
||||||
|
"url": "https://huggingface.co/HuggingFaceM4/idefics-9b",
|
||||||
|
"multimodal": True,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
__GLOBALS = locals()
|
||||||
|
for data in ModelType:
|
||||||
|
__GLOBALS[data.name] = data.value["type"]
|
||||||
|
|
||||||
|
|
||||||
def get_model(
|
def get_model(
|
||||||
model_id: str,
|
model_id: str,
|
||||||
revision: Optional[str],
|
revision: Optional[str],
|
||||||
|
@ -267,7 +404,7 @@ def get_model(
|
||||||
else:
|
else:
|
||||||
logger.info(f"Unknown quantization method {method}")
|
logger.info(f"Unknown quantization method {method}")
|
||||||
|
|
||||||
if model_type == "ssm":
|
if model_type == MAMBA:
|
||||||
return Mamba(
|
return Mamba(
|
||||||
model_id,
|
model_id,
|
||||||
revision,
|
revision,
|
||||||
|
@ -288,8 +425,8 @@ def get_model(
|
||||||
)
|
)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
model_type == "gpt_bigcode"
|
model_type == GPT_BIGCODE
|
||||||
or model_type == "gpt2"
|
or model_type == GPT2
|
||||||
and model_id.startswith("bigcode/")
|
and model_id.startswith("bigcode/")
|
||||||
):
|
):
|
||||||
if FLASH_ATTENTION:
|
if FLASH_ATTENTION:
|
||||||
|
@ -315,7 +452,7 @@ def get_model(
|
||||||
trust_remote_code=trust_remote_code,
|
trust_remote_code=trust_remote_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
if model_type == "bloom":
|
if model_type == BLOOM:
|
||||||
return BLOOMSharded(
|
return BLOOMSharded(
|
||||||
model_id,
|
model_id,
|
||||||
revision,
|
revision,
|
||||||
|
@ -324,7 +461,7 @@ def get_model(
|
||||||
dtype=dtype,
|
dtype=dtype,
|
||||||
trust_remote_code=trust_remote_code,
|
trust_remote_code=trust_remote_code,
|
||||||
)
|
)
|
||||||
elif model_type == "mpt":
|
elif model_type == MPT:
|
||||||
return MPTSharded(
|
return MPTSharded(
|
||||||
model_id,
|
model_id,
|
||||||
revision,
|
revision,
|
||||||
|
@ -333,7 +470,7 @@ def get_model(
|
||||||
dtype=dtype,
|
dtype=dtype,
|
||||||
trust_remote_code=trust_remote_code,
|
trust_remote_code=trust_remote_code,
|
||||||
)
|
)
|
||||||
elif model_type == "gpt2":
|
elif model_type == GPT2:
|
||||||
if FLASH_ATTENTION:
|
if FLASH_ATTENTION:
|
||||||
return FlashGPT2(
|
return FlashGPT2(
|
||||||
model_id,
|
model_id,
|
||||||
|
@ -354,7 +491,7 @@ def get_model(
|
||||||
dtype=dtype,
|
dtype=dtype,
|
||||||
trust_remote_code=trust_remote_code,
|
trust_remote_code=trust_remote_code,
|
||||||
)
|
)
|
||||||
elif model_type == "gpt_neox":
|
elif model_type == GPT_NEOX:
|
||||||
if FLASH_ATTENTION:
|
if FLASH_ATTENTION:
|
||||||
return FlashNeoXSharded(
|
return FlashNeoXSharded(
|
||||||
model_id,
|
model_id,
|
||||||
|
@ -383,7 +520,7 @@ def get_model(
|
||||||
trust_remote_code=trust_remote_code,
|
trust_remote_code=trust_remote_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
elif model_type == "phi":
|
elif model_type == PHI:
|
||||||
if FLASH_ATTENTION:
|
if FLASH_ATTENTION:
|
||||||
return FlashPhi(
|
return FlashPhi(
|
||||||
model_id,
|
model_id,
|
||||||
|
@ -418,7 +555,7 @@ def get_model(
|
||||||
trust_remote_code=trust_remote_code,
|
trust_remote_code=trust_remote_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
elif model_type == "llama" or model_type == "baichuan" or model_type == "phi3":
|
elif model_type == LLAMA or model_type == BAICHUAN or model_type == PHI3:
|
||||||
if FLASH_ATTENTION:
|
if FLASH_ATTENTION:
|
||||||
return FlashLlama(
|
return FlashLlama(
|
||||||
model_id,
|
model_id,
|
||||||
|
@ -439,7 +576,7 @@ def get_model(
|
||||||
dtype=dtype,
|
dtype=dtype,
|
||||||
trust_remote_code=trust_remote_code,
|
trust_remote_code=trust_remote_code,
|
||||||
)
|
)
|
||||||
if model_type == "gemma":
|
if model_type == GEMMA:
|
||||||
if FLASH_ATTENTION:
|
if FLASH_ATTENTION:
|
||||||
return FlashGemma(
|
return FlashGemma(
|
||||||
model_id,
|
model_id,
|
||||||
|
@ -461,7 +598,7 @@ def get_model(
|
||||||
trust_remote_code=trust_remote_code,
|
trust_remote_code=trust_remote_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
if model_type == "cohere":
|
if model_type == COHERE:
|
||||||
if FLASH_ATTENTION:
|
if FLASH_ATTENTION:
|
||||||
return FlashCohere(
|
return FlashCohere(
|
||||||
model_id,
|
model_id,
|
||||||
|
@ -483,7 +620,7 @@ def get_model(
|
||||||
trust_remote_code=trust_remote_code,
|
trust_remote_code=trust_remote_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
if model_type == "dbrx":
|
if model_type == DBRX:
|
||||||
if FLASH_ATTENTION:
|
if FLASH_ATTENTION:
|
||||||
return FlashDbrx(
|
return FlashDbrx(
|
||||||
model_id,
|
model_id,
|
||||||
|
@ -505,7 +642,7 @@ def get_model(
|
||||||
trust_remote_code=trust_remote_code,
|
trust_remote_code=trust_remote_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
if model_type in ["RefinedWeb", "RefinedWebModel", "falcon"]:
|
if model_type in ["RefinedWeb", "RefinedWebModel", FALCON]:
|
||||||
if sharded:
|
if sharded:
|
||||||
if FLASH_ATTENTION:
|
if FLASH_ATTENTION:
|
||||||
if config_dict.get("alibi", False):
|
if config_dict.get("alibi", False):
|
||||||
|
@ -539,7 +676,7 @@ def get_model(
|
||||||
trust_remote_code=trust_remote_code,
|
trust_remote_code=trust_remote_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
if model_type == "mistral":
|
if model_type == MISTRAL:
|
||||||
sliding_window = config_dict.get("sliding_window", -1)
|
sliding_window = config_dict.get("sliding_window", -1)
|
||||||
if (
|
if (
|
||||||
((sliding_window is None or sliding_window == -1) and FLASH_ATTENTION)
|
((sliding_window is None or sliding_window == -1) and FLASH_ATTENTION)
|
||||||
|
@ -566,7 +703,7 @@ def get_model(
|
||||||
trust_remote_code=trust_remote_code,
|
trust_remote_code=trust_remote_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
if model_type == "mixtral":
|
if model_type == MIXTRAL:
|
||||||
sliding_window = config_dict.get("sliding_window", -1)
|
sliding_window = config_dict.get("sliding_window", -1)
|
||||||
if (
|
if (
|
||||||
((sliding_window is None or sliding_window == -1) and FLASH_ATTENTION)
|
((sliding_window is None or sliding_window == -1) and FLASH_ATTENTION)
|
||||||
|
@ -593,7 +730,7 @@ def get_model(
|
||||||
trust_remote_code=trust_remote_code,
|
trust_remote_code=trust_remote_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
if model_type == "starcoder2":
|
if model_type == STARCODER2:
|
||||||
sliding_window = config_dict.get("sliding_window", -1)
|
sliding_window = config_dict.get("sliding_window", -1)
|
||||||
if (
|
if (
|
||||||
((sliding_window is None or sliding_window == -1) and FLASH_ATTENTION)
|
((sliding_window is None or sliding_window == -1) and FLASH_ATTENTION)
|
||||||
|
@ -621,7 +758,7 @@ def get_model(
|
||||||
trust_remote_code=trust_remote_code,
|
trust_remote_code=trust_remote_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
if model_type == "qwen2":
|
if model_type == QWEN2:
|
||||||
sliding_window = config_dict.get("sliding_window", -1)
|
sliding_window = config_dict.get("sliding_window", -1)
|
||||||
if (
|
if (
|
||||||
((sliding_window is None or sliding_window == -1) and FLASH_ATTENTION)
|
((sliding_window is None or sliding_window == -1) and FLASH_ATTENTION)
|
||||||
|
@ -647,7 +784,7 @@ def get_model(
|
||||||
trust_remote_code=trust_remote_code,
|
trust_remote_code=trust_remote_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
if model_type == "opt":
|
if model_type == OPT:
|
||||||
return OPTSharded(
|
return OPTSharded(
|
||||||
model_id,
|
model_id,
|
||||||
revision,
|
revision,
|
||||||
|
@ -657,7 +794,7 @@ def get_model(
|
||||||
trust_remote_code=trust_remote_code,
|
trust_remote_code=trust_remote_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
if model_type == "t5":
|
if model_type == T5:
|
||||||
return T5Sharded(
|
return T5Sharded(
|
||||||
model_id,
|
model_id,
|
||||||
revision,
|
revision,
|
||||||
|
@ -666,7 +803,7 @@ def get_model(
|
||||||
dtype=dtype,
|
dtype=dtype,
|
||||||
trust_remote_code=trust_remote_code,
|
trust_remote_code=trust_remote_code,
|
||||||
)
|
)
|
||||||
if model_type == "idefics":
|
if model_type == IDEFICS:
|
||||||
if FLASH_ATTENTION:
|
if FLASH_ATTENTION:
|
||||||
return IDEFICSSharded(
|
return IDEFICSSharded(
|
||||||
model_id,
|
model_id,
|
||||||
|
@ -678,7 +815,7 @@ def get_model(
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(FLASH_ATT_ERROR_MESSAGE.format("Idefics"))
|
raise NotImplementedError(FLASH_ATT_ERROR_MESSAGE.format("Idefics"))
|
||||||
if model_type == "idefics2":
|
if model_type == IDEFICS2:
|
||||||
if FLASH_ATTENTION:
|
if FLASH_ATTENTION:
|
||||||
return Idefics2(
|
return Idefics2(
|
||||||
model_id,
|
model_id,
|
||||||
|
@ -703,7 +840,7 @@ def get_model(
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(FLASH_ATT_ERROR_MESSAGE.format("Idefics"))
|
raise NotImplementedError(FLASH_ATT_ERROR_MESSAGE.format("Idefics"))
|
||||||
|
|
||||||
if model_type == "llava_next":
|
if model_type == LLAVA_NEXT:
|
||||||
if FLASH_ATTENTION:
|
if FLASH_ATTENTION:
|
||||||
return LlavaNext(
|
return LlavaNext(
|
||||||
model_id,
|
model_id,
|
||||||
|
|
|
@ -1,13 +1,34 @@
|
||||||
import subprocess
|
import subprocess
|
||||||
import argparse
|
import argparse
|
||||||
|
import ast
|
||||||
|
|
||||||
|
TEMPLATE = """
|
||||||
|
# Supported Models and Hardware
|
||||||
|
|
||||||
|
Text Generation Inference enables serving optimized models on specific hardware for the highest performance. The following sections list which models are hardware are supported.
|
||||||
|
|
||||||
|
## Supported Models
|
||||||
|
|
||||||
|
SUPPORTED_MODELS
|
||||||
|
|
||||||
|
If the above list lacks the model you would like to serve, depending on the model's pipeline type, you can try to initialize and serve the model anyways to see how well it performs, but performance isn't guaranteed for non-optimized models:
|
||||||
|
|
||||||
|
```python
|
||||||
|
# for causal LMs/text-generation models
|
||||||
|
AutoModelForCausalLM.from_pretrained(<model>, device_map="auto")`
|
||||||
|
# or, for text-to-text generation models
|
||||||
|
AutoModelForSeq2SeqLM.from_pretrained(<model>, device_map="auto")
|
||||||
|
```
|
||||||
|
|
||||||
|
If you wish to serve a supported model that already exists on a local folder, just point to the local folder.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
text-generation-launcher --model-id <PATH-TO-LOCAL-BLOOM>
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def check_cli(check: bool):
|
||||||
parser = argparse.ArgumentParser()
|
|
||||||
parser.add_argument("--check", action="store_true")
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
output = subprocess.check_output(["text-generation-launcher", "--help"]).decode(
|
output = subprocess.check_output(["text-generation-launcher", "--help"]).decode(
|
||||||
"utf-8"
|
"utf-8"
|
||||||
)
|
)
|
||||||
|
@ -41,7 +62,7 @@ def main():
|
||||||
block = []
|
block = []
|
||||||
|
|
||||||
filename = "docs/source/basic_tutorials/launcher.md"
|
filename = "docs/source/basic_tutorials/launcher.md"
|
||||||
if args.check:
|
if check:
|
||||||
with open(filename, "r") as f:
|
with open(filename, "r") as f:
|
||||||
doc = f.read()
|
doc = f.read()
|
||||||
if doc != final_doc:
|
if doc != final_doc:
|
||||||
|
@ -53,12 +74,63 @@ def main():
|
||||||
).stdout.decode("utf-8")
|
).stdout.decode("utf-8")
|
||||||
print(diff)
|
print(diff)
|
||||||
raise Exception(
|
raise Exception(
|
||||||
"Doc is not up-to-date, run `python update_doc.py` in order to update it"
|
"Cli arguments Doc is not up-to-date, run `python update_doc.py` in order to update it"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
with open(filename, "w") as f:
|
with open(filename, "w") as f:
|
||||||
f.write(final_doc)
|
f.write(final_doc)
|
||||||
|
|
||||||
|
|
||||||
|
def check_supported_models(check: bool):
|
||||||
|
filename = "server/text_generation_server/models/__init__.py"
|
||||||
|
with open(filename, "r") as f:
|
||||||
|
tree = ast.parse(f.read())
|
||||||
|
|
||||||
|
enum_def = [
|
||||||
|
x for x in tree.body if isinstance(x, ast.ClassDef) and x.name == "ModelType"
|
||||||
|
][0]
|
||||||
|
_locals = {}
|
||||||
|
_globals = {}
|
||||||
|
exec(f"import enum\n{ast.unparse(enum_def)}", _globals, _locals)
|
||||||
|
ModelType = _locals["ModelType"]
|
||||||
|
list_string = ""
|
||||||
|
for data in ModelType:
|
||||||
|
list_string += f"- [{data.value['name']}]({data.value['url']})"
|
||||||
|
if data.value.get("multimodal", None):
|
||||||
|
list_string += " (Multimodal)"
|
||||||
|
list_string += "\n"
|
||||||
|
|
||||||
|
final_doc = TEMPLATE.replace("SUPPORTED_MODELS", list_string)
|
||||||
|
|
||||||
|
filename = "docs/source/supported_models.md"
|
||||||
|
if check:
|
||||||
|
with open(filename, "r") as f:
|
||||||
|
doc = f.read()
|
||||||
|
if doc != final_doc:
|
||||||
|
tmp = "supported.md"
|
||||||
|
with open(tmp, "w") as g:
|
||||||
|
g.write(final_doc)
|
||||||
|
diff = subprocess.run(
|
||||||
|
["diff", tmp, filename], capture_output=True
|
||||||
|
).stdout.decode("utf-8")
|
||||||
|
print(diff)
|
||||||
|
raise Exception(
|
||||||
|
"Supported models is not up-to-date, run `python update_doc.py` in order to update it"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
with open(filename, "w") as f:
|
||||||
|
f.write(final_doc)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("--check", action="store_true")
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
check_cli(args.check)
|
||||||
|
check_supported_models(args.check)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue