Skip to content
Merged

TTS #2545

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1003 commits
Select commit Hold shift + click to select a range
558b052
Update rl_replacements.py
danielhanchen Mar 18, 2025
800a465
Update vision.py
danielhanchen Mar 18, 2025
8753a59
Update rl_replacements.py
danielhanchen Mar 18, 2025
0f73f12
Merge branch 'main' into nightly
danielhanchen Mar 18, 2025
2c41fc9
Update vision.py
danielhanchen Mar 18, 2025
645493d
Update vision.py
danielhanchen Mar 19, 2025
f19967e
Update vision.py
danielhanchen Mar 19, 2025
0f20d66
Update vision.py
danielhanchen Mar 19, 2025
369ce00
Update vision.py
danielhanchen Mar 19, 2025
1098955
Update vision.py
danielhanchen Mar 19, 2025
c6b956f
Remove double generate patch
danielhanchen Mar 19, 2025
d1ee347
Update vision.py
danielhanchen Mar 19, 2025
9e04f88
Update vision.py
danielhanchen Mar 19, 2025
36c052c
Update vision.py
danielhanchen Mar 19, 2025
8f3658a
Update vision.py
danielhanchen Mar 19, 2025
8aaaa44
Update vision.py
danielhanchen Mar 19, 2025
0b95576
Update mapper.py
danielhanchen Mar 19, 2025
cca0d38
Update vision.py
danielhanchen Mar 19, 2025
7d47557
fix: config.torch_dtype in LlamaModel_fast_forward_inference (#2091)
lurf21 Mar 19, 2025
50490c0
versioning
danielhanchen Mar 19, 2025
fd150a1
Merge branch 'nightly' of https://github.com/unslothai/unsloth into n…
danielhanchen Mar 19, 2025
a38e5cb
Update vision.py
danielhanchen Mar 19, 2025
58f3c94
Update vision.py
danielhanchen Mar 19, 2025
d2f1688
Update vision.py
danielhanchen Mar 19, 2025
b785bf6
Update vision.py
danielhanchen Mar 19, 2025
418ad9a
Update vision.py
danielhanchen Mar 19, 2025
88f8a2e
Update vision.py
danielhanchen Mar 19, 2025
95b4e83
Update vision.py
danielhanchen Mar 19, 2025
2ef2724
Update vision.py
danielhanchen Mar 19, 2025
1b2b2d2
Update vision.py
danielhanchen Mar 19, 2025
8fda1f0
Update vision.py
danielhanchen Mar 19, 2025
3bbdb99
model_type_arch
danielhanchen Mar 19, 2025
e7128de
Update vision.py
danielhanchen Mar 19, 2025
37dd658
Update vision.py
danielhanchen Mar 19, 2025
d1edf54
Update vision.py
danielhanchen Mar 19, 2025
a9cbff5
Update vision.py
danielhanchen Mar 19, 2025
d45b1b1
Update vision.py
danielhanchen Mar 19, 2025
013b185
Update vision.py
danielhanchen Mar 19, 2025
03e91ef
Merge branch 'main' into nightly
danielhanchen Mar 19, 2025
7c71307
Merge branch 'main' into nightly
danielhanchen Mar 19, 2025
33d1b8f
Update loader.py
danielhanchen Mar 19, 2025
8ad7e95
check
danielhanchen Mar 19, 2025
d40ebf6
Update _utils.py
danielhanchen Mar 19, 2025
167b4bd
Update loader.py
danielhanchen Mar 19, 2025
67d169a
Update loader.py
danielhanchen Mar 19, 2025
cf949ba
Remove prints
danielhanchen Mar 19, 2025
9ec6833
Update README.md
jackswl Mar 20, 2025
3e8149d
Merge branch 'main' into nightly
danielhanchen Mar 21, 2025
a747009
Update _utils.py
danielhanchen Mar 21, 2025
372979e
Update _utils.py
danielhanchen Mar 21, 2025
8bffb7a
versioning
danielhanchen Mar 21, 2025
cd49eaf
Update _utils.py
danielhanchen Mar 21, 2025
d94e161
Update _utils.py
danielhanchen Mar 21, 2025
2d4c407
Update _utils.py
danielhanchen Mar 21, 2025
fa910ab
Update llama.py
danielhanchen Mar 21, 2025
7cd95f5
Update llama.py
danielhanchen Mar 21, 2025
a0ebbb2
Update llama.py
danielhanchen Mar 21, 2025
6b5bab8
Update llama.py
danielhanchen Mar 21, 2025
b728a01
Update llama.py
danielhanchen Mar 21, 2025
25ca0f8
Update llama.py
danielhanchen Mar 21, 2025
6de5694
Update llama.py
danielhanchen Mar 21, 2025
f63306b
Update llama.py
danielhanchen Mar 21, 2025
f016b01
Update llama.py
danielhanchen Mar 21, 2025
b5f6727
Update llama.py
danielhanchen Mar 21, 2025
1718438
Update llama.py
danielhanchen Mar 21, 2025
6ff1aa2
Update llama.py
danielhanchen Mar 21, 2025
f26f772
Update llama.py
danielhanchen Mar 21, 2025
18ab3c1
Update llama.py
danielhanchen Mar 21, 2025
38dd9d1
Update llama.py
danielhanchen Mar 22, 2025
ebb10cd
Update llama.py
danielhanchen Mar 22, 2025
beecad0
Update llama.py
danielhanchen Mar 22, 2025
e716e15
Update llama.py
danielhanchen Mar 22, 2025
62e4ae5
Update llama.py
danielhanchen Mar 22, 2025
1eba050
Update llama.py
danielhanchen Mar 22, 2025
a015c38
Update llama.py
danielhanchen Mar 22, 2025
0c995e8
Update llama.py
danielhanchen Mar 22, 2025
5ba0878
Update llama.py
danielhanchen Mar 22, 2025
cd5e195
Update llama.py
danielhanchen Mar 22, 2025
855695d
Update llama.py
danielhanchen Mar 22, 2025
4d7e3a1
Update vision.py
danielhanchen Mar 22, 2025
33194f1
HF Transfer
danielhanchen Mar 22, 2025
ef71732
fix(utils): add missing importlib import to fix NameError (#2134)
naliazheli Mar 22, 2025
1d7b570
Add QLoRA Train and Merge16bit Test (#2130)
jeromeku Mar 22, 2025
167b482
Update pyproject.toml
danielhanchen Mar 22, 2025
d28b929
Merge branch 'main' into nightly
danielhanchen Mar 22, 2025
2064656
Merge branch 'main' into nightly
danielhanchen Mar 22, 2025
3fdfff8
Update vision.py
danielhanchen Mar 26, 2025
172fe3c
Update vision.py
danielhanchen Mar 26, 2025
da6ad9f
Update vision.py
danielhanchen Mar 26, 2025
781887f
Update vision.py
danielhanchen Mar 26, 2025
fce9e82
Update loader.py
danielhanchen Mar 26, 2025
9ceabbe
Update loader.py
danielhanchen Mar 26, 2025
87dc533
Revert
danielhanchen Mar 26, 2025
cafd05e
Update vision.py
danielhanchen Mar 26, 2025
6ebcae0
Update vision.py
danielhanchen Mar 26, 2025
9f34d47
Update vision.py
danielhanchen Mar 26, 2025
26b0c83
Update vision.py
danielhanchen Mar 26, 2025
f9dd304
Update vision.py
danielhanchen Mar 26, 2025
10cfe62
Bug fix
danielhanchen Mar 26, 2025
bfa1b9f
Update mapper.py
danielhanchen Mar 26, 2025
b3c2975
check SDPA for Mistral 3, Pixtral
danielhanchen Mar 26, 2025
75ce106
Update vision.py
danielhanchen Mar 26, 2025
86c6060
Versioning
danielhanchen Mar 26, 2025
d4c0550
Update rl_replacements.py
danielhanchen Mar 26, 2025
c493054
Merge branch 'main' into nightly
danielhanchen Mar 26, 2025
0b2b903
Update README.md
jackswl Mar 26, 2025
f6dfa80
add model registry
jeromeku Mar 28, 2025
a5e7b3a
move hf hub utils to unsloth/utils
jeromeku Mar 28, 2025
dc8f34e
refactor global model info dicts to dataclasses
jeromeku Mar 30, 2025
7cd2763
fix dataclass init
jeromeku Mar 30, 2025
9899a72
fix llama registration
jeromeku Mar 30, 2025
310c598
remove deprecated key function
jeromeku Mar 30, 2025
e70d035
start registry reog
jeromeku Mar 30, 2025
de1fe25
add llama vision
jeromeku Mar 30, 2025
7e2207c
quant types -> Enum
jeromeku Mar 30, 2025
c3a1aff
remap literal quant types to QuantType Enum
jeromeku Mar 30, 2025
03de6df
add llama model registration
jeromeku Mar 30, 2025
fa95aa0
fix quant tag mapping
jeromeku Mar 30, 2025
fdafa78
add qwen2.5 models to registry
jeromeku Mar 31, 2025
6049310
add option to include original model in registry
jeromeku Mar 31, 2025
8dc3d66
handle quant types per model size
jeromeku Mar 31, 2025
1237075
separate registration of base and instruct llama3.2
jeromeku Mar 31, 2025
baab018
add QwenQVQ to registry
jeromeku Mar 31, 2025
6b08fc3
add gemma3 to registry
jeromeku Mar 31, 2025
44e227b
add phi
jeromeku Mar 31, 2025
d633179
add deepseek v3
jeromeku Mar 31, 2025
0755b45
add deepseek r1 base
jeromeku Mar 31, 2025
17358e6
add deepseek r1 zero
jeromeku Mar 31, 2025
975d263
add deepseek distill llama
jeromeku Mar 31, 2025
229ae10
add deepseek distill models
jeromeku Mar 31, 2025
6439e88
remove redundant code when constructing model names
jeromeku Mar 31, 2025
4e1df71
add mistral small to registry
jeromeku Mar 31, 2025
6d4ede4
rename model registration methods
jeromeku Apr 1, 2025
a774726
rename deepseek registration methods
jeromeku Apr 1, 2025
a2a4366
refactor naming for mistral and phi
jeromeku Apr 1, 2025
02fbb87
add global register models
jeromeku Apr 1, 2025
7fbde42
refactor model registration tests for new registry apis
jeromeku Apr 1, 2025
a2d3ad9
add model search method
jeromeku Apr 1, 2025
13a1126
remove deprecated registration api
jeromeku Apr 1, 2025
4840a32
add quant type test
jeromeku Apr 1, 2025
7d64639
add registry readme
jeromeku Apr 1, 2025
12b0d32
make llama registration more specific
jeromeku Apr 1, 2025
ea75001
clear registry when executing individual model registration file
jeromeku Apr 1, 2025
d854070
more registry readme updates
jeromeku Apr 1, 2025
2a4a274
Merge branch 'main' into nightly
danielhanchen Apr 1, 2025
03ab51d
Merge pull request #2255 from jeromeku/registry-refactor
shimmyshimmer Apr 2, 2025
0c95691
Merge pull request #2119 from jackswl/patch-1
shimmyshimmer Apr 3, 2025
0c1b3ff
Update _auto_install.py
danielhanchen Apr 5, 2025
d5e1880
Llama4
danielhanchen Apr 6, 2025
56f14e8
Merge branch 'main' into nightly
danielhanchen Apr 10, 2025
1d10f0e
Merge branch 'main' into nightly
danielhanchen Apr 20, 2025
cc2c02c
Merge branch 'main' into nightly
danielhanchen Apr 26, 2025
6dbf677
Merge branch 'main' into nightly
danielhanchen Apr 30, 2025
98177a0
Update synthetic.py
danielhanchen Apr 30, 2025
c217c75
Update synthetic.py
danielhanchen Apr 30, 2025
49d610e
Update synthetic.py
danielhanchen Apr 30, 2025
63698fc
Update synthetic.py
danielhanchen Apr 30, 2025
5b138c7
Update synthetic.py
danielhanchen Apr 30, 2025
c5d632a
Update synthetic.py
danielhanchen Apr 30, 2025
d25f93c
Update synthetic.py
danielhanchen Apr 30, 2025
ad45d26
Update synthetic.py
danielhanchen Apr 30, 2025
4874c72
Update synthetic.py
danielhanchen Apr 30, 2025
95f595a
Update synthetic.py
danielhanchen Apr 30, 2025
de0dbc6
Update synthetic.py
danielhanchen Apr 30, 2025
0ea2279
Synthetic data
danielhanchen Apr 30, 2025
3329c77
Merge branch 'main' into nightly
danielhanchen Apr 30, 2025
d1845c7
Update mapper.py
danielhanchen Apr 30, 2025
64d21f8
Xet and Synthetic
danielhanchen Apr 30, 2025
f522381
Update synthetic.py
danielhanchen Apr 30, 2025
9687fb3
Update loader.py
danielhanchen Apr 30, 2025
0d323a3
Update synthetic.py
danielhanchen Apr 30, 2025
c49d5ff
Update synthetic.py
danielhanchen Apr 30, 2025
c48079b
Update synthetic.py
danielhanchen Apr 30, 2025
1dd6034
Update synthetic.py
danielhanchen Apr 30, 2025
9ae987c
Update synthetic.py
danielhanchen Apr 30, 2025
ccf7065
Update synthetic.py
danielhanchen Apr 30, 2025
376cb9a
Update synthetic.py
danielhanchen Apr 30, 2025
9827a68
Update synthetic.py
danielhanchen Apr 30, 2025
9e6b59e
Update synthetic.py
danielhanchen Apr 30, 2025
fd9f3dc
Update synthetic.py
danielhanchen Apr 30, 2025
3f346e7
Update synthetic.py
danielhanchen Apr 30, 2025
74f42ba
Update synthetic.py
danielhanchen Apr 30, 2025
6dc3383
Update synthetic.py
danielhanchen Apr 30, 2025
7e3849f
Update synthetic.py
danielhanchen Apr 30, 2025
afcbb2c
Update synthetic.py
danielhanchen Apr 30, 2025
49b3343
Update synthetic.py
danielhanchen Apr 30, 2025
f3475b4
Update synthetic.py
danielhanchen Apr 30, 2025
7d5a8b3
Update synthetic.py
danielhanchen Apr 30, 2025
c50c039
Update synthetic.py
danielhanchen Apr 30, 2025
e85e987
Update synthetic.py
danielhanchen Apr 30, 2025
270f02f
Update synthetic.py
danielhanchen Apr 30, 2025
5a05158
Update synthetic.py
danielhanchen Apr 30, 2025
a536173
Update synthetic.py
danielhanchen Apr 30, 2025
90783f7
Update synthetic.py
danielhanchen Apr 30, 2025
eb37b78
Update synthetic.py
danielhanchen Apr 30, 2025
ecdd496
Update synthetic.py
danielhanchen Apr 30, 2025
050306f
Update synthetic.py
danielhanchen Apr 30, 2025
b7ac229
Update pyproject.toml
danielhanchen May 1, 2025
0ee8529
Delete .gitignore
danielhanchen May 1, 2025
bd36d00
Merge branch 'main' into nightly
danielhanchen May 1, 2025
be60490
Update synthetic.py
danielhanchen May 1, 2025
b645497
Update synthetic.py
danielhanchen May 1, 2025
3840255
Update synthetic.py
danielhanchen May 1, 2025
4c4f194
Update synthetic.py
danielhanchen May 1, 2025
5dd52bf
Update synthetic.py
danielhanchen May 1, 2025
8f28047
Update synthetic.py
danielhanchen May 1, 2025
791bfdd
Update synthetic.py
danielhanchen May 1, 2025
e319c96
Update synthetic.py
danielhanchen May 1, 2025
b4798c5
Update synthetic.py
danielhanchen May 1, 2025
b32e2f9
Update synthetic.py
danielhanchen May 1, 2025
1e7ca2f
Update synthetic.py
danielhanchen May 1, 2025
dbd3089
Update synthetic.py
danielhanchen May 1, 2025
6f2d524
Update synthetic.py
danielhanchen May 1, 2025
f8db408
Update synthetic.py
danielhanchen May 1, 2025
cd170e2
Update synthetic.py
danielhanchen May 1, 2025
c874a24
Update synthetic.py
danielhanchen May 1, 2025
152cde6
Update synthetic.py
danielhanchen May 1, 2025
984ca31
Update _utils.py
danielhanchen May 1, 2025
95bc443
Update pyproject.toml
danielhanchen May 1, 2025
d11d060
Update synthetic.py
danielhanchen May 1, 2025
4f3fe1b
Update synthetic.py
danielhanchen May 1, 2025
8154746
Merge branch 'main' into nightly
danielhanchen May 13, 2025
cb02396
Update synthetic.py
danielhanchen May 13, 2025
8ae377a
Update synthetic.py
danielhanchen May 13, 2025
0f7a8b8
Merge branch 'main' into nightly
danielhanchen May 15, 2025
50860ef
Merge branch 'main' into nightly
danielhanchen May 15, 2025
6304676
Update chat_templates.py
danielhanchen May 15, 2025
70c13c4
Seasame force float16 / float32
danielhanchen May 15, 2025
40d8b88
Fix Seasame
danielhanchen May 15, 2025
5684e86
Update loader.py
danielhanchen May 15, 2025
6b6521a
Update vision.py
danielhanchen May 15, 2025
8de07a1
Update vision.py
danielhanchen May 15, 2025
9a7bc91
Update vision.py
danielhanchen May 15, 2025
7502614
Update loader.py
danielhanchen May 15, 2025
636aa9b
is_multimodal
danielhanchen May 15, 2025
fcb3aa7
Update loader.py
danielhanchen May 15, 2025
3aa8a91
Update loader.py
danielhanchen May 15, 2025
c96d7b1
Update loader.py
danielhanchen May 15, 2025
45a85eb
Update loader.py
danielhanchen May 15, 2025
f8f4589
Update vision.py
danielhanchen May 15, 2025
a8c5b6f
Update vision.py
danielhanchen May 15, 2025
8a5b99d
Update vision.py
danielhanchen May 15, 2025
1bb1174
UNSLOTH_DISABLE_STATIC_GENERATION
danielhanchen May 15, 2025
ba6fd2f
Update vision.py
danielhanchen May 15, 2025
8b8ccff
Auto vision detection
danielhanchen May 15, 2025
c504076
Sesame
danielhanchen May 15, 2025
1b142f4
Whisper
danielhanchen May 15, 2025
1ba3128
Update loader.py
danielhanchen May 15, 2025
01f50b0
Update loader.py
danielhanchen May 15, 2025
a0df20a
Update loader.py
danielhanchen May 15, 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 @@ -37,7 +37,7 @@ triton = [
]

huggingface = [
"unsloth_zoo>=2025.5.5",
"unsloth_zoo>=2025.5.6",
"packaging",
"tyro",
"transformers==4.51.3,!=4.47.0",
Expand Down Expand Up @@ -381,7 +381,7 @@ colab-ampere-torch220 = [
"flash-attn>=2.6.3",
]
colab-new = [
"unsloth_zoo>=2025.5.5",
"unsloth_zoo>=2025.5.6",
"packaging",
"tyro",
"transformers==4.51.3,!=4.47.0",
Expand Down
31 changes: 24 additions & 7 deletions unsloth/chat_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1036,9 +1036,21 @@
{%- endif %}
{%- endif %}
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
{%- for message in messages[::-1] %}
{%- for forward_message in messages %}
{%- set index = (messages|length - 1) - loop.index0 %}
{%- if ns.multi_step_tool and message.role == "user" and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
{%- set message = messages[index] %}
{%- set current_content = message.content if message.content is not none else '' %}
{%- set tool_start = '<tool_response>' %}
{%- set tool_start_length = tool_start|length %}
{%- set start_of_message = current_content[:tool_start_length] %}
{%- set tool_end = '</tool_response>' %}
{%- set tool_end_length = tool_end|length %}
{%- set start_pos = (current_content|length) - tool_end_length %}
{%- if start_pos < 0 %}
{%- set start_pos = 0 %}
{%- endif %}
{%- set end_of_message = current_content[start_pos:] %}
{%- if ns.multi_step_tool and message.role == "user" and not(start_of_message == tool_start and end_of_message == tool_end) %}
{%- set ns.multi_step_tool = false %}
{%- set ns.last_query_index = index %}
{%- endif %}
Expand All @@ -1053,8 +1065,9 @@
{%- set reasoning_content = message.reasoning_content %}
{%- else %}
{%- if '</think>' in message.content %}
{%- set content = message.content.split('</think>')[-1].lstrip('\n') %}
{%- set reasoning_content = message.content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
{%- set content = (message.content.split('</think>')|last).lstrip('\n') %}
{%- set reasoning_content = (message.content.split('</think>')|first).rstrip('\n') %}
{%- set reasoning_content = (reasoning_content.split('<think>')|last).lstrip('\n') %}
{%- endif %}
{%- endif %}
{%- if loop.index0 > ns.last_query_index %}
Expand Down Expand Up @@ -1110,7 +1123,7 @@
qwen3_ollama = \
'''
FROM {__FILE_LOCATION__}
TEMPLATE """{{ if .Messages }}
TEMPLATE """{{- if .Messages }}
{{- if or .System .Tools }}<|im_start|>system
{{- if .System }}
{{ .System }}
Expand Down Expand Up @@ -1161,8 +1174,12 @@
{{ end }}<|im_start|>assistant
{{ end }}{{ .Response }}{{ if .Response }}<|im_end|>{{ end }}"""
PARAMETER stop "<|im_end|>"
PARAMETER temperature 1.5
PARAMETER min_p 0.1
PARAMETER stop "<|im_start|>"
PARAMETER temperature 0.6
PARAMETER min_p 0.0
PARAMETER top_k 20
PARAMETER top_p 0.95
PARAMETER repeat_penalty 1
'''

qwen3_template_eos_token = "<|im_end|>"
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.5.3"
__version__ = "2025.5.4"

__all__ = [
"SUPPORTS_BFLOAT16",
Expand Down
6 changes: 4 additions & 2 deletions unsloth/models/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,12 @@ def from_pretrained(
if transformers_version < Version("4.50.0.dev0"):
raise RuntimeError("Unsloth: Granite Vision only works on transformers >= 4.50.0." + NIGHTLY)
elif "csm-1b" in model_name.lower():
os.environ["UNSLOTH_COMPILE_DISABLE"] = "1"
os.environ["UNSLOTH_DISABLE_FAST_GENERATION"] = "1"
os.environ["UNSLOTH_DISABLE_STATIC_GENERATION"] = "1" # Sesame fails
os.environ["UNSLOTH_FORCE_CUSTOM_DTYPE"] = "torch.float16;if name.endswith(('_proj', 'fc1', 'fc2', 'codebook', 'head')): module.to(torch.float16)"
elif "olmo-2" in model_name.lower() and transformers_version < Version("4.50.0.dev0"):
raise RuntimeError("Unsloth: OLMo-2 only works on transformers >= 4.50.0." + NIGHTLY)
elif "whisper" in model_name.lower():
os.environ["UNSLOTH_DISABLE_STATIC_GENERATION"] = "1" # Whisper fails
pass

if USE_MODELSCOPE and not os.path.exists(model_name):
Expand Down
20 changes: 20 additions & 0 deletions unsloth/models/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,26 @@
"microsoft/Phi-4-mini-reasoning",
"unsloth/phi-4-mini-reasoning-bnb-4bit",
),
"unsloth/csm-1b" : (
"unsloth/csm-1b",
"sesame/csm-1b",
),
"unsloth/whisper-large-v3" : (
"unsloth/whisper-large-v3",
"openai/whisper-large-v3",
),
"unsloth/whisper-large-v3-turbo" : (
"unsloth/whisper-large-v3-turbo",
"openai/whisper-large-v3-turbo",
),
"unsloth/whisper-small" : (
"unsloth/whisper-small",
"openai/whisper-small",
),
"unsloth/CrisperWhisper" : (
"unsloth/CrisperWhisper",
"nyrahealth/CrisperWhisper",
),
}

INT_TO_FLOAT_MAPPER = {}
Expand Down
31 changes: 27 additions & 4 deletions unsloth/models/vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ def unsloth_base_fast_generate(
# Use hybrid if sliding window seen, otherwise try static
cache_implementation = getattr(self.config, "cache_implementation", None)
if getattr(self, "_supports_static_cache", True):
cache_implementation = "static"
if os.environ.get("UNSLOTH_DISABLE_STATIC_GENERATION", "0") == "0":
cache_implementation = "static"
else:
cache_implementation = None
else:
cache_implementation = None
if cache_implementation is not None:
Expand All @@ -199,10 +202,10 @@ def unsloth_base_fast_generate(
cache_implementation = "hybrid"
if "generation_config" in kwargs:
kwargs["generation_config"].cache_implementation = cache_implementation
kwargs["generation_config"].compile_config = _compile_config
kwargs["generation_config"].compile_config = _compile_config if cache_implementation is not None else None
else:
kwargs["cache_implementation"] = cache_implementation
kwargs["compile_config"] = _compile_config
kwargs["compile_config"] = _compile_config if cache_implementation is not None else None
pass

try:
Expand Down Expand Up @@ -310,6 +313,19 @@ def from_pretrained(
bnb_compute_dtype = torch.float16
do_forced_float32 = True
pass

# Check for custom data-types
custom_datatype = None
correct_dtype = None
if os.environ.get("UNSLOTH_FORCE_CUSTOM_DTYPE", "") != "":
custom_datatype = os.environ["UNSLOTH_FORCE_CUSTOM_DTYPE"]
assert custom_datatype.count(";") == 1
bnb_compute_dtype, custom_datatype = custom_datatype.split(";", 1)
dtype = torch.float32
bnb_compute_dtype = eval(bnb_compute_dtype)
correct_dtype = bnb_compute_dtype
pass

# Stop SDPA for some archs like Pixtral / Mistral3
if not ("attn_implementation" in kwargs):
kwargs["attn_implementation"] = "sdpa"
Expand Down Expand Up @@ -374,12 +390,18 @@ def from_pretrained(
# Return old flag
os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = old_hf_transfer

# Edit data-types
if custom_datatype is not None:
for name, module in model.named_modules():
exec(custom_datatype)
pass

# Counteract saved tokenizers
tokenizer_name = model_name if tokenizer_name is None else tokenizer_name
is_vlm = (auto_model is AutoModelForVision2Seq)
is_whisper = (whisper_language is not None and whisper_task is not None)
auto_processor = AutoProcessor if (is_vlm or is_whisper) else AutoTokenizer
if whisper_language and whisper_task:
if (whisper_language and whisper_task) or auto_model.__name__.endswith("ForConditionalGeneration"):
tokenizer = auto_processor.from_pretrained(
tokenizer_name,
padding_side = "right",
Expand Down Expand Up @@ -415,6 +437,7 @@ def from_pretrained(
downcast_rope = False,
fix_embeddings = False,
do_forced_float32 = do_forced_float32,
correct_dtype = correct_dtype,
)
model, tokenizer = patch_tokenizer(model, tokenizer)
model = post_patch_loss_function(model)
Expand Down