# XTuner

> Train and fine-tune large language and vision-language models, including ultra-large MoE models

- Category: Training & Fine-Tuning / Fine-Tuning Frameworks
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/InternLM/xtuner
- Website: https://xtuner.readthedocs.io
- Canonical page: https://ai-tldr.dev/tools/xtuner/

## In short

XTuner is an open-source toolkit from the InternLM team for fine-tuning and training large language models and vision-language models. It supports supervised fine-tuning, multimodal pre-training, and reinforcement learning methods such as GRPO, and runs on both NVIDIA GPUs and Ascend NPUs. It sits in the Fine-Tuning Frameworks category of the Training & Fine-Tuning tools and is open-source, written in Python and licensed Apache-2.0.

## Overview

XTuner is an open-source toolkit from the InternLM team for fine-tuning and training large language models and vision-language models. It supports supervised fine-tuning, multimodal pre-training, and reinforcement learning methods such as GRPO, and runs on both NVIDIA GPUs and Ascend NPUs.

XTuner V1, released in September 2025, is a training engine designed for ultra-large Mixture-of-Experts (MoE) models. It can train models in the hundreds of billions of parameters without the complexity of traditional 3D parallel setups, and supports long sequence lengths through memory-efficient design and DeepSpeed Ulysses sequence parallelism.

It fits in the fine-tuning frameworks space for teams who need to scale training beyond what fits on a single setup. It works with model families like Qwen3, InternVL, InternS1, DeepSeek V3, and integrates with inference engines such as LMDeploy for deployment.

## What it does

- Fine-tunes LLMs and vision-language models, including multimodal pre-training and supervised fine-tuning
- Dropless MoE training that scales to 200B models without expert parallelism and up to 1T parameters
- Long-sequence support, including 200B MoE models at 64k context, with DeepSpeed Ulysses sequence parallelism
- Reinforcement learning with GRPO, plus MPO, DAPO, and multi-turn agentic RL on the roadmap
- Runs on NVIDIA GPUs (FP8/BF16) and Ascend NPUs (BF16) across supported model families
- Inference integration with LMDeploy, with vLLM and SGLang support planned

## Getting started

Install XTuner from source, then run a small SFT job to confirm the setup works. A recent NVIDIA driver (greater than 550.127.08) is recommended.

1. Clone and install

   Clone the repository and install it in editable mode with pip.

```bash
git clone https://github.com/InternLM/xtuner.git
cd xtuner
pip install -e .
```

2. Run a minimal SFT job

   Use torchrun with the V1 SFT entry point and an example config to verify training runs end to end.

```bash
torchrun xtuner/v1/train/cli/sft.py --model-cfg examples/v1/sft_qwen3_tiny.py \
  --chat_template qwen3 --dataset tests/resource/openai_sft.jsonl
```

3. Optional speed and MoE extras

   For faster training install flash-attn (or flash-attn-3), and install GroupedGEMM when training MoE models. These are optional add-ons, not required for the basic install.

## When to use it

- Fine-tuning large MoE models (hundreds of billions of parameters) without setting up traditional 3D parallel training
- Supervised fine-tuning of LLMs such as Qwen3 on instruction datasets
- Multimodal pre-training and fine-tuning of vision-language models like InternVL
- Running reinforcement learning (GRPO) on large models, with deployment through LMDeploy
