Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ShardFormer] Add Ulysses Sequence Parallelism support for Command-R, Qwen2 and ChatGLM #5854

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2793854
Add Ulysses SP support for Qwen2
GuangyaoZhang Jun 24, 2024
dd8b5ec
Add Ulysses SP support for ChatGLM
GuangyaoZhang Jun 25, 2024
4b1ce24
Add Ulysses SP support for Command-R
GuangyaoZhang Jun 25, 2024
5c5fd30
Fix pytest typo
GuangyaoZhang Jun 25, 2024
2a25a2a
[Feature] optimize PP overlap (#5735)
Edenzzzz Jun 26, 2024
8e718a1
[gemini] fixes for benchmarking (#5847)
botbw Jun 26, 2024
5dfbcd7
[zero] use bucket during allgather (#5860)
ver217 Jun 27, 2024
d9d5e7e
[shardformer] Support the T5ForTokenClassification model (#5816)
GuangyaoZhang Jun 27, 2024
3c7cda0
[Inference]Lazy Init Support (#5785)
LRY89757 Jun 27, 2024
eaea88c
[release] update version (#5864)
ver217 Jun 28, 2024
773d9f9
[shardformer]delete xformers (#5859)
flybird11111 Jun 28, 2024
416580b
[MoE/ZeRO] Moe refactor with zero refactor (#5821)
Hz188 Jun 28, 2024
3dc0d1d
ChatGLM, Qwen2, Command-R Support SP+PP together
GuangyaoZhang Jun 28, 2024
f9d544b
remove unnecessary pytest
GuangyaoZhang Jun 30, 2024
8ab46b4
[Shardformer] change qwen2 modeling into gradient checkpointing styl…
CjhHa1 Jul 1, 2024
936d0b0
[doc] Update llama + sp compatibility; fix dist optim table
Edenzzzz Jul 1, 2024
7c2f79f
[pre-commit.ci] pre-commit autoupdate (#5572)
pre-commit-ci[bot] Jul 1, 2024
ea94c07
[hotfix] fix the bug that large tensor exceed the maximum capacity of…
Hz188 Jul 2, 2024
133bbd5
revert some exchange to avoid misunderstanding caused by git diff
GuangyaoZhang Jul 3, 2024
eb24fcd
[Hotfix] Fix OPT gradient checkpointing forward
Edenzzzz Jul 3, 2024
6cd4c32
[shardformer] fix the moe (#5883)
wangbluo Jul 3, 2024
7afbc81
[quant] fix bitsandbytes version check (#5882)
ver217 Jul 4, 2024
7997683
[pre-commit.ci] pre-commit autoupdate (#5878)
pre-commit-ci[bot] Jul 4, 2024
3420921
[shardformer] DeepseekMoE support (#5871)
Hz188 Jul 5, 2024
8ec24b6
[Hoxfix] Fix CUDA_DEVICE_MAX_CONNECTIONS for comm overlap
Edenzzzz Jul 5, 2024
cba2052
[Feat] Diffusion Model(PixArtAlpha/StableDiffusion3) Support (#5838)
LRY89757 Jul 8, 2024
392933a
ChatGLM sp with pp redundance removal
GuangyaoZhang Jul 8, 2024
66abf1c
[HotFix] CI,import,requirements-test for #5838 (#5892)
LRY89757 Jul 8, 2024
b554515
Add Ulysses SP support for Qwen2
GuangyaoZhang Jun 24, 2024
f5aa99b
Add Ulysses SP support for ChatGLM
GuangyaoZhang Jun 25, 2024
8cbb469
Add Ulysses SP support for Command-R
GuangyaoZhang Jun 25, 2024
6b5cf33
Fix pytest typo
GuangyaoZhang Jun 25, 2024
9861cd2
ChatGLM, Qwen2, Command-R Support SP+PP together
GuangyaoZhang Jun 28, 2024
2218792
remove unnecessary pytest
GuangyaoZhang Jun 30, 2024
7334a5b
revert some exchange to avoid misunderstanding caused by git diff
GuangyaoZhang Jul 3, 2024
0ae41f5
ChatGLM sp with pp redundance removal
GuangyaoZhang Jul 8, 2024
82164a7
Merge branch 'sp' of github.com:GuangyaoZhang/ColossalAI into sp
GuangyaoZhang Jul 9, 2024
64359a6
Empty Commit to trigger build on PR
GuangyaoZhang Jul 9, 2024
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
3 changes: 2 additions & 1 deletion .github/workflows/build_on_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
runs-on: [self-hosted, gpu]
container:
image: hpcaitech/pytorch-cuda:2.1.0-12.1.0
options: --gpus all --rm -v /dev/shm -v /data/scratch/llama-tiny:/data/scratch/llama-tiny
options: --gpus all --rm -v /dev/shm -v /data/scratch:/data/scratch
timeout-minutes: 90
defaults:
run:
Expand Down Expand Up @@ -165,6 +165,7 @@ jobs:
env:
LD_LIBRARY_PATH: /github/home/.tensornvme/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
LLAMA_PATH: /data/scratch/llama-tiny
MOE_TENSOR_PATH: /data/scratch/moe_tensors

- name: Collate artifact
env:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build_on_schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: [self-hosted, gpu]
container:
image: hpcaitech/pytorch-cuda:2.1.0-12.1.0
options: --gpus all --rm -v /dev/shm -v /data/scratch/llama-tiny:/data/scratch/llama-tiny
options: --gpus all --rm -v /dev/shm -v /data/scratch/:/data/scratch/
timeout-minutes: 90
steps:
- name: Check GPU Availability # ensure all GPUs have enough memory
Expand Down Expand Up @@ -69,6 +69,7 @@ jobs:
env:
LD_LIBRARY_PATH: /github/home/.tensornvme/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
LLAMA_PATH: /data/scratch/llama-tiny
MOE_TENSOR_PATH: /data/scratch/moe_tensors

- name: Notify Lark
id: message-preparation
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/compatiblity_test_on_dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
matrix: ${{fromJson(needs.matrix_preparation.outputs.matrix)}}
container:
image: ${{ matrix.container }}
options: --gpus all --rm -v /dev/shm -v /data/scratch/cifar-10:/data/scratch/cifar-10 -v /data/scratch/llama-tiny:/data/scratch/llama-tiny
options: --gpus all --rm -v /dev/shm -v /data/scratch/:/data/scratch/
timeout-minutes: 200
steps:
- name: Install dependencies
Expand Down Expand Up @@ -92,3 +92,4 @@ jobs:
DATA: /data/scratch/cifar-10
LD_LIBRARY_PATH: /github/home/.tensornvme/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
LLAMA_PATH: /data/scratch/llama-tiny
MOE_TENSOR_PATH: /data/scratch/moe_tensors
3 changes: 2 additions & 1 deletion .github/workflows/compatiblity_test_on_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
matrix: ${{fromJson(needs.matrix_preparation.outputs.matrix)}}
container:
image: ${{ matrix.container }}
options: --gpus all --rm -v /dev/shm -v /data/scratch/cifar-10:/data/scratch/cifar-10 -v /data/scratch/llama-tiny:/data/scratch/llama-tiny
options: --gpus all --rm -v /dev/shm -v /data/scratch/:/data/scratch/
timeout-minutes: 200
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-run-test-${{ matrix.container }}
Expand Down Expand Up @@ -87,3 +87,4 @@ jobs:
DATA: /data/scratch/cifar-10
LD_LIBRARY_PATH: /github/home/.tensornvme/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
LLAMA_PATH: /data/scratch/llama-tiny
MOE_TENSOR_PATH: /data/scratch/moe_tensors
3 changes: 2 additions & 1 deletion .github/workflows/compatiblity_test_on_schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
matrix: ${{fromJson(needs.matrix_preparation.outputs.matrix)}}
container:
image: ${{ matrix.container }}
options: --gpus all --rm -v /dev/shm -v /data/scratch/cifar-10:/data/scratch/cifar-10 -v /data/scratch/llama-tiny:/data/scratch/llama-tiny
options: --gpus all --rm -v /dev/shm -v /data/scratch/:/data/scratch/
timeout-minutes: 200
steps:
- name: Install dependencies
Expand Down Expand Up @@ -85,6 +85,7 @@ jobs:
DATA: /data/scratch/cifar-10
LD_LIBRARY_PATH: /github/home/.tensornvme/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
LLAMA_PATH: /data/scratch/llama-tiny
MOE_TENSOR_PATH: /data/scratch/moe_tensors

- name: Notify Lark
id: message-preparation
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
repos:

- repo: https://github.com/PyCQA/autoflake
rev: v2.2.1
rev: v2.3.1
hooks:
- id: autoflake
name: autoflake (python)
args: ['--in-place', '--remove-unused-variables', '--remove-all-unused-imports', '--ignore-init-module-imports']

- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
name: sort all imports (python)

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1
rev: 24.4.2
hooks:
- id: black
name: black formatter
args: ['--line-length=120', '--target-version=py37', '--target-version=py38', '--target-version=py39','--target-version=py310']

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v13.0.1
rev: v18.1.8
hooks:
- id: clang-format
name: clang formatter
types_or: [c++, c]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.6.0
hooks:
- id: check-yaml
- id: check-merge-conflict
Expand Down
16 changes: 10 additions & 6 deletions applications/ColossalChat/coati/dataset/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,19 @@ def __call__(self, instances: Sequence[Dict[str, List[int]]]) -> Dict[str, torch

# `List[torch.Tensor]`
batch_input_ids = [
torch.LongTensor(instance["input_ids"][: self.max_length])
if len(instance["input_ids"]) > self.max_length
else torch.LongTensor(instance["input_ids"])
(
torch.LongTensor(instance["input_ids"][: self.max_length])
if len(instance["input_ids"]) > self.max_length
else torch.LongTensor(instance["input_ids"])
)
for instance in instances
]
batch_labels = [
torch.LongTensor(instance["labels"][: self.max_length])
if len(instance["labels"]) > self.max_length
else torch.LongTensor(instance["labels"])
(
torch.LongTensor(instance["labels"][: self.max_length])
if len(instance["labels"]) > self.max_length
else torch.LongTensor(instance["labels"])
)
for instance in instances
]
if self.tokenizer.padding_side == "right":
Expand Down
1 change: 1 addition & 0 deletions applications/ColossalChat/coati/models/loss.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
loss functions
"""

from typing import Optional, Tuple

import torch
Expand Down
1 change: 1 addition & 0 deletions applications/ColossalChat/coati/models/reward_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
reward model
"""

from typing import Optional

import torch
Expand Down
1 change: 1 addition & 0 deletions applications/ColossalChat/coati/trainer/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Training utilities for Coati.
"""

from typing import Any

import torch
Expand Down
14 changes: 12 additions & 2 deletions applications/ColossalEval/colossal_eval/dataset/agieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ def get_prompt(line: Dict, dataset_name: str, logger: DistributedLogger) -> Dict
option_string = "ABCDEFG"
count = len(line["options"])

input = "问题:" + line["question"] + " " + "从以下选项中选择:" + " ".join(line["options"]) + "\n" + "答案:"
input = (
"问题:" + line["question"] + " " + "从以下选项中选择:" + " ".join(line["options"]) + "\n" + "答案:"
)

all_classes = list(option_string[0:count])

Expand Down Expand Up @@ -150,7 +152,15 @@ def combine_prompt(prompt_path, dataset_name, load_explanation=True, chat_mode=F
)
elif dataset_name in chinese_qa_datasets:
question_input = (
"问题:" + passage + " " + question + "\n" + "从以下选项中选择:" + " ".join(options) + "\n" + "答案:{}".format(label)
"问题:"
+ passage
+ " "
+ question
+ "\n"
+ "从以下选项中选择:"
+ " ".join(options)
+ "\n"
+ "答案:{}".format(label)
)
elif dataset_name in english_cloze_datasets:
question_input = "Question: ".format(idx + 1) + question + "\n" + "Answer: {}".format(answer)
Expand Down
6 changes: 5 additions & 1 deletion applications/ColossalEval/colossal_eval/dataset/ceval.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@
"urban_and_rural_planner": ["Urban and Rural Planner", "注册城乡规划师", "Other"],
"accountant": ["Accountant", "注册会计师", "Other"],
"fire_engineer": ["Fire Engineer", "注册消防工程师", "Other"],
"environmental_impact_assessment_engineer": ["Environmental Impact Assessment Engineer", "环境影响评价工程师", "Other"],
"environmental_impact_assessment_engineer": [
"Environmental Impact Assessment Engineer",
"环境影响评价工程师",
"Other",
],
"tax_accountant": ["Tax Accountant", "税务师", "Other"],
"physician": ["Physician", "医师资格", "Other"],
}
Expand Down
8 changes: 5 additions & 3 deletions applications/ColossalEval/colossal_eval/dataset/mtbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ def load(path: str, logger: DistributedLogger, few_shot: bool) -> List[Dict]:
"instruction": question["turns"],
"input": "",
"output": [],
"target": [""] * turn_number
if question["question_id"] not in reference
else reference[question["question_id"]],
"target": (
[""] * turn_number
if question["question_id"] not in reference
else reference[question["question_id"]]
),
}

if category in dataset["test"]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def _get_choices_indices(self, language: str):
self.indices_for_choices[0].append(
self.tokenizer(f"Answer: {choice}", add_special_tokens=False).input_ids[-1]
)
self.indices_for_choices[1].append(self.tokenizer(f"答案:{choice}", add_special_tokens=False).input_ids[-1])
self.indices_for_choices[1].append(
self.tokenizer(f"答案:{choice}", add_special_tokens=False).input_ids[-1]
)

def _load_tokenizer(self, path: str, tokenizer_path: Optional[str], tokenizer_kwargs: dict):
"""
Expand Down
Empty file.
Empty file.
92 changes: 0 additions & 92 deletions applications/ColossalMoE/colossal_moe/models/mixtral_layer.py

This file was deleted.

4 changes: 0 additions & 4 deletions applications/ColossalMoE/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import torch
import torch.distributed as dist
from colossal_moe.models.mixtral_checkpoint import MixtralMoEHybridParallelCheckpointIO
from colossal_moe.models.mixtral_policy import MixtralForCausalLMPolicy
from transformers import AutoTokenizer
from transformers.models.mixtral import MixtralConfig, MixtralForCausalLM

Expand Down Expand Up @@ -70,8 +68,6 @@ def main():
ep_size=ep_size,
zero_stage=1,
precision=args.precision,
custom_policy=MixtralForCausalLMPolicy(),
checkpoint_io=MixtralMoEHybridParallelCheckpointIO,
enable_fused_normalization=args.use_layernorm_kernel,
enable_jit_fused=args.use_kernel,
)
Expand Down
3 changes: 2 additions & 1 deletion applications/ColossalMoE/infer.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
NUM_GPU=2
MODEL="mistralai/Mixtral-8x7B-v0.1"
# MODEL="mistralai/Mixtral-8x7B-v0.1"
MODEL="mistralai/Mixtral-8x7B-Instruct-v0.1"

# ep
torchrun --standalone --nproc_per_node $NUM_GPU infer.py \
Expand Down
Loading
Loading