baidu-baige /LoongSage

A production-grade, high-efficiency Agentic RL framework for frontier LLMs with validated recipes.

★ 1,000⑂ 22👁 4⑃ 76● 16▤ 2
PythonApache-2.0Created 2026-08-28docs.loongsage.org/
Download: v0.2.1v0.2.1 ↓0.2.12026-11-24
1,000
stars
22
forks
4
watchers
76
prs
16
issues
2
releases

README

中文 | English




 LoongSage: The Coda of LLM training

Production-Grade · Agentic · Scalable · Lightweight

A production-grade, high-efficiency Agentic RL framework for frontier LLMs with validated recipes.


  
  
  
  
  
  



  
  
  




______________________________________________________________________

LoongSage is a post-training reinforcement learning framework for Large Language Models (LLMs), with Ray as the scheduling foundation, Megatron-Core as the training backend, and SGLang as the inference backend. It focuses on: Training ultra-large models with a minimalist architecture, supporting zero-intrusion access for any agent, and providing system-level training-inference consistency guarantees.

______________________________________________________________________

 🌟 Features

 🤖 Versatility — Any agent, any paradigm, any data mix

- Zero-Intrusion Agent Access — Agents only need to call the framework's inference service via a standard chat completion interface. Multi-turn context concatenation, tool output recognition, loss masking, trajectory collection, and sandbox full-lifecycle management are all handled automatically by the built-in AgentFlow module, achieving complete decoupling between the framework foundation and agent business logic.
- Multi-Paradigm Online Distillation — Natively supports PG-Style, GKD-Style, and mixed distillation modes, with built-in TopK, full-vocabulary, and JSD KL distillation strategies as well as multi-teacher distillation.
- Multi-Data-Source Mixed Training — Agents, reward functions, teacher models, and sampling hyperparameters can be configured independently per data source, while the proportion of each source is kept strictly globally consistent across every Rank and every Mini-Batch.

 ✅ Correctness — Reproducible convergence, observable bias

- Out-of-the-Box Training Recipes — Tuned end-to-end configurations are provided for typical scenarios such as math reasoning, agentic code repair, and full-vocabulary online distillation. Each recipe is hardened by real production training on MoE models inside Baidu (DeepSeek-V4-Flash, Qwen3-30B-A3B), so reaching stable convergence takes no hyperparameter guesswork.
- System-Level Training-Inference Consistency Guarantee — Built-in Router Replay (R3) for experts, FP32 output layer, TITO, importance sampling correction, M2PO, OPSM, and other consistency alignment techniques, together with real-time monitoring of distribution bias. In MoE architectures and low-precision scenarios, training-inference probability bias is stably held at the 1e-4 magnitude, significantly reducing the risk of training collapse.

 ⚡ Efficiency — Throughput tuned for ultra-large scale

- Fully Asynchronous Training — Supports partial rollout and oversampling. Sampling and training are fully decoupled, advancing in parallel and overlapping in time, with flexible data staleness and sliding window strategies. This effectively eliminates long-tail requests slowing down global tra

Top issues

Latest release

v0.2.1 v0.2.1 2026-11-24
Highlights

 DeepSeek-V4.1 vision: GRPO training of DeepSeek-V4.1 with image inputs, with geo3k (single image) and MMRB (multi-image) recipes.
 ERNIE 5.5: GRPO training of ERNIE-5.5-Flash-Base, with DAPO-math and GSM8K recipes.
 Group reward: score all trajectories of a prompt together with RewardFunction.group_rm.
 Countdown example: agent, reward and data pre-processor, with a single-GPU Qwen3-0.6B recipe.

 What's New

 Models & Training

 DeepSeek-V4.1 vision support. Enable with multimodal.enable. V4.1 uses its own image processor, driven by the vision_ fields of the checkpoint

Snapshot: 2026-11-27T22:26:53Z · Data license Apache-2.0 · JSON