Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
348 commits
Select commit Hold shift + click to select a range
87758b9
Update loader.py
danielhanchen Aug 21, 2025
97d34d4
Update loader.py
danielhanchen Aug 21, 2025
43bf41f
Update loader.py
danielhanchen Aug 21, 2025
6e7ad52
Update loader.py
danielhanchen Aug 21, 2025
d605aa7
Update loader.py
danielhanchen Aug 21, 2025
f417dc8
Update loader.py
danielhanchen Aug 21, 2025
05fe3d1
Update loader.py
danielhanchen Aug 21, 2025
a79d6f6
Update loader.py
danielhanchen Aug 21, 2025
59702c4
Update loader.py
danielhanchen Aug 21, 2025
1b66aee
Update loader.py
danielhanchen Aug 21, 2025
a71fa05
Update loader.py
danielhanchen Aug 21, 2025
d3e8625
Update loader.py
danielhanchen Aug 21, 2025
fb112cf
Update loader.py
danielhanchen Aug 21, 2025
5dbdcc5
Update loader.py
danielhanchen Aug 21, 2025
fdaa007
Update loader.py
danielhanchen Aug 21, 2025
ba0eb04
Bug fix
danielhanchen Aug 21, 2025
3f98262
Update loader.py
danielhanchen Aug 21, 2025
3e6511b
Update loader.py
danielhanchen Aug 21, 2025
c9e7537
Update loader.py
danielhanchen Aug 21, 2025
2e38e8a
Update loader.py
danielhanchen Aug 22, 2025
8b3a8ba
Update loader.py
danielhanchen Aug 22, 2025
f706d20
torch_dtype
danielhanchen Aug 22, 2025
bf863a8
Merge branch 'main' into nightly
danielhanchen Aug 28, 2025
84ca61f
Merge branch 'main' into nightly
danielhanchen Aug 30, 2025
e82fd70
Merge branch 'main' into nightly
danielhanchen Sep 4, 2025
c61a21d
Merge branch 'main' into nightly
danielhanchen Sep 4, 2025
b56cc1b
Update rl.py
danielhanchen Sep 4, 2025
c47f936
Fix CE Loss
danielhanchen Sep 4, 2025
6093c4c
Merge branch 'main' into nightly
danielhanchen Sep 4, 2025
0b896c5
Versioning
danielhanchen Sep 4, 2025
327f517
Merge branch 'main' into nightly
danielhanchen Sep 4, 2025
5b0c47a
Merge branch 'main' into nightly
danielhanchen Sep 8, 2025
de5c3b5
Merge branch 'main' into nightly
danielhanchen Sep 9, 2025
7234a62
Update loader.py
danielhanchen Sep 9, 2025
68c1aba
Update loader.py
danielhanchen Sep 9, 2025
d07b819
Merge branch 'main' into nightly
danielhanchen Sep 9, 2025
05fc2f2
extract_model_type_from_config
danielhanchen Sep 9, 2025
99c7afb
Model types
danielhanchen Sep 10, 2025
fc5d91d
Update loader.py
danielhanchen Sep 10, 2025
702a9ea
get_transformers_model_type
danielhanchen Sep 10, 2025
8ece4a6
Update loader.py
danielhanchen Sep 10, 2025
f3ac0e3
Update loader.py
danielhanchen Sep 10, 2025
d2b0d41
Update loader.py
danielhanchen Sep 10, 2025
e5920fe
Update rl.py
danielhanchen Sep 10, 2025
bf0367e
Update pyproject.toml
danielhanchen Sep 10, 2025
d2c2cc1
Update loader.py
danielhanchen Sep 10, 2025
337557c
Merge branch 'main' into nightly
danielhanchen Sep 10, 2025
b038d5d
Merge branch 'main' into nightly
danielhanchen Sep 10, 2025
39da8b4
Merge branch 'main' into nightly
danielhanchen Sep 13, 2025
35ca177
Update loader.py
danielhanchen Sep 13, 2025
2eaf868
Update loader.py
danielhanchen Sep 13, 2025
7c892e7
Update loader.py
danielhanchen Sep 13, 2025
72ff24c
Versioning
danielhanchen Sep 14, 2025
9654895
Merge branch 'main' into nightly
danielhanchen Sep 15, 2025
227842c
Update _utils.py
danielhanchen Sep 15, 2025
505ae67
Update _utils.py
danielhanchen Sep 15, 2025
80465dc
Update _utils.py
danielhanchen Sep 15, 2025
4150e08
Update _utils.py
danielhanchen Sep 15, 2025
27bae35
Merge branch 'main' into nightly
danielhanchen Sep 15, 2025
7d4bf8d
Merge branch 'main' into nightly
danielhanchen Sep 15, 2025
e1f981b
Merge branch 'main' into nightly
danielhanchen Sep 16, 2025
032c2c8
Update vision.py
danielhanchen Sep 16, 2025
b105aae
Update vision.py
danielhanchen Sep 16, 2025
400df38
Fix DataParallel
danielhanchen Sep 16, 2025
809a8b3
Update _utils.py
danielhanchen Sep 16, 2025
a5c7fa6
Merge branch 'main' into nightly
danielhanchen Sep 16, 2025
78627e5
Merge branch 'main' into nightly
danielhanchen Sep 17, 2025
3dcc091
Update rl.py
danielhanchen Sep 17, 2025
28b1d50
Update synthetic.py
danielhanchen Sep 17, 2025
de162d3
Update synthetic.py
danielhanchen Sep 17, 2025
a507a7d
Update synthetic.py
danielhanchen Sep 17, 2025
cda7263
Update synthetic.py
danielhanchen Sep 17, 2025
dd8ad92
Update synthetic.py
danielhanchen Sep 17, 2025
a725b98
Update synthetic.py
danielhanchen Sep 17, 2025
321f1a3
Update synthetic.py
danielhanchen Sep 17, 2025
357e501
Update synthetic.py
danielhanchen Sep 17, 2025
8a03656
Update synthetic.py
danielhanchen Sep 17, 2025
d7832d0
Update synthetic.py
danielhanchen Sep 17, 2025
84f5434
Update synthetic.py
danielhanchen Sep 17, 2025
17b2e98
Update synthetic.py
danielhanchen Sep 17, 2025
58f658e
Merge branch 'main' into nightly
danielhanchen Sep 17, 2025
5364138
Update mapper.py
danielhanchen Sep 17, 2025
8dbd008
Versioning
danielhanchen Sep 17, 2025
256f8fe
Merge branch 'main' into nightly
danielhanchen Sep 18, 2025
d7ca79f
Update loader.py
danielhanchen Sep 18, 2025
bb90785
Update loader.py
danielhanchen Sep 18, 2025
3289826
Update rl.py
danielhanchen Sep 18, 2025
a042114
Versioning
danielhanchen Sep 18, 2025
dfa91f7
Merge branch 'main' into nightly
danielhanchen Sep 18, 2025
ffa04dd
Update _utils.py
danielhanchen Sep 18, 2025
b365444
Fix auto_mapping
danielhanchen Sep 19, 2025
c60dfb0
Merge branch 'main' into nightly
danielhanchen Sep 19, 2025
bbb8252
Merge branch 'main' into nightly
danielhanchen Sep 19, 2025
f88e880
Merge branch 'main' into nightly
danielhanchen Sep 20, 2025
5ce7bf8
Update loader.py
danielhanchen Sep 20, 2025
755e6e2
Update loader.py
danielhanchen Sep 20, 2025
d01b8af
Update vision.py
danielhanchen Sep 20, 2025
d048d3a
Update vision.py
danielhanchen Sep 21, 2025
81ba78e
Update loader.py
danielhanchen Sep 21, 2025
0bb74fe
Message
danielhanchen Sep 21, 2025
14fdb22
Update vision.py
danielhanchen Sep 21, 2025
ce4f2b6
Update loader.py
danielhanchen Sep 21, 2025
e333b03
Update vision.py
danielhanchen Sep 21, 2025
456d225
cache_implementation
danielhanchen Sep 21, 2025
1cd7b85
Update vision.py
danielhanchen Sep 21, 2025
2b0d219
Update loader.py
danielhanchen Sep 21, 2025
d1c9283
Update vision.py
danielhanchen Sep 21, 2025
a0df6ab
Update vision.py
danielhanchen Sep 21, 2025
450b2da
Update vision.py
danielhanchen Sep 21, 2025
b1116d5
Update loader.py
danielhanchen Sep 21, 2025
7210cb1
Update vision.py
danielhanchen Sep 21, 2025
f148170
Save max_seq_length
danielhanchen Sep 21, 2025
7fa66da
Update _utils.py
danielhanchen Sep 21, 2025
0b49db1
Update rl.py
danielhanchen Sep 22, 2025
f1c47f8
Update vision.py
danielhanchen Sep 22, 2025
27f6203
Update llama.py
danielhanchen Sep 22, 2025
f06179f
Mistral3 vllm (#3349)
Datta0 Sep 22, 2025
67a544d
Set padding to 0
danielhanchen Sep 22, 2025
7238327
Fix patch
danielhanchen Sep 23, 2025
8a1e6fb
fixup patch (#3359)
danielhanchen Sep 23, 2025
f0ec1ae
Update vision.py
danielhanchen Sep 23, 2025
a64a3b2
Versioning
danielhanchen Sep 23, 2025
1b7640b
Update vision.py
danielhanchen Sep 23, 2025
f5c4385
Update vision.py
danielhanchen Sep 24, 2025
8438a76
Update vision.py
danielhanchen Sep 24, 2025
5867273
Update vision.py
danielhanchen Sep 24, 2025
7b2bef1
Update vision.py
danielhanchen Sep 24, 2025
82a7697
Update vision.py
danielhanchen Sep 24, 2025
aa9b200
Update vision.py
danielhanchen Sep 24, 2025
eb1df23
Update vision.py
danielhanchen Sep 24, 2025
563aa35
Update vision.py
danielhanchen Sep 24, 2025
4bfde2e
Update vision.py
danielhanchen Sep 24, 2025
d6beafe
MXFP4 dequant
danielhanchen Sep 24, 2025
19cfe1b
Update loader.py
danielhanchen Sep 24, 2025
63a7f65
Update vision.py
danielhanchen Sep 24, 2025
df5282b
load_in_16bit
danielhanchen Sep 24, 2025
e7174b1
Update vision.py
danielhanchen Sep 24, 2025
ffe5aca
Update vision.py
danielhanchen Sep 24, 2025
81356cc
Update vision.py
danielhanchen Sep 24, 2025
2313ea9
Update rl.py
danielhanchen Sep 25, 2025
0c18d86
Update vision.py
danielhanchen Sep 26, 2025
19017fd
offload_embedding
danielhanchen Sep 26, 2025
77fca79
Update vision.py
danielhanchen Sep 26, 2025
92084ba
Update vision.py
danielhanchen Sep 26, 2025
499f939
Update vision.py
danielhanchen Sep 26, 2025
402af41
Merge branch 'main' into nightly
danielhanchen Sep 26, 2025
07723f5
Merge branch 'main' into nightly
danielhanchen Sep 26, 2025
7a499e4
Merge branch 'main' into nightly
danielhanchen Sep 26, 2025
fffcea8
Merge branch 'main' into nightly
danielhanchen Sep 28, 2025
f72c0a9
Update vision.py
danielhanchen Sep 28, 2025
2a7cfa0
Update vision.py
danielhanchen Sep 28, 2025
2577d81
Update vision.py
danielhanchen Sep 28, 2025
1eee987
Update rl_replacements.py
danielhanchen Sep 30, 2025
e7f3170
Merge branch 'main' into nightly
danielhanchen Sep 30, 2025
1edc796
Update loader.py
danielhanchen Sep 30, 2025
205d09c
Fix padding issue
danielhanchen Sep 30, 2025
07cc6ed
Update pyproject.toml
danielhanchen Sep 30, 2025
d225f7f
Update _utils.py
danielhanchen Sep 30, 2025
5d6c3d9
Update pyproject.toml
danielhanchen Sep 30, 2025
af56af3
Update _utils.py
danielhanchen Sep 30, 2025
ad080bb
Merge branch 'main' into nightly
danielhanchen Oct 1, 2025
eb2d403
Update vision.py
danielhanchen Oct 1, 2025
9bc76e8
Update vision.py
danielhanchen Oct 1, 2025
a0425bb
Update vision.py
danielhanchen Oct 1, 2025
b0ba73c
Update vision.py
danielhanchen Oct 1, 2025
f85a91a
Update vision.py
danielhanchen Oct 1, 2025
80dce6b
Merge branch 'main' into nightly
danielhanchen Oct 5, 2025
47f2ef7
Update vision.py
danielhanchen Oct 5, 2025
06fc86f
New models
danielhanchen Oct 5, 2025
dcf22c8
Merge branch 'main' into nightly
danielhanchen Oct 5, 2025
ca3426a
Merge branch 'main' into nightly
danielhanchen Oct 14, 2025
8a09a7d
Merge branch 'main' into nightly
danielhanchen Oct 14, 2025
20b9202
Merge branch 'main' into nightly
danielhanchen Oct 16, 2025
778da7d
Update llama.py
danielhanchen Oct 16, 2025
ed443ee
Versioning
danielhanchen Oct 16, 2025
da00e2f
Update _utils.py
danielhanchen Oct 16, 2025
250ea60
Update llama.py
danielhanchen Oct 16, 2025
a921ea6
Update _utils.py
danielhanchen Oct 16, 2025
f1e76eb
Merge branch 'main' into nightly
danielhanchen Oct 16, 2025
c90df87
Update llama.py
danielhanchen Oct 16, 2025
c64f011
Fix AMD
danielhanchen Oct 16, 2025
8eecf7d
Update _utils.py
danielhanchen Oct 16, 2025
c22b9a3
Update llama.py
danielhanchen Oct 16, 2025
38b9e00
Update vision.py
danielhanchen Oct 16, 2025
b99dcd5
DEVICE_TYPE_TORCH
danielhanchen Oct 16, 2025
19bc977
Update __init__.py
danielhanchen Oct 16, 2025
5aa6a39
Update __init__.py
danielhanchen Oct 16, 2025
597cf05
Merge branch 'main' into nightly
danielhanchen Oct 16, 2025
cbeb4be
Merge branch 'main' into nightly
danielhanchen Oct 17, 2025
0576c13
Update _utils.py
danielhanchen Oct 17, 2025
ee46343
Move DEVICE_TYPE
danielhanchen Oct 17, 2025
09fd925
Update rl_replacements.py
danielhanchen Oct 17, 2025
bd22cb1
Update loader.py
danielhanchen Oct 17, 2025
9fe4d31
AMD install script
danielhanchen Oct 17, 2025
3026498
Move AMD
danielhanchen Oct 17, 2025
c8150dc
Update _amd_install.sh
danielhanchen Oct 17, 2025
f25c365
Update pyproject.toml
danielhanchen Oct 17, 2025
2b470fd
Merge branch 'main' into nightly
danielhanchen Oct 17, 2025
315c2cf
Update pyproject.toml
danielhanchen Oct 17, 2025
b5d3df8
Delete _amd_install.sh
danielhanchen Oct 17, 2025
55dd1f6
Update device_type.py
danielhanchen Oct 17, 2025
0960fe4
Update loader.py
danielhanchen Oct 17, 2025
cb8c2bb
Merge branch 'main' into nightly
danielhanchen Oct 19, 2025
5f0d9fa
Update _utils.py
danielhanchen Oct 20, 2025
1f726a4
Update _utils.py
danielhanchen Oct 20, 2025
8d29c64
Update _utils.py
danielhanchen Oct 20, 2025
0e9fb1d
Update _utils.py
danielhanchen Oct 20, 2025
9950e27
Update _utils.py
danielhanchen Oct 20, 2025
d995f71
Update tokenizer_utils.py
danielhanchen Oct 20, 2025
c4db81b
Versioning
danielhanchen Oct 20, 2025
ea37dd6
Update pyproject.toml
danielhanchen Oct 20, 2025
5ff7234
Update loader.py
danielhanchen Oct 20, 2025
47c2dd6
Update _utils.py
danielhanchen Oct 20, 2025
ead800e
Update pyproject.toml
danielhanchen Oct 20, 2025
2dc2420
Update pyproject.toml
danielhanchen Oct 20, 2025
eba9bb3
Update _utils.py
danielhanchen Oct 20, 2025
3c3765c
Update pyproject.toml
danielhanchen Oct 20, 2025
367d6dc
Update _utils.py
danielhanchen Oct 20, 2025
ca3f688
Update _utils.py
danielhanchen Oct 20, 2025
f6dd92b
Update loader.py
danielhanchen Oct 20, 2025
1393bd8
Update _utils.py
danielhanchen Oct 20, 2025
0da8129
Update _utils.py
danielhanchen Oct 20, 2025
0a2ce91
local_files_only
danielhanchen Oct 20, 2025
c9f5c1a
Cut Cross Entropy
danielhanchen Oct 20, 2025
7613541
Update llama.py
danielhanchen Oct 20, 2025
df98380
Merge branch 'main' into nightly
danielhanchen Oct 20, 2025
2014012
Merge branch 'main' into nightly
danielhanchen Oct 22, 2025
e7572ea
Merge branch 'main' into nightly
danielhanchen Oct 22, 2025
f21d215
Merge branch 'main' into nightly
danielhanchen Oct 23, 2025
764fafb
Merge branch 'main' into nightly
danielhanchen Oct 27, 2025
79a62ee
Merge branch 'main' into nightly
danielhanchen Oct 28, 2025
fe7227b
Merge branch 'main' into nightly
danielhanchen Oct 30, 2025
0965781
Update vision.py
danielhanchen Oct 30, 2025
6bf04ce
Update vision.py
danielhanchen Oct 30, 2025
7ea715e
Update vision.py
danielhanchen Oct 30, 2025
dbe1eae
Merge branch 'main' into nightly
danielhanchen Oct 30, 2025
97f2a84
Merge branch 'main' into nightly
danielhanchen Oct 30, 2025
1d5ed23
Qwen 3 VL vLLM (#3489)
Datta0 Oct 31, 2025
9e71dd9
Update __init__.py
danielhanchen Oct 31, 2025
d3aa31e
patch_torchao
danielhanchen Oct 31, 2025
65ba577
torchao_logger
danielhanchen Oct 31, 2025
59e8eb8
Merge branch 'main' into nightly
danielhanchen Nov 2, 2025
c79e957
Update rl_replacements.py
danielhanchen Nov 2, 2025
df8763f
Fix
danielhanchen Nov 2, 2025
716e71c
Update rl.py
danielhanchen Nov 3, 2025
a3ed184
Update rl.py
danielhanchen Nov 3, 2025
549dfb4
Update rl.py
danielhanchen Nov 3, 2025
fc3a577
Update rl.py
danielhanchen Nov 3, 2025
839ccbf
Update _utils.py
danielhanchen Nov 3, 2025
6cd3f52
Versioning
danielhanchen Nov 3, 2025
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ huggingfacenotorch = [
"hf_transfer",
"diffusers",
"transformers>=4.51.3,!=4.52.0,!=4.52.1,!=4.52.2,!=4.52.3,!=4.53.0,!=4.54.0,!=4.55.0,!=4.55.1,!=4.57.0,<=4.57.2",
"trl>=0.18.2,!=0.19.0,<=0.23.0",
"trl>=0.18.2,!=0.19.0,<=0.24.0",
]
huggingface = [
"unsloth[huggingfacenotorch]",
"unsloth_zoo>=2025.10.13",
"unsloth_zoo>=2025.11.1",
"torchvision",
"unsloth[triton]",
]
Expand Down Expand Up @@ -489,7 +489,7 @@ colab-ampere-torch220 = [
"flash-attn>=2.6.3 ; ('linux' in sys_platform)",
]
colab-new = [
"unsloth_zoo>=2025.10.13",
"unsloth_zoo>=2025.11.1",
"packaging",
"tyro",
"transformers>=4.51.3,!=4.52.0,!=4.52.1,!=4.52.2,!=4.52.3,!=4.53.0,!=4.54.0,!=4.55.0,!=4.55.1,!=4.57.0,<=4.57.2",
Expand All @@ -507,7 +507,7 @@ colab-new = [
]
colab-no-deps = [
"accelerate>=0.34.1",
"trl>=0.18.2,!=0.19.0,<=0.23.0",
"trl>=0.18.2,!=0.19.0,<=0.24.0",
"peft>=0.7.1",
"xformers ; ('linux' in sys_platform or sys_platform == 'win32') and (platform_machine == 'AMD64' or platform_machine == 'x86_64')",
"bitsandbytes>=0.45.5,!=0.46.0,!=0.48.0",
Expand Down
19 changes: 9 additions & 10 deletions unsloth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
# their code at import time. If they're imported first, the original (slower,
# more memory-intensive) implementations will be used instead of Unsloth's
# optimized versions, potentially causing OOM errors or slower training.

if already_imported:
# stacklevel=2 makes warning point to user's import line rather than this library code,
# showing them exactly where to fix the import order in their script
Expand All @@ -40,7 +39,7 @@
f"Please restructure your imports with 'import unsloth' at the top of your file.",
stacklevel = 2,
)
pass
del already_imported, critical_modules

# Unsloth currently does not work on multi GPU setups - sadly we are a 2 brother team so
# enabling it will require much more work, so we have to prioritize. Please understand!
Expand All @@ -57,14 +56,12 @@
# Log Unsloth is being used
os.environ["UNSLOTH_IS_PRESENT"] = "1"

import importlib.util
from pathlib import Path
from importlib.metadata import version as importlib_version
from importlib.metadata import PackageNotFoundError
# Check for unsloth_zoo
try:
unsloth_zoo_version = importlib_version("unsloth_zoo")
if Version(unsloth_zoo_version) < Version("2025.10.13"):
if Version(unsloth_zoo_version) < Version("2025.11.1"):
print(
"Unsloth: Please update Unsloth and Unsloth-Zoo to the latest version!\n"\
"Do this via `pip install --upgrade --force-reinstall --no-cache-dir --no-deps unsloth unsloth_zoo`"
Expand All @@ -82,7 +79,7 @@
raise ImportError(f"Unsloth: Please install unsloth_zoo via `pip install unsloth_zoo` then retry!")
except:
raise
pass
del PackageNotFoundError, importlib_version

# Try importing PyTorch and check version
try:
Expand All @@ -92,8 +89,8 @@
"Unsloth: Pytorch is not installed. Go to https://pytorch.org/.\n"\
"We have some installation instructions on our Github page."
)
except Exception as exception:
raise exception
except:
raise
pass

from unsloth_zoo.device_type import (
Expand Down Expand Up @@ -130,7 +127,7 @@ def is_bf16_supported(including_emulation = False):
else:
def is_bf16_supported(): return SUPPORTS_BFLOAT16
torch.cuda.is_bf16_supported = is_bf16_supported
pass
del major_version, minor_version
elif DEVICE_TYPE == "hip":
SUPPORTS_BFLOAT16 = torch.cuda.is_bf16_supported()
elif DEVICE_TYPE == "xpu":
Expand Down Expand Up @@ -179,6 +176,8 @@ def is_bf16_supported(): return SUPPORTS_BFLOAT16
latest_cuda = np.argsort([float(find_number.search(x).group(1)) for x in possible_cudas])[::-1][0]
latest_cuda = possible_cudas[latest_cuda]
os.system(f"ldconfig /usr/local/{latest_cuda}")
del find_number, latest_cuda
del possible_cudas, find_cuda
pass

importlib.reload(bnb)
Expand All @@ -200,7 +199,7 @@ def is_bf16_supported(): return SUPPORTS_BFLOAT16
"Also try `sudo ldconfig /usr/local/cuda-xx.x` - find the latest cuda version.\n"\
"Unsloth will still run for now, but maybe it might crash - let's hope it works!"
)
pass
del libcuda_dirs
elif DEVICE_TYPE == "hip":
# NO-OP for rocm device
pass
Expand Down
5 changes: 4 additions & 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.10.12"
__version__ = "2025.11.1"

__all__ = [
"SUPPORTS_BFLOAT16",
Expand Down Expand Up @@ -235,6 +235,9 @@ def filter(self, x): return not (self.text in x.getMessage())
# No label_names provided for model class
from transformers.trainer import logger as transformers_trainer_logger
transformers_trainer_logger.addFilter(HideLoggingMessage("No label_names"))

# The tokenizer has new PAD/BOS/EOS tokens that differ from the model config and generation config.
transformers_trainer_logger.addFilter(HideLoggingMessage("The tokenizer has new"))
del transformers_trainer_logger

# Using the default loss: `ForCausalLMLoss`.
Expand Down
13 changes: 8 additions & 5 deletions unsloth/models/rl.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,11 +752,11 @@ def _patch_trl_rl_trainers(trainer_file = "grpo_trainer"):
" scale_rewards = False\n"\
"elif loss_type.lower() == 'dapo':\n"\
" if mask_truncated_completions != True:\n"\
" print('Unsloth: The DAPO paper recommends `mask_truncated_completions = True`')\n"\
" print('Unsloth: The DAPO paper recommends `mask_truncated_completions = True` - we will set it.')\n"\
" if epsilon_high != 0.28:\n"\
" print('Unsloth: The DAPO paper recommends `epsilon_high = 0.28`')\n"\
" print('Unsloth: The DAPO paper recommends `epsilon_high = 0.28` - we will set it.')\n"\
" if beta != 0.0:\n"\
" print('Unsloth: The DAPO paper recommends setting `beta = 0.0` to remove the KL term')\n"\
" print('Unsloth: The DAPO paper recommends setting `beta = 0.0` to remove the KL term - we will set it.')\n"\
" mask_truncated_completions = True\n"\
" epsilon_high = 0.28\n"\
" beta = 0.0\n"\
Expand Down Expand Up @@ -1085,10 +1085,13 @@ def patch_functions(RLTrainer, trainer_file, RLTrainer_name, all_imports, import
)

# Replace self.llm.generate and self.llm.chat
lora_name = trainer_file + "_lora_model"
if "CUDA_VISIBLE_DEVICES" in os.environ:
lora_name = trainer_file + "_lora_model_' + " + "(os.environ.get('CUDA_VISIBLE_DEVICES', '0').replace(',',''))"
else:
lora_name = trainer_file + "_lora_model'"
source = re.sub(
r"(self\.llm\.(?:generate|chat)\([^\)]{1,})\)",
r"\1, lora_request = self.model.load_lora('" + lora_name + r"', load_tensors = True))",
r"\1, lora_request = self.model.load_lora('" + lora_name + r", load_tensors = True))",
source
)
# Prefer using unsloth's sampling params and fallback to trl's if not found
Expand Down
8 changes: 4 additions & 4 deletions unsloth/models/rl_replacements.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,17 @@ def grpo_trainer__generate_and_score_completions(function_name, function):
replacement_lines = """
batch_size = self.args.per_device_train_batch_size if mode == "train" else self.args.per_device_eval_batch_size
try:
#TRL 0.23.1 and below path
# TRL 0.23.1 and below path
if not has_images:
# Left pad prompt before calculation old and ref hidden states
prompt_completion_ids = left_pack_padding(prompt_completion_ids, self.processing_class.pad_token_id)
self.model.for_training()
except:
#TRL 0.24.0 and below path
except:
# TRL 0.24.0 and below path
if images is None:
# Left pad prompt before calculation old and ref hidden states
prompt_completion_ids = left_pack_padding(prompt_completion_ids, self.processing_class.pad_token_id)
self.model.for_training()"""
self.model.for_training()"""

function = function.replace(line_to_replace, replacement_lines)

Expand Down
1 change: 1 addition & 0 deletions unsloth/models/vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"qwen2_5_vl",
"gemma3",
"mistral3",
"qwen3_vl",
]
VLLM_NON_LORA_VLM = [
"mllama",
Expand Down