Skip to content

Support for Seq2Seq Models (T5, T5Gemma, etc.) - #3153

Closed
maxzuo wants to merge 2728 commits into
unslothai:mainfrom
maxzuo:feature/seq2seq
Closed

maxzuo wants to merge 2728 commits into
unslothai:mainfrom
maxzuo:feature/seq2seq

Conversation

@maxzuo

@maxzuo maxzuo commented Aug 14, 2025

Copy link
Copy Markdown
Contributor

PR Description

Adds support for Seq2Seq models: AutoModelForSeq2SeqLM.

Why

Seq2Seq models are not directly supported, despite support for all model architectures. This is because FastModel.from_pretrained sets the auto_model parameter to either AutoModelForCausalLM or AutoModelForVision2Seq/AutoModelForImageTextToText.

Further, since models like T5 have class names ending in ForConditionalGeneration, unsloth registers this as a VLM and tries to load it as such.

I use AutoModelForSeq2SeqLM._model_mapping to check if a model config is registered as a Seq2Seq model. This logic can be extended to other auto models (e.g., AutoModelForSequenceClassification) if desired.

Links

Support for T5 has some community interest:

danielhanchen and others added 30 commits June 30, 2025 06:01
…#2817)

* Added conda/mamba section to blackwell installation readme

* fix conda creation suffix and vllm install syntax
* Update vision.py

* Bug fix

* Update mapper.py

* check SDPA for Mistral 3, Pixtral

* Update vision.py

* Versioning

* Update rl_replacements.py

* Update README.md

* add model registry

* move hf hub utils to unsloth/utils

* refactor global model info dicts to dataclasses

* fix dataclass init

* fix llama registration

* remove deprecated key function

* start registry reog

* add llama vision

* quant types -> Enum

* remap literal quant types to QuantType Enum

* add llama model registration

* fix quant tag mapping

* add qwen2.5 models to registry

* add option to include original model in registry

* handle quant types per model size

* separate registration of base and instruct llama3.2

* add QwenQVQ to registry

* add gemma3 to registry

* add phi

* add deepseek v3

* add deepseek r1 base

* add deepseek r1 zero

* add deepseek distill llama

* add deepseek distill models

* remove redundant code when constructing model names

* add mistral small to registry

* rename model registration methods

* rename deepseek registration methods

* refactor naming for mistral and phi

* add global register models

* refactor model registration tests for new registry apis

* add model search method

* remove deprecated registration api

* add quant type test

* add registry readme

* make llama registration more specific

* clear registry when executing individual model registration file

* more registry readme updates

* Update _auto_install.py

* Llama4

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Synthetic data

* Update mapper.py

* Xet and Synthetic

* Update synthetic.py

* Update loader.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update pyproject.toml

* Delete .gitignore

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update _utils.py

* Update pyproject.toml

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update synthetic.py

* Update chat_templates.py

* Seasame force float16 / float32

* Fix Seasame

* Update loader.py

* Update vision.py

* Update vision.py

* Update vision.py

* Update loader.py

* is_multimodal

* Update loader.py

* Update loader.py

* Update loader.py

* Update loader.py

* Update vision.py

* Update vision.py

* Update vision.py

* UNSLOTH_DISABLE_STATIC_GENERATION

* Update vision.py

* Auto vision detection

* Sesame

* Whisper

* Update loader.py

* Update loader.py

* Update loader.py

* Update mapper.py

* Update vision.py

* Update vision.py

* Update vision.py

* Update vision.py

* Update vision.py

* Update vision.py

* Update loader.py

* Update loader.py

* Update loader.py

* Update loader.py

* Update _utils.py

* Update rl.py

* versioning

* Update rl.py

* Update rl.py

* Update rl.py

* Update rl.py

* Update rl.py

* logging

* Update pyproject.toml

* Update rl.py

* versioning

* Update rl.py

* Update rl.py

* Update rl_replacements.py

* Update rl_replacements.py

* Update rl.py

* Update rl_replacements.py

* Update rl_replacements.py

* logits / temperature

* Update rl_replacements.py

* Update pyproject.toml

* Update rl_replacements.py

* Update rl_replacements.py

* Debugging only

* Update llama.py

* Update llama.py

* Update rl_replacements.py

* Update rl_replacements.py

* Update rl_replacements.py

* Update rl_replacements.py

* Update rl_replacements.py

* Generic efficient GRPO

* Update rl_replacements.py

* Update rl_replacements.py

* Remove debugging

* Update rl_replacements.py

* Update rl_replacements.py

* Update vision.py

* Update llama.py

* Update rl_replacements.py

* versioning

* Update _utils.py

* Update vision.py

* Update mapper.py

* Update loader.py

* Update mapper.py

* Update vision.py

* Update loader.py

* Update vision.py

* Update loader.py

* Update _utils.py

* Update vision.py

* gradient checkpointing

* Gemma 3N fixes

* Update loader.py

* Versioning

* Gemma 3N fixes

* Update vision.py

* Update vision.py

* Update loader.py

* Update vision.py

---------

Co-authored-by: Jack Shi Wei Lun <[email protected]>
Co-authored-by: jeromeku <[email protected]>
Co-authored-by: Michael Han <[email protected]>
add new validate_loftq_config to __all__
…lothai#2811)

* Convert torch.bfloat16, torch.float16, etc. to vLLM valid dtypes

* removed newlines and extra whitespace
* [Feature] enable unsloth on amd gpu

* fix the comment

---------

Co-authored-by: Daniel Han <[email protected]>
shimmyshimmer and others added 18 commits August 8, 2025 09:27
Add Qwen3 Instruct / Thinking chat templates
* Fix mamba

* Update loader.py

* Update vision.py

* Update loader.py

* Filter vLLM standby logs (unslothai#3131)

* filter vLLM standby logs

* safeguard standby logger patch

* Update unsloth/models/_utils.py

* Update unsloth/models/_utils.py

* Update unsloth/models/_utils.py

---------

Co-authored-by: Daniel Han <[email protected]>

* Update loader.py

* Add scaler

* Update llama.py

* Update _utils.py

* Versioning

---------

Co-authored-by: Datta Nimmaturi <[email protected]>
This was referenced Aug 14, 2025
@maxzuo
maxzuo marked this pull request as draft August 14, 2025 18:16
@Datta0

Datta0 commented Aug 18, 2025

Copy link
Copy Markdown
Contributor

Hey @maxzuo thanks for the contribution
It'd be of great help if you can possibly create a notebook showing fine-tuning of any small seq2seq model on google colab.
Also I notice this PR is marked draft. Are you intending to add more things to this?

@maxzuo

maxzuo commented Aug 18, 2025

Copy link
Copy Markdown
Contributor Author

@Datta0 sure I'm actively working on it, actually why I converted this to a draft. Will let you know!

@Aman-byte1

Copy link
Copy Markdown

@maxzuo did u work on it?

@felixmaechtle

Copy link
Copy Markdown

Hey @maxzuo

are there any updates? I'd like to fine-tune T5Gemma with your PR, do you think this is possible?

Best,
Felix

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.

please give t5 support. Support T5 models