[Kernel] Switch fp8 layers to use the CUTLASS kernels#5183
[Kernel] Switch fp8 layers to use the CUTLASS kernels#5183pcmoritz merged 9 commits intovllm-project:mainfrom
Conversation
|
Just ran a quick sanity check for correctness. Output looks good on all three. I tried tensor_parallel_size=2 as well for the 70B model, and that looks good |
| return torch.narrow(output, 0, 0, x.shape[0]) | ||
|
|
||
| # We use the CUTLASS kernels by default but they don't support bias yet | ||
| if bias is None: |
There was a problem hiding this comment.
Do we also do a branch if we are on ada lovelace and CUDA 12.1?
There was a problem hiding this comment.
We will need to if on CUDA < 12.4. We also need a branch if on CUDA 11.8. @comaniac do you know if torch._scaled_mm is supported in that case?
There was a problem hiding this comment.
I only know that it only supports SM89+. We can try to call this op with torch+cu118 to test out.
There was a problem hiding this comment.
The cutlass kernels need at least SM89 as well, for the record.
There was a problem hiding this comment.
Yeah that makes sense. Older architectures don't have native FP8 so we can't get speedup from them, which seems not necessary to be covered.
There was a problem hiding this comment.
Note: we already have a mechanism for determining if a LinearMethod can run on a specific cuda arch. The LinearMethod exposes get_min_capability which is called during model loading.
|
Did you run benchmarks to compare the end-to-end performance? ITL for different qps |
Not yet. But obviously need this before we merge |
|
I'll do a benchmark on Monday anyways. btw it'd be great if this PR is rebased onto the latest main that includes all required changes (it's likely the case already I suppose |
|
@tlrmchlsmth @robertgshaw2-neuralmagic per offline discussion, this PR should be ok to go at least for now? |
|
Yeah, let's get it landed. It needs to check a few more cases for falling back to scaled_mm. I'll get to that today and then mark it ready for review |
pcmoritz
left a comment
There was a problem hiding this comment.
Great work and thanks for adding the benchmarks :)
There was a problem hiding this comment.
LGTM. Thanks!
I also did some benchmarks with this PR. Note that all results are in TP=4 on H100 and with chunked prefill enabled (this is just my own requirement). Prompts are 550 tokens, decoding 150 tokens.
| Model | QPS | scaled_mm-ITL | cutlass-ITL | scaled_mm-TTFT | cutlass-TTFT |
|---|---|---|---|---|---|
| Llama-3-70B | 1 | 17.3 | 16.3 | 68.7 | 68.7 |
| Llama-3-70B | 4 | 22.7 | 21.2 | 72.3 | 72.6 |
| Llama-3-70B | 8 | 35.9 | 33.6 | 83.1 | 81.2 |
| Mixtral-8x7B | 1 | 9.1 | 8.9 | 43.1 | 40.7 |
| Mixtral-8x7B | 4 | 11.4 | 10.7 | 42.6 | 38.4 |
| Mixtral-8x7B | 8 | 15.6 | 14.3 | 43.4 | 42.8 |
|
@tlrmchlsmth Awesome work! Was trying this but ran into a problem when checking the cutlass fp8 support. Made a fix that works in my case in #5352. |
Bug description: With torch 2.4.0.dev20240603+cu121, cutlass_fp8_supported outputs False, and the (capability, version) before the comparison is (90, 11111111112) This PR fixes the support check for FP8 CUTLASS ( cutlass_fp8_supported) which was introduced in #5183.
) Switching from torch._scaled_mm to vLLM's cutlass fp8 kernels when supported as we are seeing 5-15% improvement in e2e performance on neuralmagic/Meta-Llama-3-8B-Instruct-FP8 see https://docs.google.com/spreadsheets/d/1GiAnmzyGHgZ6zL_LDSTm35Bdrt4A8AaFEurDlISYYA4/ for some quick e2e benchmarks and vllm-project#5144 for comparisons across different GEMM sizes.
Bug description: With torch 2.4.0.dev20240603+cu121, cutlass_fp8_supported outputs False, and the (capability, version) before the comparison is (90, 11111111112) This PR fixes the support check for FP8 CUTLASS ( cutlass_fp8_supported) which was introduced in vllm-project#5183.
) Switching from torch._scaled_mm to vLLM's cutlass fp8 kernels when supported as we are seeing 5-15% improvement in e2e performance on neuralmagic/Meta-Llama-3-8B-Instruct-FP8 see https://docs.google.com/spreadsheets/d/1GiAnmzyGHgZ6zL_LDSTm35Bdrt4A8AaFEurDlISYYA4/ for some quick e2e benchmarks and vllm-project#5144 for comparisons across different GEMM sizes.
Bug description: With torch 2.4.0.dev20240603+cu121, cutlass_fp8_supported outputs False, and the (capability, version) before the comparison is (90, 11111111112) This PR fixes the support check for FP8 CUTLASS ( cutlass_fp8_supported) which was introduced in vllm-project#5183.
Bug description: With torch 2.4.0.dev20240603+cu121, cutlass_fp8_supported outputs False, and the (capability, version) before the comparison is (90, 11111111112) This PR fixes the support check for FP8 CUTLASS ( cutlass_fp8_supported) which was introduced in vllm-project/vllm#5183.
) Switching from torch._scaled_mm to vLLM's cutlass fp8 kernels when supported as we are seeing 5-15% improvement in e2e performance on neuralmagic/Meta-Llama-3-8B-Instruct-FP8 see https://docs.google.com/spreadsheets/d/1GiAnmzyGHgZ6zL_LDSTm35Bdrt4A8AaFEurDlISYYA4/ for some quick e2e benchmarks and vllm-project#5144 for comparisons across different GEMM sizes.
) Switching from torch._scaled_mm to vLLM's cutlass fp8 kernels when supported as we are seeing 5-15% improvement in e2e performance on neuralmagic/Meta-Llama-3-8B-Instruct-FP8 see https://docs.google.com/spreadsheets/d/1GiAnmzyGHgZ6zL_LDSTm35Bdrt4A8AaFEurDlISYYA4/ for some quick e2e benchmarks and vllm-project#5144 for comparisons across different GEMM sizes.
Bug description: With torch 2.4.0.dev20240603+cu121, cutlass_fp8_supported outputs False, and the (capability, version) before the comparison is (90, 11111111112) This PR fixes the support check for FP8 CUTLASS ( cutlass_fp8_supported) which was introduced in vllm-project#5183.
) Switching from torch._scaled_mm to vLLM's cutlass fp8 kernels when supported as we are seeing 5-15% improvement in e2e performance on neuralmagic/Meta-Llama-3-8B-Instruct-FP8 see https://docs.google.com/spreadsheets/d/1GiAnmzyGHgZ6zL_LDSTm35Bdrt4A8AaFEurDlISYYA4/ for some quick e2e benchmarks and vllm-project#5144 for comparisons across different GEMM sizes.
Bug description: With torch 2.4.0.dev20240603+cu121, cutlass_fp8_supported outputs False, and the (capability, version) before the comparison is (90, 11111111112) This PR fixes the support check for FP8 CUTLASS ( cutlass_fp8_supported) which was introduced in vllm-project#5183.
) Switching from torch._scaled_mm to vLLM's cutlass fp8 kernels when supported as we are seeing 5-15% improvement in e2e performance on neuralmagic/Meta-Llama-3-8B-Instruct-FP8 see https://docs.google.com/spreadsheets/d/1GiAnmzyGHgZ6zL_LDSTm35Bdrt4A8AaFEurDlISYYA4/ for some quick e2e benchmarks and vllm-project#5144 for comparisons across different GEMM sizes.
Bug description: With torch 2.4.0.dev20240603+cu121, cutlass_fp8_supported outputs False, and the (capability, version) before the comparison is (90, 11111111112) This PR fixes the support check for FP8 CUTLASS ( cutlass_fp8_supported) which was introduced in vllm-project#5183.
Switching from
torch._scaled_mmto vLLM's cutlass fp8 kernels when supported as we are seeing 5-15% improvement in e2e performance onneuralmagic/Meta-Llama-3-8B-Instruct-FP8see https://docs.google.com/spreadsheets/d/1GiAnmzyGHgZ6zL_LDSTm35Bdrt4A8AaFEurDlISYYA4/ for some quick e2e benchmarks and #5144 for comparisons across different GEMM sizes.
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,LLMclass, 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:
format.shto format your code.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-requiredand 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:
action-requiredlabel on the PR if there are changes required. The contributor should address the comments and ping the reviewer to re-review the PR.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!