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] Refactor Cutlass c3x #10049

Merged
merged 2 commits into from
Dec 19, 2024

Conversation

varun-sundar-rabindranath
Copy link
Contributor

@varun-sundar-rabindranath varun-sundar-rabindranath commented Nov 5, 2024

Refactor Cutlass c3x kernels for better maintainability and easier experimentation.

  • Break scaled_mm_c3x.cu into,
    • scaled_mm_c3x.cuh : All the base cutlass c3x code (cutlass_3x_gemm and cutlass_gemm_caller).
    • scaled_mm_c3x_sm90_fp8_dispatch.cuh : All fp8 kernels along with the gemm shape based dispatch function.
    • scaled_mm_c3x_sm90_int8_dispatch.cuh : All int8 kernels along with the gemm shape based dispatch function.
    • scaled_mm_c3x.cu : interfaces expected by scaled_mm_entry.cu

Copy link

github-actions bot commented Nov 5, 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.

🚀

@varun-sundar-rabindranath varun-sundar-rabindranath marked this pull request as draft November 5, 2024 20:35
@varun-sundar-rabindranath varun-sundar-rabindranath marked this pull request as ready for review November 12, 2024 03:27
@varun-sundar-rabindranath
Copy link
Contributor Author

@tlrmchlsmth @ProExpertProg @LucasWilkinson PTAL. Thanks!

@LucasWilkinson
Copy link
Contributor

LGTM (just FYI may conflict with #9855)

Copy link
Collaborator

@tlrmchlsmth tlrmchlsmth left a comment

Choose a reason for hiding this comment

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

LGTM

@tlrmchlsmth tlrmchlsmth added the ready ONLY add when PR is ready to merge/full CI is needed label Nov 12, 2024
@varun-sundar-rabindranath varun-sundar-rabindranath force-pushed the varun/cutlass-c3x-refactor branch 2 times, most recently from 7dbe3b3 to 4f44aac Compare November 15, 2024 14:35
Copy link

mergify bot commented Nov 18, 2024

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @varun-sundar-rabindranath.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@varun-sundar-rabindranath
Copy link
Contributor Author

@tlrmchlsmth re-requesting review as the PR is now rebased.

Copy link
Collaborator

@tlrmchlsmth tlrmchlsmth left a comment

Choose a reason for hiding this comment

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

Looks good! (Likely wait for #10995)

@@ -1,384 +1,22 @@
// clang-format will break include orders
// switch off clang format as the include statement indentation is inconsistent.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually do you need to turn off clang-format here? The reason for turning it off is that CUTLASS headers need to be included in a specific order but it looks like that's not the case following the refactor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using clang-format in this block, turns,

#include <cudaTypedefs.h>

#if defined CUDA_VERSION && CUDA_VERSION >= 12000

#include "scaled_mm_c3x_sm90_fp8_dispatch.cuh"
#include "scaled_mm_c3x_sm90_int8_dispatch.cuh"

#include "cutlass_extensions/epilogue/scaled_mm_epilogues_c3x.hpp"

using namespace vllm;

into

#include <cudaTypedefs.h>

#if defined CUDA_VERSION && CUDA_VERSION >= 12000

    #include "scaled_mm_c3x_sm90_fp8_dispatch.cuh"
    #include "scaled_mm_c3x_sm90_int8_dispatch.cuh"

    #include "cutlass_extensions/epilogue/scaled_mm_epilogues_c3x.hpp"

using namespace vllm;

the #if seems trigger inconsistent indenting. I switched off clang-format in this block to avoid that.

I moved the original clang-format toggle to scaled_mm_c3x.cuh.

// clang-format will break include orders

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had second thoughts about this and removed the clang-format block. It is probably better to stick to the convention.

@varun-sundar-rabindranath varun-sundar-rabindranath force-pushed the varun/cutlass-c3x-refactor branch 2 times, most recently from 55d9927 to e5f324b Compare December 18, 2024 16:13
Varun Sundar Rabindranath added 2 commits December 19, 2024 03:28
Signed-off-by: Varun Sundar Rabindranath <varun@neuralmagic.com>
Signed-off-by: Varun Sundar Rabindranath <varun@neuralmagic.com>
@tlrmchlsmth tlrmchlsmth enabled auto-merge (squash) December 19, 2024 03:31
@tlrmchlsmth tlrmchlsmth merged commit 8936316 into vllm-project:main Dec 19, 2024
75 checks passed
BKitor pushed a commit to BKitor/vllm that referenced this pull request Dec 30, 2024
Signed-off-by: Varun Sundar Rabindranath <varun@neuralmagic.com>
Co-authored-by: Varun Sundar Rabindranath <varun@neuralmagic.com>
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.

4 participants