Repository navigation
Closed
Labels
Description
when execute:
from unsloth import FastLanguageModel # unsloth must import before trl
from omegaconf import OmegaConf
from trl import SFTTrainer, SFTConfig
from data.dataset import get_dataset
NUM_GPUS = 8
config = OmegaConf.load("conf/default.yaml")
print(config)
# 加载模型
model, tokenizer = FastLanguageModel.from_pretrained(
config.model.pretrained_model,
max_seq_length=config.data.max_length,
load_in_4bit=False,
load_in_8bit=False,
full_finetuning=True, # We have full finetuning now!
)
raise error:
Traceback (most recent call last):
File "/usr/local/miniconda3/lib/python3.10/site-packages/unsloth_zoo/compiler.py", line 433, in create_new_function
new_module, old_path = import_module(compile_folder, name)
File "/usr/local/miniconda3/lib/python3.10/site-packages/unsloth_zoo/compiler.py", line 428, in import_module
new_module = importlib.import_module(name)
File "/usr/local/miniconda3/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/export/App/training_platform/PinoModel/unsloth_compiled_cache/Linear_peft_forward.py", line 42, in <module>
def unsloth_forward(self, x: torch.Tensor, *args: Any, **kwargs: Any) -> torch.Tensor:
NameError: name 'Any' is not defined. Did you mean: 'any'?
unsloth: 2025.6.12
unsloth-zoo: 2025.6.8
Reacted by Nikolai Kolodziej, Radim Tylecek, Antoine Delplace and Matteo Nizard
Activity
woct0rdho commentedon Jul 3, 2025
We need to add a line:
after https://github.com/unslothai/unsloth-zoo/blob/362fb45ee5906052bf09a43f1052c578159069ac/unsloth_zoo/compiler.py#L1283
wasimysaid commentedon Jul 3, 2025
same thing
Apolsus commentedon Jul 3, 2025
A quick fix is adding this code before loading models
Note that this is not a permanent solution
Datta0 commentedon Jul 4, 2025
Hey @Apolsus can you please share the generated
Linear_peft_forward.pyfile? Ideally it should havefrom peft.tuners.lora.layer import (Any, F, nn, torch)which should take care of the importsAlso would be helpful if you can point me to the version of peft you're using
rtylecek commentedon Jul 4, 2025
Same issue here. I am getting only
from peft.tuners.lora.inc import (torch)inLinear_peft_forward.pyFull header:
antoinedelplace commentedon Jul 4, 2025
I did
before
to make it work.
rolandtannous commentedon Jul 10, 2025
@antoinedelplace @rtylecek @Apolsus @Shine1i
we just made a new release that should solve this problem for you.
If you're running the code on a local vm, make sure to upgrade your install of unsloth via
pip install --force-reinstall --upgrade unsloth-zoo
pip install --force-reinstall --upgrade unsloth
On the other hand, If you're running the notebooks on colab no need to do introduce any changes to the install cells as the notebook will grab the newest version from pypi for you anyway.
Make sure to leave a comment if this doesn't work out for you with the necessary details and code snippets that would allow us to reproduce the errors you're observing and we'll take it from there.
danielhanchen commentedon Jul 17, 2025
Yep please update Unsloth: