Skip to content

Conversation

@kaixuanliu
Copy link
Contributor

No description provided.

@kaixuanliu
Copy link
Contributor Author

This PR optimized the performance of flashBert path for HPU device, with this optimization, the mean latency drops from 6.4 ms to 4.32 ms, which finally aligns with the perf of tei-gaudi.

@kaixuanliu
Copy link
Contributor Author

@Narsil @regisss pls help review, thx!

@yao-matrix
Copy link

Seems you changed modeling which cover other devices, do you validated GPU, CPU, XPU? what's the performance?

@kaixuanliu
Copy link
Contributor Author

kaixuanliu commented Mar 10, 2025

For CPU and XPU device, I just passed 2 extra args to calc attention, and these 2 args are only used in hpu_attn calculation. The other changes is just replace torch.addmm to F.linear, which I suppose there should be no perf difference. I validated the output correctness of CPU. I will double check the perf of both CPU and XPU and output of XPU.

@kaixuanliu
Copy link
Contributor Author

Have double checked the output correctness of XPU devices and perf of both CPU/XPU, no change compared with original implementation.

__all__ = ["Model"]

TRUST_REMOTE_CODE = os.getenv("TRUST_REMOTE_CODE", "false").lower() in ["true", "1"]

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's remove this new blank line as it's the only change in the file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, have fixed it.

Signed-off-by: kaixuanliu <[email protected]>
@regisss regisss merged commit 6e4133b into huggingface:main Mar 11, 2025
2 of 9 checks passed
@kaixuanliu kaixuanliu deleted the flash_bert_hpu branch June 5, 2025 01:56
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.

4 participants