Views
No views yet
| Prompt Length | Batch Size | PyTorch 2.1 torch.compile | ONNX Runtime CUDA |
|---|---|---|---|
| 32 | 1 | 53.64ms | 15.68ms |
| 256 | 1 | 59.55ms | 26.05ms |
| 1024 | 1 | 89.82ms | 99.05ms |
| 2048 | 1 | 208.0ms | 227.0ms |
| 32 | 4 | 70.8ms | 19.62ms |
| 256 | 4 | 78.6ms | 81.29ms |
| 1024 | 4 | 373.7ms | 369.6ms |
| 2048 | 4 | N/A | 879.2ms |
1git clone https://github.com/microsoft/onnxruntime
2cd onnxruntimepython3 -m pip install -r onnxruntime/python/tools/transformers/models/llama/requirements-cuda.txt1from optimum.onnxruntime import ORTModelForCausalLM
2from onnxruntime import InferenceSession
3from transformers import AutoConfig, AutoTokenizer
4
5sess = InferenceSession("falcon-7b.onnx", providers = ["CUDAExecutionProvider"])
6config = AutoConfig.from_pretrained("tiiuae/falcon-7b")
7
8model = ORTFalconForCausalLM(sess, config, use_cache = True, use_io_binding = True)
9
10tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-7b")
11
12inputs = tokenizer("Instruct: What is a fermi paradox?\nOutput:", return_tensors="pt")
13
14outputs = model.generate(**inputs)
15
16print(tokenizer.decode(outputs[0], skip_special_tokens=True))