You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Getting error with loading Llama unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit #1726
I am training LLama 3.1 8B instrcut . I am getting this error -
🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.
🦥 Unsloth Zoo will now patch everything to make training faster!
2025-02-16 22:37:37,972 - INFO - Successfully initialized W&B logging
2025-02-16 22:37:37,973 - INFO - Loading model and tokenizer: unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit
2025-02-16 22:37:38,039 - ERROR - Failed to load model/tokenizer: Unsloth: unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit is not supported in your current Unsloth version! Please update Unsloth via:
2025-02-16 22:37:38,039 - ERROR - Training script failed: Unsloth: unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit is not supported in your current Unsloth version! Please update Unsloth via:
then also its not working . I trained thismodel before . I was working fine . But after recent changes in the hugging face repository, its not working .
just add one more line on your previous version unsloth. Notice the reinstall of unsloth will overwrite this modification.
Hi @danielhanchen, thank you for your huge contribute to unsloth. Maybe this is not the correct way to fix this. But given base model name = 'unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit' and if I wish to use previous version with this base model, seems it is the only way I can do. Otherwise we need to update the latest version of mapper.py (but we are not developer :>)
Explaination
with the base model 'unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit'. The issue comes here
Source code for reference
NEW_INT_TO_FLOAT_MAPPER, NEW_FLOAT_TO_INT_MAPPER, NEW_MAP_TO_UNSLOTH_16bit = _get_new_mapper()
def get_model_name(model_name, load_in_4bit = True):
new_model_name = __get_model_name(
model_name = model_name,
load_in_4bit = load_in_4bit,
INT_TO_FLOAT_MAPPER = INT_TO_FLOAT_MAPPER,
FLOAT_TO_INT_MAPPER = FLOAT_TO_INT_MAPPER,
MAP_TO_UNSLOTH_16bit = MAP_TO_UNSLOTH_16bit,
)
if new_model_name is None and model_name.count("/") == 1 and model_name[0].isalnum():
# Try checking if a new Unsloth version allows it!
NEW_INT_TO_FLOAT_MAPPER, NEW_FLOAT_TO_INT_MAPPER, NEW_MAP_TO_UNSLOTH_16bit = _get_new_mapper()
upgraded_model_name = __get_model_name(
model_name = model_name,
load_in_4bit = load_in_4bit,
INT_TO_FLOAT_MAPPER = NEW_INT_TO_FLOAT_MAPPER,
FLOAT_TO_INT_MAPPER = NEW_FLOAT_TO_INT_MAPPER,
MAP_TO_UNSLOTH_16bit = NEW_MAP_TO_UNSLOTH_16bit,
)
if upgraded_model_name is not None:
raise NotImplementedError(
f"Unsloth: {model_name} is not supported in your current Unsloth version! Please update Unsloth via:\n\n"\
'pip uninstall unsloth unsloth_zoo -y\n'\
'pip install --upgrade --no-cache-dir "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"\n'\
'pip install --upgrade --no-cache-dir "git+https://github.com/unslothai/unsloth-zoo.git"\n'\
)
pass
pass
return new_model_name if new_model_name is not None else model_name
def _get_new_mapper():
try:
import requests
new_mapper = "https://raw.githubusercontent.com/unslothai/unsloth/main/unsloth/models/mapper.py"
with requests.get(new_mapper, timeout = 3) as new_mapper: new_mapper = new_mapper.text
new_mapper = new_mapper[new_mapper.find("__INT_TO_FLOAT_MAPPER"):]
new_mapper = new_mapper\
.replace("INT_TO_FLOAT_MAPPER", "NEW_INT_TO_FLOAT_MAPPER")\
.replace("FLOAT_TO_INT_MAPPER", "NEW_FLOAT_TO_INT_MAPPER")\
.replace("MAP_TO_UNSLOTH_16bit", "NEW_MAP_TO_UNSLOTH_16bit")
exec(new_mapper, globals())
return NEW_INT_TO_FLOAT_MAPPER, NEW_FLOAT_TO_INT_MAPPER, NEW_MAP_TO_UNSLOTH_16bit
except:
return {}, {}, {}
pass
pass
in above _get_new_mapper, it always refer to the latest mapper.py. And it will raise NotImplementedError here. However, because the mapper.py is kept updating, it will lead to the error above. You can compare the mapper.py version from github, you will find the latest update on this file lead to above error.
Lets take model_name='unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit' as a example, with previous mapper.pyversion 2024-11, the model name will not in the FLOAT_TO_INT_MAPPER dictionary, but after it refer to the latest mapper.py version here by _get_new_mapper() function. Even I didn't update my unsloth, the model name will be found in NEW_FLOAT_TO_INT_MAPPER dictionary with this latest version mapper.py. Means we are running on 2024.11.7 and then the script will check whether the model name on latest version mapper.py and then it raise above error. Need to read about the function get_model_name above which related to the FLOAT_TO_INT_MAPPER AND NEW_FLOAT_TO_INT_MAPPER dictionary, if new_model_name and upgraded_model_name are both None, it will return original model name. However, if new_model_name is None but upgraded_model_name is not None , it will raise an Error (Hope I stated clear)
it worked for me by updating unsloth and fixing trl on 0.12.0 and unsloth_zoo==2025.2.3 and using "unsloth/Meta-Llama-3.1-8B-Instruct" with "load_in_4bit=True"
Hi guys really unsure why you're getting this issue? We tested it on Colab with it and it works perfectly fine. Do you guys have any code we can look at?
This should be fixed now - sorry on the delay - please update with uv pip install --upgrade unsloth unsloth_zoo --force-reinstall --no-cache-dir - if it's not fixed yet, it'll be in the next pip / PyPI release - if it's still not working after that, please open another issue - appreciate it again!
Activity
chengju-zhou commentedon Feb 17, 2025
same issue
zuozhenLib commentedon Feb 17, 2025
@SnehaKumari14 K Hi, I had the same issue, but now I fixed it by editing the source code.
My env: unsloth==2024.11.7
Solution:
don't need to update the unsloth to the latest. With your previous used version of unsloth, edit the
mapper.pyfile on you localYou will find your local
mapper.pyis almost the code here, notice the link is from previous version.To make things correct, you only need to modified above part as below and save:
just add one more line on your previous version unsloth. Notice the reinstall of unsloth will overwrite this modification.
Hi @danielhanchen, thank you for your huge contribute to unsloth. Maybe this is not the correct way to fix this. But given base model name = 'unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit' and if I wish to use previous version with this base model, seems it is the only way I can do. Otherwise we need to update the latest version of
mapper.py(but we are not developer :>)Explaination
with the base model 'unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit'. The issue comes here
Source code for reference
in above
_get_new_mapper, it always refer to the latestmapper.py. And it will raise NotImplementedError here. However, because themapper.pyis kept updating, it will lead to the error above. You can compare themapper.pyversion from github, you will find the latest update on this file lead to above error.Lets take model_name='unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit' as a example, with previous
mapper.pyversion 2024-11, the model name will not in theFLOAT_TO_INT_MAPPERdictionary, but after it refer to the latestmapper.pyversion here by_get_new_mapper()function. Even I didn't update my unsloth, the model name will be found inNEW_FLOAT_TO_INT_MAPPERdictionary with this latest versionmapper.py. Means we are running on 2024.11.7 and then the script will check whether the model name on latest versionmapper.pyand then it raise above error. Need to read about the functionget_model_nameabove which related to theFLOAT_TO_INT_MAPPERANDNEW_FLOAT_TO_INT_MAPPERdictionary, ifnew_model_nameandupgraded_model_nameare both None, it will return original model name. However, ifnew_model_nameis None butupgraded_model_nameis not None , it will raise an Error (Hope I stated clear)ilyes-bk commentedon Feb 17, 2025
it worked for me by updating unsloth and fixing trl on 0.12.0 and unsloth_zoo==2025.2.3 and using "unsloth/Meta-Llama-3.1-8B-Instruct" with "load_in_4bit=True"
ayan4m1 commentedon Mar 29, 2025
Try adding
--force-reinstallto the pip install commands for unsloth and unsloth_zoo.shimmyshimmer commentedon May 9, 2025
Hi guys really unsure why you're getting this issue? We tested it on Colab with it and it works perfectly fine. Do you guys have any code we can look at?
danielhanchen commentedon Jun 18, 2026
This should be fixed now - sorry on the delay - please update with
uv pip install --upgrade unsloth unsloth_zoo --force-reinstall --no-cache-dir- if it's not fixed yet, it'll be in the next pip / PyPI release - if it's still not working after that, please open another issue - appreciate it again!