Agent skill

unsloth-grpo

Stars 0
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/cuba6112/skillfactory/tree/main/skills/unsloth-grpo

SKILL.md

Overview

Unsloth-grpo enables training of reasoning models using Group Relative Policy Optimization (GRPO). This technique replaces traditional PPO Reward and Value models with group statistics, achieving 8x memory savings and allowing long-context RL training on limited VRAM.

When to Use

  • When building DeepSeek-R1 style reasoning models.
  • When performing Reinforcement Learning with Verifiable Rewards (RLVR) for math or code.
  • When training models with long context lengths (e.g., 20K tokens) on single GPUs.

Decision Tree

  1. Is your model size < 1.5B?
    • Yes: Model may struggle with consistent thinking tokens; consider 1.5B-8B.
  2. Is the reward verifiable (e.g., math answer)?
    • Yes: Use RLVR with regex-based reward functions.
  3. Are you training on a single GPU with long context?
    • Yes: Use GRPOTrainer to benefit from the 8x memory reduction.

Workflows

  1. Converting to Reasoning LLM: Load a base model with fast_inference = True, define a reward function for <thought> and <answer> tags, and train with GRPOTrainer.
  2. Implementing Verifiable Rewards (RLVR): Create a correctness function using regex to extract answers and assign rewards (e.g., 2.0) or penalties (-1.0) based on ground truth.
  3. Speed Optimization with FP8: Select an FP8 Dynamic model and use optim = 'adamw_8bit' to further reduce memory during the RL rollout phase.

Non-Obvious Insights

  • GRPO eliminates the need for both the Reward Model and the Value Model, relying purely on group generation statistics for policy updates.
  • Unsloth's GRPO implementation allows training 20K context reasoning models with only ~9.8GB of additional VRAM.
  • For stable training, num_generations should be set to 8 per prompt to provide sufficient statistical variance for the reward calculation.

Evidence

  • "Unsloth shaves 8x memory usage for long context GRPO, so we need only an extra 9.8GB in extra VRAM for 20K context lengths!" Source
  • "Introducing Long-context Reasoning (GRPO) in Unsloth. Train your own reasoning model with just 5GB VRAM." Source

Scripts

  • scripts/unsloth-grpo_tool.py: Template for GRPOTrainer and verifiable reward functions.
  • scripts/unsloth-grpo_tool.js: Node.js utility for monitoring RL training metrics.

Dependencies

  • unsloth
  • trl
  • vllm (recommended for faster generation in rollouts)

References

  • references/README.md

Expand your agent's capabilities with these related and highly-rated skills.

cuba6112/skillfactory

prompt-engineering

Comprehensive prompt engineering techniques for Claude models. Use this skill when crafting, optimizing, or debugging prompts for Claude API, Claude Code, or any Claude-powered application. Covers system prompts, role prompting, multishot examples, chain of thought, XML structuring, long context handling, extended thinking, prompt chaining, Claude 4.x-specific best practices, and agentic orchestration including subagents, agent loops, skills, MCP integration, and multi-agent workflows.

0 0
Explore
cuba6112/skillfactory

adk-rag-agent

Build RAG (Retrieval-Augmented Generation) agents with Google ADK and Vertex AI RAG Engine. Use when implementing document Q&A, knowledge base search, or citation-backed responses. Covers VertexAiRagRetrieval tool, corpus setup, and citation formatting.

0 0
Explore
cuba6112/skillfactory

headless-cli-agents

Build agentic systems using Claude CLI in headless mode or the Claude Agent SDK. Use when building automation pipelines, CI/CD integrations, multi-agent orchestration, or programmatic Claude interactions. Covers CLI flags (-p, --output-format), session management (--resume, --continue), Python SDK (claude-agent-sdk), custom tools, and agent loop patterns.

0 0
Explore
cuba6112/skillfactory

notion-knowledge-capture

Capture conversations and decisions into structured Notion pages; use when turning chats/notes into wiki entries, how-tos, decisions, or FAQs with proper linking.

0 0
Explore
cuba6112/skillfactory

mcp-builder

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

0 0
Explore
cuba6112/skillfactory

gh-fix-ci

Inspect GitHub PR checks with gh, pull failing GitHub Actions logs, summarize failure context, then create a fix plan and implement after user approval. Use when a user asks to debug or fix failing PR CI/CD checks on GitHub Actions and wants a plan + code changes; for external checks (e.g., Buildkite), only report the details URL and mark them out of scope.

0 0
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results