Skip to content

Applying LoRA Doesn't Change Model Output #2009

Closed

Description

@SpaceHunterInf

Greetings,

I am extremely confused why my model generates consistent result w/o my rank=64 LoRA. What's even more confusing is, the LoRA works in my notebook after training. But whenn I start fresh, loading the LoRA again, it gives the output of the original model.

model_name=="Qwen/Qwen2.5-1.5B-Instruct",
vllm==0.7.3
trl==0.15.2
unsloth==2025.2.14
unsloth_zoo==2025.2.7

So I followed the tutorial notebook, trained the model using GRPO trainer. Then within the notebook, I model.save_lora("grpo_saved_lora"), then I do this using vllm with greedy decoding:

sampling_params = SamplingParams(
    max_tokens=32,  # Maximum number of tokens to generate
    temperature=0,  # Temperature of 0 means no randomness (deterministic)
    top_p=1.0,      # Consider all tokens in the distribution
    top_k=1         # Only select the most likely token at each step
)

outputs = model.fast_generate(
    test_split,
    sampling_params = sampling_params,
    lora_request = model.load_lora("grpo_saved_lora"),
)

These are all fine, I have different set of output compare with before training. But then, when I try to load the model lora with a separate script. The output is suddenly consistent with the original model, even I loaded the lora in this way.

cfg = load_config(args.config)
    model, tokenizer = FastLanguageModel.from_pretrained(
        model_name=cfg.model_name,
        max_seq_length=cfg.max_seq_length,
        load_in_4bit=cfg.load_in_4bit,
        fast_inference=cfg.fast_inference,
        max_lora_rank=cfg.lora_rank,
        gpu_memory_utilization=cfg.gpu_memory_utilization,
    )
    lora = None
    
    if args.lora_path is not None:
        model = FastLanguageModel.get_peft_model(
            model,
            r=cfg.lora_rank,
            target_modules=cfg.target_modules,
            lora_alpha=cfg.lora_rank,
            use_gradient_checkpointing="unsloth",
            random_state=3407,
        )
        lora = model.load_lora(args.lora_path)
        print('using lora ' + args.lora_path)
            
    _, _, test_dataset = get_dataset("ecqa")
    
    sampling_params = SamplingParams( # Greedy decoding
        max_tokens=32,  # Maximum number of tokens to generate
        temperature=0,  # Temperature of 0 means no randomness (deterministic)
        top_p=1.0,      # Consider all tokens in the distribution
        top_k=1         # Only select the most likely token at each step
    )
    
    vllm_prompts = [x['prompt'] for x in test_dataset]
    
    outputs = model.fast_generate(
        vllm_prompts,
        sampling_params = sampling_params,
        lora_request = lora
    )

Could you please help me? I am really confused.

Thank you very much.

Activity

  1. JangDongHyeon11 commented on Mar 14, 2025

    @JangDongHyeon11

    I have the same issue.
    When merging models using LoRA, the model does not change.
    It seems that all models trained after the latest Unsloth update have this issue.

    However, models trained previously do not have this problem.

  2. FloLey commented on Mar 14, 2025

    @FloLey

    I think this is the same issue as all those:
    #1670
    #1763
    #1877
    #1929
    #1971

  3. SpaceHunterInf commented on Mar 14, 2025

    @SpaceHunterInf
    Author

    Yeah... it seems like it's the exact same issue. I am using the lastest release though. Have you ever find any workaround for this except using the resume_training trick? How do othe people saving trained model now? I thought this should be some urgent bug that needs to be fixed.

    So everyone else just finetune the entire model instead of using LoRA???

  4. SpaceHunterInf commented on Mar 14, 2025

    @SpaceHunterInf
    Author

    I have the same issue. When merging models using LoRA, the model does not change. It seems that all models trained after the latest Unsloth update have this issue.

    However, models trained previously do not have this problem.

    Could you please share the version number that you were using? So you just downgrade and everything works again?

  5. FloLey commented on Mar 15, 2025

    @FloLey

    Yeah... it seems like it's the exact same issue. I am using the lastest release though. Have you ever find any workaround for this except using the resume_training trick? How do othe people saving trained model now? I thought this should be some urgent bug that needs to be fixed.

    So everyone else just finetune the entire model instead of using LoRA???

    No idea, I've been waiting for this to be fixed or for someone to explain how to work around the issue, as I need the LoRA merged with the base model as well. I've seen this issue pop up multiple times already, so I'm trying to track this to get attention to it, but I don't want to put pressure on the owners of this repo.

  6. llzllx70 commented on Mar 16, 2025

    @llzllx70

    I meet the same issue too, a big bug!

  7. kalachx commented on Mar 16, 2025

    @kalachx

    I would say it is not only big bug but a complete deal breaker for the project. Such issues show complete lack of testing being done before making releases.
    If something as mundane as saving model doesn't work then what certainty can I have that other features work? For example whole models might have bugs because each model family needs specific support and why there are always patches for new models - since no one tests this stuff how do I know some older model family still works?
    Change something, do wrong tests (read: see that training starts and not that it actually works) or no tests at all and then user sits there waiting for their model to cook to then end up disappointed. As new user I experience only frustration and zero results. Did thousands of GPRO training steps and nothing. Model behaves identical to untrained model.

  8. danielhanchen commented on Mar 16, 2025

    @danielhanchen
    Member

    Hi apologies everyone - let me investigate and I'll see what I can do to fix the issue!

  9. Alpacolypse commented on Mar 17, 2025

    @Alpacolypse

    Is anyone aware of a workaround for this issue?

  10. shimmyshimmer commented on Mar 18, 2025

    @shimmyshimmer
    Member

    So we investigated the issue and were able to reproduce the issue (results after merging in 16-bit are same as before training).

    However, we checked that _merge_lora is working as expected and that the base_layer weights before / after merging are indeed different by roughly the magnitude of B @ A (since the scale factor is 1 per the default Qwen-GRPO notebook).

    We will need to conduct a deeper investigation into this thank you.

    Do you guys know when this issue started firstly occuring?

  11. danielhanchen commented on Mar 18, 2025

    @danielhanchen
    Member

    Apologies on the issue - I might, but not 100% sure might have fixed the issue - if you guys still have the trained LoRA on your disk, could you try model.load_lora( "directory", load_tensors = False) ie use load_tensors = False as the extra argument

  12. llzllx70 commented on Mar 18, 2025

    @llzllx70

    Image

    [rank0]: File "~/anaconda3/envs/Unsloth/lib/python3.10/site-packages/unsloth_zoo/vllm_utils.py", line 1202, in load_lora
    [rank0]: raise OSError(f"Unsloth: LoRA filepath = {save_directory} does not exist!")

    [rank0]: OSError: Unsloth: LoRA filepath = grpo_saved_lora does not exist!

  13. danielhanchen commented on Mar 18, 2025

    @danielhanchen
    Member

    Hmmm ok let me see if I can bypass the checks - again apologies!

  14. JangDongHyeon commented on Mar 18, 2025

    @JangDongHyeon

    Currently, the issue is not only with GRPO, but also when training the model with LoRA and merging it, the model does not change.

  15. shimmyshimmer commented on Mar 18, 2025

    @shimmyshimmer
    Member

    Hi guys we have likely resolved the issue. Please update unsloth and let us know if it works! Thank you

  16. 24 remaining items

  17. danielhanchen commented on Mar 21, 2025

    @danielhanchen
    Member

    Hey guys - apologies on the delay - specifically for GRPO - it's fixed! I also made an advanced GRPO notebook which is actually much better than the original - it uses an A100 and does LoRA on Llama 3.2 3B, since it was faster.

    NO NEED to retrain LoRA - if you saved it, then reload it! Unsloth inference is now fully fixed in the original GRPO and advanced notebook. (Please use advanced since I added many more reward functions, and it's much better for convergence!

    Advanced Colab notebook: https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Advanced_Llama3_1_(3B)_GRPO_LoRA.ipynb

    I also show the previous model without GRPO for the question "What is the sqrt of 101?"

    Image

    The trained GRPO on the same question - which definitely show it's working!

    Image

    Using the following works without changing code - I fixed model.lora_lora

    output = model.fast_generate(
        text,
        sampling_params = sampling_params,
        lora_request = model.load_lora("grpo_saved_lora"),
    )[0].outputs[0].text

    I also restarted the entire Colab, and just load the LoRA via the above (without training), and it worked correctly!

    You can test if the LoRA is working by just counting the formatting:

    no_trained_outputs = model.fast_generate(
        [text]*30,
        sampling_params = sampling_params,
        lora_request = None,
    )
    no_trained_outputs = [x.outputs[0].text for x in no_trained_outputs]
    trained_outputs = model.fast_generate(
        [text]*30,
        sampling_params = sampling_params,
        lora_request = model.load_lora("grpo_saved_lora"),
    )
    trained_outputs = [x.outputs[0].text for x in trained_outputs]
    
    symbols = [reasoning_start, reasoning_end, solution_start, solution_end]
    print(sum(sum(x.count(y) == 1 for y in symbols) for x in no_trained_outputs))
    print(sum(sum(x.count(y) == 1 for y in symbols) for x in trained_outputs))

    You should get more good results as GRPO follows the formatting correctly for the trained outputs - if you don't see any changes, then GRPO failed.

    My training loss curves for the advanced notebook:

    Image

    Steps to get the latest updates:

    1. Update Unsloth via versioning to the latest stable:
    pip install --upgrade --force-reinstall \
    "unsloth==2025.3.18" "unsloth-zoo==2025.3.16"
    
    1. You do NOT need to retrain the LoRA - simply load it. I also added a LoRA error check to the advanced Colab to check if it's actually trained!

    2. Gemma 3 does not use vLLM for now - this does NOT affect it.

    Tagging everyone since I'm assuming this was important! Again apologies on the delay - there were tonnes of new models and stuff, so hopefully this helps!
    @kalachx @SpaceHunterInf @JangDongHyeon @caiqizh @accemlcc @llzllx70 @FloLey @shimmyshimmer @Alpacolypse @nazarenodefrancescomaize @YaqiWangCV @zzz1YAO @JangDongHyeon11

  18. llzllx70 commented on Mar 21, 2025

    @llzllx70

    I think it would be better if the tests have the same prompt before and after load lora.
    As it can shows that the improve come from lora but not the system_prompt

  19. accemlcc commented on Mar 22, 2025

    @accemlcc

    Okay, I ran the notebook, made an 8bit GGUF out of it, loaded it into LMStudio, and fed it question 1000 from the training set. With the system prompt 'You are a helpful assistant. Think before you answer and place it in {reasoning_start} and {reasoning_end}. Then, provide your answer between {solution_start} and {solution_end},' it does a better job of following these instructions than the standard model. As for reasoning: it simply excludes its normal response within the reasoning tags, so it fundamentally 'thinks' before it answers. You can see this in the training log; the standard Llama 3B is already remarkably smart and can basically answer all questions correctly... This leads me to the fundamental question: Do these models even need reasoning? Would it perhaps be a new training goal to reconsider its standard response, so to speak, a 'rethink' of the normal 'think'? Would it make sense to use new tokens for this? ... Fundamentally, I consider this repo to be a great inspiration... I need to rethink my goals, everything is moving so fast.

  20. YaqiWangCV commented on Mar 23, 2025

    @YaqiWangCV

    I'm encountering an issue while using GRPO to train a text entity recognition model. Although the reward can reach a very high level, the reasoning process gradually degrades and eventually only outputs two words:

    <reasoning>
    First analysis
    </reasoning>
    

    Can anyone tell me why the reasoning process degrades? How can I make the model expand its reasoning process to further improve performance? Very grateful for any help!

  21. gurveervirk commented on Mar 23, 2025

    @gurveervirk

    Hey guys - apologies on the delay - specifically for GRPO - it's fixed! I also made an advanced GRPO notebook which is actually much better than the original - it uses an A100 and does LoRA on Llama 3.2 3B, since it was faster.

    NO NEED to retrain LoRA - if you saved it, then reload it! Unsloth inference is now fully fixed in the original GRPO and advanced notebook. (Please use advanced since I added many more reward functions, and it's much better for convergence!

    Advanced Colab notebook: https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Advanced_Llama3_1_(3B)_GRPO_LoRA.ipynb

    I also show the previous model without GRPO for the question "What is the sqrt of 101?"

    Image

    The trained GRPO on the same question - which definitely show it's working!

    Image

    Using the following works without changing code - I fixed model.lora_lora

    output = model.fast_generate(
    text,
    sampling_params = sampling_params,
    lora_request = model.load_lora("grpo_saved_lora"),
    )[0].outputs[0].text

    I also restarted the entire Colab, and just load the LoRA via the above (without training), and it worked correctly!

    You can test if the LoRA is working by just counting the formatting:

    no_trained_outputs = model.fast_generate(
    [text]*30,
    sampling_params = sampling_params,
    lora_request = None,
    )
    no_trained_outputs = [x.outputs[0].text for x in no_trained_outputs]
    trained_outputs = model.fast_generate(
    [text]*30,
    sampling_params = sampling_params,
    lora_request = model.load_lora("grpo_saved_lora"),
    )
    trained_outputs = [x.outputs[0].text for x in trained_outputs]

    symbols = [reasoning_start, reasoning_end, solution_start, solution_end]
    print(sum(sum(x.count(y) == 1 for y in symbols) for x in no_trained_outputs))
    print(sum(sum(x.count(y) == 1 for y in symbols) for x in trained_outputs))
    You should get more good results as GRPO follows the formatting correctly for the trained outputs - if you don't see any changes, then GRPO failed.

    My training loss curves for the advanced notebook:

    Image

    Steps to get the latest updates:

    1. Update Unsloth via versioning to the latest stable:
    pip install --upgrade --force-reinstall \
    "unsloth==2025.3.18" "unsloth-zoo==2025.3.16"
    
    1. You do NOT need to retrain the LoRA - simply load it. I also added a LoRA error check to the advanced Colab to check if it's actually trained!

    2. Gemma 3 does not use vLLM for now - this does NOT affect it.

    Tagging everyone since I'm assuming this was important! Again apologies on the delay - there were tonnes of new models and stuff, so hopefully this helps! @kalachx @SpaceHunterInf @JangDongHyeon @caiqizh @accemlcc @llzllx70 @FloLey @shimmyshimmer @Alpacolypse @nazarenodefrancescomaize @YaqiWangCV @zzz1YAO @JangDongHyeon11

    Hi @danielhanchen,

    Looked at your notebook for the changes. I have saved the final grpo adapter to my hf account via push_to_hub() method. However, when trying to load the model from hf in another session, the model performed similar to the base model, without grpo tuning.

    Should I be loading the model like that, or is there any other way?

    The lora adapter for grpo tuned qwen model, when saved using save_lora() has a size of ~220MB, whereas the one saved via push_to_hub() has a size of ~420MB. Can someone clarify this discrepancy?

    Thanks!

  22. added
    lora merging
    on Mar 24, 2025
  23. ngohoangnam28101995 commented on Mar 25, 2025

    @ngohoangnam28101995

    So we investigated the issue and were able to reproduce the issue (results after merging in 16-bit are same as before training).

    However, we checked that _merge_lora is working as expected and that the base_layer weights before / after merging are indeed different by roughly the magnitude of B @ A (since the scale factor is 1 per the default Qwen-GRPO notebook).

    We will need to conduct a deeper investigation into this thank you.

    Do you guys know when this issue started firstly occuring?

    I loaded in 4-bit and also have the same issued

  24. nazarenodefrancescomaize commented on Mar 25, 2025

    @nazarenodefrancescomaize

    I think the problem is not fixed yet.
    I reloaded an already done training as suggested but the saved lora and the hf pushed ones have the same behaviour of the original model.
    I'm on "unsloth==2025.3.18" "unsloth-zoo==2025.3.16"

    The wird thing is that with the previous version of unlosth (2025.3.13) the saved lora worked, the merged and pushed model not.

    The training code:

    [...]
    
    model_id = "unsloth/phi-4"
    
    model, tokenizer = FastLanguageModel.from_pretrained(
        model_name = model_id,
        max_seq_length = 8000,
        load_in_4bit = True, 
        fast_inference = True, 
        max_lora_rank = lora_rank,
        gpu_memory_utilization = gpu_memory_utilization, 
        cache_dir = cache_dir
    )
    
    model = FastLanguageModel.get_peft_model(
        model,
        r = lora_rank, # Choose any number > 0 ! Suggested 8, 16, 32, 64, 128
        target_modules = [
            "q_proj", "k_proj", "v_proj", "o_proj",
            "gate_proj", "up_proj", "down_proj",
        ], # Remove QKVO if out of memory
        lora_alpha = lora_rank,
        use_gradient_checkpointing = "unsloth", 
        random_state = 42
    )
    
    [...]
    
    trainer.train()
    
    # tried all of these saving methods
    ##model.save_pretrained(f"{checkpoint_dir}/grpo_saved_lora_fix")  
    ##tokenizer.save_pretrained(f"{checkpoint_dir}/grpo_saved_lora_fix")
    model.save_lora(f"{checkpoint_dir}/grpo_saved_lora_fix") # suggested on Advanced_Llama3_1_(3B)_GRPO_LoRA
    
    
    # check lora code suggested on Advanced_Llama3_1_(3B)_GRPO_LoRA
    from safetensors import safe_open
    tensors = {}
    with safe_open(f"{checkpoint_dir}/grpo_saved_lora_fix/adapter_model.safetensors", framework = "pt") as f:
        # Verify both A and B are non zero
        for key in f.keys():
            tensor = f.get_tensor(key)
            n_zeros = (tensor == 0).sum() / tensor.numel()
            assert(n_zeros.item() != tensor.numel())
    print(f"OK") # It prints "OK", so the lora seems trained
    
    # inference
    
    text = tokenizer.apply_chat_template([
        {"role" : "system", "content" : SYSTEM_PROMPT},
        {
          "role" : "user",
          "content" : "Quante R ci sono nella parola ramarro?"
        },
    ], tokenize = False, add_generation_prompt = True)
    
    #from vllm.lora.request import LoRARequest
    from vllm import SamplingParams
    sampling_params = SamplingParams(
        temperature = 0.9, # same as training
        top_p = 0.95,
        max_tokens = 8000,
        stop = ["</risposta>"]
    )
    output = model.fast_generate(
        text,
        sampling_params = sampling_params,
        # Each of them produce the same "vanilla" results
        lora_request = model.load_lora(f"{checkpoint_dir}/grpo_saved_lora_fix"),
        #lora_request = LoRARequest('lora', 1, lora_path='/content/checkpoint/checkpoint-1040')
    )[0].outputs[0].text
    
    print(output)
    
    # push the merged model
    
    user_id = "userd_id" # CHANGE ME
    model_name = 'model_name'
    print(user_id)
    print(model_name)
    print(f"Pushing to {user_id}/{model_name}")
    
    # Just LoRA adapters
    model.save_pretrained_merged(f"{model_name}-lora-only", tokenizer, save_method = "lora")
    model.push_to_hub_merged(f"{user_id}/{model_name}-lora-only", tokenizer, save_method = "lora", token = os.getenv("HF_TOKEN"))
    
    # Merge to 16bit
    import os
    model.save_pretrained_merged(model_name, tokenizer, save_method = "merged_16bit")
    model.push_to_hub_merged(f"{user_id}/{model_name}", tokenizer, save_method = "merged_16bit", token = os.getenv("HF_TOKEN"))
    
    
  25. Macharia-Maurice commented on Apr 4, 2025

    @Macharia-Maurice

    🚨 Error loading merged float16 model from Hugging Face

    I fine-tuned Qwen2-vl-7b for tomato leaf disease detection using Unsloth. After fine-tuning, I uploaded the merged model in float16 to Hugging Face using Lightning.AI on a T4 GPU (Colab kept crashing).

    model.push_to_hub_merged("havoic206/Qwen2-vl-7b-TomatoLeafDoctor", tokenizer, token=HF_TOKEN)

    Now, when I try to load the model:

    model, tokenizer = FastVisionModel.from_pretrained(
        "havoic206/Qwen2-vl-7b-TomatoLeafDoctor",
        load_in_4bit=True,
    )

    On Lightning AI, I get this error:

    FileNotFoundError: No such file or directory: "havoic206/Qwen2-vl-7b-TomatoLeafDoctor/model-00001-of-00004.safetensors"
    

    On Colab, I get this:

    OSError: havoic206/Qwen2-vl-7b-TomatoLeafDoctor does not appear to have a file named pytorch_model.bin, model.safetensors, tf_model.h5, model.ckpt or flax_model.msgpack.
    

    The files in my repo look like this:

    Image

    I successfully load the LoRA weights from my Hugging Face repository, and the model returns responses that align with the training performed.
    Only issue is loading the merged model.

  26. nazarenodefrancescomaize commented on Apr 7, 2025

    @nazarenodefrancescomaize

    You are not alone, it is related to #1521

  27. Macharia-Maurice commented on Apr 7, 2025

    @Macharia-Maurice

    You are not alone, it is related to #1521

    So merging LoRA to the base model is an issue, and even for those who successfully merge and try to inference the merged model, they still face an issue where performance deteriorates ???

  28. nazarenodefrancescomaize commented on Apr 7, 2025

    @nazarenodefrancescomaize

    You are not alone, it is related to #1521

    So merging LoRA to the base model is an issue, and even for those who successfully merge and try to inference the merged model, they still face an issue where performance deteriorates ???

    Yes. I have spent hundreds of dollars on A100 in order to finetune with GRPO Phi-4 and now that model is stuck on the virtual runtime because I cannot merge the model and push it to HF, and neither pushing only the lora works, because applying that lora gives only vanilla outputs.

    I also tried retraining with latest versions of unsloth using smaller models (phi-4-mini and gemma-3), also using their own colabs without touching anything. Nothing.
    For now, it is a waste of money, I'm sorry to say that.

  29. metalwhale commented on Apr 14, 2025

    @metalwhale

    I'm not sure if this will work (since I have no way to verify), but in my case, it seems like I can load the LoRA using one of the following methods:

    • Load the LoRA twice as suggested in this comment:
      model.load_lora(lora_dir)  # First time
      completion = model.fast_generate(
          [prompt],
          sampling_params=sampling_params,
          lora_request=model.load_lora(lora_dir),  # Second time
      )[0].outputs[0].text
    • Directly set LORA_REQUEST_ID to a positive value before calling load_lora:
      from unsloth_zoo import vllm_utils
      vllm_utils.LORA_REQUEST_ID = 1
      completion = model.fast_generate(
          [prompt],
          sampling_params=sampling_params,
          lora_request=model.load_lora(lora_dir),
      )[0].outputs[0].text

    My hypothesis:

    • Please correct me if I'm wrong, but I found a relevant piece of code suggesting that vLLM requires the LoRA ID to be set to a positive value. However, by default LORA_REQUEST_ID is set to 0, which prevents the LoRA from loading (??)
    • Further testing supports this: running the following line right after model.fast_generate:
      print(model.vllm_engine.llm_engine.list_loras())
      produces different results depending on the method used:
      • If you leave the LoRA ID at its default value 0 (i.e., don't use one of the methods above): it prints an empty set(), indicating that the LoRA was not loaded
      • If you use one of the above methods: it prints {1}, indicating that the LoRA was successfully loaded

    Package versions:

    • unsloth: 2025.3.19
    • unsloth-zoo: 2025.3.17
    • vllm: 0.8.2
  30. rolandtannous commented on Jun 6, 2025

    @rolandtannous
    Contributor

    @Alpacolypse @FloLey @JangDongHyeon @JangDongHyeon11 @Macharia-Maurice @Mtrya @Serzhanov @SpaceHunterInf @YaqiWangCV @accemlcc @adamtcdev @akbarsigit @allen20200111 @caiqizh @daegonYu @gurveervirk @ikirtanee @jeromeku @jotaefe0 @kalachx @llzllx70 @metalwhale @nazarenodefrancescomaize @ngohoangnam28101995 @shed-e @void-mckenzie @youbin2014 @zzz1YAO

    A fix has now been merged into pypi for both vision and language models and extensively tested.
    reference:
    unslothai/unsloth-zoo#135
    unslothai/unsloth-zoo#158
    #2673
    Merging and saving should work now.

    Best Practice is save to 16bits (which is the default operation if you do not specify anything), and load in 4 bits if you have to.
    For production systems, you might wanna consider post training quantization methods with calibration. These take longer but can also be more reliable.
    Saving and merging to 4bits might degrade performance of the model.

    To access this recent fix, and if you're running this in a local python environment, please make sure to upgrade your python environment using

    pip install --upgrade unsloth_zoo
    pip install --upgrade unsloth
    

    If you're in colab, the notebooks install cell will also be updated shortly but should be something like

    %%capture
    import os
    if "COLAB_" not in "".join(os.environ.keys()):
        !pip install unsloth
    else:
        # Do this only in Colab notebooks! Otherwise use pip install unsloth
        !pip install --no-deps bitsandbytes accelerate xformers==0.0.29.post3 peft trl triton transformers cut_cross_entropy unsloth_zoo
        !pip install sentencepiece protobuf "datasets>=3.4.1" huggingface_hub hf_transfer
        !pip install --no-deps unsloth
    

    as we're no longer pinning transformers or trl.

    Also note that whenever you need to merge while saving or while pushing to hub, make sure to use

    save_pretrained_merged()
    

    and

    push_to_hub_merged()
    

    If you are not merging at all, use

    save_pretrained
    

    and

    push_to_hub
    

    instead.

    This has been closed for now. Feel free to comment if you face any problems.
    Happy finetuning.

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

    fixed - pending confirmationlora merging

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions