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

Add a benchmark script for in-batch prefix caching #2494

Merged
merged 3 commits into from
Dec 17, 2024

Conversation

merrymercy
Copy link
Contributor

@merrymercy merrymercy commented Dec 17, 2024

Changes

Some results

Please note that there are huge variances across runs.

  • Results with the old default policy
Latency of test_batch_by_batch          : 1.9585 s
Latency of test_batch_by_batch_with_hint: 1.9020 s
Latency of test_send_all                : 3.7643 s
Latency of test_batch_by_batch          : 1.9868 s
Latency of test_batch_by_batch_with_hint: 1.9520 s
Latency of test_send_all                : 3.0549 s
  • The goal: the Latency of test_send_all should be very close to the Latency of test_batch_by_batch_with_hint (the oracle).

@merrymercy merrymercy changed the title Revert the delayed scheduling for in-batch prefix caching Add a benchmark script for in-batch prefix caching Dec 17, 2024
@merrymercy merrymercy force-pushed the pr-add-in-prefix-bench branch from 61f9266 to 401414b Compare December 17, 2024 02:43
@merrymercy merrymercy merged commit 56198b4 into main Dec 17, 2024
1 of 2 checks passed
@merrymercy merrymercy deleted the pr-add-in-prefix-bench branch December 17, 2024 02:49
@libratiger
Copy link
Contributor

I was intrigued by your benchmark results, particularly noting that test_send_all showed slower performance compared to other methods. To verify this, I conducted tests on my own server, but interestingly, I observed opposite results:

Latency of test_batch_by_batch          : 2.3765 s
Latency of test_batch_by_batch_with_hint: 2.4907 s
Latency of test_send_all                : 2.2191 s

The tests were run using the following commands:

python3 -m sglang.launch_server --model Qwen/Qwen2.5-3B-Instruct
# Changed the tokenizer to Qwen
python bench_in_batch_prefix.py

Environment details:

  • SGLang version: 0.4.1
  • Hardware: A100 GPU

I repeated these experiments multiple times and also tested with a smaller model, but the results consistently showed the same pattern: test_send_all performed faster than the other methods.

@libratiger
Copy link
Contributor

attention_backend='flashinfer', sampling_backend='flashinfer',

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants