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
GRPOTrainer example works with trl but generate "noise" with unsloth #1844
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 inferencemax_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=notis_bfloat16_supported(),
per_device_train_batch_size=4,
gradient_accumulation_steps=2, # Increase to 4 for smoother trainingnum_generations=8, # Decrease if out of memorymax_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 & Biasesoutput_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!
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:
.
.
.
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!
@StarLight1212, I cannot see vllm_cache=True anywhere in your snippet.
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 inferencemax_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=notis_bfloat16_supported(),
per_device_train_batch_size=4,
gradient_accumulation_steps=2, # Increase to 4 for smoother trainingnum_generations=8, # Decrease if out of memorymax_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 & Biasesoutput_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!
How do you turn on vllm_cache? It's not in your code snippet
Activity
StarLight1212 commentedon Feb 27, 2025
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=Trueand found that the model could run normally and generate proper sequences. To be more specific, the settings are as follows: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, oncevllm_cacheis turned on, the aforementioned problems are resolved!DiTo97 commentedon Feb 27, 2025
@StarLight1212, I cannot see
vllm_cache=Trueanywhere in your snippet.nottrz commentedon Feb 27, 2025
@StarLight1212 Thank you very much for your detailed answer :)
I added fast_inference, enforce_eager, gpu_memory_utilization here:
and use_vllm = True in the GRPOConfig
Now it works with the Llama 3B and 8B!
Note:
pip install vllm
downgraded several core packages but everything works fine.
Summer142857 commentedon Mar 1, 2025
The same problem, which is not resolved yet.
Summer142857 commentedon Mar 1, 2025
I found the way to resolve it. You can just downgrade your unsloth to 2025.2.12 and do not use vllm.
You can also refer to #1810
danielhanchen commentedon Mar 5, 2025
@nottrz @DiTo97 @Summer142857 @Summer142857 Apologies just fixed! For Colab / Kaggle, please restart and run all. For local machines, please do:
shimmyshimmer commentedon Jun 6, 2025
If this issue still has not been resolved feel free to make a new issue but ill be closing for now!
mikeknapp commentedon Aug 19, 2025
How do you turn on vllm_cache? It's not in your code snippet
fix(install): add bitsandbytes ROCm install for Windows (mirrors inst…