Support for Transformer / Attention (QKV) layers and torch.matmul in hls4ml, and resource optimization strategies? #1460
hub-sszhang
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi hls4ml team,
I am working on deploying a small transformer-like model (self-attention + MLP) to FPGA using hls4ml.
My model includes:
I understand that hls4ml mainly supports Dense and convolutional layers, so I would like to ask:
Additionally, I am trying to manually implement the attention part in Vitis HLS.
Currently, I have already applied:
#pragma HLS PIPELINE#pragma HLS ARRAY_PARTITIONHowever, resource usage (DSP/LUT) is still quite high.
So I would also like to ask:
Are there recommended strategies to further optimize resource usage for matrix multiplications in HLS (e.g., QK^T and attention × V)?
Are there best practices for implementing or approximating softmax efficiently in FPGA (for low latency and low resource usage)?
Both latency and resource usage are critical for my study.
Any suggestions or references would be greatly appreciated.
Thanks a lot for your help!
Beta Was this translation helpful? Give feedback.
All reactions