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

Implement Quick GELU #254

Merged
merged 7 commits into from
Jun 16, 2023
Merged

Implement Quick GELU #254

merged 7 commits into from
Jun 16, 2023

Conversation

monatis
Copy link
Contributor

@monatis monatis commented Jun 12, 2023

Closes #253

This is needed for CLIP-like models and I'm implementing clip.cpp here. It will also be a base for upcoming multimodal models that uses CLIP as an image embedder.

@Green-Sky
Copy link
Contributor

you let some formatting happen. please only commit code changes.

@monatis
Copy link
Contributor Author

monatis commented Jun 12, 2023

Oh sorry, missed that. I'll fix it.

@monatis
Copy link
Contributor Author

monatis commented Jun 13, 2023

This is ready for review now.

@monatis monatis mentioned this pull request Jun 16, 2023
@monatis
Copy link
Contributor Author

monatis commented Jun 16, 2023

Hi @ggerganov Can ı have your attention here please? clip.cpp is almost ready, and I'm only crafting more examples and then I can announce it.

I can also add a link in the examples section in readme if you thing it deserves this.

p.s.: The next step will be using clip.cpp and llama.cpp to infer with LLaVA

Copy link
Owner

@ggerganov ggerganov left a comment

Choose a reason for hiding this comment

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

Rename to ggml_gelu_quick, GELU_QUICK, etc, in all instances

From what I read, this is just an approximation of GELU that is supposed to be faster but inaccurate. Why not use the original ggml_gelu()? It is already doing table lookup so there is no difference in performance + it is more accurate

Also, keep in mind that in the future you can use ggml_map_unary_f32() to implement this kind of 1D mapping functions in your project without having to wait for ggml to provide them

@monatis
Copy link
Contributor Author

monatis commented Jun 16, 2023

Unfortunately that theoretically small divergence between GELU and Quick GELU lead to large differences at the end, I suppose it accumulates through 12 layers. So I couldn't get good results until implementing Quick GELU.

@monatis monatis requested a review from ggerganov June 16, 2023 14:04
@ggerganov ggerganov merged commit 873f19f into ggerganov:master Jun 16, 2023
CCLDArjun pushed a commit to CCLDArjun/ggml that referenced this pull request Dec 18, 2023
This causes long prompts to parse very slowly.
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.

Implement Quick GELU
3 participants