Skip to content

The V100 ran GRPO training with incorrect output. #1888

Closed

Description

@godsdarling

Random responses occur after the first step, and rewards are given only in the first step.

Image

Image

I changed the xformers and torch-related environment to these versions because I encountered an error when I ran pip install unsloth.

$ pip install xformers==0.0.27.post2
$ pip install torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 --index-url https://download.pytorch.org/whl/cu121

I also turned off load_in_4bit because it caused a bitsandbytes environment problem. Additionally, I turned off fast_inference in vLLM.

from unsloth import is_bfloat16_supported
import torch
max_seq_length = 512 # Can increase for longer reasoning traces
lora_rank = 32 # Larger rank = smarter, but slower

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = "./model_downloaded/Llama-3.2-3B-Instruct",
    max_seq_length = max_seq_length,
    load_in_4bit = False, # False for LoRA 16bit turn off
    device_map="auto",
    fast_inference = False, # Enable vLLM fast inference turn off
    max_lora_rank = lora_rank,
    gpu_memory_utilization = 0.9, # Reduce if out of memory
)
#
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", # Enable long context finetuning
    random_state = 3407,
)

Training arguments are:

from trl import GRPOConfig, GRPOTrainer
training_args = GRPOConfig(
    use_vllm = False, # 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 = 1,
    gradient_accumulation_steps = 1, # Increase to 4 for smoother training
    num_generations = 6, # Decrease if out of memory
    max_prompt_length = 256,
    max_completion_length = 200,
    num_train_epochs = 1, # Set to 1 for a full training run
    max_steps = 200,
    save_steps = 200,
    max_grad_norm = 0.5,
    report_to = "none", # Can use Weights & Biases
    output_dir = "./outputs/official_data/",
)

Other code remains unchanged.

This is my specific environment when training.

Image

Could anyone help or offer some suggestions? Many thanks.

Activity

  1. Yueeeeeeee commented on Mar 5, 2025

    @Yueeeeeeee

    Downgrade to 2025.2.12 should work

  2. danielhanchen commented on Mar 5, 2025

    @danielhanchen
    Member

    @Yueeeeeeee @godsdarling Apologies just fixed! For Colab / Kaggle, please restart and run all. For local machines, please do:

    pip install --force-reinstall --upgrade --no-cache-dir --no-deps unsloth unsloth_zoo
    
  3. godsdarling commented on Mar 14, 2025

    @godsdarling
    Author

    it worked,thanks all

  4. ahnesi commented on Apr 5, 2025

    @ahnesi

    It still doesn't work for me, after reinstalling.
    The output is not gibberish, but it seems to not follow the system prompt at all when I set fast_inference=False.
    Could you help?

  5. Xtdzs commented on Jun 25, 2025

    @Xtdzs

    When I didn't use vllm for inference, the gibberish output from the process of GRPO training occured after the first step as usual. Thus all my rewards and losses turned to ZERO after the first step. Could you please help me figure out the cause of my problem?

    My setup is shown below:

    Unsloth 2025.6.5: Fast Qwen2 patching. Transformers: 4.52.4.
    NVIDIA GeForce RTX 4090. Num GPUs = 1. Max memory: 23.643 GB. Platform: Linux.
    Torch: 2.7.0+cu126. CUDA: 8.9. CUDA Toolkit: 12.6. Triton: 3.3.0
    Bfloat16 = TRUE. FA [Xformers = 0.0.30. FA2 = False]

    model, tokenizer = FastLanguageModel.from_pretrained(
    fast_inference= False,
    load_in_4bit = True,
    dtype=None,
    device_map={"":0}
    )

    model = FastLanguageModel.get_peft_model(
    model,
    r = lora_rank,
    target_modules = [
    "q_proj", "k_proj", "v_proj", "o_proj",
    "gate_proj", "up_proj", "down_proj",
    ],
    lora_alpha = lora_rank,
    use_gradient_checkpointing = "unsloth"
    random_state = 3407,
    )

    training_args = GRPOConfig(
    use_vllm = False,
    learning_rate = 5e-5,
    adam_beta1 = 0.9,
    adam_beta2 = 0.99,
    weight_decay = 0.1,
    warmup_ratio = 0.1,
    lr_scheduler_type = "cosine",
    optim = "adamw_8bit",
    logging_steps = 1,
    bf16 = is_bfloat16_supported(),
    fp16 = not is_bfloat16_supported(),
    per_device_train_batch_size = 1,
    gradient_accumulation_steps = 2,
    num_generations = 3,
    max_prompt_length = max_prompt_length,
    max_completion_length = max_completion_length,
    num_train_epochs = 1,
    # max_steps = 250,
    max_steps= 300,
    save_steps = 100,
    max_grad_norm = 0.1,
    report_to = "none",
    output_dir = "",
    ddp_backend=None,
    ddp_find_unused_parameters = None
    )

    trainer = GRPOTrainer(
    model = model,
    processing_class = tokenizer,
    reward_funcs = [reward_func],
    args = training_args,
    train_dataset = dataset,
    )

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