Skip to content

Commit e19c6ae

Browse files
flybird11111ver217digger-yubinmakeswell
authored
[CI] run pre-commit (#5577)
* fix * [release] update version (#5411) * [hotfix] fix typo s/keywrods/keywords etc. (#5429) * [devops] fix compatibility (#5444) * [devops] fix compatibility * [hotfix] update compatibility test on pr * [devops] fix compatibility * [devops] record duration during comp test * [test] decrease test duration * fix falcon * [shardformer] fix gathering output when using tensor parallelism (#5431) * fix * padding vocab_size when using pipeline parallellism padding vocab_size when using pipeline parallellism fix fix * fix * fix fix fix * fix gather output * fix * fix * fix fix resize embedding fix resize embedding * fix resize embedding fix * revert * revert * revert * [doc] release Open-Sora 1.0 with model weights (#5468) * [doc] release Open-Sora 1.0 with model weights * [doc] release Open-Sora 1.0 with model weights * [doc] release Open-Sora 1.0 with model weights * [doc] update open-sora demo (#5479) * [doc] update open-sora demo * [doc] update open-sora demo * [doc] update open-sora demo * [example] add grok-1 inference (#5485) * [misc] add submodule * remove submodule * [example] support grok-1 tp inference * [example] add grok-1 inference script * [example] refactor code * [example] add grok-1 readme * [exmaple] add test ci * [exmaple] update readme * run pre-commit --------- Co-authored-by: Hongxin Liu <[email protected]> Co-authored-by: digger yu <[email protected]> Co-authored-by: binmakeswell <[email protected]>
1 parent 179e73e commit e19c6ae

File tree

82 files changed

+894
-887
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+894
-887
lines changed

.github/workflows/build_on_pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,4 @@ jobs:
201201
uses: actions/upload-artifact@v3
202202
with:
203203
name: report
204-
path: report/
204+
path: report/

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,4 +551,4 @@ Copyright 2021- HPC-AI Technology Inc. All rights reserved.
551551
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
552552
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
553553
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
554-
THE SOFTWARE.
554+
THE SOFTWARE.

applications/Chat/benchmarks/benchmark_opt_lora_dummy.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@ def main(args):
7676
if args.strategy == "ddp":
7777
strategy = DDPStrategy()
7878
elif args.strategy == "colossalai_gemini":
79-
strategy = GeminiStrategy(placement_policy="static",initial_scale=2**5)
79+
strategy = GeminiStrategy(placement_policy="static", initial_scale=2**5)
8080
elif args.strategy == "colossalai_gemini_cpu":
81-
strategy = GeminiStrategy(placement_policy="static", offload_optim_frac=1.0, offload_param_frac=1.0, initial_scale=2**5)
81+
strategy = GeminiStrategy(
82+
placement_policy="static", offload_optim_frac=1.0, offload_param_frac=1.0, initial_scale=2**5
83+
)
8284
elif args.strategy == "colossalai_zero2":
8385
strategy = LowLevelZeroStrategy(stage=2, placement_policy="cuda")
8486
elif args.strategy == "colossalai_zero2_cpu":

applications/Chat/coati/dataset/sft_dataset.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,21 @@ def _preprocess(
5151
"""Preprocess the data by tokenizing."""
5252
sequences = [s + t + tokenizer.eos_token for s, t in zip(sources, targets)]
5353
sequences_token = tokenizer(
54-
sequences, max_length=max_length, padding="max_length", truncation=True, return_tensors="pt", add_special_tokens=False
54+
sequences,
55+
max_length=max_length,
56+
padding="max_length",
57+
truncation=True,
58+
return_tensors="pt",
59+
add_special_tokens=False,
5560
)
5661

5762
sources_token = tokenizer(
58-
sources, max_length=max_length, padding="max_length", truncation=True, return_tensors="pt", add_special_tokens=False
63+
sources,
64+
max_length=max_length,
65+
padding="max_length",
66+
truncation=True,
67+
return_tensors="pt",
68+
add_special_tokens=False,
5969
)
6070

6171
assert sequences_token["attention_mask"].dim() == 2, "seq2seq model should be preprocessed differently"
@@ -66,7 +76,7 @@ def _preprocess(
6676
if tokenizer.padding_side == "right":
6777
# |prompt|completion|eos|pad|
6878
labels[i][:source_len] = IGNORE_INDEX
69-
if pad_len>0:
79+
if pad_len > 0:
7080
labels[i][-pad_len:] = IGNORE_INDEX
7181
elif tokenizer.padding_side == "left":
7282
# |pad|prompt|completion|eos|

applications/Chat/coati/models/base/actor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,3 @@ def forward(
3030
"""Returns model output."""
3131
output = self.model(input_ids, attention_mask=attention_mask, **model_kwargs)
3232
return output
33-

applications/Chat/coati/ray/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ def get_strategy_from_args(strategy: str):
7575
elif strategy == "colossalai_zero2":
7676
strategy_ = LowLevelZeroStrategy(stage=2, placement_policy="cuda")
7777
elif strategy == "colossalai_gemini_cpu":
78-
strategy_ = GeminiStrategy(placement_policy="static", offload_optim_frac=1.0, offload_param_frac=1.0, initial_scale=2**5)
78+
strategy_ = GeminiStrategy(
79+
placement_policy="static", offload_optim_frac=1.0, offload_param_frac=1.0, initial_scale=2**5
80+
)
7981
elif strategy == "colossalai_zero2_cpu":
8082
strategy_ = LowLevelZeroStrategy(stage=2, placement_policy="cpu")
8183
else:

applications/Chat/coati/trainer/strategies/ddp.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,17 @@ def save_pretrained(
101101

102102
model_path = os.path.join(path, "pytorch_model.bin")
103103
self.save_model(model, model_path, shard=shard)
104+
104105
def _replace_keys(model_path: str, replace_fn: Callable):
105106
state_dict = torch.load(model_path, map_location="cpu")
106107
state_dict = {replace_fn(k): v for k, v in state_dict.items()}
107108
torch.save(state_dict, model_path)
109+
108110
# FIXME: save_model would add "model." prefix to keys of pytorch_model.bin
109111
# HACK: rename keys of pytorch_model.bin
110112
if dist.get_rank() == 0:
111113
_replace_keys(model_path, lambda k: k.replace("model.", "", 1))
112114

113-
114115
def get_model_state_dict_shard(self, model: nn.Module, **config):
115116
# TODO: implement sharding on naive strategy
116117
model = self.unwrap_model(model)

applications/Chat/examples/community/peft/train_peft_prompts.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ def main(args):
2424
if args.strategy == "ddp":
2525
strategy = DDPStrategy()
2626
elif args.strategy == "colossalai_gemini":
27-
strategy = GeminiStrategy(placement_policy="static", offload_optim_frac=1.0, offload_param_frac=1.0, initial_scale=2**5)
27+
strategy = GeminiStrategy(
28+
placement_policy="static", offload_optim_frac=1.0, offload_param_frac=1.0, initial_scale=2**5
29+
)
2830
elif args.strategy == "colossalai_zero2":
2931
strategy = LowLevelZeroStrategy(stage=2, placement_policy="cpu")
3032
else:

applications/Chat/examples/train_sft.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ torchrun --standalone --nproc_per_node=4 train_sft.py \
2525
--accumulation_steps 8 \
2626
--lr 2e-5 \
2727
--max_datasets_size 512 \
28-
--max_epochs 1
28+
--max_epochs 1

applications/Colossal-LLaMA-2/colossal_llama2/model/init_model.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88

99
import numpy as np
1010
import torch
11-
from transformers import LlamaTokenizer, LlamaForCausalLM
11+
from transformers import LlamaForCausalLM, LlamaTokenizer
1212

1313
from colossalai.logging import get_dist_logger
1414

15-
1615
logger = get_dist_logger()
1716

1817

0 commit comments

Comments
 (0)