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]: Cutlass 2:4 Sparsity + FP8/Int8 Quant Support #10995

Merged
merged 102 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 97 commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
5d51361
Add cutlass 2:4 infrastructure
Faraz9877 Oct 22, 2024
17f5b96
Update with test code
Faraz9877 Oct 28, 2024
471a03c
Clean up a bit; both fp8 and int8 working
Faraz9877 Oct 30, 2024
0b332fb
Add fp16 and bf16 support to sparse cutlass mm
Faraz9877 Oct 30, 2024
da31648
semi_structured for fp16 and bf16 and int8
ilmarkov Oct 1, 2024
e655f94
Fix A100 int8 tests
ilmarkov Oct 2, 2024
5fc3c1c
Add fp8 cusparseLt
ilmarkov Oct 9, 2024
9cf36d6
wip
ilmarkov Oct 9, 2024
ad09e79
Fix signatures
ilmarkov Oct 9, 2024
e75eabc
Fix compilation and tests
ilmarkov Oct 13, 2024
0306390
Update for older platforms
ilmarkov Oct 15, 2024
1021acb
Add benchmarks
ilmarkov Oct 16, 2024
19ce358
Fix typo
ilmarkov Oct 23, 2024
959408c
Added scaled_mm for fp8.
ilmarkov Oct 24, 2024
117b87b
Add docstrings
ilmarkov Oct 28, 2024
2c7e68e
Update for torch 2.5
ilmarkov Oct 30, 2024
922f4f8
Add handling contiguous dense input for int8 and fp8
ilmarkov Oct 30, 2024
beca038
Add fp8 cusparseLt
ilmarkov Oct 9, 2024
5d9cd25
Fix compilation and tests
ilmarkov Oct 13, 2024
39ad9d4
Add caching of cusparseLT meta
ilmarkov Oct 23, 2024
520eb62
Cached cusparseLt
ilmarkov Oct 25, 2024
20956e6
Fix destroy function
ilmarkov Oct 25, 2024
87c8088
Prepare for reproduce
ilmarkov Oct 25, 2024
4ea58b1
Fix cusparseLt caching
ilmarkov Oct 30, 2024
f0551ef
Make cached version default function
ilmarkov Nov 5, 2024
d7476e8
Fixes and polishing after rebase
ilmarkov Nov 6, 2024
681ea5e
add sparse 2:4 weight loading suport
dsikka Oct 23, 2024
ecf878f
Some more changes!
rahul-tuli Oct 29, 2024
80952dc
Cleanup
rahul-tuli Oct 31, 2024
8462c9d
get uncompressed to work; update gemm to use contiguous; use alex's u…
dsikka Nov 1, 2024
0a3e506
patch
dsikka Nov 4, 2024
2e28972
use our decompressor
dsikka Nov 4, 2024
28f0abb
Some more work
rahul-tuli Nov 6, 2024
c7a97a8
Use new scaled_T function
rahul-tuli Nov 7, 2024
ccadad0
Add multiprocessing for kernel sweep benchmarking
Faraz9877 Nov 8, 2024
807737c
Add multi-GPU
Faraz9877 Nov 8, 2024
04c19a5
Add cutlass_scaled_sparse_mm op
Faraz9877 Nov 14, 2024
2a85c5a
Clean up
Faraz9877 Nov 14, 2024
1b381c9
Update code
Faraz9877 Nov 14, 2024
4e31076
Update code
Faraz9877 Nov 14, 2024
13fccf4
Clean up the benchmarking
Faraz9877 Nov 14, 2024
b345cc8
Clean up the cutlass benchmarking
Faraz9877 Nov 14, 2024
2d03e1d
Fix cmake errors
Faraz9877 Nov 14, 2024
e9439cc
Fix the cmake TAG
Faraz9877 Nov 14, 2024
4ba7c0f
Merge branch 'buildable' into rahul-quant-merged-rs
robertgshaw2-neuralmagic Nov 15, 2024
f74ef37
update
robertgshaw2-neuralmagic Nov 15, 2024
f5bc9eb
fixed
robertgshaw2-neuralmagic Nov 15, 2024
1316076
updated
robertgshaw2-neuralmagic Nov 15, 2024
4d2b12c
updated
robertgshaw2-neuralmagic Nov 15, 2024
fe30b53
updated, calling things properly
robertgshaw2-neuralmagic Nov 15, 2024
4c61b19
running end to end but not passing
robertgshaw2-neuralmagic Nov 15, 2024
86716f8
updated
robertgshaw2-neuralmagic Nov 15, 2024
349d904
stash
robertgshaw2-neuralmagic Nov 15, 2024
b860f9e
update
robertgshaw2-neuralmagic Nov 15, 2024
df462b5
Fix batch size and zeros issue
Faraz9877 Nov 18, 2024
14f6141
working e2e
robertgshaw2-neuralmagic Nov 18, 2024
abfd85d
Enable other datatypes
Faraz9877 Nov 18, 2024
540d0ce
Add the heuristics for fp8
Faraz9877 Nov 19, 2024
b45c158
updated
robertgshaw2-neuralmagic Nov 19, 2024
5f7339e
Cleanup
rahul-tuli Nov 20, 2024
ed15777
Move model compressor to scheme
rahul-tuli Nov 21, 2024
34a84a4
Cleanup + updates for compressed_tensor changes
rahul-tuli Dec 3, 2024
4045bda
Add cherry-picked heuristic for Llama3 8B model
Faraz9877 Nov 20, 2024
7c61ab0
updated with latest kernel
robertgshaw2-neuralmagic Dec 3, 2024
a8a1b57
Merge pull request #35 from neuralmagic/rob/semi-structured
dsikka Dec 6, 2024
4e060df
remove compressed support; validate against ct models for tp=1,24
dsikka Dec 6, 2024
7a6d027
add testing cases
dsikka Dec 6, 2024
0987c98
add support for all cases; update tests
dsikka Dec 6, 2024
c7d1cc3
Merge pull request #37 from neuralmagic/dipika/sem-struc-uncomp
dsikka Dec 6, 2024
e5c6d10
Merge branch 'main' into dipika/rebased
dsikka Dec 7, 2024
299fe32
rebase fix?
dsikka Dec 7, 2024
fbbd469
Fix the w8a8 build errors
Faraz9877 Dec 8, 2024
6dfc5c9
fix int8 so that it works; applying format'
dsikka Dec 8, 2024
4820ebe
support for sparse only ct models
dsikka Dec 8, 2024
2c32ce0
add 2:4 sparse only support, add test cases, add torch.comile workaround
dsikka Dec 8, 2024
a27ca81
add int8 quant tests
dsikka Dec 8, 2024
81c4360
Update code
Faraz9877 Dec 11, 2024
6d574af
Update code, flip sparse op operand order to be consistent with dense
Faraz9877 Dec 11, 2024
72f4577
Clean up code comments
Faraz9877 Dec 11, 2024
208b2a0
Format vllm code
Faraz9877 Dec 11, 2024
7020096
Update code
Faraz9877 Dec 12, 2024
f222aae
Update code
Faraz9877 Dec 12, 2024
c7a3a7d
Update code
Faraz9877 Dec 12, 2024
94a4945
Update code
Faraz9877 Dec 12, 2024
7fedb94
Update code
Faraz9877 Dec 12, 2024
3d6c50a
Update code
Faraz9877 Dec 12, 2024
8d94e1f
Update code
Faraz9877 Dec 12, 2024
b039820
Update code
Faraz9877 Dec 12, 2024
67aae3e
Clean up code
Faraz9877 Dec 12, 2024
154814f
Update benchmarking code and remove empty files
Faraz9877 Dec 12, 2024
ac059b4
Update code
Faraz9877 Dec 12, 2024
b559b6a
Push activations and output transposes into CUTLASS code
Faraz9877 Dec 13, 2024
4c927a0
Address reviews; one compression test left to pass
Faraz9877 Dec 13, 2024
b177ab6
Fix the scale swap bug
Faraz9877 Dec 13, 2024
8879323
Clean up benchmarking
Faraz9877 Dec 13, 2024
18ba3de
Minimize includes and reformat the compressor file
Faraz9877 Dec 14, 2024
c8f573b
Fix an indent
Faraz9877 Dec 16, 2024
4916577
Fix compress_entry names and add some comments
Faraz9877 Dec 16, 2024
c7b8a2c
Add ElementE for metadata type to spelling exceptions
Faraz9877 Dec 16, 2024
0d38f0a
Created the entry + arch structure for the compressor and ignore 2to4…
Faraz9877 Dec 17, 2024
c459bbc
Fix minor issues
Faraz9877 Dec 17, 2024
2c15abc
Small fix
Faraz9877 Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ if(VLLM_GPU_LANG STREQUAL "CUDA")
SET(CUTLASS_ENABLE_HEADERS_ONLY ON CACHE BOOL "Enable only the header library")

# Set CUTLASS_REVISION manually -- its revision detection doesn't work in this case.
set(CUTLASS_REVISION "v3.5.1" CACHE STRING "CUTLASS revision to use")
set(CUTLASS_REVISION "v3.6.0" CACHE STRING "CUTLASS revision to use")

# Use the specified CUTLASS source directory for compilation if VLLM_CUTLASS_SRC_DIR is provided
if (DEFINED ENV{VLLM_CUTLASS_SRC_DIR})
Expand All @@ -222,13 +222,13 @@ if(VLLM_GPU_LANG STREQUAL "CUDA")
FetchContent_Declare(
cutlass
GIT_REPOSITORY https://github.com/nvidia/cutlass.git
GIT_TAG v3.5.1
GIT_TAG 8aa95dbb888be6d81c6fbf7169718c5244b53227
GIT_PROGRESS TRUE

# Speed up CUTLASS download by retrieving only the specified GIT_TAG instead of the history.
# Important: If GIT_SHALLOW is enabled then GIT_TAG works only with branch names and tags.
# So if the GIT_TAG above is updated to a commit hash, GIT_SHALLOW must be set to FALSE
GIT_SHALLOW TRUE
# GIT_SHALLOW FALSE
Copy link
Member

Choose a reason for hiding this comment

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

Should this be uncommented as FALSE now?

Suggested change
# GIT_SHALLOW FALSE
GIT_SHALLOW FALSE

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah sure. It's also the default I think but better be explicit as you said.

)
endif()
FetchContent_MakeAvailable(cutlass)
Expand All @@ -240,7 +240,9 @@ if(VLLM_GPU_LANG STREQUAL "CUDA")
"csrc/quantization/awq/gemm_kernels.cu"
"csrc/custom_all_reduce.cu"
"csrc/permute_cols.cu"
"csrc/quantization/cutlass_w8a8/scaled_mm_entry.cu")
"csrc/quantization/cutlass_w8a8/scaled_mm_entry.cu"
"csrc/sparse/cutlass/sparse_scaled_mm_entry.cu"
"csrc/sparse/cutlass/sparse_compressor.cu")

set_gencode_flags_for_srcs(
SRCS "${VLLM_EXT_SRC}"
Expand Down Expand Up @@ -270,11 +272,14 @@ if(VLLM_GPU_LANG STREQUAL "CUDA")
endif()

#
# The cutlass_scaled_mm kernels for Hopper (c3x, i.e. CUTLASS 3.x) require
# The cutlass_scaled_mm cutlass_scaled_sparse_mm, and cutlass_compressor kernels
# For Hopper (c3x, i.e. CUTLASS 3.x) require
# CUDA 12.0 or later (and only work on Hopper, 9.0/9.0a for now).
cuda_archs_loose_intersection(SCALED_MM_3X_ARCHS "9.0;9.0a" "${CUDA_ARCHS}")
if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_GREATER 12.0 AND SCALED_MM_3X_ARCHS)
set(SRCS "csrc/quantization/cutlass_w8a8/scaled_mm_c3x.cu")
set(SRCS "csrc/quantization/cutlass_w8a8/scaled_mm_c3x.cu"
"csrc/sparse/cutlass/sparse_compressor.cu"
"csrc/sparse/cutlass/sparse_scaled_mm_c3x.cu")
set_gencode_flags_for_srcs(
SRCS "${SRCS}"
CUDA_ARCHS "${SCALED_MM_3X_ARCHS}")
Expand All @@ -283,12 +288,12 @@ if(VLLM_GPU_LANG STREQUAL "CUDA")
message(STATUS "Building scaled_mm_c3x for archs: ${SCALED_MM_3X_ARCHS}")
else()
if (NOT ${CMAKE_CUDA_COMPILER_VERSION} VERSION_GREATER 12.0 AND SCALED_MM_3X_ARCHS)
message(STATUS "Not building scaled_mm_c3x as CUDA Compiler version is "
message(STATUS "Not building cutlass_c3x kernels as CUDA Compiler version is "
"not >= 12.0, we recommend upgrading to CUDA 12.0 or "
"later if you intend on running FP8 quantized models on "
"later if you intend on running FP8 sparse or quantized models on "
"Hopper.")
else()
message(STATUS "Not building scaled_mm_c3x as no compatible archs found "
message(STATUS "Not building cutlass_c3x as no compatible archs found "
"in CUDA target architectures")
endif()

Expand Down Expand Up @@ -403,7 +408,7 @@ define_gpu_extension_target(
SOURCES ${VLLM_EXT_SRC}
COMPILE_FLAGS ${VLLM_GPU_FLAGS}
ARCHITECTURES ${VLLM_GPU_ARCHES}
INCLUDE_DIRECTORIES ${CUTLASS_INCLUDE_DIR}
INCLUDE_DIRECTORIES ${CUTLASS_INCLUDE_DIR};${CUTLASS_TOOLS_UTIL_INCLUDE_DIR}
USE_SABI 3
WITH_SOABI)

Expand Down
Loading
Loading