Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
562 commits
Select commit Hold shift + click to select a range
36bf805
Update llama.py
danielhanchen Feb 13, 2025
a3af8e3
Update llama.py
danielhanchen Feb 13, 2025
9d10d2f
Update llama.py
danielhanchen Feb 13, 2025
b30a81f
Update llama.py
danielhanchen Feb 13, 2025
b7e8559
Update llama.py
danielhanchen Feb 13, 2025
4b201d9
Update rl_replacements.py
danielhanchen Feb 13, 2025
dc723bc
Update rl_replacements.py
danielhanchen Feb 13, 2025
0309949
Update rl_replacements.py
danielhanchen Feb 13, 2025
c409574
Update rl_replacements.py
danielhanchen Feb 13, 2025
8e5b09a
Update llama.py
danielhanchen Feb 13, 2025
6652f1d
Update rl_replacements.py
danielhanchen Feb 13, 2025
9215bbe
Update rl_replacements.py
danielhanchen Feb 13, 2025
4bff998
Update rl_replacements.py
danielhanchen Feb 13, 2025
c859030
Update rl_replacements.py
danielhanchen Feb 13, 2025
2daa8e3
Update rl_replacements.py
danielhanchen Feb 13, 2025
527a0c4
Update rl_replacements.py
danielhanchen Feb 13, 2025
087a5dc
Update rl_replacements.py
danielhanchen Feb 13, 2025
73210b3
Update rl_replacements.py
danielhanchen Feb 13, 2025
9934ac5
Merge branch 'main' into nightly
danielhanchen Feb 13, 2025
2635f2a
Update llama.py
danielhanchen Feb 13, 2025
69ab838
Update _utils.py
danielhanchen Feb 13, 2025
d5d7a06
Merge branch 'main' into nightly
danielhanchen Feb 13, 2025
c9e450f
Merge branch 'main' into nightly
danielhanchen Feb 13, 2025
44d00e8
Merge branch 'main' into nightly
danielhanchen Feb 13, 2025
447dfc4
Merge branch 'main' into nightly
danielhanchen Feb 13, 2025
acf98dc
Update llama.py
danielhanchen Feb 14, 2025
1399110
Update _utils.py
danielhanchen Feb 14, 2025
881105b
Update rl_replacements.py
danielhanchen Feb 14, 2025
cfdd3f1
Update rl.py
danielhanchen Feb 14, 2025
95b7df5
Update rl.py
danielhanchen Feb 14, 2025
17bfcf9
Update rl.py
danielhanchen Feb 14, 2025
61c219d
Update rl.py
danielhanchen Feb 14, 2025
9794dc2
Update rl.py
danielhanchen Feb 14, 2025
3687a6f
Update llama.py
danielhanchen Feb 14, 2025
c495bfa
Update llama.py
danielhanchen Feb 14, 2025
f9055a7
Update llama.py
danielhanchen Feb 14, 2025
945e3f9
Update llama.py
danielhanchen Feb 14, 2025
3d9fe12
Update rl_replacements.py
danielhanchen Feb 14, 2025
ed90785
Update llama.py
danielhanchen Feb 14, 2025
640bc88
Update llama.py
danielhanchen Feb 14, 2025
bb3bb2d
Update llama.py
danielhanchen Feb 14, 2025
9065938
Update llama.py
danielhanchen Feb 14, 2025
07b48f5
Merge branch 'main' into nightly
danielhanchen Feb 14, 2025
48c5e0d
GRPO optimized
danielhanchen Feb 14, 2025
3a1fb63
Update rl.py
danielhanchen Feb 14, 2025
19014b0
Update rl_replacements.py
danielhanchen Feb 14, 2025
0c17e79
Update rl_replacements.py
danielhanchen Feb 14, 2025
aee44e2
Update rl.py
danielhanchen Feb 14, 2025
953d957
Update rl.py
danielhanchen Feb 14, 2025
2a2b9f7
Update rl.py
danielhanchen Feb 14, 2025
fcb0f4a
Update rl.py
danielhanchen Feb 14, 2025
eabc365
Update rl_replacements.py
danielhanchen Feb 14, 2025
7408318
Update rl_replacements.py
danielhanchen Feb 14, 2025
f35eae3
Update rl_replacements.py
danielhanchen Feb 14, 2025
2b89dae
Selective Log softmax
danielhanchen Feb 14, 2025
45c8431
Fix GRPO bsz
danielhanchen Feb 14, 2025
644cedf
Update rl.py
danielhanchen Feb 14, 2025
4b765d7
Update rl_replacements.py
danielhanchen Feb 14, 2025
0a7c56d
Update rl_replacements.py
danielhanchen Feb 15, 2025
1b43e1d
Update rl_replacements.py
danielhanchen Feb 15, 2025
d588665
Update rl_replacements.py
danielhanchen Feb 15, 2025
54bd827
Fix TRL
danielhanchen Feb 15, 2025
c6d6e6b
Merge branch 'main' into nightly
danielhanchen Feb 15, 2025
fa560ce
Metrics GRPO
danielhanchen Feb 15, 2025
46462f1
Update rl_replacements.py
danielhanchen Feb 15, 2025
12c497a
Update rl_replacements.py
danielhanchen Feb 15, 2025
b8aca94
Merge branch 'main' into nightly
danielhanchen Feb 15, 2025
c14faee
No compile
danielhanchen Feb 16, 2025
1fcad32
Update rl.py
danielhanchen Feb 16, 2025
80be827
Remove docs
danielhanchen Feb 16, 2025
9254243
Update rl.py
danielhanchen Feb 16, 2025
09cb804
Update rl.py
danielhanchen Feb 16, 2025
86dabcf
Update rl.py
danielhanchen Feb 16, 2025
ba1c93e
Update rl.py
danielhanchen Feb 16, 2025
0d75afd
Update rl_replacements.py
danielhanchen Feb 16, 2025
1803658
Update rl.py
danielhanchen Feb 16, 2025
a856085
Update rl.py
danielhanchen Feb 16, 2025
eeac4f3
Update rl_replacements.py
danielhanchen Feb 16, 2025
6f1beb0
Update rl_replacements.py
danielhanchen Feb 16, 2025
222b1e7
llama-quantize on WINDOWS WSL error fix - edit save.py (gguf saving b…
everythingisc00l Feb 16, 2025
103cff4
Update rl_replacements.py
danielhanchen Feb 17, 2025
89a1d03
Update rl_replacements.py
danielhanchen Feb 17, 2025
c46b544
Update rl_replacements.py
danielhanchen Feb 17, 2025
ed84307
Update rl_replacements.py
danielhanchen Feb 17, 2025
93d3f16
Update rl_replacements.py
danielhanchen Feb 17, 2025
429ba6d
Update rl_replacements.py
danielhanchen Feb 17, 2025
1e42bad
Update rl_replacements.py
danielhanchen Feb 17, 2025
38a1885
Update rl_replacements.py
danielhanchen Feb 17, 2025
f0ee4f5
Update rl_replacements.py
danielhanchen Feb 17, 2025
b68dce6
Update rl_replacements.py
danielhanchen Feb 17, 2025
0827067
Update llama.py
danielhanchen Feb 17, 2025
204cd7a
Update rl_replacements.py
danielhanchen Feb 17, 2025
e141075
Update rl_replacements.py
danielhanchen Feb 17, 2025
a07a9e3
Update rl_replacements.py
danielhanchen Feb 17, 2025
cf2720d
Update llama.py
danielhanchen Feb 17, 2025
5c6f586
Update llama.py
danielhanchen Feb 18, 2025
2e07623
Update rl_replacements.py
danielhanchen Feb 18, 2025
8025cfe
Update rl_replacements.py
danielhanchen Feb 18, 2025
ba48495
Update rl_replacements.py
danielhanchen Feb 18, 2025
f0078de
Update rl.py
danielhanchen Feb 18, 2025
15e0140
Update rl.py
danielhanchen Feb 18, 2025
5f5cca4
Update rl_replacements.py
danielhanchen Feb 18, 2025
d80be70
Update rl.py
danielhanchen Feb 18, 2025
47a85eb
Update rl.py
danielhanchen Feb 18, 2025
f09478d
Update rl_replacements.py
danielhanchen Feb 18, 2025
97637c5
Update rl_replacements.py
danielhanchen Feb 18, 2025
58bd27f
Update rl_replacements.py
danielhanchen Feb 18, 2025
7c0c749
Update rl_replacements.py
danielhanchen Feb 18, 2025
97b55c1
Update rl_replacements.py
danielhanchen Feb 18, 2025
24c7a2f
Update rl_replacements.py
danielhanchen Feb 18, 2025
06b2cd3
unsloth_num_chunks
danielhanchen Feb 18, 2025
cbb16e3
Update rl.py
danielhanchen Feb 18, 2025
d16299b
Update rl_replacements.py
danielhanchen Feb 18, 2025
0c1a808
Update rl_replacements.py
danielhanchen Feb 18, 2025
6796801
Update rl_replacements.py
danielhanchen Feb 18, 2025
bd046ca
Update rl.py
danielhanchen Feb 18, 2025
ac2e814
Update rl.py
danielhanchen Feb 18, 2025
a88712f
Update rl.py
danielhanchen Feb 18, 2025
0daa328
Update rl.py
danielhanchen Feb 18, 2025
1afe3f2
Update rl.py
danielhanchen Feb 18, 2025
6732822
Update rl_replacements.py
danielhanchen Feb 18, 2025
5efe9f3
Update rl_replacements.py
danielhanchen Feb 18, 2025
15442d1
Update rl_replacements.py (#1754)
SethHWeidman Feb 19, 2025
91ab43d
Optional logits
danielhanchen Feb 19, 2025
a6a5f60
Update rl.py
danielhanchen Feb 19, 2025
83ce085
Update rl.py
danielhanchen Feb 19, 2025
8ece11f
Update rl.py
danielhanchen Feb 19, 2025
bc6bfae
Update rl.py
danielhanchen Feb 20, 2025
95fb6a4
Update rl.py
danielhanchen Feb 20, 2025
ba01cf5
Update rl.py
danielhanchen Feb 20, 2025
eb48b98
Update rl.py
danielhanchen Feb 20, 2025
3c750a1
Update rl.py
danielhanchen Feb 20, 2025
515cf5a
Update rl_replacements.py
danielhanchen Feb 20, 2025
2cf4349
Update rl.py
danielhanchen Feb 20, 2025
ae8bf68
Update rl.py
danielhanchen Feb 20, 2025
e07f4bc
Update rl.py
danielhanchen Feb 20, 2025
f11e5ab
Merge branch 'main' into nightly
danielhanchen Feb 20, 2025
3fccf5d
Update rl.py
danielhanchen Feb 20, 2025
798ad95
fix an import error (#1767)
NinoRisteski Feb 20, 2025
2957d89
SamplingParams
danielhanchen Feb 20, 2025
19d57bc
Convert mask to float (#1762)
Erland366 Feb 20, 2025
07aea40
[Windows Support] Add latest `xformers` wheels to pyproject.toml (#1753)
versipellis Feb 20, 2025
77109a4
Merge branch 'nightly' of https://github.com/unslothai/unsloth into n…
danielhanchen Feb 20, 2025
f3d9efb
vLLMSamplingParams
danielhanchen Feb 20, 2025
6d5caca
Update __init__.py
danielhanchen Feb 20, 2025
3a5610e
default num_chunks == -1
danielhanchen Feb 20, 2025
0362bd2
Versioning
danielhanchen Feb 20, 2025
2969db8
Merge branch 'main' into nightly
danielhanchen Feb 20, 2025
b5eda24
Update llama.py
danielhanchen Feb 20, 2025
7de0022
Update llama.py
danielhanchen Feb 20, 2025
d4d7694
Update llama.py
danielhanchen Feb 20, 2025
0bbfbe8
Update llama.py
danielhanchen Feb 20, 2025
ae6e2bd
Update llama.py
danielhanchen Feb 20, 2025
1792deb
Update _utils.py
danielhanchen Feb 20, 2025
5dcd079
Update rl_replacements.py
danielhanchen Feb 20, 2025
ec6e0b7
Update rl_replacements.py
danielhanchen Feb 20, 2025
bc1d2ce
Update pyproject.toml
danielhanchen Feb 20, 2025
adbe38e
Update pyproject.toml
danielhanchen Feb 20, 2025
a9b542f
Export Model to ollama.com (#1648)
gjyotin305 Feb 22, 2025
f853ac0
Merge branch 'main' into nightly
danielhanchen Mar 3, 2025
9cab347
Update cross_entropy_loss.py
danielhanchen Mar 3, 2025
0ae9082
torch_cuda_device
danielhanchen Mar 3, 2025
f21314c
Update utils.py
danielhanchen Mar 3, 2025
9215212
Update utils.py
danielhanchen Mar 3, 2025
9d95aee
Update utils.py
danielhanchen Mar 3, 2025
35e9144
device
danielhanchen Mar 3, 2025
30b6f94
device
danielhanchen Mar 3, 2025
64e2b00
Update loader.py
danielhanchen Mar 3, 2025
ffa3278
Update llama.py
danielhanchen Mar 3, 2025
748c5b5
Update README.md
danielhanchen Mar 3, 2025
469ed48
Update llama.py
danielhanchen Mar 3, 2025
bc87afd
Update llama.py
danielhanchen Mar 3, 2025
ee9d6e5
Update _utils.py
danielhanchen Mar 4, 2025
91458bb
Update utils.py
danielhanchen Mar 4, 2025
a7a5d75
Update utils.py
danielhanchen Mar 4, 2025
d93cca2
Update utils.py
danielhanchen Mar 4, 2025
6e2a3a8
Update utils.py
danielhanchen Mar 4, 2025
8f9ba99
Update utils.py
danielhanchen Mar 4, 2025
ed697da
Update llama.py
danielhanchen Mar 4, 2025
d73c34b
Update llama.py
danielhanchen Mar 4, 2025
4485da7
Update llama.py
danielhanchen Mar 4, 2025
45ea48c
Update llama.py
danielhanchen Mar 4, 2025
8c4b79c
Update llama.py
danielhanchen Mar 4, 2025
c2ae510
Update utils.py
danielhanchen Mar 4, 2025
432ea24
Update utils.py
danielhanchen Mar 4, 2025
dcff03c
Update utils.py
danielhanchen Mar 4, 2025
6ef0866
Update utils.py
danielhanchen Mar 4, 2025
8c8ce96
__version__
danielhanchen Mar 4, 2025
208971b
Update rl.py
danielhanchen Mar 4, 2025
adc6977
Bug fixes
danielhanchen Mar 4, 2025
949c298
Bug fixes
danielhanchen Mar 4, 2025
ad6d962
Merge branch 'main' into nightly
danielhanchen Mar 4, 2025
59b24ad
Update llama.py
danielhanchen Mar 5, 2025
5df3936
Update _utils.py
danielhanchen Mar 5, 2025
b8b0f9c
_wrap_fast_inference
danielhanchen Mar 5, 2025
6f0857b
Update llama.py
danielhanchen Mar 5, 2025
109364b
Update llama.py
danielhanchen Mar 5, 2025
dd4bd07
Update llama.py
danielhanchen Mar 5, 2025
b356fce
Update llama.py
danielhanchen Mar 5, 2025
e022016
Update llama.py
danielhanchen Mar 5, 2025
12094a7
Update llama.py
danielhanchen Mar 5, 2025
2836128
Update llama.py
danielhanchen Mar 5, 2025
c956616
Update llama.py
danielhanchen Mar 5, 2025
e887f43
Update llama.py
danielhanchen Mar 5, 2025
95f872d
Update llama.py
danielhanchen Mar 5, 2025
647dbb4
Update llama.py
danielhanchen Mar 5, 2025
f640c8d
Update _utils.py
danielhanchen Mar 5, 2025
91a4fce
SFT dataset prepare
danielhanchen Mar 5, 2025
4495148
Update pyproject.toml
danielhanchen Mar 5, 2025
f41dff5
Update rl_replacements.py
danielhanchen Mar 5, 2025
0a3dbfa
Update rl_replacements.py
danielhanchen Mar 5, 2025
7d8f100
Update rl_replacements.py
danielhanchen Mar 5, 2025
413ea80
Update rl.py
danielhanchen Mar 5, 2025
3f5ce93
Update llama.py
danielhanchen Mar 5, 2025
185bced
Update llama.py
danielhanchen Mar 5, 2025
fd11ad7
Update utils.py
danielhanchen Mar 5, 2025
97ed0b4
bug fix
danielhanchen Mar 5, 2025
68eca88
Update llama.py
danielhanchen Mar 5, 2025
5daf9b5
Update llama.py
danielhanchen Mar 5, 2025
858bb76
Update llama.py
danielhanchen Mar 5, 2025
daedc34
Update llama.py
danielhanchen Mar 5, 2025
95e2371
Update llama.py
danielhanchen Mar 5, 2025
fccd68a
Update __init__.py
danielhanchen Mar 5, 2025
c665e0b
Update _utils.py
danielhanchen Mar 6, 2025
d207daf
Merge branch 'main' into nightly
danielhanchen Mar 6, 2025
dbf7eac
Update _utils.py
danielhanchen Mar 6, 2025
b55f6d9
Update _utils.py
danielhanchen Mar 6, 2025
c7abf7d
Update _utils.py
danielhanchen Mar 6, 2025
98d5ab0
Update _utils.py
danielhanchen Mar 6, 2025
f72794e
Update rl.py
danielhanchen Mar 6, 2025
1ec0ee2
Update rl.py
danielhanchen Mar 6, 2025
5350c6a
Update rl.py
danielhanchen Mar 6, 2025
9009ef0
Update _utils.py
danielhanchen Mar 6, 2025
7f7899d
Update __init__.py
danielhanchen Mar 6, 2025
334bd77
Update _utils.py
danielhanchen Mar 6, 2025
ade31e2
Version
danielhanchen Mar 6, 2025
a31e45b
Merge branch 'main' into nightly
danielhanchen Mar 6, 2025
8015ff2
versioning
danielhanchen Mar 6, 2025
d8777be
Update _utils.py
danielhanchen Mar 6, 2025
132b838
Update llama.py
danielhanchen Mar 6, 2025
21faa50
Update llama.py
danielhanchen Mar 6, 2025
af5d875
Merge branch 'main' into nightly
danielhanchen Mar 6, 2025
904e1c5
Bug fixes
danielhanchen Mar 7, 2025
761bb8f
FastModel
danielhanchen Mar 8, 2025
7bf880f
__doc__
danielhanchen Mar 8, 2025
c93b51b
Update vision.py
danielhanchen Mar 8, 2025
f8867be
Update loader.py
danielhanchen Mar 8, 2025
2ab1828
Update loader.py
danielhanchen Mar 8, 2025
e05baed
Update loader.py
danielhanchen Mar 8, 2025
31012a7
version
danielhanchen Mar 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ triton = [
]

huggingface = [
"unsloth_zoo>=2025.3.7",
"unsloth_zoo>=2025.3.8",
"packaging",
"tyro",
"transformers>=4.46.1,!=4.47.0",
Expand Down Expand Up @@ -354,7 +354,7 @@ colab-ampere-torch220 = [
"flash-attn>=2.6.3",
]
colab-new = [
"unsloth_zoo>=2025.3.7",
"unsloth_zoo>=2025.3.8",
"packaging",
"tyro",
"transformers>=4.46.1,!=4.47.0",
Expand Down
2 changes: 1 addition & 1 deletion unsloth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def is_bf16_supported(): return SUPPORTS_BFLOAT16
# Check for unsloth_zoo
try:
unsloth_zoo_version = importlib_version("unsloth_zoo")
if Version(unsloth_zoo_version) < Version("2025.3.7"):
if Version(unsloth_zoo_version) < Version("2025.3.8"):
try:
os.system("pip install --upgrade --no-cache-dir --no-deps unsloth_zoo")
except:
Expand Down
2 changes: 1 addition & 1 deletion unsloth/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

from .llama import FastLlamaModel
from .loader import FastLanguageModel, FastVisionModel
from .loader import FastLanguageModel, FastVisionModel, FastTextModel, FastModel
from .mistral import FastMistralModel
from .qwen2 import FastQwen2Model
from .granite import FastGraniteModel
Expand Down
2 changes: 1 addition & 1 deletion unsloth/models/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "2025.3.8"
__version__ = "2025.3.9"

__all__ = [
"SUPPORTS_BFLOAT16",
Expand Down
18 changes: 15 additions & 3 deletions unsloth/models/llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def original_apply_o(self, X):
pass

from math import sqrt as math_sqrt
KV_CACHE_INCREMENT = 256 # KV Cache update size
KV_CACHE_INCREMENT = 512 # KV Cache update size
torch_nn_functional_softmax = torch.nn.functional.softmax
# SDPA has GQA internally
SDPA_HAS_GQA = "enable_gqa" in scaled_dot_product_attention.__doc__
Expand Down Expand Up @@ -1656,6 +1656,13 @@ def from_pretrained(
"Are you certain you want to do remote code execution?"
)
pass
if fast_inference:
import platform
if platform.system().lower() == 'windows':
print("Unsloth: vLLM does not work in Windows! Will use Unsloth inference!")
fast_inference = False
pass

if token is None: token = get_token()
if model_patcher is None: model_patcher = FastLlamaModel
SUPPORTS_BFLOAT16 = is_bfloat16_supported()
Expand Down Expand Up @@ -1966,12 +1973,17 @@ def from_pretrained(
for layer in model.model.layers:
layer.self_attn.rotary_emb = rotary_emb
pass


# Add for_inference and for_training
model.for_training = functools.partial(FastLlamaModel.for_training, model)
model.for_inference = functools.partial(FastLlamaModel.for_inference, model)

# Patch generate
if model.generate.__name__ != "unsloth_fast_generate":
model._old_generate = model.generate
unsloth_fast_generate.__doc__ = model._old_generate.__doc__
model.generate = types.MethodType(unsloth_fast_generate, model)
pass
return model, tokenizer
pass

Expand Down Expand Up @@ -2404,7 +2416,7 @@ def get_peft_model(
# Add for_inference and for_training
model.for_training = functools.partial(FastLlamaModel.for_training, model)
model.for_inference = functools.partial(FastLlamaModel.for_inference, model)

# Patch generate
if model.generate.__name__ != "unsloth_fast_generate":
model._old_generate = model.generate
Expand Down
39 changes: 28 additions & 11 deletions unsloth/models/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,13 @@ def from_pretrained(
patch_loss_functions,
post_patch_loss_function,
)
from .vision import FastBaseVisionModel

from .vision import FastBaseModel
from transformers import (
AutoModelForVision2Seq,
AutoModelForCausalLM,
)

class FastVisionModel(FastBaseVisionModel):
class FastModel(FastBaseModel):
@staticmethod
def from_pretrained(
model_name = "unsloth/Llama-3.2-11B-Vision-Instruct-bnb-4bit",
Expand All @@ -413,7 +416,7 @@ def from_pretrained(
patch_compiling_bitsandbytes()
if use_gradient_checkpointing == "unsloth":
patch_unsloth_smart_gradient_checkpointing(dtype = dtype)

old_model_name = model_name
if not use_exact_model_name:
model_name = get_model_name(model_name, load_in_4bit)
Expand All @@ -427,7 +430,7 @@ def from_pretrained(
from huggingface_hub.utils import disable_progress_bars, enable_progress_bars, are_progress_bars_disabled
was_disabled = are_progress_bars_disabled()
disable_progress_bars()

autoconfig_error = None
peft_error = None
try:
Expand Down Expand Up @@ -458,7 +461,7 @@ def from_pretrained(

# Old transformers versions check
both_exist = (is_model and is_peft) and not SUPPORTS_LLAMA32

# New transformers need to check manually.
if SUPPORTS_LLAMA32:
# Check if folder exists locally
Expand Down Expand Up @@ -515,9 +518,12 @@ def from_pretrained(
if not was_disabled: enable_progress_bars()

do_logging = os.environ.get("UNSLOTH_ENABLE_LOGGING", "0") == "1"
redirector = sys.stdout if do_logging else open(os.devnull, "w")
if do_logging:
redirector = contextlib.nullcontext()
else:
redirector = contextlib.redirect_stdout(open(os.devnull, "w"))

with contextlib.redirect_stdout(redirector):
with redirector:
patch_loss_functions(torch_compile = False)
model_types = unsloth_compile_transformers(
model_name = model_name,
Expand Down Expand Up @@ -547,7 +553,6 @@ def from_pretrained(
return_logits = return_logits,
)
pass
if do_logging: redirector.close()

# Check if this is local model since the tokenizer gets overwritten
if os.path.exists(os.path.join(old_model_name, "tokenizer_config.json")) and \
Expand All @@ -559,7 +564,12 @@ def from_pretrained(
tokenizer_name = None
pass

model, tokenizer = FastBaseVisionModel.from_pretrained(
# Check if VLM
is_vlm = (x.endswith("ForConditionalGeneration") for x in model_config.architectures)
is_vlm = is_vlm or hasattr(model_config, "vision_config")
auto_model = AutoModelForVision2Seq if is_vlm else AutoModelForCausalLM

model, tokenizer = FastBaseModel.from_pretrained(
model_name = model_name,
max_seq_length = max_seq_length,
dtype = _get_dtype(dtype),
Expand All @@ -570,6 +580,7 @@ def from_pretrained(
revision = revision if not is_peft else None,
model_types = model_types,
tokenizer_name = tokenizer_name,
auto_model = auto_model,
*args, **kwargs,
)

Expand Down Expand Up @@ -617,8 +628,14 @@ def from_pretrained(
trust_remote_code = trust_remote_code,
)
# Patch it as well!
model = FastBaseVisionModel.patch_peft_model(model, use_gradient_checkpointing)
model = FastBaseModel.patch_peft_model(model, use_gradient_checkpointing)
pass
return model, tokenizer
pass
pass

class FastVisionModel(FastModel):
pass

class FastTextModel(FastModel):
pass
15 changes: 15 additions & 0 deletions unsloth/models/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,21 @@
"open-thoughts/OpenThinker-7B",
"unsloth/OpenThinker-7B-bnb-4bit",
),
"unsloth/granite-3.2-2b-instruct-unsloth-bnb-4bit" : (
"unsloth/granite-3.2-2b-instruct",
"ibm-granite/granite-3.2-2b-instruct",
"unsloth/granite-3.2-2b-instruct-bnb-4bit",
),
"unsloth/granite-3.2-8b-instruct-unsloth-bnb-4bit" : (
"unsloth/granite-3.2-8b-instruct",
"ibm-granite/granite-3.2-8b-instruct",
"unsloth/granite-3.2-8b-instruct-bnb-4bit",
),
"unsloth/QwQ-32B-unsloth-bnb-4bit" : (
"unsloth/QwQ-32B",
"Qwen/QwQ-32B",
"unsloth/QwQ-32B-bnb-4bit",
),
}

INT_TO_FLOAT_MAPPER = {}
Expand Down
Loading