Skip to content

Getting error with loading Llama unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit #1726

Closed

Description

@SnehaKumari14

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:

pip uninstall unsloth unsloth_zoo -y
pip install --upgrade --no-cache-dir "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
pip install --upgrade --no-cache-dir "git+https://github.com/unslothai/unsloth-zoo.git"

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:

I tried these steps :
pip uninstall unsloth unsloth_zoo -y
pip install --upgrade --no-cache-dir "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
pip install --upgrade --no-cache-dir "git+https://github.com/unslothai/unsloth-zoo.git"

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 .

Please help me resolve this issue.

Activity

  1. chengju-zhou commented on Feb 17, 2025

    @chengju-zhou

    same issue

  2. zuozhenLib commented on Feb 17, 2025

    @zuozhenLib

    @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.py file on you local

    import importlib.util
    unsloth_path = importlib.util.find_spec("unsloth").submodule_search_locations[0]
    
    # TODO: modify {unsloth_path}/models/mapper.py
    

    You will find your local mapper.py is 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:

    "unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit" : (
            "unsloth/Meta-Llama-3.1-8B-Instruct",
            "meta-llama/Meta-Llama-3.1-8B-Instruct",
            "unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bit",
        ),
    

    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.py version 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)

  3. ilyes-bk commented on Feb 17, 2025

    @ilyes-bk

    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"

  4. ayan4m1 commented on Mar 29, 2025

    @ayan4m1

    Try adding --force-reinstall to the pip install commands for unsloth and unsloth_zoo.

  5. shimmyshimmer commented on May 9, 2025

    @shimmyshimmer
    Member

    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?

  6. danielhanchen commented on Jun 18, 2026

    @danielhanchen
    Member

    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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions