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

Community contribution: Adding GGUF support for more architectures #33260

Open
10 of 15 tasks
SunMarc opened this issue Sep 2, 2024 · 28 comments
Open
10 of 15 tasks

Community contribution: Adding GGUF support for more architectures #33260

SunMarc opened this issue Sep 2, 2024 · 28 comments
Labels
Feature request Request for a new feature Good Second Issue Issues that are more difficult to do than "Good First" issues - give it a try if you want!

Comments

@SunMarc
Copy link
Member

SunMarc commented Sep 2, 2024

Feature request

Recently, we have added the ability to load gguf files within transformers.

The goal was to offer the possibility to users to further train/fine-tune their gguf models.

See Workflow 1) Load gguf file in transformers: we dequantize the weights to fp32, then we load the weights to be used with PyTorch.
from transformers import AutoTokenizer, AutoModelForCausalLM

model_id = "TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF"
filename = "tinyllama-1.1b-chat-v1.0.Q6_K.gguf"

tokenizer = AutoTokenizer.from_pretrained(model_id, gguf_file=filename)
model = AutoModelForCausalLM.from_pretrained(model_id, gguf_file=filename)
  1. train/finetune

  2. Convert the model back to gguf to use in the ggml ecosystem using convert_hf_to_gguf script or using gguf-my-repo space if you pushed your model on the hub :

tokenizer.save_pretrained('directory')
model.save_pretrained('directory')

!python ${path_to_llama_cpp}/convert-hf-to-gguf.py ${directory}

Let's try to add GGUF support for more architectures! Currently supported architectures are

  • Llama
  • Mistral
  • Qwen2

It would be great to add the support for more architectures such as

... and many more (Feel free to suggest more architectures ! The model needs to integrated in transformers)

Adding this feature would require to follow the same protocol as in this PR :

  1. Update GGUF_TENSOR_MAPPING and GGUF_CONFIG_MAPPING in order to map the tensor/config of the gguf file to the one on transformers.
  2. Create a GGUFXXXConverter(XXXConverter) class to convert the gguf tokenizer to a transformers one.
  3. Write tests

If you are interested to take up the challenge, comment below with the architecture name you want to integrate and open a PR!

Once you open a PR, feel free to ping @SunMarc @LysandreJik @ArthurZucker for a review !

Motivation

Support for more gguf models

Your contribution

Reviewing PRs and possibly adding the support for more models

@SunMarc SunMarc added the Feature request Request for a new feature label Sep 2, 2024
@SunMarc SunMarc added the Good Second Issue Issues that are more difficult to do than "Good First" issues - give it a try if you want! label Sep 2, 2024
@VladOS95-cyber
Copy link
Contributor

@SunMarc I am going to take Qwen2Moe

@KingNish24
Copy link

@SunMarc I want to take Gemma2

@junejae
Copy link
Contributor

junejae commented Sep 3, 2024

@SunMarc May I suggest & take T5? Seems GGUF version of T5 encoder is highly used for getting along with FLUX.

@010kim
Copy link
Contributor

010kim commented Sep 3, 2024

@SunMarc Hello! Unless someone else is working on this model already, may I take MiniCPM-V?

@SunMarc
Copy link
Member Author

SunMarc commented Sep 3, 2024

@SunMarc May I suggest & take T5? Seems GGUF version of T5 encoder is highly used for getting along with FLUX.

Added @junejae !

@SunMarc Hello! Unless someone else is working on this model already, may I take MiniCPM-V?

Hi @010kim, thanks for the interest ! MiniCPM-V model relies on trust_remote_code=True, so I don't think we can add this model for now with gguf support. We don't want to have code in transformers that relies on modeling files that are on the hub. I will think about extending trust_remote_code=True to gguf support, so that the author of the model can add it himself !

@010kim
Copy link
Contributor

010kim commented Sep 3, 2024

Hi @010kim, thanks for the interest ! MiniCPM-V model relies on trust_remote_code=True, so I don't think we can add this model for now with gguf support. We don't want to have code in transformers that relies on modeling files that are on the hub. I will think about extending trust_remote_code=True to gguf support, so that the author of the model can add it himself !

@SunMarc Thank you so much for your response. It also makes sense the author should work on it. What about Cohere? Can I take it?

@jungnerd
Copy link
Contributor

jungnerd commented Sep 5, 2024

Hi @SunMarc 👋🏻
May I work with CLIP model if nobody is working on it?

@SunMarc
Copy link
Member Author

SunMarc commented Sep 5, 2024

Hey @jungnerd ! The model you choose needs to be in the conversion script from hf to gguf. See the script here

@g-prz
Copy link
Contributor

g-prz commented Sep 9, 2024

Hey @SunMarc 🙋‍♂️
I'd like to try my chance to contribute to this issue, can I take Falcon? 🦅

@VladOS95-cyber
Copy link
Contributor

Hi @SunMarc, I take bloom if nobody is working on it

@fabxoe
Copy link
Contributor

fabxoe commented Sep 12, 2024

Hi @SunMarc, I'd like to handle the work related to Codestrall :)

@jungnerd
Copy link
Contributor

Hey @jungnerd ! The model you choose needs to be in the conversion script from hf to gguf. See the script here

There is conversion script for clip model(clip.cpp). Can I use this to contribute?

@g-prz g-prz mentioned this issue Sep 13, 2024
5 tasks
@cjfghk5697
Copy link
Contributor

Hi @SunMarc,
I'm interested in this issue. Would it be okay if I worked on the BLIP model?

@cjfghk5697
Copy link
Contributor

Hi @SunMarc, I'm interested in this issue. Would it be okay if I worked on the BLIP model?

Hi @SunMarc, I'd like to work on the BLIP model, but after researching, I found that it might be challenging due to the Vision model structure. Would it be alright if I switched to working on the Smol model instead?

@g-prz
Copy link
Contributor

g-prz commented Sep 19, 2024

Hey @SunMarc 🤗
Gonna continue with granite 🪨

@cjfghk5697
Copy link
Contributor

cjfghk5697 commented Sep 21, 2024

@SunMarc
I checked the Smol model and confirmed that it's already functioning well without needing any further work. In the issue mentioned that supporting the Smol model would be beneficial, but is there any specific work required?

If not, I’ll proceed with switching to the dbrx model.

@SunMarc
Copy link
Member Author

SunMarc commented Sep 23, 2024

@SunMarc
I checked the Smol model and confirmed that it's already functioning well without needing any further work. In the issue mentioned that supporting the Smol model would be beneficial, but is there any specific work required?

If not, I’ll proceed with switching to the dbrx model.

Oh indeed, this is because it is a llama architecture.

@VladOS95-cyber
Copy link
Contributor

VladOS95-cyber commented Sep 29, 2024

Hi @SunMarc! I am going to start working on StableLM model

@yijun-lee
Copy link
Contributor

Is any work being done on the Gemma2? If not, I would like to proceed with it!
@SunMarc @KingNish24

@g-prz g-prz mentioned this issue Oct 3, 2024
5 tasks
@VladOS95-cyber
Copy link
Contributor

Hi @SunMarc! I suppose GPT2 gguf is not supported yet, if this is a case, I'll take it

@fabxoe
Copy link
Contributor

fabxoe commented Oct 5, 2024

Hi @SunMarc, I'd like to handle the work related to Codestrall :)

Codestrall's tokenizer was just llama tokenizer.
It looks like I don't need to handle codes of Codestrall

This was referenced Oct 5, 2024
@010kim
Copy link
Contributor

010kim commented Oct 6, 2024

@SunMarc Thank you so much for your response. It also makes sense the author should work on it. What about Cohere? Can I take it?

I went through the codes, and i was able to to load Cohere gguf model, but could not load the tokenizer. This is because Cohere slow tokenizer is not implemented in HuggingFace. (Only FastTokenizer is available for Cohere) Is there a way around to fix this? @SunMarc

@VladOS95-cyber
Copy link
Contributor

Hey @SunMarc! I"ll take Starcoder2 as next model

@VladOS95-cyber
Copy link
Contributor

Hi @SunMarc! I am going to start working on Mamba

@farrosalferro
Copy link
Contributor

Are you still working on Gemma2? @yijun-lee @KingNish24 ? If not, is it possible for me to try working on it? Thank you!

@yijun-lee
Copy link
Contributor

Are you still working on Gemma2? @yijun-lee @KingNish24 ? If not, is it possible for me to try working on it? Thank you!

I’m running behind schedule, but I’m making progress! I’ll handle it.

@farrosalferro
Copy link
Contributor

farrosalferro commented Nov 8, 2024

I’m running behind schedule, but I’m making progress! I’ll handle it.

Glad to know! Then is it possible for me to try working on Nemotron? @SunMarc

@farrosalferro
Copy link
Contributor

Could you please kindly check my PR @SunMarc? Thank you
Add Nemotron GGUF Loading Support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request Request for a new feature Good Second Issue Issues that are more difficult to do than "Good First" issues - give it a try if you want!
Projects
None yet
Development

No branches or pull requests