hf_text-generation-inference/server
drbh bd405e035b
Impl simple mamba model (#1480)
This draft PR is a work in progress implementation of the mamba model.
This PR currently loads weights, and produces correct logits after a
single pass.

This PR still needs to correctly integrate this model so it produces
tokens as expected, and apply optimization to avoid all copies during
runtime/unnecessary operations.

#### Helpful resources
[Mamba: Linear-Time Sequence Modeling with Selective State Spaces
(Albert Gu and Tri Dao)](https://arxiv.org/abs/2312.00752)
https://github.com/johnma2006/mamba-minimal

https://github.com/huggingface/candle/blob/main/candle-examples/examples/mamba-minimal/model.rs
https://github.com/huggingface/transformers/pull/28094

Notes: this dev work is currently targeting `state-spaces/mamba-130m`,
so if you want to test please use that model. Additionally when starting
the router the prefill needs to be limited: `cargo run --
--max-batch-prefill-tokens 768 --max-input-length 768`


## Update / Current State

Integration tests have been added and basic functionality such as model
loading is supported.

```bash
cd integration-tests
pytest -vv models/test_fused_kernel_mamba.py
```
- [x] add tests
- [x] load model
- [x] make simple request 
- [ ] resolve warmup issue
- [ ] resolve output issues


fetching models tested during dev
```bash
text-generation-server download-weights state-spaces/mamba-130m
text-generation-server download-weights state-spaces/mamba-1.4b
text-generation-server download-weights state-spaces/mamba-2.8b
```

The server can be run 
```bash
cd server
 MASTER_ADDR=127.0.0.1 MASTER_PORT=5555 python text_generation_server/cli.py serve state-spaces/mamba-2.8b
```

router
```bash
cargo run
```

make a request
```bash
curl -s localhost:3000/generate \
    -X POST \
    -d '{"inputs":"What is Deep Learning?","parameters":{"max_new_tokens":20}}' \
    -H 'Content-Type: application/json' | jq
```

response
```json
{
  "generated_text": "\n\nDeep learning is a machine learning technique that uses a deep neural network to learn from data."
}
```

---------

Co-authored-by: Nicolas Patry <patry.nicolas@protonmail.com>
2024-02-08 10:19:45 +01:00
..
custom_kernels Add RoCm support (#1243) 2023-11-27 14:08:12 +01:00
exllama_kernels GPTQ support on ROCm (#1489) 2024-01-26 16:27:44 +01:00
exllamav2_kernels GPTQ support on ROCm (#1489) 2024-01-26 16:27:44 +01:00
tests Fixing top_n_tokens. (#1497) 2024-01-26 20:13:47 +01:00
text_generation_server Impl simple mamba model (#1480) 2024-02-08 10:19:45 +01:00
.gitignore Impl simple mamba model (#1480) 2024-02-08 10:19:45 +01:00
Makefile Impl simple mamba model (#1480) 2024-02-08 10:19:45 +01:00
Makefile-awq Add AWQ quantization inference support (#1019) (#1054) 2023-09-25 15:31:27 +02:00
Makefile-eetq feat: eetq gemv optimization when batch_size <= 4 (#1502) 2024-01-31 12:05:49 +01:00
Makefile-flash-att Add RoCm support (#1243) 2023-11-27 14:08:12 +01:00
Makefile-flash-att-v2 `make install-flash-attn-v2-cuda` should work like `make install-flash-attn-v2` used to work. (#1294) 2023-11-28 16:28:40 +01:00
Makefile-selective-scan Impl simple mamba model (#1480) 2024-02-08 10:19:45 +01:00
Makefile-vllm Speculative (#1308) 2023-12-11 12:46:30 +01:00
README.md feat(router): refactor API and add openAPI schemas (#53) 2023-02-03 12:43:37 +01:00
poetry.lock v1.4.0 (#1494) 2024-01-26 19:04:57 +01:00
pyproject.toml v1.4.0 (#1494) 2024-01-26 19:04:57 +01:00
requirements_common.txt Add RoCm support (#1243) 2023-11-27 14:08:12 +01:00
requirements_cuda.txt v1.4.0 (#1494) 2024-01-26 19:04:57 +01:00
requirements_rocm.txt v1.4.0 (#1494) 2024-01-26 19:04:57 +01:00

README.md

Text Generation Inference Python gRPC Server

A Python gRPC server for Text Generation Inference

Install

make install

Run

make run-dev