dev-slx commited on
Commit
ac7e481
1 Parent(s): d4a22d6

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +149 -0
README.md ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ ---
6
+ # SliceX AI™ ELM Turbo
7
+ **ELM** (which stands for **E**fficient **L**anguage **M**odels) **Turbo** is the next generation model in the series of cutting-edge language models from [SliceX AI](https://slicex.ai) that is designed to achieve the best in class performance in terms of _quality_, _throughput_ & _memory_.
8
+
9
+ <div align="center">
10
+ <img src="elm-turbo-starfruit.png" width="256"/>
11
+ </div>
12
+
13
+ ELM is designed to be a modular and customizable family of neural networks that are highly efficient and performant. Today we are sharing the second version in this series: **ELM Turbo** models (named _Starfruit_).
14
+
15
+ _Model:_ ELM Turbo introduces a more _adaptable_, _decomposable LLM architecture_ thereby yielding flexibility in (de)-composing LLM models into smaller stand-alone slices. In comparison to our previous version, the new architecture allows for more powerful model slices to be learnt during the training process (yielding better quality & higher generative capacity) and a higher level of control wrt LLM efficiency - fine-grained slices to produce varying LLM model sizes (depending on the user/task needs and deployment criteria, i.e., Cloud or Edge device constraints).
16
+
17
+ _Training:_ ELM Turbo introduces algorithmic optimizations that allows us to train a single model but once trained the ELM Turbo model can be sliced in many ways to fit different user/task needs. We formulate the entire training procedure for ELM Turbo as a _continual learning process_ during which we apply **"slicing"** operations & corresponding optimizations during the pre-training and/or fine-tuning stage. In a nutshell, this procedure _teaches the model to learn & compress its knowledge into smaller slices_.
18
+
19
+ _Fast Inference with Customization:_ As with our previous version, once trained, ELM Turbo model architecture permits flexible inference strategies at runtime depending on deployment & device constraints to allow users to make optimal compute/memory tradeoff choices for their application needs. In addition to the blazing fast speeds achieved by native ELM Turbo slice optimization, we also layered in NVIDIA's TensorRT-LLM integration to get further speedups. The end result 👉 optimized ELM Turbo models that achieve one of the world's best LLM performance.
20
+
21
+ - **Blog:** [Medium](https://medium.com/sujith-ravi/introducing-elm-turbo-next-generation-efficient-decomposable-llms-a2347bd08676)
22
+
23
+ - **Github:** https://github.com/slicex-ai/elm-turbo
24
+
25
+ - **HuggingFace** (access ELM Turbo Models in HF): 👉 [here](https://huggingface.co/collections/slicexai/elm-turbo-66945032f3626024aa066fde)
26
+
27
+ ## ELM Turbo Model Release
28
+ In this version, we employed our new, improved decomposable ELM techniques on a widely used open-source LLM, `microsoft/Phi-3-mini-128k-instruct` (3.82B params) (check [phi3-license](https://huggingface.co/microsoft/Phi-3-mini-128k-instruct/resolve/main/LICENSE) for usage). After training, we generated three smaller slices with parameter counts ranging from 1.33 billion to 2.01 billion. Furthermore, we seamlessly integrated these slices into NVIDIA's [TensoRT-LLM](https://github.com/NVIDIA/TensorRT-LLM), providing trtllm engines compatible with A100 and H100 GPUs, respectively.
29
+
30
+ - [Section 1.](https://github.com/slicex-ai/elm-turbo/blob/main/README.md#1-run-elm-turbo-models-with-huggingface-transformers-library) 👉 instructions to run ELM-Turbo with the Huggingface Transformers library :hugs:.
31
+ - [Section 2.](https://github.com/slicex-ai/elm-turbo/blob/main/README.md#2-running-elm-turbo-via-nvidias-tensorrt-llm) 👉 instructions to run ELM-Turbo engines powered by NVIDIA's TensoRT-LLM.
32
+
33
+ **NOTE**: The open-source datasets from the HuggingFace hub used for instruction fine-tuning ELM Turbo include, but are not limited to: `allenai/tulu-v2-sft-mixture`, `microsoft/orca-math-word-problems-200k`, `mlabonne/WizardLM_evol_instruct_70k-ShareGPT`, and `mlabonne/WizardLM_evol_instruct_v2_196K-ShareGPT`. We advise users to exercise caution when utilizing ELM Turbo, as these datasets may contain factually incorrect information, unintended biases, inappropriate content, and other potential issues. It is recommended to thoroughly evaluate the model's outputs and implement appropriate safeguards for your specific use case.
34
+
35
+ ## 1. Run ELM Turbo models with Huggingface Transformers library.
36
+ There are three ELM Turbo slices derived from the `phi3-mini` (3.82B params) model:
37
+ 1. `slicexai/elm-turbo-0.125-instruct` (1.33B params)
38
+ 2. `slicexai/elm-turbo-0.25-instruct`(1.56B params)
39
+ 3. `slicexai/elm-turbo-0.50-instruct` (2.01B params)
40
+
41
+ Required packages for [Hugginface Phi-3-mini](https://huggingface.co/microsoft/Phi-3-mini-128k-instruct) & corresponding ELM Turbo model slices.
42
+ ```bash
43
+ flash_attn==2.5.8
44
+ torch==2.3.1
45
+ accelerate==0.31.0
46
+ transformers==4.41.2
47
+ ```
48
+
49
+ Example - To run the `slicexai/elm-turbo-0.50-instruct`
50
+ ```python
51
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
52
+ import torch
53
+
54
+ elm_turbo_model = "slicexai/elm-turbo-0.50-instruct"
55
+ model = AutoModelForCausalLM.from_pretrained(
56
+ elm_turbo_model,
57
+ device_map="cuda",
58
+ torch_dtype=torch.bfloat16,
59
+ trust_remote_code=True,
60
+ attn_implementation="flash_attention_2"
61
+ )
62
+ messages = [
63
+ {"role": "user", "content": "Can you provide ways to eat combinations of bananas and dragonfruits?"},
64
+ ]
65
+
66
+ tokenizer = AutoTokenizer.from_pretrained(elm_turbo_model, legacy=False)
67
+ pipe = pipeline(
68
+ "text-generation",
69
+ model=model,
70
+ tokenizer=tokenizer,
71
+ )
72
+
73
+ generation_args = {
74
+ "max_new_tokens": 500,
75
+ "return_full_text": False,
76
+ "repetition_penalty": 1.2,
77
+ "temperature": 0.0,
78
+ "do_sample": False,
79
+ }
80
+
81
+ output = pipe(messages, **generation_args)
82
+ print(output[0]['generated_text'])
83
+ ```
84
+
85
+ ## 2. Running ELM Turbo via Nvidia's TensorRT-LLM
86
+
87
+ - **[Cloud AI]** If you are using A100 or H100 GPUs, you can utilize our pre-built ELM Turbo-TRTLLM engines. Below are the instructions to install and run them.
88
+
89
+ - Additionally, you can build your own TRTLLM engines by following the instructions provided in [Section (c)](https://github.com/slicex-ai/elm-turbo/blob/main/README.md#c-optional-create--run-your-own-elm-turbo-trtllm-engines-from-elm-turbo-huggingfacehf-checkpoints) below.
90
+
91
+ - **[Edge AI]** To run on edge (Windows RTX), follow the instructions provided by Nvidia in their TRT-LLM documentation: [Windows README](https://github.com/NVIDIA/TensorRT-LLM/blob/main/windows/README.md).
92
+
93
+
94
+ ### (a) Download & install Nvidia's TensorRT-LLM with docker.
95
+ The following commands create a Docker container named `elm_trtllm` and install TensorRT-LLM. If you encounter any installation errors related to TensorRT-LLM, please refer to the troubleshooting section [here](https://nvidia.github.io/TensorRT-LLM/reference/troubleshooting.html).
96
+ ```
97
+ git clone https://github.com/slicex-ai/elm-turbo.git
98
+ cd elm-turbo
99
+ sh setup_trtllm.sh
100
+ ```
101
+ This creates a docker named `elm_trtllm` and installs tensorrt_llm.
102
+
103
+ ### (b) Run pre-built ELM Turbo-trtllm engines with your input prompts.
104
+
105
+ Example: To run our pre-built trt-engine for `slicexai/elm-turbo-0.50-instruct` on A100 & H100 gpus respectively,
106
+ ```
107
+ docker attach elm_trtllm
108
+ cd /lm
109
+ sh run_elm_turbo_trtllm_engine.sh slicexai/elm-turbo-0.50-instruct A100 "plan a fun day with my grandparents."
110
+ sh run_elm_turbo_trtllm_engine.sh slicexai/elm-turbo-0.50-instruct H100 "plan a fun day with my grandparents."
111
+ ```
112
+
113
+ Detailed instructions to run the engine:
114
+ ```
115
+ Usage: sh run_elm_turbo_trtllm_engine.sh <elm_turbo_model_id> <gpu_type> "<input_prompt>"
116
+ Supported elm-turbo_model_id choices : [slicexai/elm-turbo-0.50-instruct, slicexai/elm-turbo-0.25-instruct, slicexai/elm-turbo-0.125-instruct]
117
+ Supported gpu_types : [A100, H100]
118
+ ```
119
+
120
+
121
+ ### (c) (Optional) Create & run your own ELM Turbo-trtllm engines from ELM Turbo Huggingface(HF) checkpoints.
122
+
123
+ #### Compile the Model into a TensorRT-LLM Engine
124
+ To build an elm-turbo `slicexai/elm-turbo-0.50-instruct` tensortrt_llm engine with INT-8 quantization, follow the instructions below. For more detailed configurations, refer to the Phi3 conversion instructions provided by NVIDIA [here](https://github.com/NVIDIA/TensorRT-LLM/tree/main/examples/phi).
125
+
126
+ ```bash
127
+ docker attach elm_trtllm
128
+ cd /lm/TensorRT-LLM/examples/phi
129
+ pip install flash_attn
130
+ huggingface-cli download slicexai/elm-turbo-0.50-instruct --local-dir ../slicexai/elm-turbo-0.50-instruct
131
+ python3 convert_checkpoint.py --dtype bfloat16 --use_weight_only --weight_only_precision int8 --model_dir ../slicexai/elm-turbo-0.50-instruct --output_dir ../slicexai/elm-turbo-0.50-instruct-trtllm-ckpt
132
+ trtllm-build --gpt_attention_plugin bfloat16 --gemm_plugin bfloat16 --max_seq_len 4096 --max_batch_size 256 --checkpoint_dir ../slicexai/elm-turbo-0.50-instruct-trtllm-ckpt --output_dir ../slicexai/elm-turbo-0.50-instruct-trtllm-engine
133
+ ```
134
+
135
+ #### Run the Model
136
+ Now that you’ve got your model engine, it's time to run it.
137
+
138
+ ```bash
139
+ python3 ../run.py \
140
+ --engine_dir ../slicexai/elm-turbo-0.50-instruct-trtllm-engine \
141
+ --max_output_len 512 \
142
+ --presence_penalty 0.7 \
143
+ --frequency_penalty 0.7 \
144
+ --tokenizer_dir ../slicexai/elm-turbo-0.50-instruct \
145
+ --input_text """<s><|user|>
146
+ plan a fun day with my grandparents.<|end|>
147
+ <|assistant|>
148
+ """
149
+ ```