-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move the cuda kernel into this repo from https://github.com/qwopqwop2…
- Loading branch information
Showing
3 changed files
with
599 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include <torch/all.h> | ||
#include <torch/python.h> | ||
#include <c10/cuda/CUDAGuard.h> | ||
|
||
void vecquant2matmul_cuda( | ||
torch::Tensor vec, torch::Tensor mat, torch::Tensor mul, | ||
torch::Tensor scales, torch::Tensor zeros, | ||
torch::Tensor g_idx | ||
); | ||
|
||
void vecquant2matmul( | ||
torch::Tensor vec, torch::Tensor mat, torch::Tensor mul, | ||
torch::Tensor scales, torch::Tensor zeros, | ||
torch::Tensor g_idx | ||
) { | ||
const at::cuda::OptionalCUDAGuard device_guard(device_of(vec)); | ||
vecquant2matmul_cuda(vec, mat, mul, scales, zeros, g_idx); | ||
} | ||
|
||
void vecquant3matmul_cuda( | ||
torch::Tensor vec, torch::Tensor mat, torch::Tensor mul, | ||
torch::Tensor scales, torch::Tensor zeros, | ||
torch::Tensor g_idx | ||
); | ||
|
||
void vecquant3matmul( | ||
torch::Tensor vec, torch::Tensor mat, torch::Tensor mul, | ||
torch::Tensor scales, torch::Tensor zeros, | ||
torch::Tensor g_idx | ||
) { | ||
const at::cuda::OptionalCUDAGuard device_guard(device_of(vec)); | ||
vecquant3matmul_cuda(vec, mat, mul, scales, zeros, g_idx); | ||
} | ||
|
||
void vecquant4matmul_cuda( | ||
torch::Tensor vec, torch::Tensor mat, torch::Tensor mul, | ||
torch::Tensor scales, torch::Tensor zeros, | ||
torch::Tensor g_idx | ||
); | ||
|
||
void vecquant4matmul( | ||
torch::Tensor vec, torch::Tensor mat, torch::Tensor mul, | ||
torch::Tensor scales, torch::Tensor zeros, | ||
torch::Tensor g_idx | ||
) { | ||
const at::cuda::OptionalCUDAGuard device_guard(device_of(vec)); | ||
vecquant4matmul_cuda(vec, mat, mul, scales, zeros, g_idx); | ||
} | ||
|
||
void vecquant8matmul_cuda( | ||
torch::Tensor vec, torch::Tensor mat, torch::Tensor mul, | ||
torch::Tensor scales, torch::Tensor zeros, | ||
torch::Tensor g_idx | ||
); | ||
|
||
void vecquant8matmul( | ||
torch::Tensor vec, torch::Tensor mat, torch::Tensor mul, | ||
torch::Tensor scales, torch::Tensor zeros, | ||
torch::Tensor g_idx | ||
) { | ||
const at::cuda::OptionalCUDAGuard device_guard(device_of(vec)); | ||
vecquant8matmul_cuda(vec, mat, mul, scales, zeros, g_idx); | ||
} | ||
|
||
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { | ||
m.def("vecquant2matmul", &vecquant2matmul, "Vector 2-bit Quantized Matrix Multiplication (CUDA)"); | ||
m.def("vecquant3matmul", &vecquant3matmul, "Vector 3-bit Quantized Matrix Multiplication (CUDA)"); | ||
m.def("vecquant4matmul", &vecquant4matmul, "Vector 4-bit Quantized Matrix Multiplication (CUDA)"); | ||
m.def("vecquant8matmul", &vecquant8matmul, "Vector 8-bit Quantized Matrix Multiplication (CUDA)"); | ||
} |
Oops, something went wrong.