Skip to content

RuntimeError: Unsloth: Please file a bug report! Error patching SFTTrainer #1829

Closed

Description

@ai-nikolai

Using version:

2024.06.01

We get this error:

*** Load base model and tokenizer from './temp/da-fr--Mistral-NeMo-Minitron-8B-ARChitects-Full-bnb-4bit/transformers/default/1'...
🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.
🦥 Unsloth Zoo will now patch everything to make training faster!
Traceback (most recent call last):
  File "/home/miniconda3/envs/env_arc_prize_original/lib/python3.10/site-packages/unsloth/tokenizer_utils.py", line 1061, in <module>
    exec(trainer_text, globals())
  File "<string>", line 4
    model = <class 'inspect._empty'>,
            ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Activity

  1. danielhanchen commented on Feb 26, 2025

    @danielhanchen
    Member

    Oh yep I saw this in another issue you wrote I think - will investigate!

  2. StarLight1212 commented on Feb 26, 2025

    @StarLight1212

    I encountered the same issue as you did. I checked all the installation versions on the official Colab and ensured that they were consistent, but the problem still persisted. Eventually, I set vllm_cache=True and found that the model could run normally and generate proper sequences. To be more specific, the settings are as follows:

    model, tokenizer = FastLanguageModel.from_pretrained(
            model_name=model_path,
            max_seq_length=max_seq_length,
            load_in_4bit=True,        
            fast_inference=True,      # set True if you want vLLM fast inference
            max_lora_rank=lora_rank,
            gpu_memory_utilization=0.7
        )
    
    training_args_lyrics = GRPOConfig(
        use_vllm = True, # use vLLM for fast inference!
        learning_rate = 5e-6,
        adam_beta1 = 0.9,
        adam_beta2 = 0.99,
        weight_decay = 0.1,
        warmup_ratio = 0.1,
        lr_scheduler_type = "cosine",
        optim = "paged_adamw_8bit",
        logging_steps = 1,
        bf16 = is_bfloat16_supported(),
        fp16 = not is_bfloat16_supported(),
        per_device_train_batch_size = 4,
        gradient_accumulation_steps = 2, # Increase to 4 for smoother training
        num_generations = 8, # Decrease if out of memory
        max_prompt_length = 768,
        max_completion_length = 768,
        num_train_epochs = 2, # Set to 1 for a full training run
        # max_steps = 50,
        save_steps = 250,
        max_grad_norm = 0.1,
        report_to = "none", # Can use Weights & Biases
        output_dir = "outputs_lyrics_phase",
    )

    With these settings, the program runs smoothly. It seems that the current models only support vllm-based gradient backpropagation. Without enabling vllm_cache, the first batch of data might be normal, but subsequent batches often encounter repetitive issues. However, once vllm_cache is turned on, the aforementioned problems are resolved!

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

    currently fixing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions