# LoongForge

> Baidu's training framework for LLMs, VLMs, diffusion and robot models

- Category: Training & Fine-Tuning / Efficient Training
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/baidu-baige/LoongForge
- Website: https://baidu-baige.github.io/LoongForge/
- Canonical page: https://ai-tldr.dev/tools/loongforge/
- Updated: 2026-11-05

## In short

LoongForge is an open-source training framework from the Baidu AI Cloud Baige team for large language models, vision-language models, diffusion models and embodied models such as vision-language-action (VLA) and world-action (WAM) policies. It sits in the Efficient Training category of the Training & Fine-Tuning tools and is open-source, written in Python and licensed Apache-2.0.

## Overview

LoongForge is an open-source training framework from the Baidu AI Cloud Baige team for large language models, vision-language models, diffusion models and embodied models such as vision-language-action (VLA) and world-action (WAM) policies. It was open-sourced in April 2026 from AIAK-Training-LLM, the framework Baidu used for enterprise customers' models, and ships ready-to-run configs and launch scripts for 40+ open models, from DeepSeek, Qwen, GLM and Kimi to Pi0.5, GR00T and DreamZero.

Because the best training strategy differs by model family, LoongForge has two backends. A Megatron backend (a patched Megatron-LM) handles LLMs, VLMs and diffusion, extended with MoE parallelism, heterogeneous per-component parallelism and long-sequence training. A torch-native backend handles embodied models with DDP, ZeRO-1, FSDP and HSDP, plus per-model optimizations of I/O, communication and kernels.

It supports pre-training, mid-training, supervised fine-tuning and LoRA, converts checkpoints between Megatron and Hugging Face formats, and runs on both NVIDIA GPUs and Baidu's Kunlun XPUs. The project reports training throughput from 1.45x to 5.04x over each model's open-source baseline, measured on the same hardware, with training loss kept aligned with the baseline.

## What it does

- Two backends: Megatron for LLM / VLM / diffusion training and torch-native (DDP, ZeRO-1, FSDP, HSDP) for VLA and world-action models
- MoE optimizations: overlapped All2All with activation offload, and topology-aware replication of hot experts to balance expert-parallel load
- Adaptive FP8 training, FP8 gradient and parameter communication, and custom fused operators such as a TileLang FusedDSA kernel
- VLMs assembled from interchangeable ViT and LLM components purely in config, with independent parallelism and freezing per component
- Long-sequence training with context parallelism and chunked-pipeline scheduling; Ring / Ulysses context parallelism and sample packing for video diffusion
- Megatron ↔ Hugging Face checkpoint bridge, LeRobot data loading, an Ego2Robot video-to-robot-data pipeline and closed-loop LIBERO / CALVIN / SimplerEnv / RoboTwin / ManiSkill evaluation

## Getting started

The README's quick start uses the prebuilt Docker image on an NVIDIA GPU machine (NVIDIA Container Toolkit required) and fine-tunes Pi0.5 on LIBERO on one 8-GPU node. Source builds and Kunlun XPU installs are covered in the docs.

1. Pull the image and start a container

   The mounted ./workspace folder keeps weights, datasets and outputs after the container exits.

```bash
docker pull loongforge/loongforge:latest
mkdir -p workspace
docker run --gpus all --ipc=host -it --rm \
  -v "$(pwd)/workspace:/workspace/data" \
  -w /workspace/LoongForge \
  loongforge/loongforge:latest bash
```

2. Download weights, tokenizer and dataset

   Inside the container, fetch the Pi0.5 base weights, the PaliGemma tokenizer and the LIBERO dataset with the Hugging Face CLI.

```bash
hf download lerobot/pi05_base --local-dir /workspace/data/pi05_base
hf download google/paligemma-3b-pt-224 --local-dir /workspace/data/paligemma-3b-pt-224
hf download lerobot/libero_10 --repo-type dataset --local-dir /workspace/data/libero_10
```

3. Launch training

   Paths come from environment variables; the script runs 20 steps by default to validate the setup. Logs and TensorBoard data land in OUTPUT_DIR. Launch scripts for every supported model live under examples/ (NVIDIA) and examples_xpu/ (Kunlun).

```bash
export CHECKPOINT_PATH=/workspace/data/pi05_base
export TOKENIZER_PATH=/workspace/data/paligemma-3b-pt-224
export DATA_PATH=/workspace/data/libero_10
export OUTPUT_DIR=/workspace/data/outputs/pi05

bash examples/embodied/pi05/run_pi05_ddp_finetune.sh
```

## When to use it

- Pre-training or fine-tuning large MoE LLMs such as DeepSeek, GLM, Kimi or MiniMax across many GPUs with Megatron-style parallelism
- Building a custom VLM by pairing a vision encoder with an LLM in config and training each part with its own parallel settings
- Speeding up fine-tuning of robot policies (Pi0.5, GR00T, FastWAM, DreamZero) and evaluating them in LIBERO or RoboTwin
- Running the same training recipes on Baidu Kunlun XPUs as well as NVIDIA GPUs

## Version history

- 2026-11-05 v0.2.2: Added LoongForge-VLDA, LingBot-VLA-v2, GR00T-N1.7 and Wall-OSS-0.5 recipes, Kimi-K3, GLM-5.3-flash and Qwen3.8-27B training, and the Ego2Robot data pipeline. Also brought tensor-wise Muon, FP8 gradient communication and sturdier async checkpointing.
