Skip to content

enable triton kernel on XPU - #180

Merged
BlackSamorez merged 4 commits into
Vahe1994:mainfrom
jiqing-feng:main
Aug 3, 2025
Merged

enable triton kernel on XPU#180
BlackSamorez merged 4 commits into
Vahe1994:mainfrom
jiqing-feng:main

Conversation

@jiqing-feng

@jiqing-feng jiqing-feng commented Jul 16, 2025

Copy link
Copy Markdown
Contributor

The triton kernel also works on Intel XPU and could bring 10x speed-up compared to pytorch implementation.

Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
@jiqing-feng
jiqing-feng marked this pull request as ready for review July 21, 2025 08:02
@jiqing-feng

Copy link
Copy Markdown
Contributor Author

Hi @Godofnothing . Would you please review this PR? Thanks!

@jiqing-feng

Copy link
Copy Markdown
Contributor Author

BTW, I don't understand why it has this restriction for gemv. I removed this restriction and found triton kernel still works and can give the same outputs as PyTorch Gemm.

@BlackSamorez

Copy link
Copy Markdown
Collaborator

BTW, I don't understand why it has this restriction for gemv

Repeated GEMV is faster when bs<=6 and dequant+GEMM is faster when bs>6.

@jiqing-feng

jiqing-feng commented Jul 23, 2025

Copy link
Copy Markdown
Contributor Author

BTW, I don't understand why it has this restriction for gemv

Repeated GEMV is faster when bs<=6 and dequant+GEMM is faster when bs>6.

I see, that works for cuda kernel. But for triton, it still faster than pytorch. I removed the training check for triton because it will faster than pytorch anyway.

Hi @BlackSamorez , would you please review this change? Thanks!

Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
@Vahe1994
Vahe1994 requested a review from BlackSamorez July 23, 2025 10:19
@jiqing-feng

Copy link
Copy Markdown
Contributor Author

Hi @BlackSamorez @Vahe1994 . Would you please review this PR? Thanks!

@BlackSamorez

Copy link
Copy Markdown
Collaborator

Dequantization is still faster than GEMV starting with some batch sizes. Please benchmark the two and choose a threahold.

@jiqing-feng

jiqing-feng commented Jul 28, 2025

Copy link
Copy Markdown
Contributor Author

Dequantization is still faster than GEMV starting with some batch sizes. Please benchmark the two and choose a threahold.

The restriction is for batch_size * sequence_length actually, so I tested the prefill and decode latency for triton and torch.

Here is the triton speed-up compared to pytorch on XPU.
input length = 32
| batch_size | prefill | decode |
| 1 | 6.0x | 19x |
| 4 | 1.7x | 19x |
| 8 | 1.0x | 15x |
| 32 | 0.2x | 6x |

You were right, the threshold should be 8*32=256 on XPU (because pytorch and triton show almost the same performance when batch size is 8 and input length is 32).

Hi @BlackSamorez . Thanks for your reminder, I have figured out the threshold for using gemv on XPU. Please review the changes. 😄

Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
@jiqing-feng

Copy link
Copy Markdown
Contributor Author

Hi @BlackSamorez , do you mind taking a look at this PR? Thanks!

@jiqing-feng

Copy link
Copy Markdown
Contributor Author

Hi @BlackSamorez . Do you have time to take a look at this PR? Thanks!

@BlackSamorez
BlackSamorez merged commit acce58e into Vahe1994:main Aug 3, 2025
1 of 2 checks passed
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.

2 participants