NVIDIA / cutlass

CUDA Templates for Linear Algebra Subroutines
Other
5.59k stars 950 forks source link

[QST] Dose CuTe supports FP8 in Ada lovelace? #1698

Open Godlovecui opened 2 months ago

Godlovecui commented 2 months ago

Hi: I'd like to test FP8 in RTX 4090. I can find some BF16 functions like SM80_16x8x8_F32BF16BF16F32_TN in cutlass/include/cute/arch/mma_sm80.hpp, however, I can't find some FP8 functions like SM80_16x8x8_F32E4M3E4M3FP32_TN. So, how to implement SM80_16x8x8_F32E4M3E4M3FP32_TN? Thank you~

kf-zhang commented 2 months ago

To support SM89's FP8 GEMM in CUTE, you will need to warp its PTX as shown here and implement the corresponding trait as demonstrated here.

The PTX has already been warped in CUTLASS, which serves as a good reference. Given that its layout is similar toSM80_16x8x32_S32S8S8S32_TN, you can replicate the trait of SM80_16x8x32_S32S8S8S32_TN, with the exception of the ValType.

Godlovecui commented 2 months ago

which copy operation and copy traits should I follow? When I use: using g2s_copy_op = SM80_CP_ASYNC_CACHEGLOBAL<>, it raises below error: image how to fix it? Thank you~ @kf-zhang @tmm1 @kerrmudgeon @dfyz

thakkarV commented 2 months ago

you just have to add the MMA atoms right? that should not require anything else. Its really hard to help you if you are not posting your entire diff. Can you please make an MR so that we can see the code?

Godlovecui commented 2 months ago

This is my github commit, gemm-multi-stage_e4m3_v2.cu is my test code for e4m3. I add MMA atoms in 3rd/cutlass/include/cute/arch/mma_sm80.hpp, https://github.com/Godlovecui/cute-gemm/commit/c0168852a3a62e76dd0de33e05b410510aa02837#diff-2e927406d89afc8be5b4c85da736860c23e0eac8e871bbe8c0ebbe7ebf67fe7c Thank you very much~ @thakkarV

thakkarV commented 2 months ago

This diff is nearly 100k lines large. Please make a small self contained MR

Godlovecui commented 2 months ago

This is my new commit, which only contain my modified code, Thank you for your help~ @thakkarV

https://github.com/Godlovecui/cute-gemm/commit/d7fdb5dc0910fc0a788f466195886233c473331b

gemm-multi-stage_e4m3_v2.cu is my modified code for support FP8. The step to reproduction:

  1. git clone git@github.com:Godlovecui/cute-gemm.git
  2. make -j
thakkarV commented 2 months ago

I left a review on your code

Godlovecui commented 2 months ago

I left a review on your code

ok, I try and modify it according to your review, thank you very much. @thakkarV

github-actions[bot] commented 1 month ago

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.