Skip to content

[Kernel] add bfloat16 support for gptq kernel #4781

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

Closed
wants to merge 2 commits into from

Conversation

jinzhen-lin
Copy link
Contributor

Some models would overflow when using fp16 inference (e.g. Deepseek-V2), so we should add bfloat16 support for quantization kernel. This PR add bfloat16 support for gptq kernel.

Related issue: #2149

main changes:

  • add bfloat16 input/output support for cuda kernels
  • dequant qweight to bfloat16 in proper ways.

NOTE: Currently, bfloat16 kernel may be much slower than float16 on >=sm80,<sm90 device since the support for atomicAdd with bfloat16 is not native (see description of atomicAdd). Increase the value of BLOCK_KN_SIZE can much improve the performance, but I don't sure if this will affect other situations.

@mgoin
Copy link
Member

mgoin commented May 21, 2024

@alexm-neuralmagic should we support bfloat16 here the same way as done for gptq_marlin?

@jinzhen-lin
Copy link
Contributor Author

@alexm-neuralmagic should we support bfloat16 here the same way as done for gptq_marlin?

The bfloat16 gptq kernel have serious performance issue now, I may optimize it recently.

Copy link

This pull request has been automatically marked as stale because it has not had any activity within 90 days. It will be automatically closed if no further activity occurs within 30 days. Leave a comment if you feel this pull request should remain open. Thank you!

@github-actions github-actions bot added the stale Over 90 days of inactivity label Oct 27, 2024
@mgoin
Copy link
Member

mgoin commented Oct 28, 2024

This has been resolved long ago on SM >= 80 since the GPTQ Marlin kernels support bfloat16, closing as resolved

@classmethod
def get_supported_act_dtypes(cls) -> List[torch.dtype]:
return [torch.half, torch.bfloat16]

@mgoin mgoin closed this Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Over 90 days of inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants