Skip to content

📥 Set environment variables for vLLM distributed training in GRPOTrainer #3723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 12, 2025

Conversation

qgallouedec
Copy link
Member

@qgallouedec qgallouedec commented Jul 11, 2025

Late review for #3638

If you've also time to review @toslali-ibm

from trl import GRPOTrainer, GRPOConfig
from datasets import load_dataset

train_dataset = load_dataset("trl-internal-testing/zen", "standard_prompt_only", split="train")

def main():
    training_args = GRPOConfig(
        max_completion_length=8,
        per_device_train_batch_size=3,  # reduce the batch size to reduce memory usage
        num_generations=3,  # reduce the number of generations to reduce memory usage
        use_vllm=True,
        vllm_mode="colocate",
        report_to="none",
    )

    trainer = GRPOTrainer(
        model="Qwen/Qwen3-0.6B",
        reward_funcs="trl-internal-testing/tiny-Qwen2ForSequenceClassification-2.5",
        args=training_args,
        train_dataset=train_dataset,
    )

    trainer.train()

if __name__ == "__main__":
    main()

this now work, tested with 2 GPUs

@kashif
Copy link
Collaborator

kashif commented Jul 11, 2025

thanks! I was adding them to the slow_grpo_test.py and now i can remove that when merged

@kashif
Copy link
Collaborator

kashif commented Jul 11, 2025

@qgallouedec perhaps in the docs we can say that we use these defaults and one can change it by setting the env variables if needed?

@qgallouedec
Copy link
Member Author

@qgallouedec perhaps in the docs we can say that we use these defaults and one can change it by setting the env variables if needed?

👍
Done in d48ad8f

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@qgallouedec qgallouedec merged commit 640a9f3 into main Jul 12, 2025
10 of 11 checks passed
@qgallouedec qgallouedec deleted the env-var-directly-inside-grpo branch July 12, 2025 03:15
marcandrelarochelle pushed a commit to marcandrelarochelle/trl that referenced this pull request Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants