Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update benchmark readme #12323

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions python/llm/dev/benchmark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,23 @@ with torch.inference_mode():
output_str = tokenizer.decode(output[0], skip_special_tokens=True)
```

### Sample Output
```bash
=========First token cost xx.xxxxs and 3.595703125 GB=========
=========Rest tokens cost average xx.xxxxs (31 tokens in all) and 3.595703125 GB=========
```

You can also set `verbose = True`
```python
model = BenchmarkWrapper(model, do_print=True, verbose=True)
```

```bash
=========First token cost xx.xxxxs and 3.595703125 GB=========
=========Rest token cost average xx.xxxxs (31 tokens in all) and 3.595703125 GB=========
Peak memory for every token: [3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125, 3.595703125]
```

### Inference on multi GPUs
Similarly, put this file into your benchmark directory, and then wrap your optimized model with `BenchmarkWrapper` (`model = BenchmarkWrapper(model)`).
For example, just need to apply following code patch on [Deepspeed Autotp example code](https://github.com/intel-analytics/ipex-llm/blob/main/python/llm/example/GPU/Deepspeed-AutoTP/deepspeed_autotp.py) to calculate 1st and the rest token performance:
Expand All @@ -79,10 +96,3 @@ For example, just need to apply following code patch on [Deepspeed Autotp exampl
# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
```

### Sample Output
Output will be like:
```bash
=========First token cost xx.xxxxs=========
=========Last token cost average xx.xxxxs (31 tokens in all)=========
```
Loading