# Repository Briefing: dualverse-ai/pocketrl
> Source: https://repoforai.com/repo/dualverse-ai/pocketrl (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/dualverse-ai/pocketrl
- **Official Docs / Website**: https://dualverse-ai.github.io/pocketrl/
- **Category**: LLMs & Inference (大模型与推理微调)
- **Primary Language**: Python
- **License**: Apache-2.0
- **Engineering Health**: A (87/100 · Maintenance 35/35 · Adoption 12/25 · Releases 20/20 · License 20/20)
- **Latest Release**: v0.1.0 (2026-11-27) — https://github.com/dualverse-ai/pocketrl/releases
- **Review Snapshot**: 2026-12-03
- **Deployment / Stack Signals**: GPU, CLI
- **Momentum**: 115 ★ total (+7 24h / +7 7d) · 11 forks
- **Topics**: `fine-tuning`, `grpo`, `llm`, `low-cost`, `math`, `memory-efficient`, `pytorch`, `qwen`, `reasoning`, `reinforcement-learning`, `rlvr`, `rtx-5090`
- **When to Use**: Best for: Teams running verifiable-reward experiments on supported Qwen models with limited single-host VRAM, or comparing Dense, LoGRA, and ActGRA under a shared training loop. Skip if: You need a production inference server, validated multi-node scaling, broad model-family compatibility, or exact reproduction of paper timing from the packaged runtime.

## Overview
```text
### Architecture & Core Mechanics
PocketRL is a Python/PyTorch trainer for reinforcement learning with verifiable rewards (RLVR), not an inference server. Each update samples multiple completions per prompt, grades them, and applies a Dr. GRPO policy update. The CLI enters through `pocketrl.cli:main`; YAML recipes and flags configure the run, while `TrainConfig` and `PocketRLTrainer` expose the same workflow to Python callers. The stack includes PyTorch, Transformers, Hugging Face Hub, safetensors, and PyYAML.

ActGRA fits a low-rank basis to each layer's input activations with QR factorization, applies row-wise Adam to the projected gradients, and maps updates back to the full weight matrix. Generation and training use the same BF16 weights. A packed 4-bit rounding remainder in the 7B and 27B recipes, or 8-bit at 1.5B, accumulates updates that would otherwise be lost to rounding, removing the need for a separate FP32 master copy.

### Key Capabilities & Differentiators
The built-in recipes target Qwen2.5-Math-1.5B, Qwen2.5-Math-7B, and Qwen3.8-27B. The trainer also accepts compatible Qwen2, Qwen2.5, and Qwen3.5-style hybrid text models via a Hugging Face ID or local path. The paper recipes sample eight answers per prompt across 16 prompts per update, with up to 3,000 generated tokens per answer. The loop can be reused for other verifiable tasks with a custom dataset and Python reward function.

For 7B, persistent training state drops from 113 GiB to 18 GiB; the measured peak was 22.5 GiB on one RTX 5090. The 500-update experiment took 7.3 hours at an estimated $4.71 and reached 43.0% average accuracy across six math sets at Avg@8, up from 13.4% for the base model. The 27B experiment ran 100 updates in 9.1 hours on four RTX 5090s, peaking at 31.1 GiB per card. These figures describe the experimental runs, not the separately tabulated checkpoint evaluations.

### Trade-offs & Limitations
ActGRA reduces optimizer storage by updating in an activation-derived subspace rather than retaining dense Adam state. In the 7B ablation, ActGRA and LoGRA both ran on one RTX 5090: ActGRA took 7.3 hours and peaked at 22.5 GiB, versus 12.3 hours and 31.3 GiB for LoGRA. The Dense run used two H100s, so its wall time is not a same-hardware comparison. Treat the selected rank and remainder precision as validated settings for these recipes, not universal defaults for unrelated models or reward functions.

Against TRL, the 7B comparison reports 1.8 versus 4.6 hours per 100 steps on H100 hardware. Rollout dimensions were matched, but frameworks used their own released settings and minimum viable GPU counts. PocketRL's contiguous layer placement avoids Ray and multi-node setup for the demonstrated runs, but does not establish multi-node scaling. Dollar estimates depend on GPU pricing, and peak VRAM must be rechecked when changing context length, sample count, or runtime.

### Hardware & Deployment Guide
Run locally on Linux with Python 3.10 or later and PyTorch 2.6 or later; RTX 5090 systems need a PyTorch build targeting CUDA 12.8 or newer. Install `.[math,vllm]` for math grading and vLLM evaluation, adding `hybrid` for the 27B model's `flash-linear-attention` and `causal-conv1d` dependencies. Start with `pocketrl train paper-1.5b --gpus 1`; train and eval are separate CLI commands. The first standard run fetches models and datasets; local model and dataset paths are supported.

The first public release, v0.1.0, packages a native shared-weight decoder for training. The paper used colocated vLLM generation with shared weight views at 1.5B and 7B and pipelined generation at 27B, so packaged throughput and peak VRAM can differ. The recipes save every 50 updates, accept `--resume` to continue from the latest checkpoint, and write progress to `metrics.jsonl`. Run a short trial on the intended GPU layout before budgeting a full run.
```

## Key Capabilities
```text
- Optimizer state: ActGRA uses a rank-128 activation basis in the paper recipes, refreshed every eight updates; 7B Adam state drops from 56.74 to 0.61 GiB.
- Weight storage: Generation and training share BF16 weights; a packed rounding remainder replaces FP32 master weights.
- GPU footprint: Reported peaks are 22.5 GiB on one RTX 5090 at 7B and 31.1 GiB per card on four RTX 5090s at 27B.
- Model placement: `--gpus N` partitions consecutive decoder layers across visible GPUs within one process, without Ray.
- Experiment controls: YAML recipes and CLI overrides expose Dense, LoGRA and ActGRA, checkpoint resume, JSONL metrics, and optional W&B tracking.
- Task integration: Local JSONL or Hugging Face datasets can feed a Python reward function, with additional row fields passed as keyword arguments.
```

## Quick Start / Clone
```bash
git clone https://github.com/dualverse-ai/pocketrl.git
cd pocketrl
pip install -e '.[math,vllm]'      # math grader and vLLM evaluation
pip install -e '.[math,vllm,hybrid]'  # also needed for the 27B model
```
