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

[Kernel] Tuned int8 kernels for Ada Lovelace #6848

Merged
merged 1 commit into from
Jul 30, 2024

Conversation

varun-sundar-rabindranath
Copy link
Contributor

@varun-sundar-rabindranath varun-sundar-rabindranath commented Jul 26, 2024

Add tuned Int8 kernels for Ada Lovelace

  • Added 8 unique Gemm configs to stratify Gemm shapes along the M and N dimensions.

Numbers:

GPU : L40S x 1
Command : python3 benchmarks/cutlass_benchmarks/w8a8_benchmarks.py --dtype int8 model_bench --batch-size {1,16,32,64,128,256,512}

<style type="text/css"></style>

meta-llama/Llama-2-7b-hf-TP1      
  Tuned cutlass_i8_i8_bf16_scaled_mm (us) Main cutlass_i8_i8_bf16_scaled_mm (us) speedup
MKN=(1x4096x12288) 15.4 33.10 2.15
MKN=(1x4096x4096) 9.4 31.40 3.34
MKN=(1x4096x22016) 52.1 73.00 1.40
MKN=(1x11008x4096) 17.9 76.50 4.27
MKN=(16x4096x12288) 16.8 33.30 1.98
MKN=(16x4096x4096) 9.7 31.40 3.24
MKN=(16x4096x22016) 57.1 78.60 1.38
MKN=(16x11008x4096) 18.2 76.60 4.21
MKN=(32x4096x12288) 17.9 33.20 1.85
MKN=(32x4096x4096) 9.9 31.40 3.17
MKN=(32x4096x22016) 65.2 83.20 1.28
MKN=(32x11008x4096) 19.8 76.60 3.87
MKN=(64x4096x12288) 22.5 34.30 1.52
MKN=(64x4096x4096) 12.9 31.40 2.43
MKN=(64x4096x22016) 81.2 94.20 1.16
MKN=(64x11008x4096) 26.2 76.80 2.93
MKN=(128x4096x12288) 37.2 36.30 0.98
MKN=(128x4096x4096) 19.7 31.60 1.60
MKN=(128x4096x22016) 111.1 115.60 1.04
MKN=(128x11008x4096) 44.3 76.90 1.74
MKN=(256x4096x12288) 68.6 87.80 1.28
MKN=(256x4096x4096) 27.7 32.50 1.17
MKN=(256x4096x22016) 170.8 169.90 0.99
MKN=(256x11008x4096) 65.2 78.40 1.20
MKN=(512x4096x12288) 128.3 124.40 0.97
MKN=(512x4096x4096) 41.6 41.40 1.00
MKN=(512x4096x22016) 294 296.30 1.01
MKN=(512x11008x4096) 106.1 105.90 1.00
       
meta-llama/Llama-3-8b-TP1      
       
MKN=(1x4096x6144) 10.3 31.60 3.07
MKN=(1x4096x4096) 9.5 31.40 3.31
MKN=(1x4096x28672) 188.5 194.80 1.03
MKN=(1x14336x4096) 21.9 98.20 4.48
MKN=(16x4096x6144) 11.2 31.60 2.82
MKN=(16x4096x4096) 9.7 31.30 3.23
MKN=(16x4096x28672) 192.6 198.30 1.03
MKN=(16x14336x4096) 22.5 98.30 4.37
MKN=(32x4096x6144) 12.2 31.60 2.59
MKN=(32x4096x4096) 9.9 31.40 3.17
MKN=(32x4096x28672) 195.3 201.40 1.03
MKN=(32x14336x4096) 25.5 98.40 3.86
MKN=(64x4096x6144) 15.8 31.70 2.01
MKN=(64x4096x4096) 12.8 31.40 2.45
MKN=(64x4096x28672) 197.2 206.00 1.04
MKN=(64x14336x4096) 34.4 98.50 2.86
MKN=(128x4096x6144) 22.3 31.80 1.43
MKN=(128x4096x4096) 19.7 31.60 1.60
MKN=(128x4096x28672) 190.6 212.10 1.11
MKN=(128x14336x4096) 56.3 98.60 1.75
MKN=(256x4096x6144) 37.2 36.90 0.99
MKN=(256x4096x4096) 27.7 32.50 1.17
MKN=(256x4096x28672) 243.8 243.50 1.00
MKN=(256x14336x4096) 86.6 101.90 1.18
MKN=(512x4096x6144) 68.3 87.40 1.28
MKN=(512x4096x4096) 41.7 41.50 1.00
MKN=(512x4096x28672) 397.9 408.30 1.03
MKN=(512x14336x4096) 139.7 138.20 0.99
       
meta-llama/Llama-2-13b-hf-TP1      
       
MKN=(1x5120x15360) 23 44.10 1.92
MKN=(1x5120x5120) 11.4 38.10 3.34
MKN=(1x5120x27648) 232.4 241.40 1.04
MKN=(1x13824x5120) 22.6 95.00 4.20
MKN=(16x5120x15360) 25.3 44.80 1.77
MKN=(16x5120x5120) 12 38.10 3.18
MKN=(16x5120x27648) 236.1 245.40 1.04
MKN=(16x13824x5120) 24.5 95.00 3.88
MKN=(32x5120x15360) 27.9 45.50 1.63
MKN=(32x5120x5120) 13.6 38.10 2.80
MKN=(32x5120x27648) 238.4 247.20 1.04
MKN=(32x13824x5120) 27.7 95.10 3.43
MKN=(64x5120x15360) 35.6 47.90 1.35
MKN=(64x5120x5120) 16.8 38.20 2.27
MKN=(64x5120x27648) 241.6 252.40 1.04
MKN=(64x13824x5120) 36.9 95.20 2.58
MKN=(128x5120x15360) 56.9 52.10 0.92
MKN=(128x5120x5120) 25 38.40 1.54
MKN=(128x5120x27648) 227.5 258.90 1.14
MKN=(128x13824x5120) 58.5 95.40 1.63
MKN=(256x5120x15360) 120.7 118.20 0.98
MKN=(256x5120x5120) 42.4 42.40 1.00
MKN=(256x5120x27648) 294.7 296.10 1.00
MKN=(256x13824x5120) 105.6 105.60 1.00
MKN=(512x5120x15360) 259.4 257.20 0.99
MKN=(512x5120x5120) 78.5 105.00 1.34
MKN=(512x5120x27648) 462 478.90 1.04
MKN=(512x13824x5120) 205.2 246.10 1.20
       
       
meta-llama/Llama-2-70b-hf-TP1      
       
MKN=(1x8192x10240) 23.4 59.80 2.56
MKN=(1x8192x8192) 19.4 58.90 3.04
MKN=(1x8192x57344) 778.5 803.50 1.03
MKN=(1x28672x8192) 355.7 375.80 1.06
MKN=(16x8192x10240) 25 60.30 2.41
MKN=(16x8192x8192) 22.4 58.90 2.63
MKN=(16x8192x57344) 784.4 808.00 1.03
MKN=(16x28672x8192) 359.8 377.00 1.05
MKN=(32x8192x10240) 27.9 60.40 2.16
MKN=(32x8192x8192) 25.7 59.00 2.30
MKN=(32x8192x57344) 789.9 812.00 1.03
MKN=(32x28672x8192) 362.7 378.30 1.04
MKN=(64x8192x10240) 38.4 62.50 1.63
MKN=(64x8192x8192) 34.6 59.10 1.71
MKN=(64x8192x57344) 800.9 819.70 1.02
MKN=(64x28672x8192) 370 380.60 1.03
MKN=(128x8192x10240) 68.2 67.30 0.99
MKN=(128x8192x8192) 51.1 59.70 1.17
MKN=(128x8192x57344) 702.6 835.00 1.19
MKN=(128x28672x8192) 388 387.70 1.00
MKN=(256x8192x10240) 138.1 168.70 1.22
MKN=(256x8192x8192) 80.7 81.20 1.01
MKN=(256x8192x57344) 869.4 879.10 1.01
MKN=(256x28672x8192) 423.6 422.90 1.00
MKN=(512x8192x10240) 284.4 283.00 1.00
MKN=(512x8192x8192) 169.1 169.70 1.00
MKN=(512x8192x57344) 1412 1,522.30 1.08
MKN=(512x28672x8192) 681.3 751.70 1.10

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!

@varun-sundar-rabindranath varun-sundar-rabindranath marked this pull request as draft July 26, 2024 20:18
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.

🚀

@varun-sundar-rabindranath
Copy link
Contributor Author

varun-sundar-rabindranath commented Jul 26, 2024

PFA a heatmap generated from the Gemm-Shape vs Cutlass-Op sweep done on an L40S.

model_bench-torch int8-all_heatmap

Pointers on how to read the heatmap:
X-Axis - All the Cutlass OP tried.
Y-Axis - All the GEMM Shapes in (M x N x K) format.
The Darker the cell, the Better the algorithm performed for that GEMM shape. Each row (GEMM-Shape) is normalized to be between 0.0 and 1.0. The best algorithm has a value of 1.0.

Annotations:
Brown box : What is in main
Blue box : fallback gemm
White boxes : Selected and added in this PR
Yellow boxes : Other good configs

Cutlass Op naming convention: autogen_cutlass2x_scaled_mm_dq_sm89_128x64x128_64x64x64_16x8x32_ThreadBlockSwizzleStrreamK_kGemmSplitKParallel_5_OpMultiplyAddFastAccum_i8 refers to an Op constructed with,

Tile Shape : 128x64x128
Warp Shape : 64x64x64
Instruction Shape : 16x8x32
Thread block swizzle : ThreadBlockSwizzleStreamK
Gemm mode : kGemmSplitKParallel
Main loop stages : 5
OpMultiplyAddFastAccum : FP8MathOperator (doesn't matter for this PR)
i8 : Gemm input datatype

@varun-sundar-rabindranath varun-sundar-rabindranath marked this pull request as ready for review July 26, 2024 21:26
@varun-sundar-rabindranath
Copy link
Contributor Author

varun-sundar-rabindranath commented Jul 26, 2024

This PR builds on top of #6677
DO NOT LAND THIS BEFORE THAT PR !

[edit] That PR has landed

@varun-sundar-rabindranath
Copy link
Contributor Author

/ready

@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Jul 29, 2024
@mgoin mgoin merged commit af647fb into vllm-project:main Jul 30, 2024
72 checks passed
@mgoin mgoin deleted the varun/lovelace-tune-cutlass-i8 branch July 30, 2024 02:25
tjohnson31415 added a commit to tjohnson31415/vllm that referenced this pull request Jul 30, 2024
* upstream/main: (66 commits)
  [Bugfix] Fix PaliGemma MMP (vllm-project#6930)
  [TPU] Fix greedy decoding (vllm-project#6933)
  [Kernel] Tuned int8 kernels for Ada Lovelace (vllm-project#6848)
  [Kernel] Fix marlin divide-by-zero warnings (vllm-project#6904)
  [ci] GHA workflow to remove ready label upon "/notready" comment (vllm-project#6921)
  [Kernel] Remove unused variables in awq/gemm_kernels.cu (vllm-project#6908)
  [Frontend] New `allowed_token_ids` decoding request parameter (vllm-project#6753)
  [Bugfix] Allow vllm to still work if triton is not installed. (vllm-project#6786)
  [TPU] Support tensor parallelism in async llm engine (vllm-project#6891)
  [Kernel] Fix deprecation function warnings squeezellm quant_cuda_kernel (vllm-project#6901)
  [Core] Reduce unnecessary compute when logprobs=None (vllm-project#6532)
  [Kernel] Tuned FP8 Kernels for Ada Lovelace (vllm-project#6677)
  [Model] Initialize support for InternVL2 series models (vllm-project#6514)
  [Misc] Pass cutlass_fp8_supported correctly in fbgemm_fp8 (vllm-project#6871)
  Add Nemotron to PP_SUPPORTED_MODELS (vllm-project#6863)
  [Kernel] Increase precision of GPTQ/AWQ Marlin kernel (vllm-project#6795)
  [TPU] Reduce compilation time & Upgrade PyTorch XLA version  (vllm-project#6856)
  [Docs] Add RunLLM chat widget (vllm-project#6857)
  [Model] Initial support for BLIP-2 (vllm-project#5920)
  [CI/Build][Doc] Update CI and Doc for VLM example changes (vllm-project#6860)
  ...
kylesayrs pushed a commit to neuralmagic/vllm that referenced this pull request Aug 17, 2024
Co-authored-by: Varun Sundar Rabindranath <varun@neuralmagic.com>
Alvant pushed a commit to compressa-ai/vllm that referenced this pull request Oct 26, 2024
Co-authored-by: Varun Sundar Rabindranath <varun@neuralmagic.com>
Signed-off-by: Alvant <alvasian@yandex.ru>
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