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

Fp8 support for MatMul on cuda #22698

Draft
wants to merge 39 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
61c4cb0
add test skeleton and config option for cuda fp8
amarin16 Jun 19, 2024
f67ec74
update MatMul_float8E4M3FN
amarin16 Jun 19, 2024
36d403c
add initial cublasLtMatmul logic
amarin16 Jun 21, 2024
a0a43b1
Merge branch 'main' into HEAD
amarin16 Jun 21, 2024
dc84631
update logic
amarin16 Jun 27, 2024
967f174
update spacing
amarin16 Jun 30, 2024
7d2f528
Use min_cuda_architecture 900
amarin16 Jul 8, 2024
0328f94
create and use 1.0 scales instead of getting them from the input
amarin16 Jul 10, 2024
e2fd3c3
compute scale using model weights as float
amarin16 Jul 11, 2024
4936cd2
remove unnecessary span
amarin16 Jul 11, 2024
e63e597
small update
amarin16 Jul 29, 2024
ffbefc0
merge main
amarin16 Jul 29, 2024
97bf3f1
introduce ComputeScaleKernel
amarin16 Jul 31, 2024
35fc798
use kernel to compute scale
amarin16 Jul 31, 2024
d3b6685
use instantiation to get rid of runtime error
amarin16 Jul 31, 2024
ba18ef8
only keep needed instantiations
amarin16 Jul 31, 2024
46a4bd0
Merge branch 'main' into dev/amarin16/fp8
amarin16 Jul 31, 2024
c3a2434
small fixes
amarin16 Aug 2, 2024
784cffe
refator fp8 logic into separate function
amarin16 Aug 7, 2024
b3d7731
Specialize ComputeDefault for MLFloat16
amarin16 Aug 7, 2024
ba17d9c
remove template from kernel wrapper
amarin16 Aug 7, 2024
1e5326c
handle case when deviation is 0
amarin16 Aug 8, 2024
e723488
cublasLtMatmulAlgoGetHeuristic no longer returns error
amarin16 Aug 25, 2024
046c5dc
create fp8 tensors for left_X, right_X
amarin16 Aug 26, 2024
34cdd15
Add transpose kernel
amarin16 Aug 28, 2024
0b46a22
use cuda allocator, existing transpose kernel
amarin16 Aug 29, 2024
a2f8390
compute scale using fp16, copy to device and use it
amarin16 Sep 5, 2024
52fb51c
use DefaultCudaStream in PrePack
amarin16 Sep 10, 2024
f2176b7
update print, use CUDA_R8_F_E4MR for ADesc and BDesc
amarin16 Sep 10, 2024
1b64388
merge main
amarin16 Oct 22, 2024
1256074
cleanup
amarin16 Oct 22, 2024
926268b
fix cublasLtMatmulAlgoGetHeuristic result
amarin16 Oct 31, 2024
6c2b078
Merge branch 'main' into dev/amarin16/fp8
amarin16 Oct 31, 2024
07c91ae
update interface after merge
amarin16 Oct 31, 2024
2d28c7d
Add cublaSetStream call
amarin16 Nov 6, 2024
fe8f7b4
use CublasLtHandle() instead of cublasLtCreate()
amarin16 Nov 6, 2024
402ade6
use {2, 16} dimensions in test
amarin16 Nov 6, 2024
de23a1a
Merge branch 'main' into dev/amarin16/fp8
amarin16 Nov 6, 2024
ca2cc8f
use M=16, K=32, N=16 in test
amarin16 Nov 6, 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
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@
// - "1": Gemm FastMath mode is enabled.
static const char* const kOrtSessionOptionsMlasGemmFastMathArm64Bfloat16 = "mlas.enable_gemm_fastmath_arm64_bfloat16";

// Gemm fp8 mode provides fp16 gemm acceleration with float8E4M3FN based matmul.
// Option values:
// - "0": Gemm fp8 mode is not enabled. [DEFAULT]
// - "1": Gemm fp8 mode is enabled.
static const char* const kOrtSessionOptionsGemmCudaFloat8E4M3FN = "enable_gemm_cuda_float8E4M3FN";

Check notice

Code scanning / CodeQL

Unused static variable Note

Static variable kOrtSessionOptionsGemmCudaFloat8E4M3FN is never read.
Copy link
Member

Choose a reason for hiding this comment

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

Since this is CUDA EP specific, should this be a generic session option or a CUDA EP provider option ?


// When converting DQ + MatMul -> MatMulNBits, the accuracy level of the MatMulNBits is controlled by this option.
// Refer to MatMulNBits op schema for more details.
// If not provided, default is 4.
Expand Down
Loading
Loading