Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 131 additions & 26 deletions README-ja-JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@

<div align="center">

<img src="./doc/imgs/logo.svg" width="200"/>
<div> </div>
<div align="center">
<b><font size="5">InternEvo</font></b>
<sup>
<a href="https://internlm.intern-ai.org.cn/">
<i><font size="4">HOT</font></i>
</a>
</sup>
<div> </div>
</div>
<img src="./doc/imgs/InternEvo_logo.png" width="200"/>

[![Documentation Status](https://readthedocs.org/projects/internevo/badge/?version=latest)](https://internevo.readthedocs.io/zh_CN/latest/?badge=latest)
[![license](./doc/imgs/license.svg)](./LICENSE)
Expand All @@ -28,13 +18,13 @@

</div>

<p align="center">
👋 <a href="https://discord.gg/xa29JuW87d" target="_blank">Discord</a> と <a href="https://github.com/InternLM/InternLM/assets/25839884/a6aad896-7232-4220-ac84-9e070c2633ce" target="_blank">WeChat</a> で私たちに参加してください
</p>


### 最新ニュース 🔥

- 2024/08/29: InternEvoは、huggingface形式のストリーミングデータセットをサポートしています。データフローの詳細な手順を追加しました。

- 2024/04/17: InternEvoは、NPU-910Bクラスターでモデルのトレーニングをサポートしています。

- 2024/01/17: InternLMシリーズのモデルについてさらに詳しく知りたい方は、当社の組織内の[InternLM](https://github.com/InternLM/InternLM)をご覧ください。


Expand All @@ -44,27 +34,142 @@ InternEvoは、広範な依存関係を必要とせずにモデルの事前ト

InternEvoトレーニングフレームワークを基に、当社はInternLM-7BシリーズやInternLM-20Bシリーズを含むさまざまな大規模言語モデルを継続的にリリースしています。これらのモデルは、LLaMAのような数多くの有名なオープンソースの大規模言語モデルや、その他の業界をリードするモデルを大きく上回る性能を発揮しています。

## インストール

まず、指定バージョンのtorch、torchvision、torchaudio、およびtorch-scatterをインストールしてください。
たとえば:
```bash
pip install --extra-index-url https://download.pytorch.org/whl/cu118 torch==2.1.0+cu118 torchvision==0.16.0+cu118 torchaudio==2.1.0+cu118
pip install torch-scatter -f https://data.pyg.org/whl/torch-2.1.0+cu118.html
```

InternEvoをインストールします:
```bash
pip install InternEvo
```

flash-attention(バージョンv2.2.1)をインストールします:

もしflash-attentionを使用してトレーニングを加速する必要があり、あなたの環境でサポートされている場合は、以下の通りインストールしてください:
```bash
pip install flash-attn==2.2.1
```

インストール環境やソースコードインストールに関するより詳細な情報については、以下のリンクを参照してください [インストールチュートリアル](https://internevo.readthedocs.io/en/latest/install.html#)

## クイックスタート

InternEvoのインストール、データ処理、事前トレーニング、およびファインチューニングを開始するためには、[使用チュートリアル](./doc/en/usage.md) を参照してください。
### トレーニングスクリプト

詳細については、以下をご確認ください: [internevo.readthedocs.io](https://internevo.readthedocs.io/zh_CN/latest/?badge=latest)
まず、トレーニングスクリプトを準備してください [train.py](https://github.com/InternLM/InternEvo/blob/develop/train.py)

## システムアーキテクチャ
より詳細な説明については、以下を参照してください [トレーニングチュートリアル](https://internevo.readthedocs.io/en/latest/training.html#)

アーキテクチャの詳細については、[システムアーキテクチャドキュメント](./doc/en/structure.md)を参照してください。
### データの準備

## トレーニングパフォーマンス
次に、トレーニングまたはファインチューニングのためのデータを準備してください。

InternEvoは、Flash-Attention、Apexなどの高性能モデルオペレーターを深く統合してトレーニング効率を向上させています。Hybrid Zeroテクニックを構築することにより、計算と通信の効率的な重複を実現し、トレーニング中のクロスノード通信トラフィックを大幅に削減します。InternEvoは、7Bモデルを8つのGPUから1024個のGPUに拡張することをサポートし、千のGPUスケールで最大90%の加速効率、180 TFLOPSを超えるトレーニングスループット、そしてGPUあたり秒間3600トークン以上の平均を実現します。以下の表は、異なる構成でのInternEvoのスケーラビリティテストデータを示しています:
データセットをHuggingfaceからダウンロードし、roneneldan/TinyStories データセットを例にとって説明します:
```bash
huggingface-cli download --repo-type dataset --resume-download "roneneldan/TinyStories" --local-dir "/mnt/petrelfs/hf-TinyStories"
```

トークナイザーをローカルパスに配置してください。例として、https://huggingface.co/internlm/internlm2-7b/tree/main から special_tokens_map.json、tokenizer.model、tokenizer_config.json、tokenization_internlm2.py、tokenization_internlm2_fast.py をローカルの /mnt/petrelfs/hf-internlm2-tokenizer にダウンロードしてください。

次に、設定ファイルを以下のように変更します:
```bash
TRAIN_FOLDER = "/mnt/petrelfs/hf-TinyStories"
data = dict(
type="streaming",
tokenizer_path="/mnt/petrelfs/hf-internlm2-tokenizer",
)
```

| GPU 番号 | 8 | 16 | 32 | 64 | 128 | 256 | 512 | 1024 |
| ---------------- | ---- | ---- | ---- | ---- | ----- | ----- | ----- | ------ |
| TGS | 4078 | 3939 | 3919 | 3944 | 3928 | 3920 | 3835 | 3625 |
| TFLOPS | 193 | 191 | 188 | 188 | 187 | 185 | 186 | 184 |
他のタイプのデータセットの準備については、以下を参照してください [使用方法のチュートリアル](https://internevo.readthedocs.io/en/latest/usage.html#)

TGSは、GPUごとの秒間平均処理トークン数を表しています。より多くのパフォーマンステストデータについては、[トレーニングパフォーマンスドキュメント](./doc/en/train_performance.md) をご参照ください。
### Configuration File

設定ファイルの内容は以下の通りです:[7B_sft.py](https://github.com/InternLM/InternEvo/blob/develop/configs/7B_sft.py)

より詳細な紹介については、以下を参照してください [使用方法のチュートリアル](https://internevo.readthedocs.io/en/latest/usage.html#)

### トレーニング開始

トレーニングは、slurmまたはtorch distributed環境で開始できます。

Slurm環境で2ノード16カードを使用する場合、コマンドは以下の通りです:
```bash
$ srun -p internllm -N 2 -n 16 --ntasks-per-node=8 --gpus-per-task=1 python train.py --config ./configs/7B_sft.py
```

torchを使用し、1ノード8カードで実行する場合、コマンドは以下の通りです:
```bash
$ torchrun --nnodes=1 --nproc_per_node=8 train.py --config ./configs/7B_sft.py --launcher "torch"
```

## システムアーキテクチャ

アーキテクチャの詳細については、[システムアーキテクチャドキュメント](./doc/en/structure.md)を参照してください。

## フィーチャーズー

<div align="center">
<b>InternEvo フィーチャーズー</b>
</div>
<table align="center">
<tbody>
<tr align="center" valign="bottom">
<td>
<b>データ</b>
</td>
<td>
<b>モデル</b>
</td>
<td>
<b>並列</b>
</td>
<td>
<b>ツール</b>
</td>
</tr>
<tr valign="top">
<td>
<ul>
<li>Tokenized</li>
<li>Streaming</li>
</ul>
</td>
<td>
<ul>
<li><a href="configs/_base_/models/internlm/internlm_7B.py">InternLM</a></li>
<li><a href="configs/_base_/models/internlm/internlm2_7B.py">InternLM2</a></li>
</ul>
</td>
<td>
<ul>
<li>ZeRO 1.5</li>
<li>1F1B Pipeline Parallel</li>
<li>PyTorch FSDP Training</li>
<li>Megatron-LM Tensor Parallel (MTP)</li>
<li>Megatron-LM Sequence Parallel (MSP)</li>
<li>Flash-Attn Sequence Parallel (FSP)</li>
<li>Intern Sequence Parallel (ISP)</li>
<li>Memory Profiling</li>
</ul>
</td>
<td>
<ul>
<li><a href="tools/transformers/README.md">Convert ckpt to HF</a></li>
<li><a href="tools/transformers/README.md">Revert ckpt from HF</a></li>
<li><a href="tools/tokenizer.py">Raw Data Tokenizer</a></li>
<li><a href="tools/alpaca_tokenizer.py">Alpaca data Tokenizer</a></li>
</ul>
</td>
</tr>
</td>
</tr>
</tbody>
</table>

## コントリビュート

Expand Down
157 changes: 131 additions & 26 deletions README-zh-Hans.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@

<div align="center">

<img src="./doc/imgs/logo.svg" width="200"/>
<div> </div>
<div align="center">
<b><font size="5">InternEvo</font></b>
<sup>
<a href="https://internlm.intern-ai.org.cn/">
<i><font size="4">HOT</font></i>
</a>
</sup>
<div> </div>
</div>
<img src="./doc/imgs/InternEvo_logo.png" width="200"/>

[![使用文档](https://readthedocs.org/projects/internevo/badge/?version=latest)](https://internevo.readthedocs.io/zh_CN/latest/?badge=latest)
[![license](./doc/imgs/license.svg)](./LICENSE)
Expand All @@ -28,13 +18,13 @@

</div>

<p align="center">
👋 加入我们的 <a href="https://discord.gg/xa29JuW87d" target="_blank">Discord</a> 和 <a href="https://github.com/InternLM/InternLM/assets/25839884/a6aad896-7232-4220-ac84-9e070c2633ce" target="_blank">微信群</a>
</p>


### 新闻 🔥

- 2024/08/29: InternEvo支持流式加载huggingface格式的数据集。新增详细数据流程说明的指导文档。

- 2024/04/17: InternEvo支持在NPU-910B集群上训练模型。

- 2024/01/17: 更多关于InternLM系列模型的内容,请查看组织内的 [InternLM](https://github.com/InternLM/InternLM)


Expand All @@ -44,27 +34,142 @@ InternEvo是一个开源的轻量级训练框架,旨在支持无需大量依

基于InternEvo训练框架,我们累计发布了一系列大语言模型,包括InternLM-7B系列和InternLM-20B系列,这些模型在性能上显著超越了许多知名的开源LLMs,如LLaMA和其他模型。

## 安装

首先,安装指定版本的torch, torchvision, torchaudio, and torch-scatter.
例如:
```bash
pip install --extra-index-url https://download.pytorch.org/whl/cu118 torch==2.1.0+cu118 torchvision==0.16.0+cu118 torchaudio==2.1.0+cu118
pip install torch-scatter -f https://data.pyg.org/whl/torch-2.1.0+cu118.html
```

安装InternEvo:
```bash
pip install InternEvo
```

安装flash-attention (version v2.2.1):

如果需要使用flash-attention加速训练, 并且环境中支持, 按如下方式安装:
```bash
pip install flash-attn==2.2.1
```

有关安装环境以及源码方式安装的更多详细信息,请参考[安装文档](https://internevo.readthedocs.io/zh-cn/latest/install.html#)

## 快速开始

请查看 [Usage Tutorial](./doc/en/usage.md) 来开始InternEvo的安装、数据处理、预训练与微调。
### 训练脚本

更多细节请查看文档 [internevo.readthedocs.io](https://internevo.readthedocs.io/zh_CN/latest/?badge=latest)
首先,准备训练脚本,参考:[train.py](https://github.com/InternLM/InternEvo/blob/develop/train.py)

## 系统架构
有关训练脚本的更多详细解释,请参考[训练文档](https://internevo.readthedocs.io/zh-cn/latest/training.html#)

### 数据准备

Please refer to the [System Architecture document](./doc/en/structure.md) for architecture details.
其次,准备训练或者微调的数据。

## 框架性能
从huggingface下载数据集,以 `roneneldan/TinyStories` 数据集为例:
```bash
huggingface-cli download --repo-type dataset --resume-download "roneneldan/TinyStories" --local-dir "/mnt/petrelfs/hf-TinyStories"
```

InternEvo深度集成了Flash-Attention、Apex等高性能计算库,以提高训练效率。通过构建Hybrid Zero技术,InternEvo可在训练过程中实现计算和通信的有效重叠,显著降低跨节点通信流量。InternEvo支持将7B模型从8个GPU扩展到1024个GPU,在千卡规模下可实现高达90%的加速效率,超过180 TFLOPS的训练吞吐量,平均每个GPU每秒可处理超过3600个tokens。下表展示了InternEvo在不同配置下的可扩展性测试数据:
获取分词器到本地路径。例如,从 `https://huggingface.co/internlm/internlm2-7b/tree/main` 下载special_tokens_map.json、tokenizer.model、tokenizer_config.json、tokenization_internlm2.py和tokenization_internlm2_fast.py文件,并保存到本地路径: `/mnt/petrelfs/hf-internlm2-tokenizer` 。

| GPU Number | 8 | 16 | 32 | 64 | 128 | 256 | 512 | 1024 |
| ---------------- | ---- | ---- | ---- | ---- | ----- | ----- | ----- | ------ |
| TGS | 4078 | 3939 | 3919 | 3944 | 3928 | 3920 | 3835 | 3625 |
| TFLOPS | 193 | 191 | 188 | 188 | 187 | 185 | 186 | 184 |
然后,修改配置文件:
```bash
TRAIN_FOLDER = "/mnt/petrelfs/hf-TinyStories"
data = dict(
type="streaming",
tokenizer_path="/mnt/petrelfs/hf-internlm2-tokenizer",
)
```

TGS表示每张GPU每秒可处理的平均Tokens数量。更多模型性能测试数据细节请查看 [Training Performance document](./doc/en/train_performance.md)
对于其他数据集类型的准备方式,请参考:[用户文档](https://internevo.readthedocs.io/zh-cn/latest/usage.html#)

### 配置文件

配置文件的内容,请参考:[7B_sft.py](https://github.com/InternLM/InternEvo/blob/develop/configs/7B_sft.py)

关于配置文件更多详细的说明,请参考:[用户文档](https://internevo.readthedocs.io/zh-cn/latest/usage.html#)

### 开启训练

可以在 slurm 或者 torch 分布式环境中开始训练。

slurm环境,双机16卡,启动训练命令如下:
```bash
$ srun -p internllm -N 2 -n 16 --ntasks-per-node=8 --gpus-per-task=1 python train.py --config ./configs/7B_sft.py
```

torch环境,单机8卡,启动训练命令如下:
```bash
$ torchrun --nnodes=1 --nproc_per_node=8 train.py --config ./configs/7B_sft.py --launcher "torch"
```

## 系统架构

系统架构细节请参考:[系统架构文档](./doc/structure.md)

## 特性列表

<div align="center">
<b>InternEvo 特性列表</b>
</div>
<table align="center">
<tbody>
<tr align="center" valign="bottom">
<td>
<b>数据集</b>
</td>
<td>
<b>模型</b>
</td>
<td>
<b>并行模式</b>
</td>
<td>
<b>工具</b>
</td>
</tr>
<tr valign="top">
<td>
<ul>
<li>已分词数据集</li>
<li>流式数据集</li>
</ul>
</td>
<td>
<ul>
<li><a href="configs/_base_/models/internlm/internlm_7B.py">InternLM</a></li>
<li><a href="configs/_base_/models/internlm/internlm2_7B.py">InternLM2</a></li>
</ul>
</td>
<td>
<ul>
<li>ZeRO 1.5</li>
<li>1F1B 流水线并行</li>
<li>PyTorch FSDP 训练</li>
<li>Megatron-LM 张量并行 (MTP)</li>
<li>Megatron-LM 序列化并行 (MSP)</li>
<li>Flash-Attn 序列化并行 (FSP)</li>
<li>Intern 序列化并行 (ISP)</li>
<li>内存性能分析</li>
</ul>
</td>
<td>
<ul>
<li><a href="tools/transformers/README-zh-Hans.md">将ckpt转为huggingface格式</a></li>
<li><a href="tools/transformers/README-zh-Hans.md">将ckpt从huggingface格式转为InternEvo格式</a></li>
<li><a href="tools/tokenizer.py">原始数据分词器</a></li>
<li><a href="tools/alpaca_tokenizer.py">Alpaca数据分词器</a></li>
</ul>
</td>
</tr>
</td>
</tr>
</tbody>
</table>

## 贡献

Expand Down
Loading