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

Matmul_nbits kernel for mlas sqnbits to support Fp16 inputs #21807

Merged
merged 24 commits into from
Sep 13, 2024

Conversation

liqunfu
Copy link
Contributor

@liqunfu liqunfu commented Aug 20, 2024

Description

There are 2 ways to support Fp16:

  1. At low level to use fp16 specific instructions:
    Matmul-nbit to support fp16 activation #21760
    This requires instruction support and, in case of avx, halfgemm support which is missing.
    this PR can complete after blksum compute is moved away from sgemm (https://github.com/microsoft/onnxruntime/tree/liqun/blksum)

  2. Convert Fp16 to Fp32 and use the mlas Fp32 version.
    This PR is to implement the second approach.  

Motivation and Context

support Fp16

Signed-off-by: Liqun Fu <liqfu@microsoft.com>
@liqunfu liqunfu requested a review from a team as a code owner August 20, 2024 22:26
@liqunfu liqunfu marked this pull request as draft August 20, 2024 22:27
liqunfu and others added 6 commits August 21, 2024 21:40
Signed-off-by: Liqun Fu <liqfu@microsoft.com>
Signed-off-by: Liqun Fu <liqfu@microsoft.com>
Signed-off-by: Liqun Fu <liqfu@microsoft.com>
Signed-off-by: liqunfu <liqun.fu@microsoft.com>
Signed-off-by: liqunfu <liqun.fu@microsoft.com>
Signed-off-by: Liqun Fu <liqfu@microsoft.com>
Signed-off-by: Liqun Fu <liqfu@microsoft.com>
Signed-off-by: Liqun Fu <liqfu@microsoft.com>
Signed-off-by: Liqun Fu <liqfu@microsoft.com>
Signed-off-by: Liqun Fu <liqfu@microsoft.com>
Signed-off-by: Liqun Fu <liqfu@microsoft.com>
Signed-off-by: Liqun Fu <liqfu@microsoft.com>
Signed-off-by: Liqun Fu <liqfu@microsoft.com>
@liqunfu liqunfu marked this pull request as ready for review September 5, 2024 18:31
liqunfu and others added 9 commits September 11, 2024 21:13
Signed-off-by: liqunfu <liqun.fu@microsoft.com>
Signed-off-by: Liqun Fu <liqfu@microsoft.com>
Signed-off-by: Liqun Fu <liqfu@microsoft.com>
Signed-off-by: Liqun Fu <liqfu@microsoft.com>
Signed-off-by: Liqun Fu <liqfu@microsoft.com>
Signed-off-by: Liqun Fu <liqfu@microsoft.com>
Signed-off-by: Liqun Fu <liqfu@microsoft.com>
Signed-off-by: Liqun Fu <liqfu@microsoft.com>
Copy link
Member

@yufenglee yufenglee left a comment

Choose a reason for hiding this comment

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

:shipit:

@liqunfu liqunfu merged commit a89bddd into main Sep 13, 2024
87 checks passed
@liqunfu liqunfu deleted the liqun/mlas-sqnbit-kernel-fp16 branch September 13, 2024 21:55
bias_data_v.resize((const unsigned int)(bias->Shape().Size()));
ConvertFp16ToFp32(bias_data, &bias_data_v[0], bias_data_v.size());
}
std::vector<float> C_v((const unsigned int)(y->Shape().Size()));
Copy link
Contributor

Choose a reason for hiding this comment

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

std::vector C_v

may I know why output is using vector, but tmp_a is using allocator?

axodox added a commit to axodox/onnxruntime that referenced this pull request Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants