Skip to content

GRPO example missing PEFT config resulting in "LLMEngine should not be pickled" #1632

Closed

Description

@kallewoof

I am following along with the colab notebook at https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Llama3.1_(8B)-GRPO.ipynb#scrollTo=RM566BGJv-DG and things work fine until the GRPOTrainer is initialized. Despite there being a PEFT model (the model itself), the code reaches the peft_config is None part in grpo_trainer.py:208:

        # Reference model
        if is_deepspeed_zero3_enabled():
            self.ref_model = AutoModelForCausalLM.from_pretrained(model_id, **model_init_kwargs)
        elif peft_config is None:
            # If PEFT configuration is not provided, create a reference model based on the initial model.
            self.ref_model = create_reference_model(model)
        else:
            # If PEFT is used, the reference model is not needed since the adapter can be disabled
            # to revert to the initial model.
            self.ref_model = None

which crashes in vllm/engine/llm_engine.py:497 with an LLMEngine should not be pickled! runtime error.

This is with

pip install git+https://github.com/huggingface/trl.git@e95f9fb74a3c3647b86f251b7e230ec51c64b72b

version.

Activity

  1. marv1nnnnn commented on Feb 7, 2025

    @marv1nnnnn

    Same here, running on a 4090. I modified the code according to #1624 (comment) and then met this error

    [rank0]:   File "/usr/local/lib/python3.11/dist-packages/vllm/engine/llm_engine.py", line 497, in __reduce__
    [rank0]:     raise RuntimeError("LLMEngine should not be pickled!")
    [rank0]: RuntimeError: LLMEngine should not be pickled!
    
  2. tchang1997 commented on Feb 7, 2025

    @tchang1997

    Ran into this error while trying to run something locally. I think you need to run PatchFastRL("GRPO", FastLanguageModel) before importing GRPOTrainer or any trainers from trl, since PatchFastRL calls a bunch of helpers that remove the need for peft_config in the trainer (see here).

    When I moved PatchFastRL("GRPO", FastLanguageModel) before my trl import statements, the issue went away.

  3. kallewoof commented on Feb 7, 2025

    @kallewoof
    Author

    Ran into this error while trying to run something locally. I think you need to run PatchFastRL("GRPO", FastLanguageModel) before importing GRPOTrainer or any trainers from trl, since PatchFastRL calls a bunch of helpers that remove the need for peft_config in the trainer (see here).

    When I moved PatchFastRL("GRPO", FastLanguageModel) before my trl import statements, the issue went away.

    Gah. Thanks. That's obviously the issue. I did a ruff organize without thinking.

  4. toxahak commented on Feb 14, 2025

    @toxahak

    seems like something broke in the latest version. I had to use this to get my script working again:
    pip install unsloth==2025.2.5

  5. benjamin-marie commented on Feb 14, 2025

    @benjamin-marie

    Yes, I have this issue. It was working well yesterday.

  6. cht619 commented on Apr 22, 2025

    @cht619

    how to solve is when do not use peft?

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