generation.py with kv cache (#3030)
Summary:
python e2e generation, using tiktoken tokenizer.
using text_completion, haven't tried chat_completion.
Pull Request resolved: https://github.com/pytorch/executorch/pull/3030
Test Plan:
Imported from GitHub, without a `Test Plan:` line.
Command, with prompt "Hello, I am" and seq_len = 10
```
python -m examples.models.llama2.runner.generation --pte llama_4ckpts_x.pte --tokenizer tokenizer.model --prompt="Hello I am" --temperature=0 --params ../llama-models/llama3/params_less.json --max_gen_len=10
```
fp32, xnn, kv
fp32, xnn
same results:
```
Result: [{'generation': ' a 25 year old woman. I am a'}]
```
fp32, xnn, int4
```
Result: [{'generation': ' interested in the following products: - 1 x'}]
```
fp32, xnn, kv, sdpa (need investigation)
```
Result: [{'generation': 'ฉopteraenthalenthalenthalenthalenthalenthalenthalenthal'}]
```
Reviewed By: larryliu0820
Differential Revision: D56087430
Pulled By: lucylq
fbshipit-source-id: 31c73fe87af8646bf2512e1a6aadc8804a101719 L
lucylq committed
645256dc136137ef9f37a000974270a33fbc017f
Parent: 7c81155
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
on 4/15/2024, 7:01:08 PM