Skip to content

Conversation

@junejae
Copy link
Contributor

@junejae junejae commented Sep 9, 2024

What does this PR do?

Add T5 GGUF loading support

Due to the nature of T5's architecture, I decided to replicate gguf's conversion logic, so the final code gets messy.
I tried to avoid any logical conflicts between t5's and existing model architectures, but feel free to edit codes if you find any mistakes that I haven't noticed out.

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@SunMarc @LysandreJik @ArthurZucker , could you please review this PR?

@bonlime
Copy link

bonlime commented Sep 11, 2024

Does your code allow loading T5 Encoder XXL (the one used in Flux)?
Example files here:
https://huggingface.co/city96/t5-v1_1-xxl-encoder-gguf/tree/main

@junejae
Copy link
Contributor Author

junejae commented Sep 11, 2024

@bonlime Yes, it works with AutoModelForTextEncoding class. I've tested with T5 encoder of the exact repo you linked, but I didn't commit the independent test code block for T5 encoder since the code could be dirty with embedding vector style example output.

Copy link
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

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

Thanks for your work @junejae and sorry for the delay ! Just a few nits. There are a few merge conflits, can you fix them also ?

@junejae junejae requested a review from SunMarc October 3, 2024 11:37
@junejae
Copy link
Contributor Author

junejae commented Oct 3, 2024

@SunMarc
I've resolved conflicts and added more tests. Could you please review it again?

@SunMarc
Copy link
Member

SunMarc commented Oct 3, 2024

Make sure to fix the CI also !

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@junejae junejae requested a review from SunMarc October 23, 2024 02:52
Copy link
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

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

Nice, thanks a lot !

@SunMarc SunMarc requested a review from LysandreJik October 23, 2024 12:24
Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Boom, awesome! Thanks @junejae

@SunMarc SunMarc merged commit dd267fc into huggingface:main Oct 24, 2024
BernardZach pushed a commit to BernardZach/transformers that referenced this pull request Dec 5, 2024
* add: GGUFT5Converter

* add: tensormapping for t5

* add: test code for t5

* fix: Remove whitespace from blank line

* add: t5 fp16 tests

* fix: whitespace formatting

* fix: minor formatting

* fix: testing every weights
@mirix
Copy link

mirix commented Mar 12, 2025

Is the commit merged? I still get the error:

ValueError: GGUF model with architecture t5encoder is not supported yet.

t5_gguf = 'city96/t5-v1_1-xxl-encoder-gguf'
t5_file = 't5-v1_1-xxl-encoder-Q8_0.gguf'

text_encoder_2 = T5EncoderModel.from_pretrained(
    t5_gguf,
    gguf_file=t5_file,
    torch_dtype=torch.bfloat16,
)

@SunMarc
Copy link
Member

SunMarc commented Mar 13, 2025

cc @Isotr0py

@Isotr0py Isotr0py mentioned this pull request Mar 13, 2025
7 tasks
@SlimRG
Copy link

SlimRG commented Aug 10, 2025

Pls, add this example into comments into UMT5EncoderModel's code
Using from_pretrained except from_single_file was new for me

Is the commit merged? I still get the error:

ValueError: GGUF model with architecture t5encoder is not supported yet.

t5_gguf = 'city96/t5-v1_1-xxl-encoder-gguf'
t5_file = 't5-v1_1-xxl-encoder-Q8_0.gguf'

text_encoder_2 = T5EncoderModel.from_pretrained(
    t5_gguf,
    gguf_file=t5_file,
    torch_dtype=torch.bfloat16,
)

@zwukong
Copy link

zwukong commented Dec 19, 2025

too slow😭.
need to convert first
Converting and de-quantizing GGUF tensors...: 100%|██████████████████████████████████████████████████████| 219/219 [00:56<00:00, 3.89it/s]

@SunMarc
Copy link
Member

SunMarc commented Dec 19, 2025

Yeah, we need to make this multi-threaded to go faster ;D

@zwukong
Copy link

zwukong commented Dec 19, 2025

comfyui is much faster, don't need to convert in each running.For some reason,i have to test gguf in diffusers😄

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.

8 participants