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

List of GEMM+epilogues fusion needed for Transformer Engine #674

Open
bghimireamd opened this issue Apr 11, 2023 · 1 comment
Open

List of GEMM+epilogues fusion needed for Transformer Engine #674

bghimireamd opened this issue Apr 11, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@bghimireamd
Copy link
Contributor

The ones we need for Transformer Engine are the following:

  1. CUBLASLT_EPILOGUE_GELU_AUX
    step 1 : matrix multiplication
    step 2 : apply gelu
    step 3 : store the result to seperate matrix (basically do matrix copy)

    • I think we can use CK's gemm_fastgelu for this.
  2. CUBLASLT_EPILOGUE_DGELU : 
        step 1 : matrix multiplication
        step 2 : apply derivative of gelu

  3. CUBLASLT_EPILOGUE_BIAS
        step 1 : matrix multiplication A( M, K ) X B (K, N) = C (M, N) : 
        step 2 : Obtain Bias Vector (1, M) eg: [ 0.1, 0.2 0.3]
        step 3 : Broadcast Bias Vector : 
                    we can simply replicate it N times along the columns, 
                    resulting in a new bias vector with dimensions (M x N)
                eg: 
                A(4, 2), B(2, 3), C(4, 3)
                Broadcast Bias:  

                |0.1 0.2 0.3|
                |0.1 0.2 0.3|
                |0.1 0.2 0.3|
                |0.1 0.2 0.3|
            C = C + Broadcast Bias

  1. CUBLASLT_EPILOGUE_BGRADB
        Apply Bias gradient to the input matrix B. The bias size corresponds to the number of columns of the matrix D. 
        The reduction happens over the GEMM’s “k” dimension. Store Bias gradient in the bias buffer

  2. CUBLASLT_EPILOGUE_GELU_AUX_BIAS
        * fusion of gelu and bias

  3. CUBLASLT_EPILOGUE_DGELU_BGRAD
        * fusion of gelu and bgrad

@bghimireamd bghimireamd added the enhancement New feature or request label Apr 11, 2023
@zjing14
Copy link
Contributor

zjing14 commented Apr 25, 2023

Synced with @bghimireamd, CK already has CUBLASLT_EPILOGUE_GELU_AUX, CUBLASLT_EPILOGUE_BIAS, CUBLASLT_EPILOGUE_GELU_AUX_BIAS. We can quickly add CUBLASLT_EPILOGUE_DGELU. For CUBLASLT_EPILOGUE_BGRADB, we need double-check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants