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

LayerNorm_A calculation precision is unstable, leading to incorrect recognition results. #42

Open
winf opened this issue Aug 2, 2024 · 2 comments

Comments

@winf
Copy link

winf commented Aug 2, 2024

#41 #20
When using models other than .en, if the model size exceeds ‘tiny’, the recognition results are found to be significantly incorrect. By comparing the layer-by-layer outcomes with the openai repository’s runtime results, it was ultimately determined that the source of the problem is the poor stability of mean and variance calculations in the LayerNorm_A function. I fixed the issue by replacing fp16 with fp32. Reference: https://git.bwbot.org/publish/useful-transformers/-/blob/main/lib/layernorm.cc

@winf
Copy link
Author

winf commented Aug 2, 2024

@marty1885 @guynich

@marty1885
Copy link
Contributor

Thank you! This solves my problems too!

I don't have write access to the repository. Maybe you could make a PR and upstream the changes? I can test on my end.

@winf winf mentioned this issue Aug 7, 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

No branches or pull requests

2 participants