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

To compare the matmul performance of bfloat16 and fp8. #7459

Closed
wants to merge 3 commits into from

Conversation

AllenDou
Copy link
Contributor

@AllenDou AllenDou commented Aug 13, 2024

After quantizing the AutoModelForSequenceClassification model using AutoFP8 and serving it with vllm, I've observed a significant performance drop-off. So, I've created a PR to test bfloat16 and fp8 performance. @mgoin , could you give me some advice? As you can see from the charts, the scale + cutlass time is almost same with torch.mm time.

m=4096 n=4096 k=4096
pytest test_cutlass.py -k test_compare_cutlass_fp8_torch_mm -s
use_bias=False, torch_mm_time=0.0014884472 scale_time=0.0000164509 cutlass_mm_time=0.0008094311
use_bias=False, torch_mm_time=0.0014874935 scale_time=0.0000212193 cutlass_mm_time=0.0008101463
use_bias=False, torch_mm_time=0.0014891624 scale_time=0.0000171661 cutlass_mm_time=0.0008101463
use_bias=False, torch_mm_time=0.0014884472 scale_time=0.0000157356 cutlass_mm_time=0.0008111000
use_bias=True, torch_mm_time=0.0015590191 scale_time=0.0000166893 cutlass_mm_time=0.0013942719
use_bias=True, torch_mm_time=0.0015594959 scale_time=0.0000171661 cutlass_mm_time=0.0013976097
use_bias=True, torch_mm_time=0.0015587807 scale_time=0.0000176430 cutlass_mm_time=0.0013940334
use_bias=True, torch_mm_time=0.0015587807 scale_time=0.0000171661 cutlass_mm_time=0.0013928413

Weird thing is when use_bias=True, cutlass_mm_time increases significantly.

the GPU I used is L20.


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.

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

👋 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 consists a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of default ones by unblocking the steps in your fast-check build on Buildkite UI.

Once the PR is approved and ready to go, please make sure to run full CI as it is required to merge (or just use auto-merge).

To run full CI, you can do one of these:

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

🚀

@mgoin
Copy link
Member

mgoin commented Aug 13, 2024

Hey @AllenDou you can see some benchmarks we made of our tuned FP8 kernels against the pytorch FP8 kernels in this PR #6677

I think your current measurement setup is not accurate because you are switching between the kernels each iteration and measuring the time after each iteration. Usually we run a loop of iterations over a kernel, synchronize and take the time after all iterations, then take the average to get the per-iter time. For the most standard results we try to use the PyTorch benchmarking tools, example here for existing w8a8 benchmarking: https://github.com/vllm-project/vllm/blob/main/benchmarks/cutlass_benchmarks/w8a8_benchmarks.py

@AllenDou AllenDou closed this Aug 13, 2024
@AllenDou AllenDou deleted the bf16_vs_fp8 branch August 15, 2024 06:08
@fan-niu
Copy link

fan-niu commented Sep 13, 2024

@AllenDou hi thanks for doing some research on AutoModelForSequenceClassification, Can you tell me how to use AutoModelForSequenceClassification on vllm? Thank you so much

@AllenDou
Copy link
Contributor Author

@AllenDou hi thanks for doing some research on AutoModelForSequenceClassification, Can you tell me how to use AutoModelForSequenceClassification on vllm? Thank you so much

Please refer #6260

@fan-niu
Copy link

fan-niu commented Sep 13, 2024

@AllenDou hi thanks for doing some research on AutoModelForSequenceClassification, Can you tell me how to use AutoModelForSequenceClassification on vllm? Thank you so much

Please refer #6260

Cool, thanks so much

@fan-niu
Copy link

fan-niu commented Sep 13, 2024

@AllenDou hi, I downloaded your branch (branch: bge_onemb2) and then installed the source code usingpip install -e ., but when running the service, I got the following error, my most fundamental desire is to use LlamaForSequenceClassification but find the model support list just has XLMRobertaForSequenceClassification, looking forward to your reply, thank you so much.

error info:

raise ValueError( ValueError: Model architectures ['LlamaForSequenceClassification'] are not supported for now. Supported architectures: ['AquilaModel', 'AquilaForCausalLM', 'BaiChuanForCausalLM', 'BaichuanForCausalLM', 'BloomForCausalLM', 'ChatGLMModel', 'ChatGLMForConditionalGeneration', 'CohereForCausalLM', 'DbrxForCausalLM', 'DeciLMForCausalLM', 'DeepseekForCausalLM', 'DeepseekV2ForCausalLM', 'FalconForCausalLM', 'GemmaForCausalLM', 'Gemma2ForCausalLM', 'GPT2LMHeadModel', 'GPTBigCodeForCausalLM', 'GPTJForCausalLM', 'GPTNeoXForCausalLM', 'InternLMForCausalLM', 'InternLM2ForCausalLM', 'JAISLMHeadModel', 'LlamaForCausalLM', 'LLaMAForCausalLM', 'MistralForCausalLM', 'MixtralForCausalLM', 'QuantMixtralForCausalLM', 'MptForCausalLM', 'MPTForCausalLM', 'MiniCPMForCausalLM', 'NemotronForCausalLM', 'OlmoForCausalLM', 'OPTForCausalLM', 'OrionForCausalLM', 'PersimmonForCausalLM', 'PhiForCausalLM', 'Phi3ForCausalLM', 'QWenLMHeadModel', 'Qwen2ForCausalLM', 'Qwen2MoeForCausalLM', 'RWForCausalLM', 'StableLMEpochForCausalLM', 'StableLmForCausalLM', 'Starcoder2ForCausalLM', 'ArcticForCausalLM', 'XverseForCausalLM', 'Phi3SmallForCausalLM', 'MedusaModel', 'MLPSpeculatorPreTrainedModel', 'JambaForCausalLM', 'MistralModel', 'Blip2ForConditionalGeneration', 'ChameleonForConditionalGeneration', 'FuyuForCausalLM', 'InternVLChatModel', 'LlavaForConditionalGeneration', 'LlavaNextForConditionalGeneration', 'MiniCPMV', 'PaliGemmaForConditionalGeneration', 'Phi3VForCausalLM', 'BartModel', 'BartForConditionalGeneration', 'XLMRobertaForSequenceClassification']

Start service command:
export MODEL_PATH=llama3.1-8b_sequencelabeling/ export PORT=8081 export TP=1 export gpu_memory_utilization=0.95 export max_num_batched_tokens=130000 export max_model_len=64000 export max_num_seqs=32 vllm serve ${MODEL_PATH} \ --host 0.0.0.0 \ --port ${PORT} \ --tensor-parallel-size ${TP} \ --gpu-memory-utilization ${gpu_memory_utilization} \ --max-num-batched-tokens ${max_num_batched_tokens} \ --max-model-len ${max_model_len} \ --max-num-seqs ${max_num_seqs} \ --device cuda \

@AllenDou
Copy link
Contributor Author

@fan-niu Yes, currently, #6260 only supports XLMRobertaForSequenceClassification. I will enable more model architectures once this PR is merged

@fan-niu
Copy link

fan-niu commented Sep 13, 2024

@fan-niu Yes, currently, #6260 only supports XLMRobertaForSequenceClassification. I will enable more model architectures once this PR is merged

@AllenDou thanks for your reply, because llama3.1 is very popular now, I am very looking forward to the update with this new change.

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