-
Notifications
You must be signed in to change notification settings - Fork 114
issue/1083: NVIDIA机器添加gptq_marlin_gemm算子 #1110
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
Open
xgqdut2016
wants to merge
10
commits into
main
Choose a base branch
from
issue/1083
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0dff925
issue/1083: gptq_marlin_gemm
xgqdut2016 5d28903
issue/1083: modified format
xgqdut2016 d6a778d
issue/1083: modified global
xgqdut2016 c3e1fba
issue/1083: success gptq_marlin
xgqdut2016 71e4b4c
issue/1083: modified format
xgqdut2016 598cec9
issue/1083: delete tvm
xgqdut2016 c4b99a8
issue/1083: add README.md
xgqdut2016 d8a23e0
issue/1083: add TVM_ROOT
xgqdut2016 6d82fe4
issue/1083: modified nvidia.lua
xgqdut2016 50cc3da
issue/1083: add commit id tvm-ffi
xgqdut2016 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,42 @@ | ||
| #ifndef __INFINIOP_GPTQ_MARLIN_GEMM_API_H__ | ||
| #define __INFINIOP_GPTQ_MARLIN_GEMM_API_H__ | ||
|
|
||
| #include "../operator_descriptor.h" | ||
| #include <cstdint> | ||
|
|
||
| typedef struct InfiniopDescriptor *infiniopGptqMarlinGemmDescriptor_t; | ||
|
|
||
| __INFINI_C __export infiniStatus_t infiniopCreateGptqMarlinGemmDescriptor(infiniopHandle_t handle, | ||
| infiniopGptqMarlinGemmDescriptor_t *desc_ptr, | ||
| infiniopTensorDescriptor_t out_desc, | ||
| infiniopTensorDescriptor_t a_desc, | ||
| infiniopTensorDescriptor_t b_desc, | ||
| infiniopTensorDescriptor_t b_scales_desc, | ||
| infiniopTensorDescriptor_t global_scale_desc, | ||
| infiniopTensorDescriptor_t b_zeros_desc, | ||
| infiniopTensorDescriptor_t g_idx_desc, | ||
| infiniopTensorDescriptor_t perm_desc); | ||
|
|
||
| __INFINI_C __export infiniStatus_t infiniopGetGptqMarlinGemmWorkspaceSize(infiniopGptqMarlinGemmDescriptor_t desc, size_t *size); | ||
|
|
||
| __INFINI_C __export infiniStatus_t infiniopGptqMarlinGemm(infiniopGptqMarlinGemmDescriptor_t desc, | ||
| void *workspace, | ||
| size_t workspace_size, | ||
| void *out, | ||
| const void *a, | ||
| const void *b, | ||
| void *b_scales, | ||
| void *global_scale, | ||
| void *b_zeros, | ||
| void *g_idx, | ||
| void *perm, | ||
| int64_t b_q_type_id, | ||
| bool is_k_full, | ||
| bool use_atomic_add, | ||
| bool use_fp32_reduce, | ||
| bool is_zp_float, | ||
| void *stream); | ||
|
|
||
| __INFINI_C __export infiniStatus_t infiniopDestroyGptqMarlinGemmDescriptor(infiniopGptqMarlinGemmDescriptor_t desc); | ||
|
|
||
| #endif |
This file contains hidden or 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,66 @@ | ||
| #ifndef __GPTQ_MARLIN_GEMM_H__ | ||
| #define __GPTQ_MARLIN_GEMM_H__ | ||
|
|
||
| #include "../../../utils.h" | ||
| #include "../../operator.h" | ||
| #include "../../tensor.h" | ||
| #include "info.h" | ||
|
|
||
| #define DESCRIPTOR(NAMESPACE) \ | ||
| \ | ||
| namespace op::gptq_marlin_gemm::NAMESPACE { \ | ||
| class Descriptor final : public InfiniopDescriptor { \ | ||
| struct Opaque; \ | ||
| Opaque *_opaque; \ | ||
| GptqMarlinGemmInfo _info; \ | ||
| size_t _workspace_size; \ | ||
| \ | ||
| Descriptor( \ | ||
| size_t workspace_size_, \ | ||
| Opaque *opaque, \ | ||
| GptqMarlinGemmInfo info, \ | ||
| infiniDevice_t device_type, \ | ||
| int device_id) \ | ||
| : InfiniopDescriptor{device_type, device_id}, \ | ||
| _opaque(opaque), \ | ||
| _info(info), \ | ||
| _workspace_size(workspace_size_) {} \ | ||
| \ | ||
| public: \ | ||
| ~Descriptor(); \ | ||
| \ | ||
| size_t workspaceSize() const { return _workspace_size; } \ | ||
| \ | ||
| static infiniStatus_t create( \ | ||
| infiniopHandle_t handle, \ | ||
| Descriptor **desc_ptr, \ | ||
| infiniopTensorDescriptor_t out_desc, \ | ||
| infiniopTensorDescriptor_t a_desc, \ | ||
| infiniopTensorDescriptor_t b_desc, \ | ||
| infiniopTensorDescriptor_t b_scales_desc, \ | ||
| infiniopTensorDescriptor_t global_scale_desc, \ | ||
| infiniopTensorDescriptor_t b_zeros_desc, \ | ||
| infiniopTensorDescriptor_t g_idx_desc, \ | ||
| infiniopTensorDescriptor_t perm_desc); \ | ||
| \ | ||
| infiniStatus_t calculate( \ | ||
| void *workspace, \ | ||
| size_t workspace_size, \ | ||
| void *out, \ | ||
| const void *a, \ | ||
| const void *b, \ | ||
| void *b_scales, \ | ||
| void *global_scale, \ | ||
| void *b_zeros, \ | ||
| void *g_idx, \ | ||
| void *perm, \ | ||
| int64_t b_q_type_id, \ | ||
| bool is_k_full, \ | ||
| bool use_atomic_add, \ | ||
| bool use_fp32_reduce, \ | ||
| bool is_zp_float, \ | ||
| void *stream) const; \ | ||
| }; \ | ||
| } | ||
|
|
||
| #endif //__GPTQ_MARLIN_GEMM_H__ |
This file contains hidden or 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,59 @@ | ||
| #ifndef __GPTQ_MARLIN_GEMM_INFO_H__ | ||
| #define __GPTQ_MARLIN_GEMM_INFO_H__ | ||
|
|
||
| #include "../../../utils.h" | ||
| #include "../../tensor.h" | ||
| #include <vector> | ||
|
|
||
| #include <cassert> | ||
|
|
||
| namespace op::gptq_marlin_gemm { | ||
|
|
||
| class GptqMarlinGemmInfo { | ||
| GptqMarlinGemmInfo() = default; | ||
|
|
||
| public: | ||
| infiniDtype_t dtype; | ||
| size_t M, K, N, b_q_size_1; | ||
| int num_groups; | ||
| ptrdiff_t a_stride_0; | ||
|
|
||
| static utils::Result<GptqMarlinGemmInfo> create( | ||
| infiniopTensorDescriptor_t out_desc, | ||
| infiniopTensorDescriptor_t a_desc, | ||
| infiniopTensorDescriptor_t b_desc, | ||
| infiniopTensorDescriptor_t b_scales_desc, | ||
| infiniopTensorDescriptor_t global_scale_desc, | ||
| infiniopTensorDescriptor_t b_zeros_desc, | ||
| infiniopTensorDescriptor_t g_idx_desc, | ||
| infiniopTensorDescriptor_t perm_desc) { | ||
| CHECK_OR_RETURN( | ||
| out_desc != nullptr && a_desc != nullptr && b_desc != nullptr && b_scales_desc != nullptr, | ||
| INFINI_STATUS_NULL_POINTER); | ||
| const infiniDtype_t dtype = a_desc->dtype(); | ||
| size_t M = out_desc->dim(0); | ||
| size_t N = out_desc->dim(1); | ||
| size_t K = a_desc->dim(1); | ||
| size_t b_q_size_1 = b_desc->dim(1); | ||
| int num_groups = static_cast<int>(b_scales_desc->dim(0)); | ||
| ptrdiff_t a_stride_0 = a_desc->strides()[0]; | ||
|
|
||
| auto ndim = out_desc->ndim(); | ||
| CHECK_OR_RETURN(ndim == 2 | ||
| && a_desc->ndim() == ndim | ||
| && b_desc->ndim() == ndim | ||
| && b_scales_desc->ndim() == ndim, | ||
| INFINI_STATUS_BAD_TENSOR_SHAPE); | ||
|
|
||
| CHECK_OR_RETURN(b_scales_desc->shape()[1] == N | ||
| && a_stride_0 % 8 == 0, | ||
| INFINI_STATUS_BAD_TENSOR_SHAPE); | ||
|
|
||
| return utils::Result<GptqMarlinGemmInfo>( | ||
| GptqMarlinGemmInfo{dtype, M, K, N, b_q_size_1, num_groups, a_stride_0}); | ||
| } | ||
| }; | ||
|
|
||
| } // namespace op::gptq_marlin_gemm | ||
|
|
||
| #endif // __GPTQ_MARLIN_GEMM_INFO_H__ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要指定commit id,尽量使用https的git地址