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

[Bugfix] Add random_seed to sample_hf_requests in benchmark_serving script #9013

Merged
merged 3 commits into from
Oct 17, 2024

Conversation

wukaixingxp
Copy link
Contributor

[Bugfix] Current sample_hf_requests() in benchmark_serving.py did not have a good reproducibility as it uses dataset.shuffle(), which causes the input prompts to be different between each run.

This PR adds random_seed=arg.seed argument to sample_hf_requests() and changes dataset.shuffle() to dataset.shuffle(seed=RANDOM_SEED) to ensure benchmark reproducibility. After this fix, the Total input tokens is now fixed to 12428 as shown in the test logs below.

Test Log:
first run:

python ../benchmark_serving.py --backend openai-chat --base-url http://0.0.0.0:8000/v1 --endpoint /chat/completions --model meta-llama/Llama-3.2-11B-Vision-Instruct --dataset-path lmms-lab/LLaVA-OneVision-Data --dataset-name hf --hf-subset "chart2text(cauldron)" --hf-split train --save-result
Namespace(backend='openai-chat', base_url='http://0.0.0.0:8000/v1', host='localhost', port=8000, endpoint='/chat/completions', dataset=None, dataset_name='hf', dataset_path='lmms-lab/LLaVA-OneVision-Data', model='meta-llama/Llama-3.2-11B-Vision-Instruct', tokenizer=None, best_of=1, use_beam_search=False, num_prompts=1000, logprobs=None, request_rate=inf, seed=0, trust_remote_code=False, disable_tqdm=False, profile=False, save_result=True, metadata=None, result_dir=None, result_filename=None, percentile_metrics='ttft,tpot,itl', metric_percentiles='99', sonnet_input_len=550, sonnet_output_len=150, sonnet_prefix_len=200, sharegpt_output_len=None, random_input_len=1024, random_output_len=128, random_range_ratio=1.0, random_prefix_len=0, hf_subset='chart2text(cauldron)', hf_split='train', hf_output_len=None)
Downloading readme: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 46.3k/46.3k [00:00<00:00, 9.22MB/s]
Starting initial single prompt test run...
Initial test run completed. Starting main benchmark run...
Traffic request rate: inf
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1000/1000 [03:35<00:00,  4.63it/s]
============ Serving Benchmark Result ============
Successful requests:                     1000      
Benchmark duration (s):                  215.79    
Total input tokens:                      12428     
Total generated tokens:                  63701     
Request throughput (req/s):              4.63      
Output token throughput (tok/s):         295.20    
Total Token throughput (tok/s):          352.79    
---------------Time to First Token----------------
Mean TTFT (ms):                          107762.34 
Median TTFT (ms):                        107688.53 
P99 TTFT (ms):                           210873.42 
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          101.65    
Median TPOT (ms):                        103.52    
P99 TPOT (ms):                           126.47    
---------------Inter-token Latency----------------
Mean ITL (ms):                           101.39    
Median ITL (ms):                         21.78     
P99 ITL (ms):                            480.65    
==================================================

second run:

python ../benchmark_serving.py --backend openai-chat --base-url http://0.0.0.0:8000/v1 --endpoint /chat/completions --model meta-llama/Llama-3.2-11B-Vision-Instruct --dataset-path lmms-lab/LLaVA-OneVision-Data --dataset-name hf --hf-subset "chart2text(cauldron)" --hf-split train --save-result
Namespace(backend='openai-chat', base_url='http://0.0.0.0:8000/v1', host='localhost', port=8000, endpoint='/chat/completions', dataset=None, dataset_name='hf', dataset_path='lmms-lab/LLaVA-OneVision-Data', model='meta-llama/Llama-3.2-11B-Vision-Instruct', tokenizer=None, best_of=1, use_beam_search=False, num_prompts=1000, logprobs=None, request_rate=inf, seed=0, trust_remote_code=False, disable_tqdm=False, profile=False, save_result=True, metadata=None, result_dir=None, result_filename=None, percentile_metrics='ttft,tpot,itl', metric_percentiles='99', sonnet_input_len=550, sonnet_output_len=150, sonnet_prefix_len=200, sharegpt_output_len=None, random_input_len=1024, random_output_len=128, random_range_ratio=1.0, random_prefix_len=0, hf_subset='chart2text(cauldron)', hf_split='train', hf_output_len=None)
Starting initial single prompt test run...
Initial test run completed. Starting main benchmark run...
Traffic request rate: inf
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1000/1000 [03:43<00:00,  4.47it/s]
============ Serving Benchmark Result ============
Successful requests:                     1000      
Benchmark duration (s):                  223.62    
Total input tokens:                      12428     
Total generated tokens:                  63680     
Request throughput (req/s):              4.47      
Output token throughput (tok/s):         284.77    
Total Token throughput (tok/s):          340.35    
---------------Time to First Token----------------
Mean TTFT (ms):                          112154.70 
Median TTFT (ms):                        111527.32 
P99 TTFT (ms):                           219165.63 
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          105.54    
Median TPOT (ms):                        106.54    
P99 TPOT (ms):                           136.76    
---------------Inter-token Latency----------------
Mean ITL (ms):                           105.57    
Median ITL (ms):                         22.22     
P99 ITL (ms):                            489.19    
==================================================

BEFORE SUBMITTING, PLEASE READ THE CHECKLIST BELOW AND FILL IN THE DESCRIPTION ABOVE


PR Checklist (Click to Expand)

Thank you for your contribution to vLLM! Before submitting the pull request, please ensure the PR meets the following criteria. This helps vLLM maintain the code quality and improve the efficiency of the review process.

PR Title and Classification

Only specific types of PRs will be reviewed. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:

  • [Bugfix] for bug fixes.
  • [CI/Build] for build or continuous integration improvements.
  • [Doc] for documentation fixes and improvements.
  • [Model] for adding a new model or improving an existing model. Model name should appear in the title.
  • [Frontend] For changes on the vLLM frontend (e.g., OpenAI API server, LLM class, etc.)
  • [Kernel] for changes affecting CUDA kernels or other compute kernels.
  • [Core] for changes in the core vLLM logic (e.g., LLMEngine, AsyncLLMEngine, Scheduler, etc.)
  • [Hardware][Vendor] for hardware-specific changes. Vendor name should appear in the prefix (e.g., [Hardware][AMD]).
  • [Misc] for PRs that do not fit the above categories. Please use this sparingly.

Note: If the PR spans more than one category, please include all relevant prefixes.

Code Quality

The PR need to meet the following code quality standards:

  • We adhere to Google Python style guide and Google C++ style guide.
  • Pass all linter checks. Please use format.sh to format your code.
  • The code need to be well-documented to ensure future contributors can easily understand the code.
  • Include sufficient tests to ensure the project to stay correct and robust. This includes both unit tests and integration tests.
  • Please add documentation to docs/source/ if the PR modifies the user-facing behaviors of vLLM. It helps vLLM user understand and utilize the new features or changes.

Adding or changing kernels

Each custom kernel needs a schema and one or more implementations to be registered with PyTorch.

  • Make sure custom ops are registered following PyTorch guidelines: Custom C++ and CUDA Operators and The Custom Operators Manual
  • Custom operations that return Tensors require meta-functions. Meta-functions should be implemented and registered in python so that dynamic dims can be handled automatically. See above documents for a description of meta-functions.
  • Use torch.libary.opcheck() to test the function registration and meta-function for any registered ops. See tests/kernels for examples.
  • When changing the C++ signature of an existing op, the schema must be updated to reflect the changes.
  • If a new custom type is needed, see the following document: Custom Class Support in PT2.

Notes for Large Changes

Please keep the changes as concise as possible. For major architectural changes (>500 LOC excluding kernel/data/config/test), we would expect a GitHub issue (RFC) discussing the technical design and justification. Otherwise, we will tag it with rfc-required and might not go through the PR.

What to Expect for the Reviews

The goal of the vLLM team is to be a transparent reviewing machine. We would like to make the review process transparent and efficient and make sure no contributor feel confused or frustrated. However, the vLLM team is small, so we need to prioritize some PRs over others. Here is what you can expect from the review process:

  • After the PR is submitted, the PR will be assigned to a reviewer. Every reviewer will pick up the PRs based on their expertise and availability.
  • After the PR is assigned, the reviewer will provide status update every 2-3 days. If the PR is not reviewed within 7 days, please feel free to ping the reviewer or the vLLM team.
  • After the review, the reviewer will put an action-required label on the PR if there are changes required. The contributor should address the comments and ping the reviewer to re-review the PR.
  • Please respond to all comments within a reasonable time frame. If a comment isn't clear or you disagree with a suggestion, feel free to ask for clarification or discuss the suggestion.

Thank You

Finally, thank you for taking the time to read these guidelines and for your interest in contributing to vLLM. Your contributions make vLLM a great tool for everyone!

Copy link

github-actions bot commented Oct 2, 2024

👋 Hi! Thank you for contributing to the vLLM project.
Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can do one of these:

  • Add ready label to the PR
  • Enable auto-merge.

🚀

Copy link
Collaborator

@Isotr0py Isotr0py left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. Thanks for fixing this!

Can you please fix the lint errors through running bash format.sh? Thanks!

@Isotr0py Isotr0py changed the title add random_seed to sample_hf_requests in benchmark_serving script [Bugfix] Add random_seed to sample_hf_requests in benchmark_serving script Oct 15, 2024
@Isotr0py Isotr0py self-assigned this Oct 15, 2024
@wukaixingxp
Copy link
Contributor Author

wukaixingxp commented Oct 15, 2024

@Isotr0py Thanks for your review. I run format.sh and did not see any changed made by format.sh. I do not see any of my file has any lint error but some tests still failed, what should I do?

(vllm) [ ~/work/kai/vllm (main)]$ bash format.sh
vLLM yapf: Done
vLLM mypy:
Running mypy on 
Success: no issues found in 128 source files
Running mypy on tests
Success: no issues found in 319 source files
Running mypy on vllm/assets
Success: no issues found in 5 source files
Running mypy on vllm/attention
Success: no issues found in 16 source files
Running mypy on vllm/distributed
Success: no issues found in 12 source files
Running mypy on vllm/engine
Success: no issues found in 17 source files
Running mypy on vllm/entrypoints
Success: no issues found in 24 source files
Running mypy on vllm/executor
Success: no issues found in 17 source files
Running mypy on vllm/logging
Success: no issues found in 2 source files
Running mypy on vllm/lora
Success: no issues found in 17 source files
Running mypy on vllm/model_executor
Success: no issues found in 88 source files
Running mypy on vllm/multimodal
Success: no issues found in 7 source files
Running mypy on vllm/platforms
Success: no issues found in 7 source files
Running mypy on vllm/plugins
Success: no issues found in 1 source file
Running mypy on vllm/prompt_adapter
Success: no issues found in 6 source files
Running mypy on vllm/spec_decode
Success: no issues found in 16 source files
Running mypy on vllm/transformers_utils
Success: no issues found in 30 source files
Running mypy on vllm/usage
Success: no issues found in 2 source files
Running mypy on vllm/worker
Success: no issues found in 23 source files
vLLM mypy: Done
vLLM codespell: Done
vLLM ruff: Done
vLLM isort: Done
vLLM clang-format: Done
vLLM actionlint:
vLLM actionlint: Done
(vllm) [ ~/work/kai/vllm (main)]$ git add .
(vllm) [ ~/work/kai/vllm (main)]$ git commit -m 'formated by format.sh'
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
(vllm) [~/work/kai/vllm (main)]$ git log --raw
commit 50e093943da564a32d86b37d399a26b66b8bd83b (HEAD -> main, origin/main, origin/HEAD)
Merge: dc1cf2fb 5d264f4a
Author: Kai Wu <[email protected]>
Date:   Tue Oct 15 14:27:23 2024 -0700

    Merge branch 'vllm-project:main' into main

commit 5d264f4ab8d008f0ac5b7f0adb7189d70136f3ec
Author: Grace Ho <[email protected]>
Date:   Tue Oct 15 13:30:44 2024 -0700

    pass ignore_eos parameter to all benchmark_serving calls (#9349)

:100644 100644 04999518 c1a396c8 M      benchmarks/benchmark_serving.py

commit e9d517f27673ec8736c026f2311d3c250d5f9061
Author: Nick Hill <[email protected]>
Date:   Tue Oct 15 07:19:48 2024 +0100

    [BugFix] Fix chat API continuous usage stats (#9357)

:100644 100644 0fbc4cca 3af0032f M      tests/entrypoints/openai/test_chat.py
:100644 100644 9470b6ea acb56e4a M      vllm/entrypoints/openai/serving_chat.py

commit 55e081fbad29c6710318e1715372cc927e44de8b

@Isotr0py
Copy link
Collaborator

I see, you can refer to the output of the CI here: https://github.com/vllm-project/vllm/actions/runs/11354659097/job/31582376192?pr=9013#step:5:18

@Isotr0py Isotr0py enabled auto-merge (squash) October 17, 2024 16:32
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Oct 17, 2024
@Isotr0py Isotr0py merged commit d65049d into vllm-project:main Oct 17, 2024
51 checks passed
charlifu pushed a commit to charlifu/vllm that referenced this pull request Oct 23, 2024
vrdn-23 pushed a commit to vrdn-23/vllm that referenced this pull request Oct 23, 2024
Alvant pushed a commit to compressa-ai/vllm that referenced this pull request Oct 26, 2024
garg-amit pushed a commit to garg-amit/vllm that referenced this pull request Oct 28, 2024
FerdinandZhong pushed a commit to FerdinandZhong/vllm that referenced this pull request Oct 29, 2024
sumitd2 pushed a commit to sumitd2/vllm that referenced this pull request Nov 14, 2024
KuntaiDu pushed a commit to KuntaiDu/vllm that referenced this pull request Nov 20, 2024
mfournioux pushed a commit to mfournioux/vllm that referenced this pull request Nov 20, 2024
tlrmchlsmth pushed a commit to neuralmagic/vllm that referenced this pull request Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants