From 7a7e86987dd3f8a43e338ce9d6f6f4c019cc5073 Mon Sep 17 00:00:00 2001 From: YeAnbang Date: Mon, 27 May 2024 05:55:57 +0000 Subject: [PATCH 01/19] upgrade colossal-chat support tp_group>1, add sp for sft --- .../coati/dataset/conversation.py | 5 +- .../ColossalChat/coati/dataset/loader.py | 25 +- .../coati/dataset/tokenization_utils.py | 44 +- .../ColossalChat/coati/dataset/utils.py | 11 +- .../01-ai_Yi-1.5-9B-Chat.json | 8 + .../{Vicuna.json => 01-ai_Yi-34B.json} | 5 +- .../{chatGLM2.json => THUDM_chatglm2-6b.json} | 5 +- .../THUDM_chatglm3-6b.json | 8 + .../config/conversation_template/Yi.json | 7 - ...n => baichuan-inc_Baichuan2-13B-Chat.json} | 7 +- .../colossal-llama2.json | 5 +- .../deepseek-ai_DeepSeek-V2-Lite.json | 8 + .../config/conversation_template/llama2.json | 5 +- .../microsoft_phi-2.json | 8 + ...mistralai_Mixtral-8x7B-Instruct-v0.1.json} | 5 +- .../config/conversation_template/zephyr.json | 7 - applications/ColossalChat/examples/README.md | 13 +- .../prepare_dataset.py | 2 +- .../prepare_sft_dataset.sh | 17 +- .../examples/training_scripts/hostfile | 2 +- .../examples/training_scripts/train_sft.py | 90 +- .../examples/training_scripts/train_sft.sh | 48 +- applications/ColossalChat/requirements.txt | 5 +- .../ColossalChat/tests/test_chat_template.py | 38 + .../chat_template/01-ai_Yi-1.5-9B-Chat.json | 585 +++++ .../test_data/chat_template/01-ai_Yi-34B.json | 607 +++++ .../chat_template/Qwen_Qwen-7B-Chat.json | 603 +++++ .../chat_template/THUDM_chatglm2-6b.json | 715 ++++++ .../chat_template/THUDM_chatglm3-6b.json | 585 +++++ .../baichuan-inc_Baichuan2-13B-Chat.json | 697 ++++++ .../deepseek-ai_DeepSeek-V2-Lite.json | 581 +++++ .../chat_template/microsoft_phi-2.json | 2009 +++++++++++++++++ .../mistralai_Mixtral-8x7B-Instruct-v0.1.json | 919 ++++++++ 33 files changed, 7574 insertions(+), 105 deletions(-) create mode 100644 applications/ColossalChat/config/conversation_template/01-ai_Yi-1.5-9B-Chat.json rename applications/ColossalChat/config/conversation_template/{Vicuna.json => 01-ai_Yi-34B.json} (97%) rename applications/ColossalChat/config/conversation_template/{chatGLM2.json => THUDM_chatglm2-6b.json} (90%) create mode 100644 applications/ColossalChat/config/conversation_template/THUDM_chatglm3-6b.json delete mode 100644 applications/ColossalChat/config/conversation_template/Yi.json rename applications/ColossalChat/config/conversation_template/{Qwen.json => baichuan-inc_Baichuan2-13B-Chat.json} (88%) create mode 100644 applications/ColossalChat/config/conversation_template/deepseek-ai_DeepSeek-V2-Lite.json create mode 100644 applications/ColossalChat/config/conversation_template/microsoft_phi-2.json rename applications/ColossalChat/config/conversation_template/{mistral.json => mistralai_Mixtral-8x7B-Instruct-v0.1.json} (93%) delete mode 100644 applications/ColossalChat/config/conversation_template/zephyr.json create mode 100644 applications/ColossalChat/tests/test_chat_template.py create mode 100644 applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-1.5-9B-Chat.json create mode 100644 applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-34B.json create mode 100644 applications/ColossalChat/tests/test_data/chat_template/Qwen_Qwen-7B-Chat.json create mode 100644 applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm2-6b.json create mode 100644 applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm3-6b.json create mode 100644 applications/ColossalChat/tests/test_data/chat_template/baichuan-inc_Baichuan2-13B-Chat.json create mode 100644 applications/ColossalChat/tests/test_data/chat_template/deepseek-ai_DeepSeek-V2-Lite.json create mode 100644 applications/ColossalChat/tests/test_data/chat_template/microsoft_phi-2.json create mode 100644 applications/ColossalChat/tests/test_data/chat_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json diff --git a/applications/ColossalChat/coati/dataset/conversation.py b/applications/ColossalChat/coati/dataset/conversation.py index 15a33be93..ec46ea429 100755 --- a/applications/ColossalChat/coati/dataset/conversation.py +++ b/applications/ColossalChat/coati/dataset/conversation.py @@ -17,6 +17,7 @@ class Conversation: system_message: str chat_template: str stop_ids: List[int] + end_of_assistant: str @classmethod def from_config(cls, tokenizer: PreTrainedTokenizer, config: Dict): @@ -24,7 +25,7 @@ class Conversation: Setup the conversation template from config """ tokenizer.chat_template = config["chat_template"] - conv = cls(tokenizer, config["system_message"], config["chat_template"], config["stop_ids"]) + conv = cls(tokenizer, config["system_message"], config["chat_template"], config["stop_ids"], config["end_of_assistant"]) conv.clear() return conv @@ -109,6 +110,8 @@ def setup_conversation_template( """ if any([s not in chat_template_config.keys() for s in Conversation.get_conversation_template_keys()]): # Try to automatically set up conversation template, if fail, it throws an error that you need to do it manually + if "end_of_assistant" not in chat_template_config: + raise ValueError("Please set the end of assistant token.") if "system_message" not in chat_template_config: logger.warning("No system message is provided, will not use system message.") if "chat_template" not in chat_template_config: diff --git a/applications/ColossalChat/coati/dataset/loader.py b/applications/ColossalChat/coati/dataset/loader.py index 93cc1dab8..26f210eb2 100755 --- a/applications/ColossalChat/coati/dataset/loader.py +++ b/applications/ColossalChat/coati/dataset/loader.py @@ -248,9 +248,9 @@ class StatefulDistributedSampler(DistributedSampler): shuffle: bool = True, seed: int = 0, drop_last: bool = False, - use_tp: Optional[bool] = False, + tp_size: int = 1, ) -> None: - if not use_tp: + if not tp_size>1: super().__init__( dataset=dataset, num_replicas=num_replicas, @@ -261,14 +261,16 @@ class StatefulDistributedSampler(DistributedSampler): ) else: # adapted from https://github.com/pytorch/pytorch/blob/4979f9c0d72490970e2019bb1d2284f83d93f76b/torch/utils/data/distributed.py#L62 - # TODO: support tp_group>1. will fix it later - num_replicas = 1 if rank is None: rank = dist.get_rank() + world_size = dist.get_world_size() + dp_size = world_size // tp_size # data parallel size + dp_rank = int(rank / tp_size) # data parallel rank if rank < 0: raise ValueError(f"Invalid rank {rank}, rank should be in the interval [0, 0]") self.dataset = dataset self.num_replicas = num_replicas + self.dp_rank = dp_rank self.rank = rank self.epoch = 0 self.drop_last = drop_last @@ -287,10 +289,10 @@ class StatefulDistributedSampler(DistributedSampler): self.shuffle = shuffle self.seed = seed self.start_index = 0 - self.use_tp = use_tp + self.tp_size = tp_size def __iter__(self) -> Iterator: - if self.use_tp: + if self.tp_size > 1: # TODO Add support for tp_group not equal to 1 pass # adpated from https://github.com/pytorch/pytorch/blob/4979f9c0d72490970e2019bb1d2284f83d93f76b/torch/utils/data/distributed.py#L96 @@ -316,10 +318,9 @@ class StatefulDistributedSampler(DistributedSampler): # subsample indices = indices[ - : self.total_size : self.num_replicas + self.dp_rank: self.dp_rank + self.total_size : self.num_replicas ] # num_replicas=tp_group=1, we only support tp_group==1 for now assert len(indices) == self.num_samples - return iter(indices) else: @@ -345,7 +346,7 @@ def setup_distributed_dataloader( num_workers: int = 0, collate_fn: Callable[[Sequence[Dict[str, Union[str, List[int]]]]], Dict[str, torch.Tensor]] = None, process_group: Optional[ProcessGroup] = None, - use_tp: Optional[bool] = False, + tp_size: Optional[int] = 1, **kwargs, ) -> DataLoader: """ @@ -353,14 +354,16 @@ def setup_distributed_dataloader( """ _kwargs = kwargs.copy() process_group = process_group or _get_default_group() + # world_size = tp_size * pp_size + assert process_group.size()%tp_size == 0, f"process_group.size()={process_group.size()} must be divisible by tp_size={tp_size}" sampler = StatefulDistributedSampler( dataset=dataset, - num_replicas=process_group.size() if not use_tp else 1, + num_replicas=int(process_group.size()/tp_size), rank=process_group.rank(), shuffle=shuffle, seed=seed, drop_last=drop_last, - use_tp=use_tp, + tp_size=tp_size, ) # Deterministic dataloader diff --git a/applications/ColossalChat/coati/dataset/tokenization_utils.py b/applications/ColossalChat/coati/dataset/tokenization_utils.py index 7606bc2a9..78b14ce4b 100755 --- a/applications/ColossalChat/coati/dataset/tokenization_utils.py +++ b/applications/ColossalChat/coati/dataset/tokenization_utils.py @@ -55,6 +55,8 @@ def supervised_tokenize_sft( for mess in messages: from_str = mess["from"] + if from_str is None: + print(mess) if from_str.lower() == "human": from_str = "user" elif from_str.lower() == "assistant": @@ -95,17 +97,26 @@ def supervised_tokenize_sft( target_turn = turns[target_turn_index - 1] prompt = template.get_prompt(2 * target_turn) - chunks, require_loss = split_templated_prompt_into_chunks(template.messages[: 2 * target_turn], prompt) + chunks, require_loss = split_templated_prompt_into_chunks(template.messages[: 2 * target_turn], prompt, + conversation_template.end_of_assistant) tokenized, starts, ends = tokenize_and_concatenate(tokenizer, chunks, require_loss) labels = [ignore_index] * len(tokenized) - label_decode = [] for start, end in zip(starts, ends): if end == len(tokenized): tokenized = tokenized + [tokenizer.eos_token_id] labels = labels + [ignore_index] - labels[start : end + 1] = tokenized[start : end + 1] - label_decode.append(tokenizer.decode(tokenized[start : end + 1], skip_special_tokens=False)) + labels[start : end] = tokenized[start : end] + + # truncate the sequence at the last token that requires loss calculation + to_truncate_len = 0 + for i in range(len(tokenized) - 1, -1, -1): + if labels[i] == ignore_index: + to_truncate_len += 1 + else: + break + tokenized = tokenized[: len(tokenized) - to_truncate_len] + labels = labels[: len(labels) - to_truncate_len] if tokenizer.bos_token_id is not None: if tokenized[0] != tokenizer.bos_token_id: @@ -123,6 +134,20 @@ def supervised_tokenize_sft( # For some model without bos/eos may raise the following errors try: inputs_decode = tokenizer.decode(tokenized) + start = 0 + end = 0 + label_decode = [] + for i in range(len(labels)): + if labels[i] == ignore_index: + if start!=end: + label_decode.append(tokenizer.decode(labels[start+1:i], skip_special_tokens=False)) + start = i + end = i + else: + end = i + if i == len(labels) - 1: + label_decode.append(tokenizer.decode(labels[start+1:], skip_special_tokens=False)) + except TypeError as e: raise TypeError(str(e) + f"\nUnable to decode input_ids: {tokenized}") @@ -191,7 +216,9 @@ def tokenize_prompt_dataset( # Prepare data prompt = template.get_prompt(target_turn, add_generation_prompt=True) - tokenized = tokenizer([prompt], add_special_tokens=False)["input_ids"][0] + chunks, require_loss = split_templated_prompt_into_chunks(template.messages[: target_turn], prompt, + conversation_template.end_of_assistant) + tokenized, starts, ends = tokenize_and_concatenate(tokenizer, chunks, require_loss) if tokenizer.bos_token_id is not None: if tokenized[0] != tokenizer.bos_token_id: tokenized = [tokenizer.bos_token_id] + tokenized @@ -219,7 +246,8 @@ def apply_rlhf_data_format( ): target_turn = int(len(template.messages) / 2) prompt = template.get_prompt(target_turn * 2) - chunks, require_loss = split_templated_prompt_into_chunks(template.messages[: 2 * target_turn], prompt) + chunks, require_loss = split_templated_prompt_into_chunks(template.messages[: 2 * target_turn], prompt, + tempalte.end_of_assistant) tokenized, starts, ends = tokenize_and_concatenate(tokenizer, chunks, require_loss) loss_mask = [0] * len(tokenized) mask_token = tokenizer.eos_token_id or tokenizer.pad_token_id @@ -232,8 +260,8 @@ def apply_rlhf_data_format( if end == len(tokenized): tokenized = tokenized + [tokenizer.eos_token_id] loss_mask = loss_mask + [1] - loss_mask[start : end + 1] = [1] * len(loss_mask[start : end + 1]) - label_decode.append(tokenizer.decode(tokenized[start : end + 1], skip_special_tokens=False)) + loss_mask[start : end] = [1] * len(loss_mask[start : end]) + label_decode.append(tokenizer.decode(tokenized[start : end], skip_special_tokens=False)) if tokenizer.bos_token_id is not None: if tokenized[0] != tokenizer.bos_token_id: tokenized = [tokenizer.bos_token_id] + tokenized diff --git a/applications/ColossalChat/coati/dataset/utils.py b/applications/ColossalChat/coati/dataset/utils.py index ada2afef0..eaef8af1a 100755 --- a/applications/ColossalChat/coati/dataset/utils.py +++ b/applications/ColossalChat/coati/dataset/utils.py @@ -113,20 +113,23 @@ def tokenize_and_concatenate(tokenizer: PreTrainedTokenizer, text: List[str], re return input_ids, loss_starts, loss_ends -def split_templated_prompt_into_chunks(messages: List[Dict[str, str]], prompt: str): +def split_templated_prompt_into_chunks(messages: List[Dict[str, str]], prompt: str, end_of_assistant: str): # Seperate templated prompt into chunks by human/assistant's lines, prepare data for tokenize_and_concatenate start_idx = 0 chunks = [] require_loss = [] for line in messages: + content_length = len(line["content"]) first_occur = prompt.find(line["content"], start_idx) + if line["role"].lower() == "assistant" and end_of_assistant in prompt[first_occur + content_length:]: + content_length = prompt.find(end_of_assistant, first_occur + content_length) + len(end_of_assistant) - first_occur if prompt[first_occur - 1] != " ": chunks.append(prompt[start_idx:first_occur]) - chunks.append(prompt[first_occur : first_occur + len(line["content"])]) + chunks.append(prompt[first_occur : first_occur + content_length]) else: chunks.append(prompt[start_idx : first_occur - 1]) - chunks.append(prompt[first_occur - 1 : first_occur + len(line["content"])]) - start_idx = first_occur + len(line["content"]) + chunks.append(prompt[first_occur - 1 : first_occur + content_length]) + start_idx = first_occur + content_length if line["role"].lower() == "assistant": require_loss.append(False) require_loss.append(True) diff --git a/applications/ColossalChat/config/conversation_template/01-ai_Yi-1.5-9B-Chat.json b/applications/ColossalChat/config/conversation_template/01-ai_Yi-1.5-9B-Chat.json new file mode 100644 index 000000000..85a726766 --- /dev/null +++ b/applications/ColossalChat/config/conversation_template/01-ai_Yi-1.5-9B-Chat.json @@ -0,0 +1,8 @@ +{ + "chat_template": "{% if messages[0]['role'] == 'system' %}{% set system_message = messages[0]['content'] %}{% endif %}{% if system_message is defined %}{{ system_message }}{% endif %}{% for message in messages %}{% set content = message['content'] %}{% if message['role'] == 'user' %}{{ '<|im_start|>user\\n' + content + '<|im_end|>\\n<|im_start|>assistant\\n' }}{% elif message['role'] == 'assistant' %}{{ content + '<|im_end|>' + '\\n' }}{% endif %}{% endfor %}", + "system_message": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n", + "stop_ids": [ + 7 + ], + "end_of_assistant": "<|im_end|>" +} \ No newline at end of file diff --git a/applications/ColossalChat/config/conversation_template/Vicuna.json b/applications/ColossalChat/config/conversation_template/01-ai_Yi-34B.json similarity index 97% rename from applications/ColossalChat/config/conversation_template/Vicuna.json rename to applications/ColossalChat/config/conversation_template/01-ai_Yi-34B.json index 2b00b6529..614c25ca6 100644 --- a/applications/ColossalChat/config/conversation_template/Vicuna.json +++ b/applications/ColossalChat/config/conversation_template/01-ai_Yi-34B.json @@ -3,5 +3,6 @@ "system_message": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n", "stop_ids": [ 2 - ] -} + ], + "end_of_assistant": "<|endoftext|>" +} \ No newline at end of file diff --git a/applications/ColossalChat/config/conversation_template/chatGLM2.json b/applications/ColossalChat/config/conversation_template/THUDM_chatglm2-6b.json similarity index 90% rename from applications/ColossalChat/config/conversation_template/chatGLM2.json rename to applications/ColossalChat/config/conversation_template/THUDM_chatglm2-6b.json index a2638dbe7..9d8531753 100644 --- a/applications/ColossalChat/config/conversation_template/chatGLM2.json +++ b/applications/ColossalChat/config/conversation_template/THUDM_chatglm2-6b.json @@ -3,5 +3,6 @@ "system_message": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n", "stop_ids": [ 2 - ] -} + ], + "end_of_assistant": "<|im_end|>" +} \ No newline at end of file diff --git a/applications/ColossalChat/config/conversation_template/THUDM_chatglm3-6b.json b/applications/ColossalChat/config/conversation_template/THUDM_chatglm3-6b.json new file mode 100644 index 000000000..d791e1ae8 --- /dev/null +++ b/applications/ColossalChat/config/conversation_template/THUDM_chatglm3-6b.json @@ -0,0 +1,8 @@ +{ + "chat_template": "{% for message in messages %}{% if loop.first %}[gMASK]sop<|{{ message['role'] }}|>\n {{ message['content'] }}{% else %}<|{{ message['role'] }}|>\n {{ message['content'] }}{% endif %}{% endfor %}{% if add_generation_prompt %}<|assistant|>{% endif %}", + "system_message": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n", + "stop_ids": [ + 2 + ], + "end_of_assistant": "<|user|>" +} \ No newline at end of file diff --git a/applications/ColossalChat/config/conversation_template/Yi.json b/applications/ColossalChat/config/conversation_template/Yi.json deleted file mode 100644 index 9716413b5..000000000 --- a/applications/ColossalChat/config/conversation_template/Yi.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "chat_template": "{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}", - "system_message": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n", - "stop_ids": [ - 2 - ] -} diff --git a/applications/ColossalChat/config/conversation_template/Qwen.json b/applications/ColossalChat/config/conversation_template/baichuan-inc_Baichuan2-13B-Chat.json similarity index 88% rename from applications/ColossalChat/config/conversation_template/Qwen.json rename to applications/ColossalChat/config/conversation_template/baichuan-inc_Baichuan2-13B-Chat.json index 09f706ffe..9d8531753 100644 --- a/applications/ColossalChat/config/conversation_template/Qwen.json +++ b/applications/ColossalChat/config/conversation_template/baichuan-inc_Baichuan2-13B-Chat.json @@ -2,6 +2,7 @@ "chat_template": "{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}", "system_message": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n", "stop_ids": [ - null - ] -} + 2 + ], + "end_of_assistant": "<|im_end|>" +} \ No newline at end of file diff --git a/applications/ColossalChat/config/conversation_template/colossal-llama2.json b/applications/ColossalChat/config/conversation_template/colossal-llama2.json index cc7f1e5d7..b9c17c1e2 100644 --- a/applications/ColossalChat/config/conversation_template/colossal-llama2.json +++ b/applications/ColossalChat/config/conversation_template/colossal-llama2.json @@ -3,5 +3,6 @@ "system_message": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n", "stop_ids": [ 2 - ] -} + ], + "end_of_assistant": "" +} \ No newline at end of file diff --git a/applications/ColossalChat/config/conversation_template/deepseek-ai_DeepSeek-V2-Lite.json b/applications/ColossalChat/config/conversation_template/deepseek-ai_DeepSeek-V2-Lite.json new file mode 100644 index 000000000..89a9aed85 --- /dev/null +++ b/applications/ColossalChat/config/conversation_template/deepseek-ai_DeepSeek-V2-Lite.json @@ -0,0 +1,8 @@ +{ + "chat_template": "{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{{ bos_token }}{% for message in messages %}{% if message['role'] == 'user' %}{{ 'User: ' + message['content'] + '\n\n' }}{% elif message['role'] == 'assistant' %}{{ 'Assistant: ' + message['content'] + eos_token }}{% elif message['role'] == 'system' %}{{ message['content'] + '\n\n' }}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}", + "system_message": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n", + "stop_ids": [ + 100001 + ], + "end_of_assistant": "<|end▁of▁sentence|>" +} \ No newline at end of file diff --git a/applications/ColossalChat/config/conversation_template/llama2.json b/applications/ColossalChat/config/conversation_template/llama2.json index 80558f976..5fbe8b4fc 100644 --- a/applications/ColossalChat/config/conversation_template/llama2.json +++ b/applications/ColossalChat/config/conversation_template/llama2.json @@ -3,5 +3,6 @@ "system_message": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n", "stop_ids": [ 2 - ] -} + ], + "end_of_assistant": "" +} \ No newline at end of file diff --git a/applications/ColossalChat/config/conversation_template/microsoft_phi-2.json b/applications/ColossalChat/config/conversation_template/microsoft_phi-2.json new file mode 100644 index 000000000..60ec8b763 --- /dev/null +++ b/applications/ColossalChat/config/conversation_template/microsoft_phi-2.json @@ -0,0 +1,8 @@ +{ + "chat_template": "{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}", + "system_message": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n", + "stop_ids": [ + 50256 + ], + "end_of_assistant": "<|im_end|>" +} \ No newline at end of file diff --git a/applications/ColossalChat/config/conversation_template/mistral.json b/applications/ColossalChat/config/conversation_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json similarity index 93% rename from applications/ColossalChat/config/conversation_template/mistral.json rename to applications/ColossalChat/config/conversation_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json index b48c3a3f2..9a7df645d 100644 --- a/applications/ColossalChat/config/conversation_template/mistral.json +++ b/applications/ColossalChat/config/conversation_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json @@ -3,5 +3,6 @@ "system_message": null, "stop_ids": [ 2 - ] -} + ], + "end_of_assistant": "" +} \ No newline at end of file diff --git a/applications/ColossalChat/config/conversation_template/zephyr.json b/applications/ColossalChat/config/conversation_template/zephyr.json deleted file mode 100644 index 2ab141111..000000000 --- a/applications/ColossalChat/config/conversation_template/zephyr.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "chat_template": "{% for message in messages %}\n{% if message['role'] == 'user' %}\n{{ '<|user|>\n' + message['content'] + eos_token }}\n{% elif message['role'] == 'system' %}\n{{ '<|system|>\n' + message['content'] + eos_token }}\n{% elif message['role'] == 'assistant' %}\n{{ '<|assistant|>\n' + message['content'] + eos_token }}\n{% endif %}\n{% if loop.last and add_generation_prompt %}\n{{ '<|assistant|>' }}\n{% endif %}\n{% endfor %}", - "system_message": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n", - "stop_ids": [ - 2 - ] -} diff --git a/applications/ColossalChat/examples/README.md b/applications/ColossalChat/examples/README.md index cfed3f1f3..3318e498b 100755 --- a/applications/ColossalChat/examples/README.md +++ b/applications/ColossalChat/examples/README.md @@ -338,7 +338,18 @@ In this code we provide a flexible way for users to set the conversation templat { "chat_template": (Optional), A string of chat_template used for formatting chat data. If not set (None), will use the default chat template of the provided tokenizer. If a path to a huggingface model or local model is provided, will use the chat_template of that model. To use a custom chat template, you need to manually set this field. For more details on how to write a chat template in Jinja format, please read https://huggingface.co/docs/transformers/main/chat_templating, "system_message": A string of system message to be added at the beginning of the prompt. If no is provided (None), no system message will be added, - "stop_ids": (Optional), A list of string indicating the end of assistant's response during the rollout stage of PPO training. It's recommended to set this manually for PPO training. If not set, will set to tokenizer.eos_token_ids automatically, + "end_of_assistant": The token(s) in string that denotes the end of assistance's response. For example, in the ChatGLM2 prompt format, + ``` + <|im_start|>system + system messages + + <|im_end|> + <|im_start|>user + How far is the moon? <|im_end|> + <|im_start|>assistant\n The moon is about 384,400 kilometers away from Earth.<|im_end|>... + ``` + the end_of_assistant tokens are "<|im_end|>" + "stop_ids": (Optional), A list of integers corresponds to the `end_of_assistant` tokens that indicating the end of assistance's response during the rollout stage of PPO training. It's recommended to set this manually for PPO training. If not set, will set to tokenizer.eos_token_ids automatically } ``` On your first run of the data preparation script, you only need to define the "chat_template" (if you want to use custom chat template) and the "system message" (if you want to use a custom system message), diff --git a/applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py b/applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py index 64093f88d..04e613d0c 100644 --- a/applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py +++ b/applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py @@ -226,7 +226,7 @@ def main(): "max_length": args.max_length, }, keep_in_memory=False, - num_proc=min(len(dataset), cpu_count()), + num_proc= min(len(dataset), cpu_count()), ) dataset = dataset.filter( diff --git a/applications/ColossalChat/examples/data_preparation_scripts/prepare_sft_dataset.sh b/applications/ColossalChat/examples/data_preparation_scripts/prepare_sft_dataset.sh index cf937db2a..9bb332cac 100755 --- a/applications/ColossalChat/examples/data_preparation_scripts/prepare_sft_dataset.sh +++ b/applications/ColossalChat/examples/data_preparation_scripts/prepare_sft_dataset.sh @@ -1,13 +1,22 @@ -SAVE_DIR="" +SAVE_DIR="/home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf" rm -rf $SAVE_DIR/cache rm -rf $SAVE_DIR/jsonl rm -rf $SAVE_DIR/arrow +# python prepare_dataset.py --type sft \ +# --data_input_dirs /home/yeanbang/data/experiment/dataset/sft_data/test/sft-data \ +# --conversation_template_config /home/yeanbang/data/ColossalAI/applications/ColossalChat/config/conversation_template/THUDM_chatglm3-6b.json \ +# --tokenizer_dir "/mnt/jfs-hdd/home/data/models/ChatGlm-6B" \ +# --data_cache_dir $SAVE_DIR/cache \ +# --data_jsonl_output_dir $SAVE_DIR/jsonl \ +# --data_arrow_output_dir $SAVE_DIR/arrow \ + + python prepare_dataset.py --type sft \ - --data_input_dirs /PATH/TO/SFT/DATASET \ - --conversation_template_config /PATH/TO/CHAT/TEMPLATE/CONFIG.json \ - --tokenizer_dir "" \ + --data_input_dirs /mnt/jfs-hdd/home/yeanbang/data/dataset/sft_data/alpaca/data_preprocessed/train \ + --conversation_template_config /home/yeanbang/data/ColossalAI/applications/ColossalChat/config/conversation_template/llama2.json \ + --tokenizer_dir "/mnt/jfs-hdd/share/models/Llama-2-7b-chat-hf" \ --data_cache_dir $SAVE_DIR/cache \ --data_jsonl_output_dir $SAVE_DIR/jsonl \ --data_arrow_output_dir $SAVE_DIR/arrow \ diff --git a/applications/ColossalChat/examples/training_scripts/hostfile b/applications/ColossalChat/examples/training_scripts/hostfile index d4118dda9..c46761d14 100755 --- a/applications/ColossalChat/examples/training_scripts/hostfile +++ b/applications/ColossalChat/examples/training_scripts/hostfile @@ -1 +1 @@ -10.20.1.82 +172.27.183.199 diff --git a/applications/ColossalChat/examples/training_scripts/train_sft.py b/applications/ColossalChat/examples/training_scripts/train_sft.py index ae20f2abc..5ee9b741e 100755 --- a/applications/ColossalChat/examples/training_scripts/train_sft.py +++ b/applications/ColossalChat/examples/training_scripts/train_sft.py @@ -14,13 +14,20 @@ from transformers import AutoModelForCausalLM, AutoTokenizer import colossalai from colossalai.booster import Booster -from colossalai.booster.plugin import GeminiPlugin, HybridParallelPlugin, LowLevelZeroPlugin, TorchDDPPlugin +from colossalai.booster.plugin import GeminiPlugin, HybridParallelPlugin, TorchDDPPlugin, LowLevelZeroPlugin from colossalai.cluster import DistCoordinator from colossalai.nn.lr_scheduler import CosineAnnealingWarmupLR from colossalai.nn.optimizer import HybridAdam +import inspect +import sys +import torch.distributed as dist +from colossalai.logging import get_dist_logger +logger = get_dist_logger() def train(args): + print(colossalai.__version__, inspect.getfile(colossalai)) + print(sys.executable) # check lora compatibility if "gemini" in args.plugin and args.lora_rank > 0: raise ValueError("LoRA is not supported in GeminiPlugin. Please use other plugin") @@ -35,6 +42,38 @@ def train(args): # ============================== # Initialize Booster # ============================== + init_ctx = nullcontext() + with init_ctx: + model = AutoModelForCausalLM.from_pretrained(args.pretrain, + torch_dtype=torch.bfloat16 if args.mixed_precision == "bf16" else torch.float16, + trust_remote_code=True) + # check if the hybrid parallel plugin is compatible with the model + # try: + # from colossalai.shardformer.policies.auto_policy import get_autopolicy + # policy = get_autopolicy(model) + # if policy is not None: + # if args.plugin in ['zero2', 'zero2_cpu']: + # # if compatible, set the plugin to hybrid, which use colo-attention + # args.plugin = 'hybrid' + # args.zero_stage = 2 + # if args.plugin == 'zero2_cpu': + # args.zero_cpu_offload = True + # else: + # args.zero_cpu_offload = False + # logger.info(f"Model is compatible with hybrid parallel plugin, set plugin to {args.plugin} with zero_stage {args.zero_stage} and zero_cpu_offload {args.zero_cpu_offload}") + # except NotImplementedError: + # logger.warning(f"Unable to find a policy for the model, use {args.plugin} plugin instead") + # if args.use_flash_attn: + # del model + # model = AutoModelForCausalLM.from_pretrained( + # args.pretrain, + # torch_dtype=torch.bfloat16 if args.mixed_precision == "bf16" else torch.float16, + # attn_implementation="flash_attention_2", + # trust_remote_code=True + # ) + if args.lora_rank > 0: + model = convert_to_lora_module(model, args.lora_rank, lora_train_bias=args.lora_train_bias) + if args.plugin == "ddp": """ Default torch ddp plugin without any acceleration, for @@ -47,7 +86,8 @@ def train(args): placement_policy="static", initial_scale=2**16, max_norm=args.grad_clip, - enable_gradient_accumulation=True, + enable_gradient_accumulation=True if args.accumulation_steps > 1 else False, + enable_flash_attention=args.use_flash_attn ) elif args.plugin == "gemini_auto": plugin = GeminiPlugin( @@ -55,6 +95,7 @@ def train(args): placement_policy="auto", initial_scale=2**16, max_norm=args.grad_clip, + enable_flash_attention=args.use_flash_attn ) elif args.plugin == "zero2": plugin = LowLevelZeroPlugin( @@ -71,11 +112,16 @@ def train(args): cpu_offload=True, max_norm=args.grad_clip, ) - elif args.plugin == "3d": + elif args.plugin == "hybrid": plugin = HybridParallelPlugin( tp_size=args.tp, - pp_size=1, - zero_stage=0, + pp_size=args.pp, + sp_size=args.sp, + sequence_parallelism_mode=args.sp_mode, + zero_stage=args.zero_stage, + enable_flash_attention=args.use_flash_attn, + enable_sequence_parallelism=True if args.sp > 1 else False, + cpu_offload=True if args.zero_stage>=1 and args.zero_cpu_offload else False, parallel_output=False, max_norm=args.grad_clip, precision=args.mixed_precision, @@ -93,20 +139,7 @@ def train(args): # LazyInitContext(default_device=get_current_device()) if isinstance(plugin, (GeminiPlugin,)) else nullcontext() # ) - init_ctx = nullcontext() - with init_ctx: - if args.use_flash_attn: - model = AutoModelForCausalLM.from_pretrained( - args.pretrain, - torch_dtype=torch.bfloat16 if args.mixed_precision == "bf16" else torch.float16, - use_flash_attention_2=True, - ) - coordinator.print_on_master(msg="Flash-attention enabled successfully") - else: - model = AutoModelForCausalLM.from_pretrained(args.pretrain) - if args.lora_rank > 0: - model = convert_to_lora_module(model, args.lora_rank, lora_train_bias=args.lora_train_bias) - + if args.grad_checkpoint and args.lora_rank == 0: # lora layers are not supported by gradient checkpointing model.gradient_checkpointing_enable() @@ -131,6 +164,7 @@ def train(args): tokenizer.add_bos_token = False tokenizer.add_eos_token = False + tokenizer.padding_side = "right" coordinator.print_on_master(f"Configuration file will be saved at: {args.config_file}") coordinator.print_on_master(f"Model checkpoint will be saved at: {args.save_path}") @@ -156,8 +190,13 @@ def train(args): shuffle=True, drop_last=True, collate_fn=data_collator, - use_tp=args.tp > 1, + tp_size=args.tp, ) + # print(len(train_dataloader)) + # for batch in train_dataloader: + # print(dist.get_rank(), tokenizer.batch_decode(batch["input_ids"])) + # break + coordinator.print_on_master( f"Max CUDA memory after data loader: {torch.cuda.max_memory_allocated() / 1024 ** 2:.2f} MB" ) @@ -255,7 +294,7 @@ def train(args): # save model checkpoint after fitting on only rank0 coordinator.print_on_master("Start saving final model checkpoint") - booster.save_model(model, os.path.join(args.save_path, "modeling"), shard=True) + # booster.save_model(model, os.path.join(args.save_path, "modeling"), shard=True) coordinator.print_on_master(f"Saved final model checkpoint at epoch {args.max_epochs} at folder {args.save_path}") coordinator.print_on_master(f"Max CUDA memory usage: {torch.cuda.max_memory_allocated()/1024**2:.2f} MB") @@ -270,13 +309,18 @@ if __name__ == "__main__": "--plugin", type=str, default="gemini", - choices=["gemini", "gemini_auto", "zero2", "zero2_cpu", "3d", "ddp"], + choices=["gemini", "gemini_auto", "hybrid", "ddp", "zero2_cpu", "zero2"], help="Choose which plugin to use", ) parser.add_argument("--grad_clip", type=float, default=1.0, help="Gradient clipping value") parser.add_argument("--weight_decay", type=float, default=0.1, help="Weight decay") parser.add_argument("--warmup_steps", type=int, default=None, help="Warmup steps") parser.add_argument("--tp", type=int, default=1) + parser.add_argument("--pp", type=int, default=1) + parser.add_argument("--sp", type=int, default=1) + parser.add_argument("--zero_stage", type=int, default=0, help="Zero stage", choices=[0, 1, 2]) + parser.add_argument("--zero_cpu_offload", default=False, action="store_true") + parser.add_argument("--sp_mode", type=str, default="split_gather", choices=["split_gather", "ring", "all_to_all"]) parser.add_argument("--pretrain", type=str, default=None) parser.add_argument("--tokenizer_dir", type=str, default=None) parser.add_argument("--dataset", nargs="+", default=[]) @@ -287,7 +331,7 @@ if __name__ == "__main__": parser.add_argument("--max_epochs", type=int, default=3) parser.add_argument("--batch_size", type=int, default=4) parser.add_argument("--max_len", type=int, default=512) - parser.add_argument("--mixed_precision", type=str, default="fp16", choices=["fp16", "bf16"], help="Mixed precision") + parser.add_argument("--mixed_precision", type=str, default="bf16", choices=["fp16", "bf16"], help="Mixed precision") parser.add_argument("--lora_rank", type=int, default=0, help="low-rank adaptation matrices rank") parser.add_argument( "--lora_train_bias", diff --git a/applications/ColossalChat/examples/training_scripts/train_sft.sh b/applications/ColossalChat/examples/training_scripts/train_sft.sh index d5c394377..e3bc12823 100755 --- a/applications/ColossalChat/examples/training_scripts/train_sft.sh +++ b/applications/ColossalChat/examples/training_scripts/train_sft.sh @@ -17,22 +17,22 @@ set_n_least_used_CUDA_VISIBLE_DEVICES() { # export CUDA_VISIBLE_DEVICES=4,5,6 set_n_least_used_CUDA_VISIBLE_DEVICES 4 PROJECT_NAME="sft" -PARENT_SAVE_DIR="" # Path to a folder to save checkpoints -PARENT_TENSORBOARD_DIR="" # Path to a folder to save logs -PARENT_CONFIG_FILE="" # Path to a folder to save training config logs -PRETRAINED_MODEL_PATH="" # huggingface or local model path -PRETRAINED_TOKENIZER_PATH="" # huggingface or local tokenizer path +PARENT_SAVE_DIR="/home/yeanbang/data/experiment/output/model" # Path to a folder to save checkpoints +PARENT_TENSORBOARD_DIR="/home/yeanbang/data/experiment/logs/tensorboard" # Path to a folder to save logs +PARENT_CONFIG_FILE="/home/yeanbang/data/experiment/logs/config" # Path to a folder to save training config logs +PRETRAINED_MODEL_PATH="/mnt/jfs-hdd/share/models/Llama-2-7b-chat-hf" # huggingface or local model path +PRETRAINED_TOKENIZER_PATH="/mnt/jfs-hdd/share/models/Llama-2-7b-chat-hf" # huggingface or local tokenizer path declare -a dataset=( - YOUR/SFT/DATA/DIR/arrow/part-00000 - YOUR/SFT/DATA/DIR/arrow/part-00001 - YOUR/SFT/DATA/DIR/arrow/part-00002 - YOUR/SFT/DATA/DIR/arrow/part-00003 - YOUR/SFT/DATA/DIR/arrow/part-00004 - YOUR/SFT/DATA/DIR/arrow/part-00005 - YOUR/SFT/DATA/DIR/arrow/part-00006 - YOUR/SFT/DATA/DIR/arrow/part-00007 - YOUR/SFT/DATA/DIR/arrow/part-00008 - YOUR/SFT/DATA/DIR/arrow/part-00009 + /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00000 + /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00001 + /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00002 + /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00003 + /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00004 + /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00005 + /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00006 + /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00007 + /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00008 + /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00009 ) TIMESTAMP=$(date +%Y-%m-%d-%H-%M-%S) @@ -40,6 +40,8 @@ FULL_PROJECT_NAME="${PROJECT_NAME}-${TIMESTAMP}" SAVE_DIR="${PARENT_SAVE_DIR}${FULL_PROJECT_NAME}" CONFIG_FILE="${PARENT_CONFIG_FILE}-${FULL_PROJECT_NAME}.json" +echo $(which colossalai) +echo $(which python) # the real batch size for gradient descent is number_of_node_in_hostfile * nproc_per_node * train_batch_size colossalai run --nproc_per_node 4 --master_port 31312 --hostfile ./hostfile train_sft.py \ --pretrain $PRETRAINED_MODEL_PATH \ @@ -50,10 +52,14 @@ colossalai run --nproc_per_node 4 --master_port 31312 --hostfile ./hostfile trai --config_file $CONFIG_FILE \ --lora_rank 0 \ --plugin zero2 \ - --batch_size 8 \ - --max_epochs 1 \ - --accumulation_steps 1 \ - --lr 2e-5 \ - --max_len 2048 \ + --tp 1 \ + --pp 1 \ + --zero_stage 2 \ + --batch_size 4 \ + --max_epochs 3 \ + --accumulation_steps 4 \ + --lr 5e-5 \ + --max_len 400 \ --grad_checkpoint \ - --use_wandb + --use_wandb \ + --use_flash_attn diff --git a/applications/ColossalChat/requirements.txt b/applications/ColossalChat/requirements.txt index de5f6160e..3ad29e6e1 100755 --- a/applications/ColossalChat/requirements.txt +++ b/applications/ColossalChat/requirements.txt @@ -1,9 +1,8 @@ -transformers==4.34.1 -huggingface_hub==0.17.3 +transformers>=4.37.0 tqdm datasets loralib -colossalai>=0.3.6 +colossalai>=0.3.7 torch>=1.12.1 langchain tokenizers diff --git a/applications/ColossalChat/tests/test_chat_template.py b/applications/ColossalChat/tests/test_chat_template.py new file mode 100644 index 000000000..2395c1f3c --- /dev/null +++ b/applications/ColossalChat/tests/test_chat_template.py @@ -0,0 +1,38 @@ +from coati.dataset import setup_conversation_template +from coati.dataset.conversation import Conversation +from coati.dataset.tokenization_utils import supervised_tokenize_sft +from transformers import AutoTokenizer +import json +import os + +model_data_mapping = { + 'THUDM/chatglm2-6b': 'THUDM_chatglm2-6b.json', + 'THUDM/chatglm3-6b': 'THUDM_chatglm3-6b.json', + 'baichuan-inc/Baichuan2-13B-Chat': 'baichuan-inc_Baichuan2-13B-Chat.json', + 'Qwen/Qwen-7B-Chat': 'Qwen_Qwen-7B-Chat.json', + '01-ai/Yi-1.5-9B-Chat': '01-ai_Yi-1.5-9B-Chat.json', + '01-ai/Yi-34B': '01-ai_Yi-34B.json', + 'deepseek-ai/DeepSeek-V2-Lite': 'deepseek-ai_DeepSeek-V2-Lite.json', + 'microsoft/phi-2': 'microsoft_phi-2.json', + 'mistralai/Mixtral-8x7B-Instruct-v0.1': 'mistralai_Mixtral-8x7B-Instruct-v0.1.json' +} +chat_template_config_path = '../config/conversation_template' + + +def test_tokenization_sft(): + for model in model_data_mapping: + print(f"#############{model}#############") + conversation_template_config = os.path.join(chat_template_config_path, model_data_mapping[model]) + messages = [{"from": "human", "content": "What are the three primary colors?"}, + {"from": "assistant", "content": "The three primary colors are red, blue, and yellow."}, + {"from": "human", "content": "解释个人电脑和服务器之间的区别。"}, + {"from": "assistant", "content": "个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。"}] + chat_template_config = json.load(open(conversation_template_config, "r", encoding="utf8")) + tokenizer = AutoTokenizer.from_pretrained(model, use_fast=False, trust_remote_code=True) + conversation_template = setup_conversation_template( + tokenizer, chat_template_config=chat_template_config, save_path=conversation_template_config + ) + + output = supervised_tokenize_sft({"messages": messages}, tokenizer, conversation_template) + with open(f"./test_data/chat_template/{model_data_mapping[model]}", "r", encoding="utf8") as f: + assert json.dumps(json.load(f)) == json.dumps(output), f"model: {model} failed" diff --git a/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-1.5-9B-Chat.json b/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-1.5-9B-Chat.json new file mode 100644 index 000000000..52a20f813 --- /dev/null +++ b/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-1.5-9B-Chat.json @@ -0,0 +1,585 @@ +{ + "input_ids": [ + 1, + 59603, + 9334, + 1397, + 562, + 13310, + 2756, + 597, + 663, + 15874, + 10357, + 14135, + 98, + 707, + 14135, + 3641, + 6901, + 97, + 7283, + 97, + 597, + 31081, + 8476, + 592, + 567, + 2756, + 59610, + 59575, + 3275, + 98, + 144, + 144, + 6, + 3903, + 144, + 5697, + 678, + 567, + 1604, + 5789, + 7590, + 100, + 7, + 144, + 6, + 765, + 13611, + 144, + 1263, + 1604, + 5789, + 7590, + 678, + 2894, + 97, + 5083, + 97, + 597, + 10744, + 98, + 7, + 144, + 6, + 3903, + 144, + 7714, + 2897, + 11491, + 59652, + 17504, + 7125, + 13189, + 102, + 7, + 144, + 6, + 765, + 13611, + 144, + 2897, + 11491, + 59652, + 17504, + 59626, + 12295, + 2618, + 24768, + 12780, + 2644, + 101, + 6774, + 10495, + 13189, + 5505, + 23337, + 105, + 17713, + 9217, + 59652, + 9176, + 102, + 59568, + 2897, + 11491, + 101, + 60604, + 59867, + 60084, + 60160, + 101, + 29874, + 2897, + 2253, + 59732, + 23806, + 12780, + 102, + 6774, + 8224, + 4983, + 7304, + 5973, + 105, + 11152, + 44353, + 101, + 1229, + 7252, + 33282, + 32371, + 59652, + 5186, + 102, + 2897, + 11491, + 59599, + 17713, + 9217, + 39485, + 4245, + 3600, + 9217, + 59670, + 23806, + 101, + 3438, + 6985, + 2749, + 2897, + 4195, + 1540, + 23525, + 102, + 59568, + 59732, + 17504, + 15703, + 6748, + 8262, + 4576, + 17107, + 59732, + 23806, + 12780, + 2644, + 101, + 6774, + 8224, + 4983, + 59648, + 4576, + 2479, + 4207, + 4014, + 1893, + 101, + 59738, + 8276, + 105, + 5601, + 24111, + 59652, + 6280, + 18192, + 59748, + 102, + 17504, + 8224, + 1867, + 57898, + 59599, + 17713, + 9217, + 101, + 4502, + 1229, + 17456, + 59719, + 38298, + 59652, + 59509, + 7252, + 102, + 3574, + 17504, + 1867, + 3392, + 8262, + 28830, + 15595, + 101, + 6774, + 8224, + 18802, + 59691, + 60326, + 25829, + 105, + 59647, + 22981, + 25145, + 24724, + 22981, + 43452, + 11553, + 60101, + 101, + 59659, + 3206, + 13890, + 7252, + 7042, + 59652, + 26815, + 102, + 59568, + 20237, + 101, + 2897, + 11491, + 59652, + 17504, + 7125, + 2461, + 13189, + 5505, + 30281, + 23337, + 105, + 17713, + 9217, + 59652, + 9176, + 102, + 2897, + 11491, + 4983, + 2897, + 2253, + 101, + 59732, + 17504, + 4983, + 3392, + 8262, + 28830, + 15595, + 102, + 1893, + 12507, + 17713, + 9217, + 8224, + 59806, + 2897, + 11491, + 16549, + 101, + 59659, + 5731, + 13890, + 9176, + 59652, + 26815, + 102, + 7 + ], + "labels": [ + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + 1263, + 1604, + 5789, + 7590, + 678, + 2894, + 97, + 5083, + 97, + 597, + 10744, + 98, + 7, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + 2897, + 11491, + 59652, + 17504, + 59626, + 12295, + 2618, + 24768, + 12780, + 2644, + 101, + 6774, + 10495, + 13189, + 5505, + 23337, + 105, + 17713, + 9217, + 59652, + 9176, + 102, + 59568, + 2897, + 11491, + 101, + 60604, + 59867, + 60084, + 60160, + 101, + 29874, + 2897, + 2253, + 59732, + 23806, + 12780, + 102, + 6774, + 8224, + 4983, + 7304, + 5973, + 105, + 11152, + 44353, + 101, + 1229, + 7252, + 33282, + 32371, + 59652, + 5186, + 102, + 2897, + 11491, + 59599, + 17713, + 9217, + 39485, + 4245, + 3600, + 9217, + 59670, + 23806, + 101, + 3438, + 6985, + 2749, + 2897, + 4195, + 1540, + 23525, + 102, + 59568, + 59732, + 17504, + 15703, + 6748, + 8262, + 4576, + 17107, + 59732, + 23806, + 12780, + 2644, + 101, + 6774, + 8224, + 4983, + 59648, + 4576, + 2479, + 4207, + 4014, + 1893, + 101, + 59738, + 8276, + 105, + 5601, + 24111, + 59652, + 6280, + 18192, + 59748, + 102, + 17504, + 8224, + 1867, + 57898, + 59599, + 17713, + 9217, + 101, + 4502, + 1229, + 17456, + 59719, + 38298, + 59652, + 59509, + 7252, + 102, + 3574, + 17504, + 1867, + 3392, + 8262, + 28830, + 15595, + 101, + 6774, + 8224, + 18802, + 59691, + 60326, + 25829, + 105, + 59647, + 22981, + 25145, + 24724, + 22981, + 43452, + 11553, + 60101, + 101, + 59659, + 3206, + 13890, + 7252, + 7042, + 59652, + 26815, + 102, + 59568, + 20237, + 101, + 2897, + 11491, + 59652, + 17504, + 7125, + 2461, + 13189, + 5505, + 30281, + 23337, + 105, + 17713, + 9217, + 59652, + 9176, + 102, + 2897, + 11491, + 4983, + 2897, + 2253, + 101, + 59732, + 17504, + 4983, + 3392, + 8262, + 28830, + 15595, + 102, + 1893, + 12507, + 17713, + 9217, + 8224, + 59806, + 2897, + 11491, + 16549, + 101, + 59659, + 5731, + 13890, + 9176, + 59652, + 26815, + 102, + 7 + ], + "inputs_decode": "<|startoftext|> A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n<|im_start|>user\nWhat are the three primary colors?<|im_end|> \n<|im_start|>assistant\nThe three primary colors are red, blue, and yellow.<|im_end|> \n<|im_start|>user\n解释个人电脑和服务器之间的区别。<|im_end|> \n<|im_start|>assistant\n个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|>", + "labels_decode": [ + " The three primary colors are red, blue, and yellow.<|im_end|>", + " 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|>" + ], + "seq_length": 286, + "seq_category": "None" +} \ No newline at end of file diff --git a/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-34B.json b/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-34B.json new file mode 100644 index 000000000..424a737d5 --- /dev/null +++ b/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-34B.json @@ -0,0 +1,607 @@ +{ + "input_ids": [ + 1, + 59653, + 34448, + 59651, + 7488, + 55701, + 4422, + 144, + 59603, + 9334, + 1397, + 562, + 13310, + 2756, + 597, + 663, + 15874, + 10357, + 14135, + 98, + 707, + 14135, + 3641, + 6901, + 97, + 7283, + 97, + 597, + 31081, + 8476, + 592, + 567, + 2756, + 59610, + 59575, + 3275, + 98, + 144, + 144, + 144, + 59666, + 1359, + 55701, + 4422, + 144, + 144, + 5697, + 678, + 567, + 1604, + 5789, + 7590, + 100, + 1273, + 59598, + 34448, + 59651, + 707, + 1604, + 5789, + 7590, + 678, + 2894, + 97, + 5083, + 97, + 597, + 10744, + 98, + 59568, + 2, + 1, + 59653, + 34448, + 59651, + 59568, + 7714, + 2897, + 11491, + 59652, + 17504, + 7125, + 13189, + 102, + 1273, + 59598, + 34448, + 59651, + 59568, + 2897, + 11491, + 59652, + 17504, + 59626, + 12295, + 2618, + 24768, + 12780, + 2644, + 101, + 6774, + 10495, + 13189, + 5505, + 23337, + 105, + 17713, + 9217, + 59652, + 9176, + 102, + 59568, + 2897, + 11491, + 101, + 60604, + 59867, + 60084, + 60160, + 101, + 29874, + 2897, + 2253, + 59732, + 23806, + 12780, + 102, + 6774, + 8224, + 4983, + 7304, + 5973, + 105, + 11152, + 44353, + 101, + 1229, + 7252, + 33282, + 32371, + 59652, + 5186, + 102, + 2897, + 11491, + 59599, + 17713, + 9217, + 39485, + 4245, + 3600, + 9217, + 59670, + 23806, + 101, + 3438, + 6985, + 2749, + 2897, + 4195, + 1540, + 23525, + 102, + 59568, + 59732, + 17504, + 15703, + 6748, + 8262, + 4576, + 17107, + 59732, + 23806, + 12780, + 2644, + 101, + 6774, + 8224, + 4983, + 59648, + 4576, + 2479, + 4207, + 4014, + 1893, + 101, + 59738, + 8276, + 105, + 5601, + 24111, + 59652, + 6280, + 18192, + 59748, + 102, + 17504, + 8224, + 1867, + 57898, + 59599, + 17713, + 9217, + 101, + 4502, + 1229, + 17456, + 59719, + 38298, + 59652, + 59509, + 7252, + 102, + 3574, + 17504, + 1867, + 3392, + 8262, + 28830, + 15595, + 101, + 6774, + 8224, + 18802, + 59691, + 60326, + 25829, + 105, + 59647, + 22981, + 25145, + 24724, + 22981, + 43452, + 11553, + 60101, + 101, + 59659, + 3206, + 13890, + 7252, + 7042, + 59652, + 26815, + 102, + 59568, + 20237, + 101, + 2897, + 11491, + 59652, + 17504, + 7125, + 2461, + 13189, + 5505, + 30281, + 23337, + 105, + 17713, + 9217, + 59652, + 9176, + 102, + 2897, + 11491, + 4983, + 2897, + 2253, + 101, + 59732, + 17504, + 4983, + 3392, + 8262, + 28830, + 15595, + 102, + 1893, + 12507, + 17713, + 9217, + 8224, + 59806, + 2897, + 11491, + 16549, + 101, + 59659, + 5731, + 13890, + 9176, + 59652, + 26815, + 102, + 59568, + 2 + ], + "labels": [ + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + 707, + 1604, + 5789, + 7590, + 678, + 2894, + 97, + 5083, + 97, + 597, + 10744, + 98, + 59568, + 2, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + 59568, + 2897, + 11491, + 59652, + 17504, + 59626, + 12295, + 2618, + 24768, + 12780, + 2644, + 101, + 6774, + 10495, + 13189, + 5505, + 23337, + 105, + 17713, + 9217, + 59652, + 9176, + 102, + 59568, + 2897, + 11491, + 101, + 60604, + 59867, + 60084, + 60160, + 101, + 29874, + 2897, + 2253, + 59732, + 23806, + 12780, + 102, + 6774, + 8224, + 4983, + 7304, + 5973, + 105, + 11152, + 44353, + 101, + 1229, + 7252, + 33282, + 32371, + 59652, + 5186, + 102, + 2897, + 11491, + 59599, + 17713, + 9217, + 39485, + 4245, + 3600, + 9217, + 59670, + 23806, + 101, + 3438, + 6985, + 2749, + 2897, + 4195, + 1540, + 23525, + 102, + 59568, + 59732, + 17504, + 15703, + 6748, + 8262, + 4576, + 17107, + 59732, + 23806, + 12780, + 2644, + 101, + 6774, + 8224, + 4983, + 59648, + 4576, + 2479, + 4207, + 4014, + 1893, + 101, + 59738, + 8276, + 105, + 5601, + 24111, + 59652, + 6280, + 18192, + 59748, + 102, + 17504, + 8224, + 1867, + 57898, + 59599, + 17713, + 9217, + 101, + 4502, + 1229, + 17456, + 59719, + 38298, + 59652, + 59509, + 7252, + 102, + 3574, + 17504, + 1867, + 3392, + 8262, + 28830, + 15595, + 101, + 6774, + 8224, + 18802, + 59691, + 60326, + 25829, + 105, + 59647, + 22981, + 25145, + 24724, + 22981, + 43452, + 11553, + 60101, + 101, + 59659, + 3206, + 13890, + 7252, + 7042, + 59652, + 26815, + 102, + 59568, + 20237, + 101, + 2897, + 11491, + 59652, + 17504, + 7125, + 2461, + 13189, + 5505, + 30281, + 23337, + 105, + 17713, + 9217, + 59652, + 9176, + 102, + 2897, + 11491, + 4983, + 2897, + 2253, + 101, + 59732, + 17504, + 4983, + 3392, + 8262, + 28830, + 15595, + 102, + 1893, + 12507, + 17713, + 9217, + 8224, + 59806, + 2897, + 11491, + 16549, + 101, + 59659, + 5731, + 13890, + 9176, + 59652, + 26815, + 102, + 59568, + 2 + ], + "inputs_decode": "<|startoftext|> [INST] <>\nA chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n\n<>\n\nWhat are the three primary colors? [/INST] The three primary colors are red, blue, and yellow. <|endoftext|><|startoftext|> [INST] 解释个人电脑和服务器之间的区别。 [/INST] 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。 <|endoftext|>", + "labels_decode": [ + " The three primary colors are red, blue, and yellow. <|endoftext|>", + " 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。 <|endoftext|>" + ], + "seq_length": 297, + "seq_category": "None" +} \ No newline at end of file diff --git a/applications/ColossalChat/tests/test_data/chat_template/Qwen_Qwen-7B-Chat.json b/applications/ColossalChat/tests/test_data/chat_template/Qwen_Qwen-7B-Chat.json new file mode 100644 index 000000000..1ebfac1d6 --- /dev/null +++ b/applications/ColossalChat/tests/test_data/chat_template/Qwen_Qwen-7B-Chat.json @@ -0,0 +1,603 @@ +{ + "input_ids": [ + 151644, + 8948, + 198, + 32, + 6236, + 1948, + 264, + 22208, + 3738, + 323, + 458, + 20443, + 11229, + 17847, + 13, + 576, + 17847, + 6696, + 10950, + 11, + 11682, + 11, + 323, + 47787, + 11253, + 311, + 279, + 3738, + 594, + 4755, + 382, + 151645, + 198, + 151644, + 872, + 198, + 3838, + 525, + 279, + 2326, + 6028, + 7987, + 30, + 151645, + 198, + 151644, + 77091, + 198, + 785, + 2326, + 6028, + 7987, + 525, + 2518, + 11, + 6303, + 11, + 323, + 13753, + 13, + 151645, + 198, + 151644, + 872, + 198, + 104136, + 99605, + 104145, + 33108, + 89047, + 104186, + 102665, + 1773, + 151645, + 198, + 151644, + 77091, + 198, + 99605, + 104145, + 33108, + 89047, + 20412, + 101441, + 99604, + 109963, + 104564, + 72448, + 3837, + 104017, + 104396, + 102665, + 101321, + 105795, + 5373, + 105433, + 85767, + 33108, + 102111, + 1773, + 220, + 99605, + 104145, + 3837, + 99846, + 13072, + 90663, + 64559, + 3837, + 20412, + 17714, + 99605, + 37029, + 68536, + 70500, + 9370, + 104564, + 1773, + 104017, + 102119, + 100751, + 101254, + 104066, + 5373, + 100415, + 33108, + 100134, + 3837, + 73670, + 104001, + 100646, + 99200, + 100535, + 113384, + 33108, + 99329, + 1773, + 99605, + 104145, + 9370, + 105433, + 85767, + 111071, + 101892, + 100142, + 85767, + 36407, + 70500, + 9370, + 3837, + 100632, + 104047, + 100345, + 99605, + 100354, + 71817, + 104790, + 1773, + 8908, + 222, + 234, + 89047, + 104802, + 101929, + 100722, + 20002, + 104378, + 68536, + 70500, + 9370, + 104564, + 72448, + 3837, + 104017, + 102119, + 100751, + 17714, + 110782, + 100646, + 71356, + 47874, + 3837, + 29524, + 100010, + 5373, + 116617, + 33108, + 26898, + 107468, + 49567, + 1773, + 89047, + 102119, + 85106, + 113313, + 9370, + 105433, + 85767, + 90395, + 100136, + 73670, + 105581, + 44636, + 118878, + 33108, + 102612, + 9370, + 104001, + 1773, + 101887, + 89047, + 85106, + 100143, + 100722, + 107494, + 104925, + 3837, + 104017, + 102119, + 102578, + 42140, + 71137, + 111249, + 5373, + 26288, + 106656, + 111390, + 33108, + 26288, + 106656, + 114897, + 102474, + 31548, + 3837, + 23031, + 100627, + 105743, + 104001, + 101149, + 33108, + 108239, + 1773, + 90476, + 119, + 53930, + 3837, + 99605, + 104145, + 33108, + 89047, + 104186, + 99558, + 102665, + 101321, + 104017, + 9370, + 105795, + 5373, + 105433, + 85767, + 33108, + 102111, + 1773, + 99605, + 104145, + 100751, + 99605, + 37029, + 3837, + 68536, + 89047, + 100751, + 100143, + 100722, + 107494, + 104925, + 1773, + 89047, + 9370, + 105433, + 85767, + 102119, + 56006, + 99605, + 104145, + 105377, + 3837, + 23031, + 101907, + 105743, + 102111, + 33108, + 108239, + 1773, + 151645 + ], + "labels": [ + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + 785, + 2326, + 6028, + 7987, + 525, + 2518, + 11, + 6303, + 11, + 323, + 13753, + 13, + 151645, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + 99605, + 104145, + 33108, + 89047, + 20412, + 101441, + 99604, + 109963, + 104564, + 72448, + 3837, + 104017, + 104396, + 102665, + 101321, + 105795, + 5373, + 105433, + 85767, + 33108, + 102111, + 1773, + 220, + 99605, + 104145, + 3837, + 99846, + 13072, + 90663, + 64559, + 3837, + 20412, + 17714, + 99605, + 37029, + 68536, + 70500, + 9370, + 104564, + 1773, + 104017, + 102119, + 100751, + 101254, + 104066, + 5373, + 100415, + 33108, + 100134, + 3837, + 73670, + 104001, + 100646, + 99200, + 100535, + 113384, + 33108, + 99329, + 1773, + 99605, + 104145, + 9370, + 105433, + 85767, + 111071, + 101892, + 100142, + 85767, + 36407, + 70500, + 9370, + 3837, + 100632, + 104047, + 100345, + 99605, + 100354, + 71817, + 104790, + 1773, + 8908, + 222, + 234, + 89047, + 104802, + 101929, + 100722, + 20002, + 104378, + 68536, + 70500, + 9370, + 104564, + 72448, + 3837, + 104017, + 102119, + 100751, + 17714, + 110782, + 100646, + 71356, + 47874, + 3837, + 29524, + 100010, + 5373, + 116617, + 33108, + 26898, + 107468, + 49567, + 1773, + 89047, + 102119, + 85106, + 113313, + 9370, + 105433, + 85767, + 90395, + 100136, + 73670, + 105581, + 44636, + 118878, + 33108, + 102612, + 9370, + 104001, + 1773, + 101887, + 89047, + 85106, + 100143, + 100722, + 107494, + 104925, + 3837, + 104017, + 102119, + 102578, + 42140, + 71137, + 111249, + 5373, + 26288, + 106656, + 111390, + 33108, + 26288, + 106656, + 114897, + 102474, + 31548, + 3837, + 23031, + 100627, + 105743, + 104001, + 101149, + 33108, + 108239, + 1773, + 90476, + 119, + 53930, + 3837, + 99605, + 104145, + 33108, + 89047, + 104186, + 99558, + 102665, + 101321, + 104017, + 9370, + 105795, + 5373, + 105433, + 85767, + 33108, + 102111, + 1773, + 99605, + 104145, + 100751, + 99605, + 37029, + 3837, + 68536, + 89047, + 100751, + 100143, + 100722, + 107494, + 104925, + 1773, + 89047, + 9370, + 105433, + 85767, + 102119, + 56006, + 99605, + 104145, + 105377, + 3837, + 23031, + 101907, + 105743, + 102111, + 33108, + 108239, + 1773, + 151645 + ], + "inputs_decode": "<|im_start|>system\nA chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n<|im_end|>\n<|im_start|>user\nWhat are the three primary colors?<|im_end|>\n<|im_start|>assistant\nThe three primary colors are red, blue, and yellow.<|im_end|>\n<|im_start|>user\n解释个人电脑和服务器之间的区别。<|im_end|>\n<|im_start|>assistant\n个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|>", + "labels_decode": [ + "The three primary colors are red, blue, and yellow.<|im_end|>", + "个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|>" + ], + "seq_length": 295, + "seq_category": "None" +} \ No newline at end of file diff --git a/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm2-6b.json b/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm2-6b.json new file mode 100644 index 000000000..bc421f470 --- /dev/null +++ b/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm2-6b.json @@ -0,0 +1,715 @@ +{ + "input_ids": [ + 906, + 31007, + 326, + 30962, + 6631, + 31007, + 30994, + 13361, + 13, + 30938, + 8911, + 1074, + 260, + 10976, + 1869, + 293, + 284, + 12060, + 7151, + 9319, + 30930, + 353, + 9319, + 3510, + 6483, + 30932, + 6374, + 30932, + 293, + 25712, + 7115, + 289, + 267, + 1869, + 30953, + 30917, + 2554, + 30930, + 13, + 13, + 31002, + 31007, + 326, + 30962, + 437, + 31007, + 30994, + 13, + 31002, + 31007, + 326, + 30962, + 6631, + 31007, + 30994, + 4865, + 13, + 1266, + 383, + 267, + 1194, + 4390, + 7129, + 30987, + 906, + 31007, + 326, + 30962, + 437, + 31007, + 30994, + 13, + 31002, + 31007, + 326, + 30962, + 6631, + 31007, + 30994, + 530, + 18971, + 13, + 353, + 1194, + 4390, + 7129, + 383, + 2603, + 30932, + 4610, + 30932, + 293, + 8362, + 30930, + 31002, + 31007, + 326, + 30962, + 437, + 31007, + 30994, + 30910, + 13, + 31002, + 31007, + 326, + 30962, + 6631, + 31007, + 30994, + 4865, + 13, + 30910, + 32929, + 31745, + 34032, + 37154, + 55083, + 32695, + 34213, + 31155, + 906, + 31007, + 326, + 30962, + 437, + 31007, + 30994, + 13, + 31002, + 31007, + 326, + 30962, + 6631, + 31007, + 30994, + 530, + 18971, + 13, + 30910, + 31745, + 34032, + 37154, + 55083, + 54532, + 33701, + 31723, + 39141, + 33606, + 31739, + 31123, + 32542, + 33248, + 34213, + 33260, + 35687, + 31201, + 36073, + 33339, + 54542, + 33116, + 31155, + 30910, + 31745, + 34032, + 31123, + 55502, + 54653, + 54872, + 54923, + 31123, + 38391, + 31745, + 31695, + 54617, + 37538, + 33606, + 31155, + 32542, + 32955, + 32419, + 32432, + 32249, + 31201, + 32645, + 44505, + 31123, + 31628, + 32557, + 41054, + 43569, + 54542, + 32033, + 31155, + 31745, + 34032, + 54530, + 36073, + 33339, + 47907, + 32001, + 31858, + 33339, + 54556, + 37538, + 31123, + 31925, + 32591, + 31793, + 31745, + 31987, + 31636, + 36058, + 31155, + 43833, + 38107, + 35231, + 32454, + 32325, + 32053, + 35299, + 54617, + 37538, + 33606, + 31739, + 31123, + 32542, + 32955, + 32419, + 54541, + 49193, + 31986, + 31863, + 31645, + 31123, + 54627, + 32438, + 31201, + 48747, + 54542, + 32410, + 38520, + 54609, + 31155, + 38107, + 32955, + 31665, + 46294, + 54530, + 36073, + 33339, + 31123, + 32187, + 31628, + 35757, + 54589, + 54376, + 54542, + 53144, + 32557, + 31155, + 31949, + 38107, + 31665, + 31818, + 32325, + 39195, + 33967, + 31123, + 32542, + 32955, + 34881, + 54573, + 55110, + 39727, + 31201, + 54539, + 36608, + 40538, + 37251, + 36608, + 52898, + 34861, + 55083, + 31123, + 54548, + 31803, + 34650, + 32557, + 32615, + 54542, + 39941, + 31155, + 30910, + 37169, + 31123, + 31745, + 34032, + 37154, + 55083, + 32695, + 31703, + 34213, + 33260, + 41215, + 35687, + 31201, + 36073, + 33339, + 54542, + 33116, + 31155, + 31745, + 34032, + 32419, + 31745, + 31695, + 31123, + 54617, + 38107, + 32419, + 31818, + 32325, + 39195, + 33967, + 31155, + 31645, + 35949, + 36073, + 33339, + 32955, + 54703, + 31745, + 34032, + 34732, + 31123, + 54548, + 32444, + 34650, + 33116, + 54542, + 39941, + 31155, + 31002, + 31007, + 326, + 30962, + 437, + 31007, + 30994, + 2 + ], + "labels": [ + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + 353, + 1194, + 4390, + 7129, + 383, + 2603, + 30932, + 4610, + 30932, + 293, + 8362, + 30930, + 31002, + 31007, + 326, + 30962, + 437, + 31007, + 30994, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + 30910, + 31745, + 34032, + 37154, + 55083, + 54532, + 33701, + 31723, + 39141, + 33606, + 31739, + 31123, + 32542, + 33248, + 34213, + 33260, + 35687, + 31201, + 36073, + 33339, + 54542, + 33116, + 31155, + 30910, + 31745, + 34032, + 31123, + 55502, + 54653, + 54872, + 54923, + 31123, + 38391, + 31745, + 31695, + 54617, + 37538, + 33606, + 31155, + 32542, + 32955, + 32419, + 32432, + 32249, + 31201, + 32645, + 44505, + 31123, + 31628, + 32557, + 41054, + 43569, + 54542, + 32033, + 31155, + 31745, + 34032, + 54530, + 36073, + 33339, + 47907, + 32001, + 31858, + 33339, + 54556, + 37538, + 31123, + 31925, + 32591, + 31793, + 31745, + 31987, + 31636, + 36058, + 31155, + 43833, + 38107, + 35231, + 32454, + 32325, + 32053, + 35299, + 54617, + 37538, + 33606, + 31739, + 31123, + 32542, + 32955, + 32419, + 54541, + 49193, + 31986, + 31863, + 31645, + 31123, + 54627, + 32438, + 31201, + 48747, + 54542, + 32410, + 38520, + 54609, + 31155, + 38107, + 32955, + 31665, + 46294, + 54530, + 36073, + 33339, + 31123, + 32187, + 31628, + 35757, + 54589, + 54376, + 54542, + 53144, + 32557, + 31155, + 31949, + 38107, + 31665, + 31818, + 32325, + 39195, + 33967, + 31123, + 32542, + 32955, + 34881, + 54573, + 55110, + 39727, + 31201, + 54539, + 36608, + 40538, + 37251, + 36608, + 52898, + 34861, + 55083, + 31123, + 54548, + 31803, + 34650, + 32557, + 32615, + 54542, + 39941, + 31155, + 30910, + 37169, + 31123, + 31745, + 34032, + 37154, + 55083, + 32695, + 31703, + 34213, + 33260, + 41215, + 35687, + 31201, + 36073, + 33339, + 54542, + 33116, + 31155, + 31745, + 34032, + 32419, + 31745, + 31695, + 31123, + 54617, + 38107, + 32419, + 31818, + 32325, + 39195, + 33967, + 31155, + 31645, + 35949, + 36073, + 33339, + 32955, + 54703, + 31745, + 34032, + 34732, + 31123, + 54548, + 32444, + 34650, + 33116, + 54542, + 39941, + 31155, + 31002, + 31007, + 326, + 30962, + 437, + 31007, + 30994, + 2 + ], + "inputs_decode": "<|im_start|>system\nA chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n<|im_end|>\n<|im_start|>user\n What are the three primary colors? <|im_end|>\n<|im_start|>assistant\n The three primary colors are red, blue, and yellow.<|im_end|> \n<|im_start|>user\n 解释个人电脑和服务器之间的区别。 <|im_end|>\n<|im_start|>assistant\n 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|>", + "labels_decode": [ + "The three primary colors are red, blue, and yellow.<|im_end|>", + "个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|>" + ], + "seq_length": 351, + "seq_category": "None" +} \ No newline at end of file diff --git a/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm3-6b.json b/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm3-6b.json new file mode 100644 index 000000000..5aab0073e --- /dev/null +++ b/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm3-6b.json @@ -0,0 +1,585 @@ +{ + "input_ids": [ + 64790, + 64792, + 906, + 31007, + 13361, + 31007, + 30994, + 13, + 316, + 8911, + 1074, + 260, + 10976, + 1869, + 293, + 284, + 12060, + 7151, + 9319, + 30930, + 353, + 9319, + 3510, + 6483, + 30932, + 6374, + 30932, + 293, + 25712, + 7115, + 289, + 267, + 1869, + 30953, + 30917, + 2554, + 30930, + 13, + 13, + 64795, + 30910, + 13, + 265, + 5011, + 383, + 267, + 1194, + 4390, + 7129, + 30987, + 64796, + 30910, + 13, + 265, + 1036, + 1194, + 4390, + 7129, + 383, + 2603, + 30932, + 4610, + 30932, + 293, + 8362, + 30930, + 64795, + 30910, + 13, + 265, + 32929, + 31745, + 34032, + 37154, + 55083, + 32695, + 34213, + 31155, + 64796, + 30910, + 13, + 265, + 31745, + 34032, + 37154, + 55083, + 54532, + 33701, + 31723, + 39141, + 33606, + 31739, + 31123, + 32542, + 33248, + 34213, + 33260, + 35687, + 31201, + 36073, + 33339, + 54542, + 33116, + 31155, + 30910, + 31745, + 34032, + 31123, + 55502, + 54653, + 54872, + 54923, + 31123, + 38391, + 31745, + 31695, + 54617, + 37538, + 33606, + 31155, + 32542, + 32955, + 32419, + 32432, + 32249, + 31201, + 32645, + 44505, + 31123, + 31628, + 32557, + 41054, + 43569, + 54542, + 32033, + 31155, + 31745, + 34032, + 54530, + 36073, + 33339, + 47907, + 32001, + 31858, + 33339, + 54556, + 37538, + 31123, + 31925, + 32591, + 31793, + 31745, + 31987, + 31636, + 36058, + 31155, + 43833, + 38107, + 35231, + 32454, + 32325, + 32053, + 35299, + 54617, + 37538, + 33606, + 31739, + 31123, + 32542, + 32955, + 32419, + 54541, + 49193, + 31986, + 31863, + 31645, + 31123, + 54627, + 32438, + 31201, + 48747, + 54542, + 32410, + 38520, + 54609, + 31155, + 38107, + 32955, + 31665, + 46294, + 54530, + 36073, + 33339, + 31123, + 32187, + 31628, + 35757, + 54589, + 54376, + 54542, + 53144, + 32557, + 31155, + 31949, + 38107, + 31665, + 31818, + 32325, + 39195, + 33967, + 31123, + 32542, + 32955, + 34881, + 54573, + 55110, + 39727, + 31201, + 54539, + 36608, + 40538, + 37251, + 36608, + 52898, + 34861, + 55083, + 31123, + 54548, + 31803, + 34650, + 32557, + 32615, + 54542, + 39941, + 31155, + 30910, + 37169, + 31123, + 31745, + 34032, + 37154, + 55083, + 32695, + 31703, + 34213, + 33260, + 41215, + 35687, + 31201, + 36073, + 33339, + 54542, + 33116, + 31155, + 31745, + 34032, + 32419, + 31745, + 31695, + 31123, + 54617, + 38107, + 32419, + 31818, + 32325, + 39195, + 33967, + 31155, + 31645, + 35949, + 36073, + 33339, + 32955, + 54703, + 31745, + 34032, + 34732, + 31123, + 54548, + 32444, + 34650, + 33116, + 54542, + 39941, + 31155, + 2 + ], + "labels": [ + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + 265, + 1036, + 1194, + 4390, + 7129, + 383, + 2603, + 30932, + 4610, + 30932, + 293, + 8362, + 30930, + 64795, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + 265, + 31745, + 34032, + 37154, + 55083, + 54532, + 33701, + 31723, + 39141, + 33606, + 31739, + 31123, + 32542, + 33248, + 34213, + 33260, + 35687, + 31201, + 36073, + 33339, + 54542, + 33116, + 31155, + 30910, + 31745, + 34032, + 31123, + 55502, + 54653, + 54872, + 54923, + 31123, + 38391, + 31745, + 31695, + 54617, + 37538, + 33606, + 31155, + 32542, + 32955, + 32419, + 32432, + 32249, + 31201, + 32645, + 44505, + 31123, + 31628, + 32557, + 41054, + 43569, + 54542, + 32033, + 31155, + 31745, + 34032, + 54530, + 36073, + 33339, + 47907, + 32001, + 31858, + 33339, + 54556, + 37538, + 31123, + 31925, + 32591, + 31793, + 31745, + 31987, + 31636, + 36058, + 31155, + 43833, + 38107, + 35231, + 32454, + 32325, + 32053, + 35299, + 54617, + 37538, + 33606, + 31739, + 31123, + 32542, + 32955, + 32419, + 54541, + 49193, + 31986, + 31863, + 31645, + 31123, + 54627, + 32438, + 31201, + 48747, + 54542, + 32410, + 38520, + 54609, + 31155, + 38107, + 32955, + 31665, + 46294, + 54530, + 36073, + 33339, + 31123, + 32187, + 31628, + 35757, + 54589, + 54376, + 54542, + 53144, + 32557, + 31155, + 31949, + 38107, + 31665, + 31818, + 32325, + 39195, + 33967, + 31123, + 32542, + 32955, + 34881, + 54573, + 55110, + 39727, + 31201, + 54539, + 36608, + 40538, + 37251, + 36608, + 52898, + 34861, + 55083, + 31123, + 54548, + 31803, + 34650, + 32557, + 32615, + 54542, + 39941, + 31155, + 30910, + 37169, + 31123, + 31745, + 34032, + 37154, + 55083, + 32695, + 31703, + 34213, + 33260, + 41215, + 35687, + 31201, + 36073, + 33339, + 54542, + 33116, + 31155, + 31745, + 34032, + 32419, + 31745, + 31695, + 31123, + 54617, + 38107, + 32419, + 31818, + 32325, + 39195, + 33967, + 31155, + 31645, + 35949, + 36073, + 33339, + 32955, + 54703, + 31745, + 34032, + 34732, + 31123, + 54548, + 32444, + 34650, + 33116, + 54542, + 39941, + 31155, + 2 + ], + "inputs_decode": "[gMASK] sop <|system|>\n A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n <|user|> \n What are the three primary colors? <|assistant|> \n The three primary colors are red, blue, and yellow. <|user|> \n 解释个人电脑和服务器之间的区别。 <|assistant|> \n 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。", + "labels_decode": [ + " The three primary colors are red, blue, and yellow. <|user|>", + " 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。" + ], + "seq_length": 286, + "seq_category": "None" +} \ No newline at end of file diff --git a/applications/ColossalChat/tests/test_data/chat_template/baichuan-inc_Baichuan2-13B-Chat.json b/applications/ColossalChat/tests/test_data/chat_template/baichuan-inc_Baichuan2-13B-Chat.json new file mode 100644 index 000000000..736baf85b --- /dev/null +++ b/applications/ColossalChat/tests/test_data/chat_template/baichuan-inc_Baichuan2-13B-Chat.json @@ -0,0 +1,697 @@ +{ + "input_ids": [ + 1, + 92655, + 92647, + 1418, + 92484, + 13387, + 92647, + 92574, + 24399, + 5, + 92343, + 15161, + 2357, + 1346, + 23815, + 3558, + 1377, + 1452, + 19649, + 11656, + 14002, + 72, + 1481, + 14002, + 6474, + 13629, + 92323, + 11144, + 92323, + 1377, + 70217, + 13514, + 1375, + 1352, + 3558, + 92404, + 92319, + 4852, + 72, + 5, + 5, + 92655, + 92647, + 1418, + 92484, + 1520, + 92647, + 92574, + 5, + 92655, + 92647, + 1418, + 92484, + 13387, + 92647, + 92574, + 8589, + 5, + 3167, + 1484, + 1352, + 2397, + 7721, + 12654, + 74, + 92655, + 92647, + 1418, + 92484, + 1520, + 92647, + 92574, + 5, + 92655, + 92647, + 1418, + 92484, + 13387, + 92647, + 92574, + 1613, + 10685, + 5, + 1524, + 2397, + 7721, + 12654, + 1484, + 5005, + 92323, + 8488, + 92323, + 1377, + 16149, + 72, + 92655, + 92647, + 1418, + 92484, + 1520, + 92647, + 92574, + 5, + 92655, + 92647, + 1418, + 92484, + 13387, + 92647, + 92574, + 8589, + 5, + 5987, + 2076, + 7283, + 18431, + 93107, + 5332, + 8592, + 66, + 92655, + 92647, + 1418, + 92484, + 1520, + 92647, + 92574, + 5, + 92655, + 92647, + 1418, + 92484, + 13387, + 92647, + 92574, + 1613, + 10685, + 5, + 2076, + 7283, + 18431, + 93107, + 92347, + 8653, + 2381, + 22152, + 9403, + 2274, + 65, + 20962, + 2231, + 8592, + 6795, + 13087, + 69, + 18512, + 7587, + 92385, + 8222, + 66, + 92311, + 2076, + 7283, + 65, + 52905, + 65, + 23044, + 2076, + 1964, + 92492, + 17274, + 9403, + 66, + 6085, + 6984, + 4349, + 4161, + 4588, + 69, + 5748, + 30443, + 65, + 1583, + 5155, + 24491, + 48901, + 92385, + 3872, + 66, + 2076, + 7283, + 92333, + 18512, + 7587, + 28068, + 2592, + 2417, + 7587, + 92393, + 17274, + 65, + 2776, + 4463, + 78704, + 3173, + 1697, + 9501, + 66, + 100178, + 31391, + 10551, + 4126, + 4121, + 3723, + 13169, + 92492, + 17274, + 9403, + 2274, + 65, + 6085, + 6984, + 4349, + 57325, + 2099, + 2936, + 2012, + 1760, + 65, + 92467, + 4516, + 69, + 36308, + 92385, + 4733, + 25092, + 92457, + 66, + 31391, + 6984, + 1836, + 49902, + 92333, + 18512, + 7587, + 65, + 3741, + 1583, + 11871, + 92434, + 55317, + 92385, + 41203, + 5155, + 66, + 3035, + 31391, + 1836, + 2590, + 4121, + 30881, + 17136, + 65, + 6085, + 6984, + 10040, + 92418, + 92888, + 40793, + 69, + 92366, + 18178, + 32629, + 18787, + 18178, + 66897, + 14685, + 93107, + 65, + 73411, + 12452, + 5155, + 82905, + 23304, + 66, + 92311, + 14748, + 65, + 2076, + 7283, + 18431, + 93107, + 5332, + 2231, + 8592, + 6795, + 20962, + 13087, + 69, + 18512, + 7587, + 92385, + 8222, + 66, + 2076, + 7283, + 4349, + 2076, + 1964, + 65, + 92492, + 31391, + 4349, + 2590, + 4121, + 30881, + 17136, + 66, + 1760, + 21050, + 18512, + 7587, + 6984, + 92596, + 2076, + 7283, + 10680, + 65, + 57310, + 12452, + 8222, + 92385, + 23304, + 66, + 92655, + 92647, + 1418, + 92484, + 1520, + 92647, + 92574, + 2 + ], + "labels": [ + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + 1524, + 2397, + 7721, + 12654, + 1484, + 5005, + 92323, + 8488, + 92323, + 1377, + 16149, + 72, + 92655, + 92647, + 1418, + 92484, + 1520, + 92647, + 92574, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + 2076, + 7283, + 18431, + 93107, + 92347, + 8653, + 2381, + 22152, + 9403, + 2274, + 65, + 20962, + 2231, + 8592, + 6795, + 13087, + 69, + 18512, + 7587, + 92385, + 8222, + 66, + 92311, + 2076, + 7283, + 65, + 52905, + 65, + 23044, + 2076, + 1964, + 92492, + 17274, + 9403, + 66, + 6085, + 6984, + 4349, + 4161, + 4588, + 69, + 5748, + 30443, + 65, + 1583, + 5155, + 24491, + 48901, + 92385, + 3872, + 66, + 2076, + 7283, + 92333, + 18512, + 7587, + 28068, + 2592, + 2417, + 7587, + 92393, + 17274, + 65, + 2776, + 4463, + 78704, + 3173, + 1697, + 9501, + 66, + 100178, + 31391, + 10551, + 4126, + 4121, + 3723, + 13169, + 92492, + 17274, + 9403, + 2274, + 65, + 6085, + 6984, + 4349, + 57325, + 2099, + 2936, + 2012, + 1760, + 65, + 92467, + 4516, + 69, + 36308, + 92385, + 4733, + 25092, + 92457, + 66, + 31391, + 6984, + 1836, + 49902, + 92333, + 18512, + 7587, + 65, + 3741, + 1583, + 11871, + 92434, + 55317, + 92385, + 41203, + 5155, + 66, + 3035, + 31391, + 1836, + 2590, + 4121, + 30881, + 17136, + 65, + 6085, + 6984, + 10040, + 92418, + 92888, + 40793, + 69, + 92366, + 18178, + 32629, + 18787, + 18178, + 66897, + 14685, + 93107, + 65, + 73411, + 12452, + 5155, + 82905, + 23304, + 66, + 92311, + 14748, + 65, + 2076, + 7283, + 18431, + 93107, + 5332, + 2231, + 8592, + 6795, + 20962, + 13087, + 69, + 18512, + 7587, + 92385, + 8222, + 66, + 2076, + 7283, + 4349, + 2076, + 1964, + 65, + 92492, + 31391, + 4349, + 2590, + 4121, + 30881, + 17136, + 66, + 1760, + 21050, + 18512, + 7587, + 6984, + 92596, + 2076, + 7283, + 10680, + 65, + 57310, + 12452, + 8222, + 92385, + 23304, + 66, + 92655, + 92647, + 1418, + 92484, + 1520, + 92647, + 92574, + 2 + ], + "inputs_decode": " <|im_start|>system\nA chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n<|im_end|>\n<|im_start|>user\nWhat are the three primary colors?<|im_end|>\n<|im_start|>assistant\nThe three primary colors are red, blue, and yellow.<|im_end|>\n<|im_start|>user\n解释个人电脑和服务器之间的区别。<|im_end|>\n<|im_start|>assistant\n个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|>", + "labels_decode": [ + "The three primary colors are red, blue, and yellow.<|im_end|>", + " 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|>" + ], + "seq_length": 342, + "seq_category": "None" +} \ No newline at end of file diff --git a/applications/ColossalChat/tests/test_data/chat_template/deepseek-ai_DeepSeek-V2-Lite.json b/applications/ColossalChat/tests/test_data/chat_template/deepseek-ai_DeepSeek-V2-Lite.json new file mode 100644 index 000000000..546e95144 --- /dev/null +++ b/applications/ColossalChat/tests/test_data/chat_template/deepseek-ai_DeepSeek-V2-Lite.json @@ -0,0 +1,581 @@ +{ + "input_ids": [ + 100000, + 32, + 12465, + 1439, + 245, + 13076, + 3807, + 285, + 274, + 18050, + 15141, + 20308, + 13, + 429, + 20308, + 4380, + 9394, + 11, + 9333, + 11, + 285, + 30513, + 9789, + 276, + 254, + 3807, + 6, + 82, + 4313, + 13, + 185, + 185, + 185, + 185, + 5726, + 25, + 2461, + 418, + 254, + 1853, + 6663, + 8247, + 30, + 185, + 185, + 77398, + 25, + 429, + 1853, + 6663, + 8247, + 418, + 3074, + 11, + 5501, + 11, + 285, + 10421, + 13, + 100001, + 5726, + 25, + 207, + 17882, + 6213, + 19462, + 50209, + 4625, + 17901, + 25628, + 398, + 185, + 185, + 77398, + 25, + 207, + 6213, + 19462, + 50209, + 4625, + 504, + 23807, + 5871, + 53947, + 33939, + 5804, + 19304, + 15047, + 24291, + 25628, + 18752, + 48548, + 537, + 34854, + 15477, + 885, + 16938, + 398, + 207, + 6213, + 19462, + 19304, + 8549, + 2217, + 4118, + 4800, + 19304, + 54533, + 6213, + 5118, + 1306, + 42753, + 33939, + 398, + 15047, + 18867, + 15055, + 16476, + 15982, + 537, + 15615, + 885, + 5782, + 19304, + 1876, + 17135, + 60574, + 98238, + 885, + 8340, + 398, + 6213, + 19462, + 337, + 34854, + 15477, + 72652, + 10263, + 7992, + 15477, + 913, + 42753, + 19304, + 6117, + 13742, + 6857, + 6213, + 9384, + 3421, + 31448, + 398, + 207, + 1306, + 59828, + 31759, + 13211, + 16690, + 8452, + 32512, + 1306, + 42753, + 33939, + 5804, + 19304, + 15047, + 18867, + 15055, + 78963, + 6037, + 8510, + 8083, + 4076, + 19304, + 1415, + 16196, + 537, + 12385, + 53913, + 885, + 18775, + 58875, + 1537, + 398, + 59828, + 18867, + 4012, + 93589, + 337, + 34854, + 15477, + 19304, + 9482, + 1876, + 33688, + 1331, + 5865, + 7438, + 885, + 88642, + 17135, + 398, + 7406, + 59828, + 4012, + 8580, + 16690, + 47322, + 45098, + 19304, + 15047, + 18867, + 27061, + 1059, + 6273, + 47500, + 537, + 748, + 45003, + 56873, + 47107, + 45003, + 81005, + 34136, + 4625, + 19304, + 851, + 8039, + 32672, + 17135, + 13951, + 885, + 59649, + 398, + 207, + 39736, + 19304, + 6213, + 19462, + 50209, + 4625, + 17901, + 5649, + 25628, + 18752, + 63889, + 48548, + 537, + 34854, + 15477, + 885, + 16938, + 398, + 6213, + 19462, + 15055, + 6213, + 5118, + 19304, + 1306, + 59828, + 15055, + 8580, + 16690, + 47322, + 45098, + 398, + 4076, + 40542, + 34854, + 15477, + 18867, + 1769, + 6213, + 19462, + 31729, + 19304, + 851, + 12383, + 32672, + 16938, + 885, + 59649, + 398, + 100001 + ], + "labels": [ + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + 429, + 1853, + 6663, + 8247, + 418, + 3074, + 11, + 5501, + 11, + 285, + 10421, + 13, + 100001, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + 207, + 6213, + 19462, + 50209, + 4625, + 504, + 23807, + 5871, + 53947, + 33939, + 5804, + 19304, + 15047, + 24291, + 25628, + 18752, + 48548, + 537, + 34854, + 15477, + 885, + 16938, + 398, + 207, + 6213, + 19462, + 19304, + 8549, + 2217, + 4118, + 4800, + 19304, + 54533, + 6213, + 5118, + 1306, + 42753, + 33939, + 398, + 15047, + 18867, + 15055, + 16476, + 15982, + 537, + 15615, + 885, + 5782, + 19304, + 1876, + 17135, + 60574, + 98238, + 885, + 8340, + 398, + 6213, + 19462, + 337, + 34854, + 15477, + 72652, + 10263, + 7992, + 15477, + 913, + 42753, + 19304, + 6117, + 13742, + 6857, + 6213, + 9384, + 3421, + 31448, + 398, + 207, + 1306, + 59828, + 31759, + 13211, + 16690, + 8452, + 32512, + 1306, + 42753, + 33939, + 5804, + 19304, + 15047, + 18867, + 15055, + 78963, + 6037, + 8510, + 8083, + 4076, + 19304, + 1415, + 16196, + 537, + 12385, + 53913, + 885, + 18775, + 58875, + 1537, + 398, + 59828, + 18867, + 4012, + 93589, + 337, + 34854, + 15477, + 19304, + 9482, + 1876, + 33688, + 1331, + 5865, + 7438, + 885, + 88642, + 17135, + 398, + 7406, + 59828, + 4012, + 8580, + 16690, + 47322, + 45098, + 19304, + 15047, + 18867, + 27061, + 1059, + 6273, + 47500, + 537, + 748, + 45003, + 56873, + 47107, + 45003, + 81005, + 34136, + 4625, + 19304, + 851, + 8039, + 32672, + 17135, + 13951, + 885, + 59649, + 398, + 207, + 39736, + 19304, + 6213, + 19462, + 50209, + 4625, + 17901, + 5649, + 25628, + 18752, + 63889, + 48548, + 537, + 34854, + 15477, + 885, + 16938, + 398, + 6213, + 19462, + 15055, + 6213, + 5118, + 19304, + 1306, + 59828, + 15055, + 8580, + 16690, + 47322, + 45098, + 398, + 4076, + 40542, + 34854, + 15477, + 18867, + 1769, + 6213, + 19462, + 31729, + 19304, + 851, + 12383, + 32672, + 16938, + 885, + 59649, + 398, + 100001 + ], + "inputs_decode": "<|begin▁of▁sentence|>A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n\n\nUser: What are the three primary colors?\n\nAssistant: The three primary colors are red, blue, and yellow.<|end▁of▁sentence|>User: 解释个人电脑和服务器之间的区别。\n\nAssistant: 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|end▁of▁sentence|>", + "labels_decode": [ + " The three primary colors are red, blue, and yellow.<|end▁of▁sentence|>", + " 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|end▁of▁sentence|>" + ], + "seq_length": 284, + "seq_category": "None" +} \ No newline at end of file diff --git a/applications/ColossalChat/tests/test_data/chat_template/microsoft_phi-2.json b/applications/ColossalChat/tests/test_data/chat_template/microsoft_phi-2.json new file mode 100644 index 000000000..f43ab7f4c --- /dev/null +++ b/applications/ColossalChat/tests/test_data/chat_template/microsoft_phi-2.json @@ -0,0 +1,2009 @@ +{ + "input_ids": [ + 50256, + 27, + 91, + 320, + 62, + 9688, + 91, + 29, + 10057, + 198, + 32, + 8537, + 1022, + 257, + 11040, + 1692, + 290, + 281, + 11666, + 4430, + 8796, + 13, + 383, + 8796, + 3607, + 7613, + 11, + 6496, + 11, + 290, + 23507, + 7429, + 284, + 262, + 1692, + 338, + 2683, + 13, + 198, + 198, + 27, + 91, + 320, + 62, + 437, + 91, + 29, + 198, + 27, + 91, + 320, + 62, + 9688, + 91, + 29, + 7220, + 198, + 2061, + 389, + 262, + 1115, + 4165, + 7577, + 30, + 27, + 91, + 320, + 62, + 437, + 91, + 29, + 198, + 27, + 91, + 320, + 62, + 9688, + 91, + 29, + 562, + 10167, + 198, + 464, + 1115, + 4165, + 7577, + 389, + 2266, + 11, + 4171, + 11, + 290, + 7872, + 29847, + 91, + 320, + 62, + 437, + 91, + 29, + 198, + 27, + 91, + 320, + 62, + 9688, + 91, + 29, + 7220, + 198, + 164, + 100, + 96, + 34932, + 232, + 10310, + 103, + 21689, + 18796, + 113, + 164, + 226, + 239, + 161, + 240, + 234, + 17312, + 235, + 27950, + 94, + 161, + 247, + 101, + 45298, + 29785, + 112, + 21410, + 44293, + 118, + 26344, + 104, + 16764, + 27, + 91, + 320, + 62, + 437, + 91, + 29, + 198, + 27, + 91, + 320, + 62, + 9688, + 91, + 29, + 562, + 10167, + 198, + 10310, + 103, + 21689, + 18796, + 113, + 164, + 226, + 239, + 161, + 240, + 234, + 17312, + 235, + 27950, + 94, + 161, + 247, + 101, + 42468, + 10310, + 97, + 163, + 100, + 235, + 38834, + 28938, + 234, + 163, + 109, + 119, + 161, + 252, + 233, + 21410, + 164, + 106, + 94, + 163, + 106, + 245, + 17312, + 118, + 163, + 111, + 119, + 163, + 119, + 253, + 171, + 120, + 234, + 22522, + 225, + 20015, + 105, + 21410, + 10310, + 119, + 17358, + 223, + 44293, + 118, + 26344, + 104, + 28839, + 101, + 12859, + 236, + 18796, + 101, + 34460, + 242, + 23513, + 163, + 94, + 105, + 20015, + 114, + 165, + 227, + 235, + 163, + 121, + 106, + 161, + 240, + 234, + 45250, + 100, + 47797, + 121, + 16764, + 220, + 10310, + 103, + 21689, + 18796, + 113, + 164, + 226, + 239, + 171, + 120, + 234, + 165, + 94, + 122, + 28938, + 235, + 45250, + 251, + 20046, + 231, + 171, + 120, + 234, + 42468, + 10310, + 118, + 10310, + 103, + 21689, + 45635, + 18796, + 101, + 32003, + 234, + 164, + 106, + 122, + 164, + 106, + 94, + 21410, + 164, + 106, + 94, + 163, + 106, + 245, + 17312, + 118, + 16764, + 22522, + 225, + 20015, + 105, + 34460, + 248, + 30585, + 116, + 18796, + 101, + 12859, + 236, + 33768, + 98, + 30585, + 116, + 21410, + 32432, + 98, + 43291, + 23513, + 161, + 101, + 109, + 20046, + 238, + 161, + 240, + 234, + 27764, + 99, + 20046, + 254, + 171, + 120, + 234, + 20998, + 107, + 20015, + 98, + 32573, + 238, + 26193, + 234, + 28938, + 226, + 163, + 100, + 235, + 28938, + 226, + 43718, + 115, + 21410, + 41753, + 242, + 18796, + 101, + 163, + 101, + 233, + 41753, + 237, + 161, + 240, + 234, + 162, + 116, + 116, + 22755, + 237, + 16764, + 10310, + 103, + 21689, + 18796, + 113, + 164, + 226, + 239, + 21410, + 163, + 94, + 105, + 20015, + 114, + 165, + 227, + 235, + 163, + 121, + 106, + 31660, + 48958, + 105, + 42468, + 162, + 234, + 231, + 163, + 227, + 100, + 43718, + 229, + 49035, + 228, + 165, + 227, + 235, + 163, + 121, + 106, + 30266, + 98, + 164, + 106, + 122, + 164, + 106, + 94, + 21410, + 171, + 120, + 234, + 38834, + 32573, + 229, + 20046, + 253, + 20998, + 107, + 20015, + 98, + 43718, + 117, + 162, + 235, + 106, + 10310, + 103, + 21689, + 165, + 250, + 222, + 162, + 109, + 224, + 32573, + 249, + 26193, + 234, + 22522, + 248, + 26344, + 114, + 16764, + 5525, + 222, + 234, + 17312, + 235, + 27950, + 94, + 161, + 247, + 101, + 42468, + 10310, + 118, + 12859, + 228, + 162, + 119, + 94, + 164, + 114, + 111, + 32014, + 34932, + 237, + 18796, + 101, + 22755, + 115, + 21410, + 165, + 250, + 222, + 162, + 109, + 224, + 32003, + 234, + 164, + 106, + 122, + 164, + 106, + 94, + 21410, + 164, + 106, + 94, + 163, + 106, + 245, + 17312, + 118, + 163, + 111, + 119, + 163, + 119, + 253, + 171, + 120, + 234, + 22522, + 225, + 20015, + 105, + 34460, + 248, + 30585, + 116, + 18796, + 101, + 12859, + 236, + 10310, + 118, + 18796, + 101, + 22755, + 115, + 162, + 237, + 238, + 160, + 122, + 249, + 28938, + 226, + 163, + 100, + 235, + 163, + 121, + 239, + 163, + 119, + 250, + 17312, + 235, + 27950, + 94, + 171, + 120, + 234, + 36685, + 224, + 163, + 121, + 239, + 44165, + 247, + 23513, + 18796, + 113, + 36310, + 165, + 224, + 106, + 20015, + 114, + 161, + 240, + 234, + 23877, + 229, + 20015, + 114, + 27670, + 254, + 164, + 122, + 241, + 163, + 255, + 231, + 16764, + 17312, + 235, + 27950, + 94, + 161, + 247, + 101, + 34460, + 248, + 30585, + 116, + 165, + 250, + 222, + 17358, + 223, + 165, + 45865, + 45250, + 100, + 47797, + 121, + 21410, + 163, + 94, + 105, + 20015, + 114, + 165, + 227, + 235, + 163, + 121, + 106, + 171, + 120, + 234, + 33176, + 114, + 10310, + 242, + 20998, + 107, + 20015, + 98, + 33699, + 123, + 20998, + 245, + 165, + 45865, + 164, + 112, + 253, + 164, + 121, + 121, + 161, + 240, + 234, + 165, + 243, + 123, + 33768, + 114, + 29785, + 112, + 21410, + 32573, + 238, + 26193, + 234, + 16764, + 18796, + 109, + 12859, + 236, + 17312, + 235, + 27950, + 94, + 161, + 247, + 101, + 165, + 250, + 222, + 17358, + 223, + 162, + 242, + 107, + 162, + 234, + 223, + 32014, + 34932, + 237, + 18796, + 101, + 22755, + 115, + 21410, + 164, + 106, + 123, + 29785, + 106, + 171, + 120, + 234, + 22522, + 225, + 20015, + 105, + 34460, + 248, + 30585, + 116, + 165, + 227, + 235, + 13783, + 229, + 13783, + 248, + 43718, + 116, + 13783, + 226, + 49426, + 228, + 161, + 247, + 101, + 23513, + 32014, + 22522, + 117, + 34932, + 237, + 37863, + 227, + 27764, + 246, + 161, + 240, + 234, + 32014, + 22522, + 117, + 34932, + 237, + 163, + 94, + 105, + 33566, + 246, + 165, + 102, + 109, + 27950, + 101, + 161, + 247, + 101, + 171, + 120, + 234, + 20015, + 98, + 162, + 237, + 238, + 165, + 45865, + 163, + 111, + 119, + 163, + 119, + 253, + 21410, + 32573, + 238, + 26193, + 234, + 34460, + 253, + 41753, + 99, + 161, + 240, + 234, + 163, + 101, + 111, + 22522, + 248, + 45250, + 100, + 16764, + 10545, + 222, + 119, + 45298, + 171, + 120, + 234, + 10310, + 103, + 21689, + 18796, + 113, + 164, + 226, + 239, + 161, + 240, + 234, + 17312, + 235, + 27950, + 94, + 161, + 247, + 101, + 45298, + 29785, + 112, + 21410, + 10310, + 119, + 17358, + 223, + 44293, + 118, + 26344, + 104, + 28839, + 101, + 12859, + 236, + 22522, + 225, + 20015, + 105, + 21410, + 18796, + 101, + 34460, + 242, + 23513, + 163, + 94, + 105, + 20015, + 114, + 165, + 227, + 235, + 163, + 121, + 106, + 161, + 240, + 234, + 45250, + 100, + 47797, + 121, + 16764, + 10310, + 103, + 21689, + 18796, + 113, + 164, + 226, + 239, + 18796, + 101, + 12859, + 236, + 10310, + 103, + 21689, + 45635, + 18796, + 101, + 171, + 120, + 234, + 32003, + 234, + 17312, + 235, + 27950, + 94, + 161, + 247, + 101, + 18796, + 101, + 12859, + 236, + 162, + 242, + 107, + 162, + 234, + 223, + 32014, + 34932, + 237, + 18796, + 101, + 22755, + 115, + 21410, + 164, + 106, + 123, + 29785, + 106, + 16764, + 17312, + 235, + 27950, + 94, + 161, + 247, + 101, + 21410, + 163, + 94, + 105, + 20015, + 114, + 165, + 227, + 235, + 163, + 121, + 106, + 34460, + 248, + 30585, + 116, + 162, + 107, + 242, + 10310, + 103, + 21689, + 18796, + 113, + 164, + 226, + 239, + 162, + 249, + 112, + 165, + 45865, + 171, + 120, + 234, + 20015, + 98, + 46479, + 251, + 46237, + 223, + 163, + 111, + 119, + 163, + 119, + 253, + 21410, + 45250, + 100, + 47797, + 121, + 161, + 240, + 234, + 163, + 101, + 111, + 22522, + 248, + 45250, + 100, + 16764, + 27, + 91, + 320, + 62, + 437, + 91, + 29, + 50256 + ], + "labels": [ + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + 464, + 1115, + 4165, + 7577, + 389, + 2266, + 11, + 4171, + 11, + 290, + 7872, + 29847, + 91, + 320, + 62, + 437, + 91, + 29, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + 10310, + 103, + 21689, + 18796, + 113, + 164, + 226, + 239, + 161, + 240, + 234, + 17312, + 235, + 27950, + 94, + 161, + 247, + 101, + 42468, + 10310, + 97, + 163, + 100, + 235, + 38834, + 28938, + 234, + 163, + 109, + 119, + 161, + 252, + 233, + 21410, + 164, + 106, + 94, + 163, + 106, + 245, + 17312, + 118, + 163, + 111, + 119, + 163, + 119, + 253, + 171, + 120, + 234, + 22522, + 225, + 20015, + 105, + 21410, + 10310, + 119, + 17358, + 223, + 44293, + 118, + 26344, + 104, + 28839, + 101, + 12859, + 236, + 18796, + 101, + 34460, + 242, + 23513, + 163, + 94, + 105, + 20015, + 114, + 165, + 227, + 235, + 163, + 121, + 106, + 161, + 240, + 234, + 45250, + 100, + 47797, + 121, + 16764, + 220, + 10310, + 103, + 21689, + 18796, + 113, + 164, + 226, + 239, + 171, + 120, + 234, + 165, + 94, + 122, + 28938, + 235, + 45250, + 251, + 20046, + 231, + 171, + 120, + 234, + 42468, + 10310, + 118, + 10310, + 103, + 21689, + 45635, + 18796, + 101, + 32003, + 234, + 164, + 106, + 122, + 164, + 106, + 94, + 21410, + 164, + 106, + 94, + 163, + 106, + 245, + 17312, + 118, + 16764, + 22522, + 225, + 20015, + 105, + 34460, + 248, + 30585, + 116, + 18796, + 101, + 12859, + 236, + 33768, + 98, + 30585, + 116, + 21410, + 32432, + 98, + 43291, + 23513, + 161, + 101, + 109, + 20046, + 238, + 161, + 240, + 234, + 27764, + 99, + 20046, + 254, + 171, + 120, + 234, + 20998, + 107, + 20015, + 98, + 32573, + 238, + 26193, + 234, + 28938, + 226, + 163, + 100, + 235, + 28938, + 226, + 43718, + 115, + 21410, + 41753, + 242, + 18796, + 101, + 163, + 101, + 233, + 41753, + 237, + 161, + 240, + 234, + 162, + 116, + 116, + 22755, + 237, + 16764, + 10310, + 103, + 21689, + 18796, + 113, + 164, + 226, + 239, + 21410, + 163, + 94, + 105, + 20015, + 114, + 165, + 227, + 235, + 163, + 121, + 106, + 31660, + 48958, + 105, + 42468, + 162, + 234, + 231, + 163, + 227, + 100, + 43718, + 229, + 49035, + 228, + 165, + 227, + 235, + 163, + 121, + 106, + 30266, + 98, + 164, + 106, + 122, + 164, + 106, + 94, + 21410, + 171, + 120, + 234, + 38834, + 32573, + 229, + 20046, + 253, + 20998, + 107, + 20015, + 98, + 43718, + 117, + 162, + 235, + 106, + 10310, + 103, + 21689, + 165, + 250, + 222, + 162, + 109, + 224, + 32573, + 249, + 26193, + 234, + 22522, + 248, + 26344, + 114, + 16764, + 5525, + 222, + 234, + 17312, + 235, + 27950, + 94, + 161, + 247, + 101, + 42468, + 10310, + 118, + 12859, + 228, + 162, + 119, + 94, + 164, + 114, + 111, + 32014, + 34932, + 237, + 18796, + 101, + 22755, + 115, + 21410, + 165, + 250, + 222, + 162, + 109, + 224, + 32003, + 234, + 164, + 106, + 122, + 164, + 106, + 94, + 21410, + 164, + 106, + 94, + 163, + 106, + 245, + 17312, + 118, + 163, + 111, + 119, + 163, + 119, + 253, + 171, + 120, + 234, + 22522, + 225, + 20015, + 105, + 34460, + 248, + 30585, + 116, + 18796, + 101, + 12859, + 236, + 10310, + 118, + 18796, + 101, + 22755, + 115, + 162, + 237, + 238, + 160, + 122, + 249, + 28938, + 226, + 163, + 100, + 235, + 163, + 121, + 239, + 163, + 119, + 250, + 17312, + 235, + 27950, + 94, + 171, + 120, + 234, + 36685, + 224, + 163, + 121, + 239, + 44165, + 247, + 23513, + 18796, + 113, + 36310, + 165, + 224, + 106, + 20015, + 114, + 161, + 240, + 234, + 23877, + 229, + 20015, + 114, + 27670, + 254, + 164, + 122, + 241, + 163, + 255, + 231, + 16764, + 17312, + 235, + 27950, + 94, + 161, + 247, + 101, + 34460, + 248, + 30585, + 116, + 165, + 250, + 222, + 17358, + 223, + 165, + 45865, + 45250, + 100, + 47797, + 121, + 21410, + 163, + 94, + 105, + 20015, + 114, + 165, + 227, + 235, + 163, + 121, + 106, + 171, + 120, + 234, + 33176, + 114, + 10310, + 242, + 20998, + 107, + 20015, + 98, + 33699, + 123, + 20998, + 245, + 165, + 45865, + 164, + 112, + 253, + 164, + 121, + 121, + 161, + 240, + 234, + 165, + 243, + 123, + 33768, + 114, + 29785, + 112, + 21410, + 32573, + 238, + 26193, + 234, + 16764, + 18796, + 109, + 12859, + 236, + 17312, + 235, + 27950, + 94, + 161, + 247, + 101, + 165, + 250, + 222, + 17358, + 223, + 162, + 242, + 107, + 162, + 234, + 223, + 32014, + 34932, + 237, + 18796, + 101, + 22755, + 115, + 21410, + 164, + 106, + 123, + 29785, + 106, + 171, + 120, + 234, + 22522, + 225, + 20015, + 105, + 34460, + 248, + 30585, + 116, + 165, + 227, + 235, + 13783, + 229, + 13783, + 248, + 43718, + 116, + 13783, + 226, + 49426, + 228, + 161, + 247, + 101, + 23513, + 32014, + 22522, + 117, + 34932, + 237, + 37863, + 227, + 27764, + 246, + 161, + 240, + 234, + 32014, + 22522, + 117, + 34932, + 237, + 163, + 94, + 105, + 33566, + 246, + 165, + 102, + 109, + 27950, + 101, + 161, + 247, + 101, + 171, + 120, + 234, + 20015, + 98, + 162, + 237, + 238, + 165, + 45865, + 163, + 111, + 119, + 163, + 119, + 253, + 21410, + 32573, + 238, + 26193, + 234, + 34460, + 253, + 41753, + 99, + 161, + 240, + 234, + 163, + 101, + 111, + 22522, + 248, + 45250, + 100, + 16764, + 10545, + 222, + 119, + 45298, + 171, + 120, + 234, + 10310, + 103, + 21689, + 18796, + 113, + 164, + 226, + 239, + 161, + 240, + 234, + 17312, + 235, + 27950, + 94, + 161, + 247, + 101, + 45298, + 29785, + 112, + 21410, + 10310, + 119, + 17358, + 223, + 44293, + 118, + 26344, + 104, + 28839, + 101, + 12859, + 236, + 22522, + 225, + 20015, + 105, + 21410, + 18796, + 101, + 34460, + 242, + 23513, + 163, + 94, + 105, + 20015, + 114, + 165, + 227, + 235, + 163, + 121, + 106, + 161, + 240, + 234, + 45250, + 100, + 47797, + 121, + 16764, + 10310, + 103, + 21689, + 18796, + 113, + 164, + 226, + 239, + 18796, + 101, + 12859, + 236, + 10310, + 103, + 21689, + 45635, + 18796, + 101, + 171, + 120, + 234, + 32003, + 234, + 17312, + 235, + 27950, + 94, + 161, + 247, + 101, + 18796, + 101, + 12859, + 236, + 162, + 242, + 107, + 162, + 234, + 223, + 32014, + 34932, + 237, + 18796, + 101, + 22755, + 115, + 21410, + 164, + 106, + 123, + 29785, + 106, + 16764, + 17312, + 235, + 27950, + 94, + 161, + 247, + 101, + 21410, + 163, + 94, + 105, + 20015, + 114, + 165, + 227, + 235, + 163, + 121, + 106, + 34460, + 248, + 30585, + 116, + 162, + 107, + 242, + 10310, + 103, + 21689, + 18796, + 113, + 164, + 226, + 239, + 162, + 249, + 112, + 165, + 45865, + 171, + 120, + 234, + 20015, + 98, + 46479, + 251, + 46237, + 223, + 163, + 111, + 119, + 163, + 119, + 253, + 21410, + 45250, + 100, + 47797, + 121, + 161, + 240, + 234, + 163, + 101, + 111, + 22522, + 248, + 45250, + 100, + 16764, + 27, + 91, + 320, + 62, + 437, + 91, + 29, + 50256 + ], + "inputs_decode": "<|endoftext|><|im_start|>system\nA chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n<|im_end|>\n<|im_start|>user\nWhat are the three primary colors?<|im_end|>\n<|im_start|>assistant\nThe three primary colors are red, blue, and yellow.<|im_end|>\n<|im_start|>user\n解释个人电脑和服务器之间的区别。<|im_end|>\n<|im_start|>assistant\n个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|><|endoftext|>", + "labels_decode": [ + "The three primary colors are red, blue, and yellow.<|im_end|>", + "个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|><|endoftext|>" + ], + "seq_length": 998, + "seq_category": "None" +} \ No newline at end of file diff --git a/applications/ColossalChat/tests/test_data/chat_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json b/applications/ColossalChat/tests/test_data/chat_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json new file mode 100644 index 000000000..f1979eb52 --- /dev/null +++ b/applications/ColossalChat/tests/test_data/chat_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json @@ -0,0 +1,919 @@ +{ + "input_ids": [ + 1, + 733, + 16289, + 28793, + 28705, + 1824, + 460, + 272, + 1712, + 6258, + 9304, + 28804, + 28705, + 733, + 28748, + 16289, + 28793, + 415, + 1712, + 6258, + 9304, + 460, + 2760, + 28725, + 5045, + 28725, + 304, + 9684, + 28723, + 2, + 733, + 16289, + 28793, + 259, + 29386, + 30334, + 28995, + 29086, + 29742, + 31753, + 29131, + 29430, + 29224, + 29180, + 29332, + 29117, + 28914, + 29209, + 29705, + 28944, + 28705, + 733, + 28748, + 16289, + 28793, + 28705, + 28995, + 29086, + 29742, + 31753, + 29131, + 29430, + 29224, + 29180, + 28971, + 29745, + 29824, + 28988, + 29338, + 29066, + 29173, + 28914, + 29382, + 29481, + 29363, + 29401, + 29531, + 28924, + 29928, + 29550, + 28914, + 29345, + 29059, + 29209, + 29705, + 29010, + 29160, + 28963, + 31787, + 29041, + 31483, + 29011, + 29253, + 29021, + 29131, + 29261, + 29084, + 28944, + 28705, + 28995, + 29086, + 29742, + 31753, + 28924, + 236, + 164, + 193, + 29046, + 30450, + 29476, + 28924, + 28971, + 29003, + 28995, + 29086, + 29154, + 28963, + 29746, + 29081, + 29382, + 28914, + 29382, + 29481, + 29363, + 28944, + 29928, + 29550, + 29217, + 29408, + 28963, + 29160, + 29142, + 29408, + 28914, + 29487, + 29089, + 29041, + 232, + 171, + 180, + 30488, + 29131, + 29500, + 30978, + 28924, + 29052, + 29074, + 29798, + 29037, + 30344, + 29824, + 30344, + 29675, + 28914, + 29298, + 28963, + 29265, + 29313, + 29131, + 30239, + 30727, + 28944, + 28995, + 29086, + 29742, + 31753, + 28914, + 31483, + 29011, + 29253, + 29021, + 28969, + 30812, + 28971, + 29518, + 30131, + 29144, + 30168, + 29253, + 29021, + 29263, + 29081, + 29382, + 28914, + 28924, + 28988, + 29202, + 29537, + 29052, + 29074, + 29521, + 29020, + 28995, + 29086, + 29259, + 29243, + 29258, + 29037, + 29018, + 29251, + 28944, + 28705, + 29746, + 29430, + 29224, + 29180, + 28971, + 29003, + 29105, + 30493, + 30303, + 29050, + 29195, + 28963, + 29106, + 28914, + 29259, + 29243, + 29746, + 29081, + 29382, + 28914, + 29382, + 29481, + 29363, + 29401, + 29531, + 28924, + 29928, + 29550, + 29217, + 29408, + 28963, + 29160, + 29003, + 28963, + 29106, + 29279, + 29954, + 30344, + 29824, + 29533, + 30229, + 29430, + 29224, + 28924, + 29118, + 29533, + 29992, + 29041, + 29742, + 29169, + 30182, + 29011, + 29131, + 29019, + 29011, + 29359, + 29226, + 29414, + 28944, + 29430, + 29224, + 29180, + 29217, + 29408, + 29259, + 29059, + 29366, + 29261, + 29084, + 28914, + 31483, + 29011, + 29253, + 29021, + 28924, + 29457, + 29958, + 29052, + 29074, + 30761, + 30154, + 29366, + 30685, + 29435, + 29131, + 29495, + 29007, + 29117, + 28914, + 29798, + 29037, + 28944, + 29590, + 29160, + 29430, + 29224, + 29180, + 29259, + 29059, + 29428, + 29569, + 29050, + 29195, + 28963, + 29106, + 28914, + 30164, + 29562, + 28924, + 29928, + 29550, + 29217, + 29408, + 29253, + 29613, + 29292, + 30080, + 29326, + 29093, + 29180, + 29041, + 29050, + 29329, + 29195, + 29188, + 29079, + 29131, + 29050, + 29329, + 29195, + 31483, + 30358, + 236, + 172, + 180, + 29129, + 29180, + 28924, + 29074, + 29279, + 29366, + 29401, + 29531, + 28914, + 29798, + 29037, + 30029, + 29184, + 29131, + 234, + 171, + 182, + 29018, + 29261, + 28944, + 28705, + 29758, + 29332, + 28924, + 28995, + 29086, + 29742, + 31753, + 29131, + 29430, + 29224, + 29180, + 29332, + 29117, + 28914, + 29345, + 29059, + 29209, + 29705, + 29010, + 29160, + 29928, + 29550, + 28914, + 28963, + 31787, + 29041, + 31483, + 29011, + 29253, + 29021, + 29131, + 29261, + 29084, + 28944, + 28995, + 29086, + 29742, + 31753, + 28963, + 29160, + 28995, + 29086, + 29154, + 28963, + 28924, + 29746, + 29430, + 29224, + 29180, + 28963, + 29160, + 29428, + 29569, + 29050, + 29195, + 28963, + 29106, + 28914, + 30164, + 29562, + 28944, + 29430, + 29224, + 29180, + 28914, + 31483, + 29011, + 29253, + 29021, + 29217, + 29408, + 29605, + 28995, + 29086, + 29742, + 31753, + 29250, + 29366, + 28924, + 29074, + 29321, + 29425, + 29401, + 29531, + 28914, + 29261, + 29084, + 29131, + 234, + 171, + 182, + 29018, + 29261, + 28944, + 2 + ], + "labels": [ + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + 415, + 1712, + 6258, + 9304, + 460, + 2760, + 28725, + 5045, + 28725, + 304, + 9684, + 28723, + 2, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + 28705, + 28995, + 29086, + 29742, + 31753, + 29131, + 29430, + 29224, + 29180, + 28971, + 29745, + 29824, + 28988, + 29338, + 29066, + 29173, + 28914, + 29382, + 29481, + 29363, + 29401, + 29531, + 28924, + 29928, + 29550, + 28914, + 29345, + 29059, + 29209, + 29705, + 29010, + 29160, + 28963, + 31787, + 29041, + 31483, + 29011, + 29253, + 29021, + 29131, + 29261, + 29084, + 28944, + 28705, + 28995, + 29086, + 29742, + 31753, + 28924, + 236, + 164, + 193, + 29046, + 30450, + 29476, + 28924, + 28971, + 29003, + 28995, + 29086, + 29154, + 28963, + 29746, + 29081, + 29382, + 28914, + 29382, + 29481, + 29363, + 28944, + 29928, + 29550, + 29217, + 29408, + 28963, + 29160, + 29142, + 29408, + 28914, + 29487, + 29089, + 29041, + 232, + 171, + 180, + 30488, + 29131, + 29500, + 30978, + 28924, + 29052, + 29074, + 29798, + 29037, + 30344, + 29824, + 30344, + 29675, + 28914, + 29298, + 28963, + 29265, + 29313, + 29131, + 30239, + 30727, + 28944, + 28995, + 29086, + 29742, + 31753, + 28914, + 31483, + 29011, + 29253, + 29021, + 28969, + 30812, + 28971, + 29518, + 30131, + 29144, + 30168, + 29253, + 29021, + 29263, + 29081, + 29382, + 28914, + 28924, + 28988, + 29202, + 29537, + 29052, + 29074, + 29521, + 29020, + 28995, + 29086, + 29259, + 29243, + 29258, + 29037, + 29018, + 29251, + 28944, + 28705, + 29746, + 29430, + 29224, + 29180, + 28971, + 29003, + 29105, + 30493, + 30303, + 29050, + 29195, + 28963, + 29106, + 28914, + 29259, + 29243, + 29746, + 29081, + 29382, + 28914, + 29382, + 29481, + 29363, + 29401, + 29531, + 28924, + 29928, + 29550, + 29217, + 29408, + 28963, + 29160, + 29003, + 28963, + 29106, + 29279, + 29954, + 30344, + 29824, + 29533, + 30229, + 29430, + 29224, + 28924, + 29118, + 29533, + 29992, + 29041, + 29742, + 29169, + 30182, + 29011, + 29131, + 29019, + 29011, + 29359, + 29226, + 29414, + 28944, + 29430, + 29224, + 29180, + 29217, + 29408, + 29259, + 29059, + 29366, + 29261, + 29084, + 28914, + 31483, + 29011, + 29253, + 29021, + 28924, + 29457, + 29958, + 29052, + 29074, + 30761, + 30154, + 29366, + 30685, + 29435, + 29131, + 29495, + 29007, + 29117, + 28914, + 29798, + 29037, + 28944, + 29590, + 29160, + 29430, + 29224, + 29180, + 29259, + 29059, + 29428, + 29569, + 29050, + 29195, + 28963, + 29106, + 28914, + 30164, + 29562, + 28924, + 29928, + 29550, + 29217, + 29408, + 29253, + 29613, + 29292, + 30080, + 29326, + 29093, + 29180, + 29041, + 29050, + 29329, + 29195, + 29188, + 29079, + 29131, + 29050, + 29329, + 29195, + 31483, + 30358, + 236, + 172, + 180, + 29129, + 29180, + 28924, + 29074, + 29279, + 29366, + 29401, + 29531, + 28914, + 29798, + 29037, + 30029, + 29184, + 29131, + 234, + 171, + 182, + 29018, + 29261, + 28944, + 28705, + 29758, + 29332, + 28924, + 28995, + 29086, + 29742, + 31753, + 29131, + 29430, + 29224, + 29180, + 29332, + 29117, + 28914, + 29345, + 29059, + 29209, + 29705, + 29010, + 29160, + 29928, + 29550, + 28914, + 28963, + 31787, + 29041, + 31483, + 29011, + 29253, + 29021, + 29131, + 29261, + 29084, + 28944, + 28995, + 29086, + 29742, + 31753, + 28963, + 29160, + 28995, + 29086, + 29154, + 28963, + 28924, + 29746, + 29430, + 29224, + 29180, + 28963, + 29160, + 29428, + 29569, + 29050, + 29195, + 28963, + 29106, + 28914, + 30164, + 29562, + 28944, + 29430, + 29224, + 29180, + 28914, + 31483, + 29011, + 29253, + 29021, + 29217, + 29408, + 29605, + 28995, + 29086, + 29742, + 31753, + 29250, + 29366, + 28924, + 29074, + 29321, + 29425, + 29401, + 29531, + 28914, + 29261, + 29084, + 29131, + 234, + 171, + 182, + 29018, + 29261, + 28944, + 2 + ], + "inputs_decode": " [INST] What are the three primary colors? [/INST] The three primary colors are red, blue, and yellow. [INST] 解释个人电脑和服务器之间的区别。 [/INST] 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。", + "labels_decode": [ + " The three primary colors are red, blue, and yellow.", + " 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。" + ], + "seq_length": 453, + "seq_category": "None" +} \ No newline at end of file From 929e1e3da4223d3c6fa7d8515789720b0d2f8ac2 Mon Sep 17 00:00:00 2001 From: YeAnbang Date: Tue, 28 May 2024 03:04:39 +0000 Subject: [PATCH 02/19] upgrade ppo dpo rm script --- .../coati/dataset/tokenization_utils.py | 2 +- .../ColossalChat/coati/models/critic.py | 6 +++ .../ColossalChat/coati/models/reward_model.py | 6 +++ .../conversation_template/01-ai_Yi-34B.json | 8 --- .../Qwen_Qwen1.5-110B-Chat.json | 9 ++++ .../prepare_sft_dataset.sh | 8 +-- .../examples/training_scripts/train_dpo.py | 19 +++++-- .../examples/training_scripts/train_ppo.py | 50 +++++++---------- .../examples/training_scripts/train_rm.py | 53 ++++++++----------- .../examples/training_scripts/train_sft.py | 51 +++++++++--------- .../examples/training_scripts/train_sft.sh | 38 ++++++------- applications/ColossalChat/tests/llama.json | 5 +- .../ColossalChat/tests/test_chat_template.py | 5 +- .../ColossalChat/tests/test_templating.sh | 46 ++++++++++++---- applications/ColossalChat/tests/test_train.sh | 2 +- 15 files changed, 169 insertions(+), 139 deletions(-) delete mode 100644 applications/ColossalChat/config/conversation_template/01-ai_Yi-34B.json create mode 100644 applications/ColossalChat/config/conversation_template/Qwen_Qwen1.5-110B-Chat.json diff --git a/applications/ColossalChat/coati/dataset/tokenization_utils.py b/applications/ColossalChat/coati/dataset/tokenization_utils.py index 78b14ce4b..0e97d57a1 100755 --- a/applications/ColossalChat/coati/dataset/tokenization_utils.py +++ b/applications/ColossalChat/coati/dataset/tokenization_utils.py @@ -247,7 +247,7 @@ def apply_rlhf_data_format( target_turn = int(len(template.messages) / 2) prompt = template.get_prompt(target_turn * 2) chunks, require_loss = split_templated_prompt_into_chunks(template.messages[: 2 * target_turn], prompt, - tempalte.end_of_assistant) + template.end_of_assistant) tokenized, starts, ends = tokenize_and_concatenate(tokenizer, chunks, require_loss) loss_mask = [0] * len(tokenized) mask_token = tokenizer.eos_token_id or tokenizer.pad_token_id diff --git a/applications/ColossalChat/coati/models/critic.py b/applications/ColossalChat/coati/models/critic.py index 80340d9bd..02bcab8d0 100755 --- a/applications/ColossalChat/coati/models/critic.py +++ b/applications/ColossalChat/coati/models/critic.py @@ -32,3 +32,9 @@ class Critic(BaseModel): ) values = self.value_head(sequence_hidden_states).squeeze(-1) # ensure shape is (B, sequence length) return values + + def get_input_embeddings(self): + return self.model.get_input_embeddings() + + def get_output_embeddings(self): + return self.model.get_output_embeddings() \ No newline at end of file diff --git a/applications/ColossalChat/coati/models/reward_model.py b/applications/ColossalChat/coati/models/reward_model.py index 18c5eca41..394f3ea90 100755 --- a/applications/ColossalChat/coati/models/reward_model.py +++ b/applications/ColossalChat/coati/models/reward_model.py @@ -36,3 +36,9 @@ class RewardModel(BaseModel): ) values = self.value_head(sequence_hidden_states).squeeze(-1) # Ensure shape is (B,) return values + + def get_input_embeddings(self): + return self.model.get_input_embeddings() + + def get_output_embeddings(self): + return self.model.get_output_embeddings() diff --git a/applications/ColossalChat/config/conversation_template/01-ai_Yi-34B.json b/applications/ColossalChat/config/conversation_template/01-ai_Yi-34B.json deleted file mode 100644 index 614c25ca6..000000000 --- a/applications/ColossalChat/config/conversation_template/01-ai_Yi-34B.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "chat_template": "{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% elif true == true and not '<>' in messages[0]['content'] %}{% set loop_messages = messages %}{% set system_message = 'You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.\\n\\nIf a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don\\'t know the answer to a question, please don\\'t share false information.' %}{% else %}{% set loop_messages = messages %}{% set system_message = false %}{% endif %}{% for message in loop_messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if loop.index0 == 0 and system_message != false %}{% set content = '<>\\n' + system_message + '\\n<>\\n\\n' + message['content'] %}{% else %}{% set content = message['content'] %}{% endif %}{% if message['role'] == 'user' %}{{ bos_token + '[INST] ' + content.strip() + ' [/INST]' }}{% elif message['role'] == 'system' %}{{ '<>\\n' + content.strip() + '\\n<>\\n\\n' }}{% elif message['role'] == 'assistant' %}{{ ' ' + content.strip() + ' ' + eos_token }}{% endif %}{% endfor %}", - "system_message": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n", - "stop_ids": [ - 2 - ], - "end_of_assistant": "<|endoftext|>" -} \ No newline at end of file diff --git a/applications/ColossalChat/config/conversation_template/Qwen_Qwen1.5-110B-Chat.json b/applications/ColossalChat/config/conversation_template/Qwen_Qwen1.5-110B-Chat.json new file mode 100644 index 000000000..d28775ab9 --- /dev/null +++ b/applications/ColossalChat/config/conversation_template/Qwen_Qwen1.5-110B-Chat.json @@ -0,0 +1,9 @@ +{ + "chat_template": "{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}", + "system_message": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n", + "stop_ids": [ + 151645, + 151643 + ], + "end_of_assistant": "<|im_end|>" +} \ No newline at end of file diff --git a/applications/ColossalChat/examples/data_preparation_scripts/prepare_sft_dataset.sh b/applications/ColossalChat/examples/data_preparation_scripts/prepare_sft_dataset.sh index 9bb332cac..47d828a6c 100755 --- a/applications/ColossalChat/examples/data_preparation_scripts/prepare_sft_dataset.sh +++ b/applications/ColossalChat/examples/data_preparation_scripts/prepare_sft_dataset.sh @@ -1,4 +1,4 @@ -SAVE_DIR="/home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf" +SAVE_DIR="/home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B" rm -rf $SAVE_DIR/cache rm -rf $SAVE_DIR/jsonl @@ -14,9 +14,9 @@ rm -rf $SAVE_DIR/arrow python prepare_dataset.py --type sft \ - --data_input_dirs /mnt/jfs-hdd/home/yeanbang/data/dataset/sft_data/alpaca/data_preprocessed/train \ - --conversation_template_config /home/yeanbang/data/ColossalAI/applications/ColossalChat/config/conversation_template/llama2.json \ - --tokenizer_dir "/mnt/jfs-hdd/share/models/Llama-2-7b-chat-hf" \ + --data_input_dirs /home/yeanbang/data/experiment/dataset/sft_data/test/sft-data \ + --conversation_template_config /home/yeanbang/data/ColossalAI/applications/ColossalChat/config/conversation_template/01-ai_Yi-1.5-9B-Chat.json \ + --tokenizer_dir "/mnt/jfs-hdd/share/models/Yi-1.5-6B" \ --data_cache_dir $SAVE_DIR/cache \ --data_jsonl_output_dir $SAVE_DIR/jsonl \ --data_arrow_output_dir $SAVE_DIR/arrow \ diff --git a/applications/ColossalChat/examples/training_scripts/train_dpo.py b/applications/ColossalChat/examples/training_scripts/train_dpo.py index f06c23a9f..53dd89393 100755 --- a/applications/ColossalChat/examples/training_scripts/train_dpo.py +++ b/applications/ColossalChat/examples/training_scripts/train_dpo.py @@ -56,6 +56,7 @@ def train(args): initial_scale=2**16, max_norm=args.grad_clip, enable_gradient_accumulation=True, + enable_flash_attention=args.use_flash_attn ) elif args.plugin == "gemini_auto": plugin = GeminiPlugin( @@ -63,6 +64,7 @@ def train(args): placement_policy="auto", initial_scale=2**16, max_norm=args.grad_clip, + enable_flash_attention=args.use_flash_attn ) elif args.plugin == "zero2": plugin = LowLevelZeroPlugin( @@ -82,9 +84,15 @@ def train(args): elif args.plugin == "3d": plugin = HybridParallelPlugin( tp_size=args.tp, - pp_size=1, - zero_stage=0, + pp_size=args.pp, + sp_size=args.sp, + sequence_parallelism_mode=args.sp_mode, + zero_stage=args.zero_stage, + enable_flash_attention=args.use_flash_attn, + enable_sequence_parallelism=True if args.sp > 1 else False, + cpu_offload=True if args.zero_stage>=1 and args.zero_cpu_offload else False, parallel_output=False, + max_norm=args.grad_clip, precision=args.mixed_precision, ) else: @@ -172,7 +180,7 @@ def train(args): shuffle=True, drop_last=True, collate_fn=data_collator, - use_tp=args.tp > 1, + tp_size=args.tp, ) num_update_steps_per_epoch = len(train_dataloader) // args.accumulation_steps @@ -290,6 +298,11 @@ if __name__ == "__main__": parser.add_argument("--weight_decay", type=float, default=0.1, help="Weight decay") parser.add_argument("--warmup_steps", type=int, default=None, help="Warmup steps") parser.add_argument("--tp", type=int, default=1) + parser.add_argument("--pp", type=int, default=1) + parser.add_argument("--sp", type=int, default=1) + parser.add_argument("--zero_stage", type=int, default=0, help="Zero stage", choices=[0, 1, 2]) + parser.add_argument("--zero_cpu_offload", default=False, action="store_true") + parser.add_argument("--sp_mode", type=str, default="split_gather", choices=["split_gather", "ring", "all_to_all"]) parser.add_argument("--pretrain", type=str, default=None) parser.add_argument("--model_type", type=str, default=None) parser.add_argument("--tokenizer_dir", type=str, default=None) diff --git a/applications/ColossalChat/examples/training_scripts/train_ppo.py b/applications/ColossalChat/examples/training_scripts/train_ppo.py index 727cff7ca..eb0c62530 100755 --- a/applications/ColossalChat/examples/training_scripts/train_ppo.py +++ b/applications/ColossalChat/examples/training_scripts/train_ppo.py @@ -18,6 +18,7 @@ from coati.models import Critic, RewardModel, convert_to_lora_module, disable_dr from coati.trainer import PPOTrainer from coati.utils import load_checkpoint from transformers import AutoModelForCausalLM, AutoTokenizer +from colossalai.shardformer.policies.auto_policy import get_autopolicy import colossalai from colossalai.booster import Booster @@ -86,32 +87,6 @@ def train(args): disable_dropout(actor) disable_dropout(critic) - if args.tp > 1: - if reward_model.model.config.architectures[0] != critic.model.config.architectures[0]: - raise ValueError("Reward model and critic model must have the same architecture") - if reward_model.model.config.architectures[0] == "BloomForCausalLM": - from colossalai.shardformer.policies.bloom import BloomPolicy - - booster_policy = BloomPolicy() - elif reward_model.model.config.architectures[0] == "LlamaForCausalLM": - from colossalai.shardformer.policies.llama import LlamaPolicy - - booster_policy = LlamaPolicy() - elif reward_model.model.config.architectures[0] == "GPT2LMHeadModel": - from colossalai.shardformer.policies.gpt2 import GPT2Policy - - booster_policy = GPT2Policy() - elif reward_model.model.config.architectures[0] == "ChatGLMModel": - from colossalai.shardformer.policies.chatglm2 import ChatGLMPolicy - - booster_policy = ChatGLMPolicy() - elif reward_model.model.config.architectures[0] == "OPTForCausalLM": - from colossalai.shardformer.policies.opt import OPTPolicy - - booster_policy = OPTPolicy() - else: - raise ValueError("Unknown model architecture for policy") - if args.lora_rank > 0: actor = convert_to_lora_module(actor, args.lora_rank, lora_train_bias=args.lora_train_bias) critic = convert_to_lora_module(critic, args.lora_rank, lora_train_bias=args.lora_train_bias) @@ -186,7 +161,7 @@ def train(args): shuffle=True, drop_last=True, collate_fn=data_collator, - use_tp=args.tp > 1, + tp_size=args.tp, ) if len(args.ptx_dataset) > 0: @@ -198,7 +173,7 @@ def train(args): shuffle=True, drop_last=True, collate_fn=data_collator, - use_tp=args.tp > 1, + tp_size=args.tp, ) else: train_pretrain_dataloader = None @@ -237,6 +212,7 @@ def train(args): initial_scale=2**16, max_norm=args.grad_clip, enable_gradient_accumulation=True, + enable_flash_attention=args.use_flash_attn ) elif args.plugin == "gemini_auto": plugin = GeminiPlugin( @@ -244,6 +220,7 @@ def train(args): placement_policy="auto", initial_scale=2**16, max_norm=args.grad_clip, + enable_flash_attention=args.use_flash_attn ) elif args.plugin == "zero2": plugin = LowLevelZeroPlugin( @@ -270,11 +247,17 @@ def train(args): ) custom_plugin = HybridParallelPlugin( tp_size=args.tp, - pp_size=1, - zero_stage=0, + pp_size=args.pp, + sp_size=args.sp, + sequence_parallelism_mode=args.sp_mode, + zero_stage=args.zero_stage, + enable_flash_attention=args.use_flash_attn, + enable_sequence_parallelism=True if args.sp > 1 else False, + cpu_offload=True if args.zero_stage>=1 and args.zero_cpu_offload else False, parallel_output=False, + max_norm=args.grad_clip, precision=args.mixed_precision, - custom_policy=booster_policy, + custom_policy=get_autopolicy(reward_model.model), ) else: raise ValueError(f"Unknown plugin {args.plugin}") @@ -474,6 +457,11 @@ if __name__ == "__main__": parser.add_argument("--warmup_steps", type=int, default=None, help="Warmup steps") parser.add_argument("--tokenizer_dir", type=str, default=None) parser.add_argument("--tp", type=int, default=1) + parser.add_argument("--pp", type=int, default=1) + parser.add_argument("--sp", type=int, default=1) + parser.add_argument("--zero_stage", type=int, default=0, help="Zero stage", choices=[0, 1, 2]) + parser.add_argument("--zero_cpu_offload", default=False, action="store_true") + parser.add_argument("--sp_mode", type=str, default="split_gather", choices=["split_gather", "ring", "all_to_all"]) parser.add_argument("--pretrain", type=str, default=None) parser.add_argument("--rm_pretrain", type=str, default=None) parser.add_argument("--checkpoint_path", type=str, default=None) diff --git a/applications/ColossalChat/examples/training_scripts/train_rm.py b/applications/ColossalChat/examples/training_scripts/train_rm.py index 364198c1d..7fbb954f9 100755 --- a/applications/ColossalChat/examples/training_scripts/train_rm.py +++ b/applications/ColossalChat/examples/training_scripts/train_rm.py @@ -15,7 +15,8 @@ from coati.dataset import ( from coati.models import LogExpLoss, LogSigLoss, RewardModel, convert_to_lora_module from coati.trainer import RewardModelTrainer from coati.utils import load_checkpoint -from transformers import AutoTokenizer +from transformers import AutoTokenizer, AutoConfig +from colossalai.shardformer.policies.auto_policy import get_autopolicy import colossalai from colossalai.booster import Booster @@ -56,31 +57,10 @@ def train(args): ) coordinator.print_on_master(msg="Flash-attention enabled successfully") else: - model = RewardModel(args.pretrain) - - if args.tp > 1: - if model.model.config.architectures[0] == "BloomForCausalLM": - from colossalai.shardformer.policies.bloom import BloomPolicy - - booster_policy = BloomPolicy() - elif model.model.config.architectures[0] == "LlamaForCausalLM": - from colossalai.shardformer.policies.llama import LlamaPolicy - - booster_policy = LlamaPolicy() - elif model.model.config.architectures[0] == "GPT2LMHeadModel": - from colossalai.shardformer.policies.gpt2 import GPT2Policy - - booster_policy = GPT2Policy() - elif model.model.config.architectures[0] == "ChatGLMModel": - from colossalai.shardformer.policies.chatglm2 import ChatGLMPolicy - - booster_policy = ChatGLMPolicy() - elif model.model.config.architectures[0] == "OPTForCausalLM": - from colossalai.shardformer.policies.opt import OPTPolicy - - booster_policy = OPTPolicy() - else: - raise ValueError("Unknown model architecture for policy") + model_config = AutoConfig.from_pretrained(args.pretrain) + model = RewardModel( + args.pretrain, + ) if args.lora_rank > 0: model = convert_to_lora_module(model, args.lora_rank, lora_train_bias=args.lora_train_bias) @@ -100,6 +80,7 @@ def train(args): placement_policy="static", initial_scale=2**16, max_norm=args.grad_clip, + enable_flash_attention=args.use_flash_attn, enable_gradient_accumulation=True, ) elif args.plugin == "gemini_auto": @@ -107,6 +88,7 @@ def train(args): precision=args.mixed_precision, placement_policy="auto", initial_scale=2**16, + enable_flash_attention=args.use_flash_attn, max_norm=args.grad_clip, ) elif args.plugin == "zero2": @@ -127,11 +109,17 @@ def train(args): elif args.plugin == "3d": plugin = HybridParallelPlugin( tp_size=args.tp, - pp_size=1, - zero_stage=0, + pp_size=args.pp, + sp_size=args.sp, + sequence_parallelism_mode=args.sp_mode, + zero_stage=args.zero_stage, + enable_flash_attention=args.use_flash_attn, + enable_sequence_parallelism=True if args.sp > 1 else False, + cpu_offload=True if args.zero_stage>=1 and args.zero_cpu_offload else False, parallel_output=False, + max_norm=args.grad_clip, precision=args.mixed_precision, - custom_policy=booster_policy, + custom_policy=get_autopolicy(model.model) ) else: raise ValueError(f"Unknown plugin {args.plugin}") @@ -189,7 +177,7 @@ def train(args): shuffle=True, drop_last=True, collate_fn=data_collator, - use_tp=args.tp > 1, + tp_size=args.tp, ) num_update_steps_per_epoch = len(train_dataloader) // args.accumulation_steps @@ -307,6 +295,11 @@ if __name__ == "__main__": parser.add_argument("--weight_decay", type=float, default=0.1, help="Weight decay") parser.add_argument("--warmup_steps", type=int, default=None, help="Warmup steps") parser.add_argument("--tp", type=int, default=1) + parser.add_argument("--pp", type=int, default=1) + parser.add_argument("--sp", type=int, default=1) + parser.add_argument("--zero_stage", type=int, default=0, help="Zero stage", choices=[0, 1, 2]) + parser.add_argument("--zero_cpu_offload", default=False, action="store_true") + parser.add_argument("--sp_mode", type=str, default="split_gather", choices=["split_gather", "ring", "all_to_all"]) parser.add_argument("--pretrain", type=str, default=None) parser.add_argument("--tokenizer_dir", type=str, default=None) parser.add_argument("--dataset", nargs="+", default=[]) diff --git a/applications/ColossalChat/examples/training_scripts/train_sft.py b/applications/ColossalChat/examples/training_scripts/train_sft.py index 5ee9b741e..2bdcfb833 100755 --- a/applications/ColossalChat/examples/training_scripts/train_sft.py +++ b/applications/ColossalChat/examples/training_scripts/train_sft.py @@ -48,29 +48,29 @@ def train(args): torch_dtype=torch.bfloat16 if args.mixed_precision == "bf16" else torch.float16, trust_remote_code=True) # check if the hybrid parallel plugin is compatible with the model - # try: - # from colossalai.shardformer.policies.auto_policy import get_autopolicy - # policy = get_autopolicy(model) - # if policy is not None: - # if args.plugin in ['zero2', 'zero2_cpu']: - # # if compatible, set the plugin to hybrid, which use colo-attention - # args.plugin = 'hybrid' - # args.zero_stage = 2 - # if args.plugin == 'zero2_cpu': - # args.zero_cpu_offload = True - # else: - # args.zero_cpu_offload = False - # logger.info(f"Model is compatible with hybrid parallel plugin, set plugin to {args.plugin} with zero_stage {args.zero_stage} and zero_cpu_offload {args.zero_cpu_offload}") - # except NotImplementedError: - # logger.warning(f"Unable to find a policy for the model, use {args.plugin} plugin instead") - # if args.use_flash_attn: - # del model - # model = AutoModelForCausalLM.from_pretrained( - # args.pretrain, - # torch_dtype=torch.bfloat16 if args.mixed_precision == "bf16" else torch.float16, - # attn_implementation="flash_attention_2", - # trust_remote_code=True - # ) + try: + from colossalai.shardformer.policies.auto_policy import get_autopolicy + policy = get_autopolicy(model) + if policy is not None: + if args.plugin in ['zero2', 'zero2_cpu']: + # if compatible, set the plugin to hybrid, which use colo-attention + args.plugin = '3d' + args.zero_stage = 2 + if args.plugin == 'zero2_cpu': + args.zero_cpu_offload = True + else: + args.zero_cpu_offload = False + logger.info(f"Model is compatible with hybrid parallel plugin, set plugin to {args.plugin} with zero_stage {args.zero_stage} and zero_cpu_offload {args.zero_cpu_offload}") + except NotImplementedError: + logger.warning(f"Unable to find a policy for the model, use {args.plugin} plugin instead") + if args.use_flash_attn: + del model + model = AutoModelForCausalLM.from_pretrained( + args.pretrain, + torch_dtype=torch.bfloat16 if args.mixed_precision == "bf16" else torch.float16, + attn_implementation="flash_attention_2", + trust_remote_code=True + ) if args.lora_rank > 0: model = convert_to_lora_module(model, args.lora_rank, lora_train_bias=args.lora_train_bias) @@ -112,7 +112,7 @@ def train(args): cpu_offload=True, max_norm=args.grad_clip, ) - elif args.plugin == "hybrid": + elif args.plugin == "3d": plugin = HybridParallelPlugin( tp_size=args.tp, pp_size=args.pp, @@ -224,7 +224,6 @@ def train(args): lr_scheduler=lr_scheduler, dataloader=train_dataloader, ) - # model = model.to(get_current_device()) torch.set_default_dtype(torch.float) coordinator.print_on_master(f"Booster init max CUDA memory: {torch.cuda.max_memory_allocated() / 1024 ** 2:.2f} MB") @@ -309,7 +308,7 @@ if __name__ == "__main__": "--plugin", type=str, default="gemini", - choices=["gemini", "gemini_auto", "hybrid", "ddp", "zero2_cpu", "zero2"], + choices=["gemini", "gemini_auto", "3d", "ddp", "zero2_cpu", "zero2"], help="Choose which plugin to use", ) parser.add_argument("--grad_clip", type=float, default=1.0, help="Gradient clipping value") diff --git a/applications/ColossalChat/examples/training_scripts/train_sft.sh b/applications/ColossalChat/examples/training_scripts/train_sft.sh index e3bc12823..f8d659258 100755 --- a/applications/ColossalChat/examples/training_scripts/train_sft.sh +++ b/applications/ColossalChat/examples/training_scripts/train_sft.sh @@ -15,24 +15,24 @@ set_n_least_used_CUDA_VISIBLE_DEVICES() { # export CUDA_VISIBLE_DEVICES=4,5,6 -set_n_least_used_CUDA_VISIBLE_DEVICES 4 +set_n_least_used_CUDA_VISIBLE_DEVICES 2 PROJECT_NAME="sft" PARENT_SAVE_DIR="/home/yeanbang/data/experiment/output/model" # Path to a folder to save checkpoints PARENT_TENSORBOARD_DIR="/home/yeanbang/data/experiment/logs/tensorboard" # Path to a folder to save logs PARENT_CONFIG_FILE="/home/yeanbang/data/experiment/logs/config" # Path to a folder to save training config logs -PRETRAINED_MODEL_PATH="/mnt/jfs-hdd/share/models/Llama-2-7b-chat-hf" # huggingface or local model path -PRETRAINED_TOKENIZER_PATH="/mnt/jfs-hdd/share/models/Llama-2-7b-chat-hf" # huggingface or local tokenizer path +PRETRAINED_MODEL_PATH="/mnt/jfs-hdd/share/models/Yi-1.5-6B" # huggingface or local model path +PRETRAINED_TOKENIZER_PATH="/mnt/jfs-hdd/share/models/Yi-1.5-6B" # huggingface or local tokenizer path declare -a dataset=( - /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00000 - /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00001 - /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00002 - /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00003 - /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00004 - /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00005 - /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00006 - /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00007 - /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00008 - /home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00009 + /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00000 + /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00001 + /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00002 + /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00003 + /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00004 + /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00005 + /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00006 + /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00007 + /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00008 + /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00009 ) TIMESTAMP=$(date +%Y-%m-%d-%H-%M-%S) @@ -43,7 +43,7 @@ CONFIG_FILE="${PARENT_CONFIG_FILE}-${FULL_PROJECT_NAME}.json" echo $(which colossalai) echo $(which python) # the real batch size for gradient descent is number_of_node_in_hostfile * nproc_per_node * train_batch_size -colossalai run --nproc_per_node 4 --master_port 31312 --hostfile ./hostfile train_sft.py \ +colossalai run --nproc_per_node 2 --master_port 31312 --hostfile ./hostfile train_sft.py \ --pretrain $PRETRAINED_MODEL_PATH \ --tokenizer_dir $PRETRAINED_TOKENIZER_PATH \ --save_interval 4000 \ @@ -51,13 +51,13 @@ colossalai run --nproc_per_node 4 --master_port 31312 --hostfile ./hostfile trai --save_path $SAVE_DIR \ --config_file $CONFIG_FILE \ --lora_rank 0 \ - --plugin zero2 \ - --tp 1 \ + --plugin 3d \ + --tp 2 \ --pp 1 \ - --zero_stage 2 \ - --batch_size 4 \ + --zero_stage 0 \ + --batch_size 2 \ --max_epochs 3 \ - --accumulation_steps 4 \ + --accumulation_steps 1 \ --lr 5e-5 \ --max_len 400 \ --grad_checkpoint \ diff --git a/applications/ColossalChat/tests/llama.json b/applications/ColossalChat/tests/llama.json index 482ff9e65..6a7e00560 100644 --- a/applications/ColossalChat/tests/llama.json +++ b/applications/ColossalChat/tests/llama.json @@ -4,5 +4,6 @@ "stop_ids": [ 29871, 2 - ] -} + ], + "end_of_assistant": "" +} \ No newline at end of file diff --git a/applications/ColossalChat/tests/test_chat_template.py b/applications/ColossalChat/tests/test_chat_template.py index 2395c1f3c..9d6babdec 100644 --- a/applications/ColossalChat/tests/test_chat_template.py +++ b/applications/ColossalChat/tests/test_chat_template.py @@ -9,14 +9,13 @@ model_data_mapping = { 'THUDM/chatglm2-6b': 'THUDM_chatglm2-6b.json', 'THUDM/chatglm3-6b': 'THUDM_chatglm3-6b.json', 'baichuan-inc/Baichuan2-13B-Chat': 'baichuan-inc_Baichuan2-13B-Chat.json', - 'Qwen/Qwen-7B-Chat': 'Qwen_Qwen-7B-Chat.json', '01-ai/Yi-1.5-9B-Chat': '01-ai_Yi-1.5-9B-Chat.json', '01-ai/Yi-34B': '01-ai_Yi-34B.json', 'deepseek-ai/DeepSeek-V2-Lite': 'deepseek-ai_DeepSeek-V2-Lite.json', 'microsoft/phi-2': 'microsoft_phi-2.json', 'mistralai/Mixtral-8x7B-Instruct-v0.1': 'mistralai_Mixtral-8x7B-Instruct-v0.1.json' } -chat_template_config_path = '../config/conversation_template' +chat_template_config_path = './config/conversation_template' def test_tokenization_sft(): @@ -34,5 +33,5 @@ def test_tokenization_sft(): ) output = supervised_tokenize_sft({"messages": messages}, tokenizer, conversation_template) - with open(f"./test_data/chat_template/{model_data_mapping[model]}", "r", encoding="utf8") as f: + with open(f"./tests/test_data/chat_template/{model_data_mapping[model]}", "r", encoding="utf8") as f: assert json.dumps(json.load(f)) == json.dumps(output), f"model: {model} failed" diff --git a/applications/ColossalChat/tests/test_templating.sh b/applications/ColossalChat/tests/test_templating.sh index 7fefede47..e8e1ed6f9 100755 --- a/applications/ColossalChat/tests/test_templating.sh +++ b/applications/ColossalChat/tests/test_templating.sh @@ -6,35 +6,59 @@ TEST_DATA_DIR=$BASE_DIR/tests/test_data DATA_SAVE_PATH=$BASE_TEMP_DIR/tests CONFIG_DIR=$BASE_DIR/config -MODELS=("colossal-llama2" "llama2" "zephyr" "mistral" "chatGLM2" "Qwen" "Vicuna" "Yi") - +MODELS=("colossal-llama2" "llama2" "mistral" "chatGLM2" "chatGLM3" "deepseek" "Yi" "baichuan") +# get_pretrain() { local model=$1 if [[ $model == "colossal-llama2" ]]; then echo "hpcai-tech/Colossal-LLaMA-2-7b-base" elif [[ $model == "llama2" ]]; then echo "hf-internal-testing/llama-tokenizer" - elif [[ $model == "zephyr" ]]; then - echo "HuggingFaceH4/zephyr-7b-beta" + elif [[ $model == "phi" ]]; then + echo "microsoft/phi-2" elif [[ $model == "mistral" ]]; then - echo "mistralai/Mistral-7B-Instruct-v0.2" + echo "mistralai/Mistral-7B-Instruct-v0.3" elif [[ $model == "chatGLM2" ]]; then echo "THUDM/chatglm2-6b" - elif [[ $model == "Qwen" ]]; then - echo "Qwen/Qwen-7B-Chat" - elif [[ $model == "Vicuna" ]]; then - echo "lmsys/vicuna-7b-v1.5" + elif [[ $model == "chatGLM3" ]]; then + echo "THUDM/chatglm3-6b" + elif [[ $model == "deepseek" ]]; then + echo "deepseek-ai/DeepSeek-V2-Lite" elif [[ $model == "Yi" ]]; then - echo "01-ai/Yi-6B-Chat" + echo "01-ai/Yi-1.5-9B-Chat" + elif [[ $model == "baichuan" ]]; then + echo "baichuan-inc/Baichuan2-13B-Chat" else echo "Unknown model $model" exit 1 fi } + get_conversation_template_config() { local model=$1 - echo "$CONFIG_DIR/conversation_template/$model.json" + if [[ $model == "colossal-llama2" ]]; then + echo "$CONFIG_DIR/conversation_template/colossal-llama2.json" + elif [[ $model == "llama2" ]]; then + echo "$CONFIG_DIR/conversation_template/llama2.json" + elif [[ $model == "deepseek" ]]; then + echo "$CONFIG_DIR/conversation_template/deepseek-ai_DeepSeek-V2-Lite.json" + elif [[ $model == "mistral" ]]; then + echo "$CONFIG_DIR/conversation_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json" + elif [[ $model == "chatGLM2" ]]; then + echo "$CONFIG_DIR/conversation_template/THUDM_chatglm2-6b.json" + elif [[ $model == "chatGLM3" ]]; then + echo "$CONFIG_DIR/conversation_template/THUDM_chatglm3-6b.json" + elif [[ $model == "phi" ]]; then + echo "$CONFIG_DIR/conversation_template/microsoft_phi-2.json" + elif [[ $model == "Yi" ]]; then + echo "$CONFIG_DIR/conversation_template/01-ai_Yi-1.5-9B-Chat.json" + elif [[ $model == "baichuan" ]]; then + echo "$CONFIG_DIR/conversation_template/baichuan-inc_Baichuan2-13B-Chat.json" + else + echo "Unknown model $model" + exit 1 + fi } # Test SFT data Preparation diff --git a/applications/ColossalChat/tests/test_train.sh b/applications/ColossalChat/tests/test_train.sh index 5ba490471..f965e4a9b 100755 --- a/applications/ColossalChat/tests/test_train.sh +++ b/applications/ColossalChat/tests/test_train.sh @@ -30,7 +30,7 @@ MODEL_SAVE_PATH=$TEMP_DIR/rlhf_models MODELS_DIR=$TEMP_DIR/models_config # Skip those tests due to CI tests timeout MODELS=('llama') -PLUGINS=('gemini' 'gemini_auto' 'zero2' 'zero2_cpu' '3d') +PLUGINS=('3d' 'gemini' 'gemini_auto' 'zero2' 'zero2_cpu') LORA_RANK=('0') # skip to reduce CI execution time, can pass all locally export OMP_NUM_THREADS=8 From 7e65b718154025930151be2cef29782545b539d6 Mon Sep 17 00:00:00 2001 From: YeAnbang Date: Tue, 28 May 2024 03:14:37 +0000 Subject: [PATCH 03/19] run pre-commit --- .../examples/training_scripts/train_sft.py | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/applications/ColossalChat/examples/training_scripts/train_sft.py b/applications/ColossalChat/examples/training_scripts/train_sft.py index 2bdcfb833..e1af3873c 100755 --- a/applications/ColossalChat/examples/training_scripts/train_sft.py +++ b/applications/ColossalChat/examples/training_scripts/train_sft.py @@ -1,8 +1,10 @@ import argparse +import inspect import json import math import os import resource +import sys from contextlib import nullcontext import torch @@ -14,17 +16,15 @@ from transformers import AutoModelForCausalLM, AutoTokenizer import colossalai from colossalai.booster import Booster -from colossalai.booster.plugin import GeminiPlugin, HybridParallelPlugin, TorchDDPPlugin, LowLevelZeroPlugin +from colossalai.booster.plugin import GeminiPlugin, HybridParallelPlugin, LowLevelZeroPlugin, TorchDDPPlugin from colossalai.cluster import DistCoordinator +from colossalai.logging import get_dist_logger from colossalai.nn.lr_scheduler import CosineAnnealingWarmupLR from colossalai.nn.optimizer import HybridAdam -import inspect -import sys -import torch.distributed as dist -from colossalai.logging import get_dist_logger logger = get_dist_logger() + def train(args): print(colossalai.__version__, inspect.getfile(colossalai)) print(sys.executable) @@ -44,23 +44,28 @@ def train(args): # ============================== init_ctx = nullcontext() with init_ctx: - model = AutoModelForCausalLM.from_pretrained(args.pretrain, - torch_dtype=torch.bfloat16 if args.mixed_precision == "bf16" else torch.float16, - trust_remote_code=True) - # check if the hybrid parallel plugin is compatible with the model + model = AutoModelForCausalLM.from_pretrained( + args.pretrain, + torch_dtype=torch.bfloat16 if args.mixed_precision == "bf16" else torch.float16, + trust_remote_code=True, + ) + # check if the hybrid parallel plugin is compatible with the model try: from colossalai.shardformer.policies.auto_policy import get_autopolicy + policy = get_autopolicy(model) if policy is not None: - if args.plugin in ['zero2', 'zero2_cpu']: + if args.plugin in ["zero2", "zero2_cpu"]: # if compatible, set the plugin to hybrid, which use colo-attention - args.plugin = '3d' + args.plugin = "3d" args.zero_stage = 2 - if args.plugin == 'zero2_cpu': + if args.plugin == "zero2_cpu": args.zero_cpu_offload = True else: args.zero_cpu_offload = False - logger.info(f"Model is compatible with hybrid parallel plugin, set plugin to {args.plugin} with zero_stage {args.zero_stage} and zero_cpu_offload {args.zero_cpu_offload}") + logger.info( + f"Model is compatible with hybrid parallel plugin, set plugin to {args.plugin} with zero_stage {args.zero_stage} and zero_cpu_offload {args.zero_cpu_offload}" + ) except NotImplementedError: logger.warning(f"Unable to find a policy for the model, use {args.plugin} plugin instead") if args.use_flash_attn: @@ -69,10 +74,10 @@ def train(args): args.pretrain, torch_dtype=torch.bfloat16 if args.mixed_precision == "bf16" else torch.float16, attn_implementation="flash_attention_2", - trust_remote_code=True + trust_remote_code=True, ) if args.lora_rank > 0: - model = convert_to_lora_module(model, args.lora_rank, lora_train_bias=args.lora_train_bias) + model = convert_to_lora_module(model, args.lora_rank, lora_train_bias=args.lora_train_bias) if args.plugin == "ddp": """ @@ -87,7 +92,7 @@ def train(args): initial_scale=2**16, max_norm=args.grad_clip, enable_gradient_accumulation=True if args.accumulation_steps > 1 else False, - enable_flash_attention=args.use_flash_attn + enable_flash_attention=args.use_flash_attn, ) elif args.plugin == "gemini_auto": plugin = GeminiPlugin( @@ -95,7 +100,7 @@ def train(args): placement_policy="auto", initial_scale=2**16, max_norm=args.grad_clip, - enable_flash_attention=args.use_flash_attn + enable_flash_attention=args.use_flash_attn, ) elif args.plugin == "zero2": plugin = LowLevelZeroPlugin( @@ -121,7 +126,7 @@ def train(args): zero_stage=args.zero_stage, enable_flash_attention=args.use_flash_attn, enable_sequence_parallelism=True if args.sp > 1 else False, - cpu_offload=True if args.zero_stage>=1 and args.zero_cpu_offload else False, + cpu_offload=True if args.zero_stage >= 1 and args.zero_cpu_offload else False, parallel_output=False, max_norm=args.grad_clip, precision=args.mixed_precision, @@ -139,7 +144,6 @@ def train(args): # LazyInitContext(default_device=get_current_device()) if isinstance(plugin, (GeminiPlugin,)) else nullcontext() # ) - if args.grad_checkpoint and args.lora_rank == 0: # lora layers are not supported by gradient checkpointing model.gradient_checkpointing_enable() From 0b4a33548cf0bb3a41019caf777f676bf2d60f7f Mon Sep 17 00:00:00 2001 From: YeAnbang Date: Tue, 28 May 2024 07:58:08 +0000 Subject: [PATCH 04/19] moupdate ci tests, st ci test cases passed, tp failed in generation for ppo, sp is buggy --- .../ColossalChat/coati/dataset/loader.py | 22 +- applications/ColossalChat/examples/README.md | 242 +++++++++++++++--- .../examples/training_scripts/train_dpo.py | 13 +- .../examples/training_scripts/train_ppo.py | 82 +++--- .../examples/training_scripts/train_rm.py | 18 +- .../examples/training_scripts/train_sft.py | 8 +- applications/ColossalChat/tests/test_train.sh | 61 ++++- 7 files changed, 355 insertions(+), 91 deletions(-) diff --git a/applications/ColossalChat/coati/dataset/loader.py b/applications/ColossalChat/coati/dataset/loader.py index 26f210eb2..76cf40f0f 100755 --- a/applications/ColossalChat/coati/dataset/loader.py +++ b/applications/ColossalChat/coati/dataset/loader.py @@ -249,8 +249,10 @@ class StatefulDistributedSampler(DistributedSampler): seed: int = 0, drop_last: bool = False, tp_size: int = 1, + sp_size: int = 1, + pp_size: int = 1, ) -> None: - if not tp_size>1: + if not tp_size > 1: super().__init__( dataset=dataset, num_replicas=num_replicas, @@ -263,9 +265,9 @@ class StatefulDistributedSampler(DistributedSampler): # adapted from https://github.com/pytorch/pytorch/blob/4979f9c0d72490970e2019bb1d2284f83d93f76b/torch/utils/data/distributed.py#L62 if rank is None: rank = dist.get_rank() - world_size = dist.get_world_size() - dp_size = world_size // tp_size # data parallel size - dp_rank = int(rank / tp_size) # data parallel rank + dist.get_world_size() + # dp_size = world_size // (tp_size * sp_size * pp_size) + dp_rank = int(rank / (tp_size * sp_size * pp_size)) # data parallel rank: if rank < 0: raise ValueError(f"Invalid rank {rank}, rank should be in the interval [0, 0]") self.dataset = dataset @@ -318,7 +320,7 @@ class StatefulDistributedSampler(DistributedSampler): # subsample indices = indices[ - self.dp_rank: self.dp_rank + self.total_size : self.num_replicas + self.dp_rank : self.dp_rank + self.total_size : self.num_replicas ] # num_replicas=tp_group=1, we only support tp_group==1 for now assert len(indices) == self.num_samples return iter(indices) @@ -347,6 +349,8 @@ def setup_distributed_dataloader( collate_fn: Callable[[Sequence[Dict[str, Union[str, List[int]]]]], Dict[str, torch.Tensor]] = None, process_group: Optional[ProcessGroup] = None, tp_size: Optional[int] = 1, + sp_size: Optional[int] = 1, + pp_size: Optional[int] = 1, **kwargs, ) -> DataLoader: """ @@ -355,15 +359,19 @@ def setup_distributed_dataloader( _kwargs = kwargs.copy() process_group = process_group or _get_default_group() # world_size = tp_size * pp_size - assert process_group.size()%tp_size == 0, f"process_group.size()={process_group.size()} must be divisible by tp_size={tp_size}" + assert ( + process_group.size() % tp_size == 0 + ), f"process_group.size()={process_group.size()} must be divisible by tp_size={tp_size}" sampler = StatefulDistributedSampler( dataset=dataset, - num_replicas=int(process_group.size()/tp_size), + num_replicas=int(process_group.size() / tp_size), rank=process_group.rank(), shuffle=shuffle, seed=seed, drop_last=drop_last, tp_size=tp_size, + sp_size=sp_size, + pp_size=pp_size, ) # Deterministic dataloader diff --git a/applications/ColossalChat/examples/README.md b/applications/ColossalChat/examples/README.md index 3318e498b..74865033e 100755 --- a/applications/ColossalChat/examples/README.md +++ b/applications/ColossalChat/examples/README.md @@ -1,7 +1,9 @@ # Examples + ## Table of Contents + - [Examples](#examples) - [Table of Contents](#table-of-contents) - [Install Requirements](#install-requirements) @@ -31,24 +33,31 @@ - [Inference example](#inference-example) - [Attention](#attention) + --- + ## Install requirements + ```shell pip install -r requirements.txt ``` + + ## Get Start with ColossalRun -You can use colossalai run to launch multi-nodes training: + +You can use colossalai run to launch multi-node training: ``` colossalai run --nproc_per_node YOUR_GPU_PER_NODE --hostfile YOUR_HOST_FILE \ train.py --OTHER_CONFIGURATIONS ``` Here is a sample hostfile: + ``` hostname1 hostname2 @@ -56,21 +65,29 @@ hostname3 hostname4 ``` -Make sure master node can access all nodes (including itself) by ssh without password. Here are some other arguments. + +Make sure the master node can access all nodes (including itself) by ssh without a password. Here are some other arguments. + - nnodes: number of nodes used in the training - nproc-per-node: specifies the number of processes to be launched per node - rdzv-endpoint: address of the host node + ### Training Configuration -This section gives a simple introduction on different training strategies that you can use and how to use them with our boosters and plugins to reduce training time and VRAM consumption. For more detail regarding training strategies, please refer to [here](https://colossalai.org/docs/concepts/paradigms_of_parallelism). For details regarding boosters and plugins, please refer to [here](https://colossalai.org/docs/basics/booster_plugins). + +This section gives a simple introduction on different training strategies that you can use and how to use them with our boosters and plugins to reduce training time and VRAM consumption. For more details regarding training strategies, please refer to [here](https://colossalai.org/docs/concepts/paradigms_of_parallelism). For details regarding boosters and plugins, please refer to [here](https://colossalai.org/docs/basics/booster_plugins). -
Gemini + + +
Gemini (Zero3) + This plugin implements Zero-3 with chunk-based and heterogeneous memory management. It can train large models without much loss in speed. It also does not support local gradient accumulation. More details can be found in [Gemini Doc](https://colossalai.org/docs/features/zero_with_chunk). + Below shows how to use the gemini in SFT training. ``` colossalai run --nproc_per_node 4 --master_port 28534 --hostfile ./hostfile train_sft.py \ @@ -89,13 +106,17 @@ colossalai run --nproc_per_node 4 --master_port 28534 --hostfile ./hostfile trai --use_wandb ``` +
-
Gemini-Auto -This option use gemini and will automatically offload tensors with low priority to cpu. It also does not support local gradient accumulation. More details can be found in [Gemini Doc](https://colossalai.org/docs/features/zero_with_chunk). +
Gemini-Auto (Zero3 with Auto-Resource-Allocation-Policy) -Below shows how to use the gemin-auto in SFT training. + +This option uses gemini and will automatically offload tensors with low priority to cpu. It also does not support local gradient accumulation. More details can be found in [Gemini Doc](https://colossalai.org/docs/features/zero_with_chunk). + + +Below shows how to use the gemini-auto in SFT training. ``` colossalai run --nproc_per_node 4 --master_port 28534 --hostfile ./hostfile train_sft.py \ --pretrain $PRETRAINED_MODEL_PATH \ @@ -113,13 +134,18 @@ colossalai run --nproc_per_node 4 --master_port 28534 --hostfile ./hostfile trai --use_wandb ``` -
+ +
+ +
Zero2 -This option will distribute the optimizer parameters and the gradient to multiple GPUs and won't offload weights to cpu. It uses reduce and gather to synchronize gradients and weights. It does not support local gradient accumulation. Though you can accumulate gradient if you insist, it cannot reduce communication cost. That is to say, it's not a good idea to use Zero-2 with pipeline parallelism. + +This option will distribute the optimizer parameters and the gradient to multiple GPUs and won't offload weights to cpu. It uses reduce and gather to synchronize gradients and weights. It does not support local gradient accumulation. Though you can accumulate gradients if you insist, it cannot reduce communication cost. That is to say, it's not a good idea to use Zero-2 with pipeline parallelism. + Below shows how to use the zero2 in SFT training. ``` @@ -139,12 +165,17 @@ colossalai run --nproc_per_node 4 --master_port 28534 --hostfile ./hostfile trai --use_wandb ``` +
+ +
Zero2CPU -This option will distribute the optimizer parameters and the gradient to multiple GPUs as well as offload parameters to cpu. It does not support local gradient accumulation. Though you can accumulate gradient if you insist, it cannot reduce communication cost. + +This option will distribute the optimizer parameters and the gradient to multiple GPUs as well as offload parameters to cpu. It does not support local gradient accumulation. Though you can accumulate gradients if you insist, it cannot reduce communication cost. + Below shows how to use the zero2-cpu in SFT training. ``` @@ -164,11 +195,20 @@ colossalai run --nproc_per_node 4 --master_port 28534 --hostfile ./hostfile trai --use_wandb ``` +
+
Tensor Parallelism -This option support Tensor Parallelism (TP). Note that if you want to use TP, zero and pipeline parallelism will be disabled. TP split large model weights/optimizer parameters/gradients into multiple small ones and distributes them to multiple GPUs, hence it is recommended to use TP when your model is large (e.g. 20B and above) or your training algorithm consumes a lot of memory (e.g. PPO). + +This option supports Tensor Parallelism (TP). Note that if you want to use TP, TP split large model weights/optimizer parameters/gradients into multiple small ones and distributes them to multiple GPUs, hence it is recommended to use TP when your model is large (e.g. 20B and above) or your training algorithm consumes a lot of memory (e.g. PPO). Currently, we have added support for TP for the following model architectures. + + +``` +bert, LLaMA, T5, GPT2, GPT-J, OPT, Bloom, Whisper, Sam, Blip2, ChatGLM (up to ChatGLM2), Falcon, Qwen2 +``` + Below shows how to use the TP in PPO training. ``` @@ -181,7 +221,7 @@ colossalai run --nproc_per_node 4 --hostfile hostfile --master_port 30039 train_ --pretrain_dataset ${ptx_dataset[@]} \ --ptx_batch_size 1 \ --ptx_coef 0.0 \ - --plugin "zero2" \ + --plugin "3d" \ --save_interval 200 \ --save_path $SAVE_DIR \ --num_episodes 2000 \ @@ -200,13 +240,87 @@ colossalai run --nproc_per_node 4 --hostfile hostfile --master_port 30039 train_ --use_wandb ``` +
+
Sequence Parallelism + + +This option supports Sequence Parallelism (SP). It is recommended to use SP when your input sequence is very long (e.g. 50K and above). Please refer to this [SP Doc](https://github.com/hpcaitech/ColossalAI/blob/b96c6390f4363f58c0df56c0ca28755f8a5f1aa2/examples/tutorial/sequence_parallel/README.md?plain=1#L1) for more information. + +Below shows how to use the SP in SFT training. +``` +# use the `split_gather` or `ring` sp mode +colossalai run --nproc_per_node 4 --master_port 28534 --hostfile ./hostfile train_sft.py \ + --pretrain $PRETRAINED_MODEL_PATH \ + --tokenizer_dir $PRETRAINED_TOKENIZER_PATH \ + --dataset ${dataset[@]} \ + --save_interval 5000 \ + --save_path $SAVE_DIR \ + --config_file $CONFIG_FILE \ + --plugin 3d \ + --tp 4 \ # TP size, nproc_per_node must be divisible by it + --sp 1 \ # SP size, must be 1 + --sp_mode 'split_gather' \ # or 'ring' + --enable_sequence_parallelism \ # must be set + --batch_size 4 \ + --max_epochs 1 \ + --accumulation_steps 4 \ + --lr 2e-5 \ + --max_len 2048 \ + --use_wandb + +# use the `all_to_all` sp mode +colossalai run --nproc_per_node 4 --master_port 28534 --hostfile ./hostfile train_sft.py \ + --pretrain $PRETRAINED_MODEL_PATH \ + --tokenizer_dir $PRETRAINED_TOKENIZER_PATH \ + --dataset ${dataset[@]} \ + --save_interval 5000 \ + --save_path $SAVE_DIR \ + --config_file $CONFIG_FILE \ + --plugin 3d \ + --tp 1 \ # TP size, must be 1 + --sp 4 \ # SP size, nproc_per_node must be divisible by it + --sp_mode 'all_to_all' \ + --enable_sequence_parallelism \ # must be set + --batch_size 4 \ + --max_epochs 1 \ + --accumulation_steps 4 \ + --lr 2e-5 \ + --max_len 2048 \ + --use_wandb +``` + + +
+ + +
Advanced Training Configuration with the Hybrid Plugin + +User can use our HybridParallelPlugin for more advanced policy control. Currently, we have added support for the following model architectures. + + +``` +bert, LLaMA, T5, GPT2, GPT-J, OPT, Bloom, Whisper, Sam, Blip2, ChatGLM (up to ChatGLM2), Falcon, Qwen2 +``` + +- We support mixing tensor parallelism with zero1/zero2/zero3: +to do that, set both `tp` and `zero_stage` +- We support mixing tensor parallelism with pipeline parallelism: +to do that, set both `tp` and `pp` + +
+ + + +
Gradient Checkpointing + This option saves VRAM consumption by selectively recomputing some of the intermediate value on-the-fly during the backward pass, rather than storing them in memory. + To enable gradient checkpointing, add --grad_checkpoint to your training script. ``` colossalai run --nproc_per_node 4 --master_port 28534 --hostfile ./hostfile train_sft.py \ @@ -226,12 +340,16 @@ colossalai run --nproc_per_node 4 --master_port 28534 --hostfile ./hostfile trai --use_wandb ``` +
+
Flash Attention + Details about flash attention can be found in the paper: [FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness](https://arxiv.org/abs/2205.14135). + To enable flash attention, add --use_flash_attn to your training script. ``` colossalai run --nproc_per_node 4 --master_port 28534 --hostfile ./hostfile train_sft.py \ @@ -251,11 +369,15 @@ colossalai run --nproc_per_node 4 --master_port 28534 --hostfile ./hostfile trai --use_wandb ``` +
+
Low Rank Adaption -Details about Low Rank Adaption (LoRA) can be found in the paper: [LoRA: Low-Rank Adaptation of Large Language Models](https://arxiv.org/abs/2106.09685). It dramatically reduce the VRAM consumption at the cost of sacrifice model capability. It is suitable for training LLM with constrained resources. + +Details about Low Rank Adaption (LoRA) can be found in the paper: [LoRA: Low-Rank Adaptation of Large Language Models](https://arxiv.org/abs/2106.09685). It dramatically reduces the VRAM consumption at the cost of sacrifice model capability. It is suitable for training LLM with constrained resources. + To enable LoRA, set --lora_rank to a positive value (usually between 20 and 64). ``` @@ -276,23 +398,26 @@ colossalai run --nproc_per_node 4 --master_port 28534 --hostfile ./hostfile trai --use_wandb ``` +
+
Other Training Arguments -- grad_clip: gradient larger than this value will be clipped. + +- grad_clip: gradients larger than this value will be clipped. - weight_decay: weight decay hyper-parameter. - warmup_steps: number of warmup steps used in setting up the learning rate scheduler. - pretrain: pretrain model path, weights will be loaded from this pretrained model unless checkpoint_path is provided. -- tokenizer_dir: specify where to load the tokenizer, if not provided, tokenizer will be loaded from pretrain model path. -- dataset: a list of strings, each is a path to a folder contains buffered dataset files in arrow format. +- tokenizer_dir: specify where to load the tokenizer, if not provided, tokenizer will be loaded from the pretrained model path. +- dataset: a list of strings, each is a path to a folder containing buffered dataset files in arrow format. - checkpoint_path: if provided, will load weights from the checkpoint_path. - config_file: path to store the training config file. - save_dir: path to store the model checkpoints. -- max_length: input will be padded/truncate to max_length before feeding to the model. -- max_epochs: number of epoch to train. +- max_length: input will be padded/truncated to max_length before feeding to the model. +- max_epochs: number of epochs to train. - batch_size: training batch size. -- mixed_precision: precision to use in training. Support 'fp16' and 'bf16'. Note that some device may not support the 'bf16' option, please refer to [Nvidia](https://developer.nvidia.com/) to check compatibility. +- mixed_precision: precision to use in training. Support 'fp16' and 'bf16'. Note that some devices may not support the 'bf16' option, please refer to [Nvidia](https://developer.nvidia.com/) to check compatibility. - save_interval: save the model weights as well as optimizer/scheduler states every save_interval steps/episodes. - merge_lora_weights: whether to merge lora weights before saving the model - lr: the learning rate used in training. @@ -300,15 +425,20 @@ colossalai run --nproc_per_node 4 --master_port 28534 --hostfile ./hostfile trai - log_dir: path to store the log. - use_wandb: if this flag is up, you can view logs on wandb. +
+ ### RLHF Training Stage1 - Supervised Instructs Tuning + Stage1 is supervised instructs fine-tuning (SFT). This step is a crucial part of the RLHF training process, as it involves training a machine learning model using human-provided instructions to learn the initial behavior for the task at hand. Here's a detailed guide on how to SFT your LLM with ColossalChat: + #### Step 1: Data Collection The first step in Stage 1 is to collect a dataset of human demonstrations of the following format. + ```json [ {"messages": @@ -328,11 +458,14 @@ The first step in Stage 1 is to collect a dataset of human demonstrations of the ] ``` + #### Step 2: Preprocessing Once you have collected your SFT dataset, you will need to preprocess it. This involves four steps: data cleaning, data deduplication, formatting and tokenization. In this section, we will focus on formatting and tokenization. + In this code we provide a flexible way for users to set the conversation template for formatting chat data using Huggingface's newest feature--- chat template. Please follow the following steps to define your chat template and preprocess your data. + - Step 1: (Optional). Define your conversation template. You need to provide a conversation template config file similar to the config files under the ./config/conversation_template directory. This config should include the following fields. ```json { @@ -342,42 +475,52 @@ In this code we provide a flexible way for users to set the conversation templat ``` <|im_start|>system system messages - + <|im_end|> <|im_start|>user How far is the moon? <|im_end|> <|im_start|>assistant\n The moon is about 384,400 kilometers away from Earth.<|im_end|>... ``` the end_of_assistant tokens are "<|im_end|>" - "stop_ids": (Optional), A list of integers corresponds to the `end_of_assistant` tokens that indicating the end of assistance's response during the rollout stage of PPO training. It's recommended to set this manually for PPO training. If not set, will set to tokenizer.eos_token_ids automatically + "stop_ids": (Optional), A list of integers corresponds to the `end_of_assistant` tokens that indicate the end of assistance's response during the rollout stage of PPO training. It's recommended to set this manually for PPO training. If not set, will set to tokenizer.eos_token_ids automatically } ``` On your first run of the data preparation script, you only need to define the "chat_template" (if you want to use custom chat template) and the "system message" (if you want to use a custom system message), + - Step 2: Run the data preparation script--- [prepare_sft_dataset.sh](./examples/data_preparation_scripts/prepare_sft_dataset.sh). Note that whether or not you have skipped the first step, you need to provide the path to the conversation template config file (via the conversation_template_config arg). If you skipped the first step, an auto-generated conversation template will be stored at the designated file path. + - Step 3: (Optional) Check the correctness of the processed data. We provided an easy way for you to do a manual checking on the processed data by checking the "$SAVE_DIR/jsonl/part-XXXX.jsonl" files. + Finishing the above steps, you have converted the raw conversation to the designated chat format and tokenized the formatted conversation, calculate input_ids, labels, attention_masks and buffer those into binary dataset files under "$SAVE_DIR/arrow/part-XXXX" folders. + For example, our Colossal-LLaMA-2 format looks like, ``` A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions. + Human: what are some pranks with a pen i can do? Assistant: Are you looking for practical joke ideas? ... ``` + #### Step 3: Training Choose a suitable model architecture for your task. Note that your model should be compatible with the tokenizer that you used to tokenize the SFT dataset. You can run [train_sft.sh](./examples/training_scripts/train_sft.sh) to start a supervised instructs fine-tuning. Please refer to the [training configuration](#training-configuration) section for details regarding supported training options. + ### RLHF Training Stage2 - Training Reward Model + Stage2 trains a reward model, which obtains corresponding scores by manually ranking different outputs for the same prompt and supervises the training of the reward model. + #### Step 1: Data Collection Below shows the preference dataset format used in training the reward model. + ```json [ {"context": [ @@ -405,42 +548,54 @@ Below shows the preference dataset format used in training the reward model. ] ``` + #### Step 2: Preprocessing Similar to the second step in the previous stage, we format the reward data into the same structured format as used in step 2 of the SFT stage. You can run [prepare_preference_dataset.sh](./examples/data_preparation_scripts/prepare_preference_dataset.sh) to prepare the preference data for reward model training. + #### Step 3: Training You can run [train_rm.sh](./examples/training_scripts/train_rm.sh) to start the reward model training. Please refer to the [training configuration](#training-configuration) section for details regarding supported training options. + #### Features and Tricks in RM Training + - We recommend using the [Anthropic/hh-rlhf](https://huggingface.co/datasets/Anthropic/hh-rlhf)and[rm-static](https://huggingface.co/datasets/Dahoas/rm-static) datasets for training the reward model. - We support 2 kinds of loss function named `log_sig`(used by OpenAI) and `log_exp`(used by Anthropic). - We log the training accuracy `train/acc`, `reward_chosen` and `reward_rejected` to monitor progress during training. - We use cosine-reducing lr-scheduler for RM training. -- We set value_head as 1 liner layer and initialize the weight of value_head using N(0,1/(d_model + 1)) distribution. +- We set value_head as one liner layer and initialize the weight of value_head using the N(0,1/(d_model + 1)) distribution. + #### Note on Reward Model Training -Before you move on the next stage, please check the following list to ensure that your reward model is stable and robust. You can check the reward chart and the accuracy chart on wandb. + +Before you move on to the next stage, please check the following list to ensure that your reward model is stable and robust. You can check the reward chart and the accuracy chart on wandb. - The mean reward for chosen data is much higher than those for rejected data - The accuracy is larger than 0.5 by a significant margin (usually should be greater than 0.6) - Optional:check the reward is positive for chosen data vice versa + Your training reward curves should look similar to the following charts.

image

+ ### RLHF Training Stage3 - Proximal Policy Optimization + In stage3 we will use reinforcement learning algorithm--- Proximal Policy Optimization (PPO), which is the most complex part of the training process: +

+ #### Step 1: Data Collection -PPO uses two kind of training data--- the prompt data and the pretrain data (optional). The first dataset is mandatory, data samples within the prompt dataset ends with a line from "human" and thus the "assistant" needs to generate a response to answer to the "human". Note that you can still use conversation that ends with a line from the "assistant", in that case, the last line will be dropped. Here is an example of the prompt dataset format. +PPO uses two kinds of training data--- the prompt data and the pretrain data (optional). The first dataset is mandatory, data samples within the prompt dataset ends with a line from "human" and thus the "assistant" needs to generate a response to answer to the "human". Note that you can still use conversation that ends with a line from the "assistant", in that case, the last line will be dropped. Here is an example of the prompt dataset format. + ```json [ @@ -456,8 +611,10 @@ PPO uses two kind of training data--- the prompt data and the pretrain data (opt ] ``` + The second dataset--- pretrained dataset is optional, provide it if you want to use the ptx loss introduced in the [InstructGPT paper](https://arxiv.org/abs/2203.02155). It follows the following format. + ```json [ { @@ -470,11 +627,14 @@ The second dataset--- pretrained dataset is optional, provide it if you want to #### Step 2: Preprocessing To prepare the prompt dataset for PPO training, simply run [prepare_prompt_dataset.sh](./examples/data_preparation_scripts/prepare_prompt_dataset.sh) -You can use the SFT dataset you prepared in the SFT stage or prepare a new one from different source for the ptx dataset. The ptx data is used to calculate ptx loss, which stablize the training according to the [InstructGPT paper](https://arxiv.org/pdf/2203.02155.pdf). + +You can use the SFT dataset you prepared in the SFT stage or prepare a new one from different source for the ptx dataset. The ptx data is used to calculate ptx loss, which stabilizes the training according to the [InstructGPT paper](https://arxiv.org/pdf/2203.02155.pdf). + #### Step 3: Training You can run the [train_ppo.sh](./examples/training_scripts/train_ppo.sh) to start PPO training. Here are some unique arguments for PPO, please refer to the training configuration section for other training configuration. Please refer to the [training configuration](#training-configuration) section for details regarding supported training options. + ```bash --pretrain $PRETRAINED_MODEL_PATH \ --rm_pretrain $PRETRAINED_MODEL_PATH \ # reward model architectural @@ -493,7 +653,9 @@ You can run the [train_ppo.sh](./examples/training_scripts/train_ppo.sh) to star --accumulation_steps 2 ``` -Each episode has two phases, the collect phase and the update phase. During the collect phase, we will collect experiences (answers generated by actor), store those in ExperienceBuffer. Then data in ExperienceBuffer is used during the update phase to update parameter of actor and critic. + +Each episode has two phases, the collect phase and the update phase. During the collect phase, we will collect experiences (answers generated by the actor), store those in ExperienceBuffer. Then data in ExperienceBuffer is used during the update phase to update parameters of actor and critic. + - Without tensor parallelism, ``` @@ -502,6 +664,7 @@ experience buffer size = train_batch_size * accumulation_steps * num_process ``` + - With tensor parallelism, ``` num_tp_group = num_process / tp @@ -510,47 +673,60 @@ experience buffer size = train_batch_size * accumulation_steps * num_tp_group ``` + ### Sample Training Results Using Default Script #### Reward

image

+ ### Note on PPO Training #### Q1: My reward is negative -Answer: Check your reward model trained in stage 1. If the reward model only generate negative reward, we actually will expect a negative reward. However, even though the reward is negative, the reward should go up. +Answer: Check your reward model trained in stage 1. If the reward model only generates negative reward, we actually will expect a negative reward. However, even though the reward is negative, the reward should go up. + #### Q2: My actor loss is negative Answer: This is normal for actor loss as PPO doesn't restrict the actor loss to be positive. + #### Q3: My reward doesn't go up (decreases) -Answer: The causes to this problem are two-fold. Check your reward model, make sure that it gives positive and strong reward for good cases and negative, strong reward for bad responses. You should also try different hyperparameter settings. +Answer: The causes of this problem are two-fold. Check your reward model, make sure that it gives positive and strong reward for good cases and negative, strong reward for bad responses. You should also try different hyperparameter settings. + #### Q4: Generation is garbage -Answer: Yes, this happens and is well documented by other implementations. After training for too many episodes, the actor gradually deviate from its original state, which may leads to decrease in language modeling capabilities. A way to fix this is to add supervised loss during PPO. Set ptx_coef to a none-zero value (between 0 and 1), which balances PPO loss and sft loss. +Answer: Yes, this happens and is well documented by other implementations. After training for too many episodes, the actor gradually deviate from its original state, which may leads to decrease in language modeling capabilities. A way to fix this is to add supervised loss during PPO. Set ptx_coef to an non-zero value (between 0 and 1), which balances PPO loss and sft loss. + ## Alternative Option For RLHF: Direct Preference Optimization + For those seeking an alternative to Reinforcement Learning from Human Feedback (RLHF), Direct Preference Optimization (DPO) presents a compelling option. DPO, as detailed in the paper (available at [https://arxiv.org/abs/2305.18290](https://arxiv.org/abs/2305.18290)), DPO offers an low-cost way to perform RLHF and usually request less computation resources compares to PPO. + ### DPO Training Stage1 - Supervised Instructs Tuning + Please refer the [sft section](#dpo-training-stage1---supervised-instructs-tuning) in the PPO part. + ### DPO Training Stage2 - DPO Training #### Step 1: Data Collection & Preparation For DPO training, you only need the preference dataset. Please follow the instruction in the [preference dataset preparation section](#rlhf-training-stage2---training-reward-model) to prepare the preference data for DPO training. + #### Step 2: Training You can run the [train_dpo.sh](./examples/training_scripts/train_dpo.sh) to start DPO training. Please refer to the [training configuration](#training-configuration) section for details regarding supported training options. + #### DPO Result

image

+ ## Hardware Requirements -For PPO, we suggest using Tensor Parallelism. The following table shows the VRAM consumption of training a 7B model on a dummy dataset with 2048 sequence length and 512 layout length with different tp_size (equal to the number of GPUs). In this experiment, we use H800 GPU with 80GB VRAM. +For PPO, we suggest using Tensor Parallelism. The following table shows the VRAM consumption of training a 7B model on a dummy dataset with 2048 sequence length and 512 layout length with different tp_size (equal to the number of GPUs). In this experiment, we use an H800 GPU with 80GB VRAM. | PPO | tp=8 | tp=4 | |-------|---------------|---------------| | bs=1 | 18485.19 MB | 42934.45 MB | @@ -558,19 +734,25 @@ For PPO, we suggest using Tensor Parallelism. The following table shows the VRAM | bs=16 | 41408.28 MB | 56778.97 MB | | bs=30 | 64047.42 MB | failed | + For DPO, we recommend using zero2 or zero2-cpu. We tested the VRAM consumption on a dummy dataset with 2048 sequence length. + - 1 H800 GPU - zero2-cpu, batch size=2, VRAM Usage=49873.90 MB - zero2-cpu, batch size=4, VRAM Usage=60998.22 MB - 4 H800 GPUs - zero2, batch size=4, VRAM Usage=67544.47 MB + ## Inference example + We support different inference options, including int8 and int4 quantization. For details, see [`inference/`](https://github.com/hpcaitech/ColossalAI/tree/main/applications/Chat/inference). + ## Attention + The examples are demos for the whole training process. You need to change the hyper-parameters to reach great performance. diff --git a/applications/ColossalChat/examples/training_scripts/train_dpo.py b/applications/ColossalChat/examples/training_scripts/train_dpo.py index 53dd89393..3c52bec76 100755 --- a/applications/ColossalChat/examples/training_scripts/train_dpo.py +++ b/applications/ColossalChat/examples/training_scripts/train_dpo.py @@ -56,7 +56,7 @@ def train(args): initial_scale=2**16, max_norm=args.grad_clip, enable_gradient_accumulation=True, - enable_flash_attention=args.use_flash_attn + enable_flash_attention=args.use_flash_attn, ) elif args.plugin == "gemini_auto": plugin = GeminiPlugin( @@ -64,7 +64,7 @@ def train(args): placement_policy="auto", initial_scale=2**16, max_norm=args.grad_clip, - enable_flash_attention=args.use_flash_attn + enable_flash_attention=args.use_flash_attn, ) elif args.plugin == "zero2": plugin = LowLevelZeroPlugin( @@ -89,8 +89,8 @@ def train(args): sequence_parallelism_mode=args.sp_mode, zero_stage=args.zero_stage, enable_flash_attention=args.use_flash_attn, - enable_sequence_parallelism=True if args.sp > 1 else False, - cpu_offload=True if args.zero_stage>=1 and args.zero_cpu_offload else False, + enable_sequence_parallelism=args.enable_sequence_parallelism, + cpu_offload=True if args.zero_stage >= 1 and args.zero_cpu_offload else False, parallel_output=False, max_norm=args.grad_clip, precision=args.mixed_precision, @@ -180,7 +180,9 @@ def train(args): shuffle=True, drop_last=True, collate_fn=data_collator, - tp_size=args.tp, + tp_size=plugin.tp_size if hasattr(plugin, "tp_size") else 1, + sp_size=plugin.sp_size if hasattr(plugin, "sp_size") else 1, + pp_size=plugin.pp_size if hasattr(plugin, "pp_size") else 1, ) num_update_steps_per_epoch = len(train_dataloader) // args.accumulation_steps @@ -300,6 +302,7 @@ if __name__ == "__main__": parser.add_argument("--tp", type=int, default=1) parser.add_argument("--pp", type=int, default=1) parser.add_argument("--sp", type=int, default=1) + parser.add_argument("--enable_sequence_parallelism", default=False, action="store_true") parser.add_argument("--zero_stage", type=int, default=0, help="Zero stage", choices=[0, 1, 2]) parser.add_argument("--zero_cpu_offload", default=False, action="store_true") parser.add_argument("--sp_mode", type=str, default="split_gather", choices=["split_gather", "ring", "all_to_all"]) diff --git a/applications/ColossalChat/examples/training_scripts/train_ppo.py b/applications/ColossalChat/examples/training_scripts/train_ppo.py index eb0c62530..92c770561 100755 --- a/applications/ColossalChat/examples/training_scripts/train_ppo.py +++ b/applications/ColossalChat/examples/training_scripts/train_ppo.py @@ -18,7 +18,6 @@ from coati.models import Critic, RewardModel, convert_to_lora_module, disable_dr from coati.trainer import PPOTrainer from coati.utils import load_checkpoint from transformers import AutoModelForCausalLM, AutoTokenizer -from colossalai.shardformer.policies.auto_policy import get_autopolicy import colossalai from colossalai.booster import Booster @@ -27,6 +26,7 @@ from colossalai.cluster import DistCoordinator from colossalai.logging import get_dist_logger from colossalai.nn.lr_scheduler import CosineAnnealingWarmupLR from colossalai.nn.optimizer import HybridAdam +from colossalai.shardformer.policies.auto_policy import get_autopolicy logger = get_dist_logger() @@ -52,7 +52,6 @@ def train(args): # ) init_ctx = nullcontext() - booster_policy = None with init_ctx: if args.use_flash_attn: actor = AutoModelForCausalLM.from_pretrained( @@ -150,34 +149,6 @@ def train(args): adamw_mode=True, ) - # configure dataset - coordinator.print_on_master(f"Load dataset: {args.prompt_dataset}") - mode_map = {"train": "train", "valid": "validation", "test": "test"} - train_prompt_dataset = load_tokenized_dataset(dataset_paths=args.prompt_dataset, mode="train", mode_map=mode_map) - data_collator = DataCollatorForPromptDataset(tokenizer=tokenizer, max_length=args.max_length - args.max_seq_len) - train_prompt_dataloader = setup_distributed_dataloader( - dataset=train_prompt_dataset, - batch_size=args.experience_batch_size, - shuffle=True, - drop_last=True, - collate_fn=data_collator, - tp_size=args.tp, - ) - - if len(args.ptx_dataset) > 0: - train_ptx_dataset = load_tokenized_dataset(dataset_paths=args.ptx_dataset, mode="train", mode_map=mode_map) - data_collator = DataCollatorForSupervisedDataset(tokenizer=tokenizer, max_length=args.max_length) - train_pretrain_dataloader = setup_distributed_dataloader( - dataset=train_ptx_dataset, - batch_size=args.ptx_batch_size, - shuffle=True, - drop_last=True, - collate_fn=data_collator, - tp_size=args.tp, - ) - else: - train_pretrain_dataloader = None - if args.warmup_steps is None: args.warmup_steps = int(0.025 * args.num_episodes) coordinator.print_on_master(f"Warmup steps is set to {args.warmup_steps}") @@ -212,7 +183,7 @@ def train(args): initial_scale=2**16, max_norm=args.grad_clip, enable_gradient_accumulation=True, - enable_flash_attention=args.use_flash_attn + enable_flash_attention=args.use_flash_attn, ) elif args.plugin == "gemini_auto": plugin = GeminiPlugin( @@ -220,7 +191,7 @@ def train(args): placement_policy="auto", initial_scale=2**16, max_norm=args.grad_clip, - enable_flash_attention=args.use_flash_attn + enable_flash_attention=args.use_flash_attn, ) elif args.plugin == "zero2": plugin = LowLevelZeroPlugin( @@ -240,9 +211,15 @@ def train(args): elif args.plugin == "3d": plugin = HybridParallelPlugin( tp_size=args.tp, - pp_size=1, - zero_stage=0, + pp_size=args.pp, + sp_size=args.sp, + sequence_parallelism_mode=args.sp_mode, + zero_stage=args.zero_stage, + enable_flash_attention=args.use_flash_attn, + enable_sequence_parallelism=args.enable_sequence_parallelism, + cpu_offload=True if args.zero_stage >= 1 and args.zero_cpu_offload else False, parallel_output=False, + max_norm=args.grad_clip, precision=args.mixed_precision, ) custom_plugin = HybridParallelPlugin( @@ -252,8 +229,8 @@ def train(args): sequence_parallelism_mode=args.sp_mode, zero_stage=args.zero_stage, enable_flash_attention=args.use_flash_attn, - enable_sequence_parallelism=True if args.sp > 1 else False, - cpu_offload=True if args.zero_stage>=1 and args.zero_cpu_offload else False, + enable_sequence_parallelism=args.enable_sequence_parallelism, + cpu_offload=True if args.zero_stage >= 1 and args.zero_cpu_offload else False, parallel_output=False, max_norm=args.grad_clip, precision=args.mixed_precision, @@ -265,6 +242,38 @@ def train(args): if args.plugin != "3d": custom_plugin = plugin + # configure dataset + coordinator.print_on_master(f"Load dataset: {args.prompt_dataset}") + mode_map = {"train": "train", "valid": "validation", "test": "test"} + train_prompt_dataset = load_tokenized_dataset(dataset_paths=args.prompt_dataset, mode="train", mode_map=mode_map) + data_collator = DataCollatorForPromptDataset(tokenizer=tokenizer, max_length=args.max_length - args.max_seq_len) + train_prompt_dataloader = setup_distributed_dataloader( + dataset=train_prompt_dataset, + batch_size=args.experience_batch_size, + shuffle=True, + drop_last=True, + collate_fn=data_collator, + tp_size=plugin.tp_size if hasattr(plugin, "tp_size") else 1, + sp_size=plugin.sp_size if hasattr(plugin, "sp_size") else 1, + pp_size=plugin.pp_size if hasattr(plugin, "pp_size") else 1, + ) + + if len(args.ptx_dataset) > 0: + train_ptx_dataset = load_tokenized_dataset(dataset_paths=args.ptx_dataset, mode="train", mode_map=mode_map) + data_collator = DataCollatorForSupervisedDataset(tokenizer=tokenizer, max_length=args.max_length) + train_pretrain_dataloader = setup_distributed_dataloader( + dataset=train_ptx_dataset, + batch_size=args.ptx_batch_size, + shuffle=True, + drop_last=True, + collate_fn=data_collator, + tp_size=plugin.tp_size if hasattr(plugin, "tp_size") else 1, + sp_size=plugin.sp_size if hasattr(plugin, "sp_size") else 1, + pp_size=plugin.pp_size if hasattr(plugin, "pp_size") else 1, + ) + else: + train_pretrain_dataloader = None + actor_booster = Booster(plugin=plugin) ref_booster = Booster(plugin=plugin) rm_booster = Booster(plugin=custom_plugin) @@ -459,6 +468,7 @@ if __name__ == "__main__": parser.add_argument("--tp", type=int, default=1) parser.add_argument("--pp", type=int, default=1) parser.add_argument("--sp", type=int, default=1) + parser.add_argument("--enable_sequence_parallelism", default=False, action="store_true") parser.add_argument("--zero_stage", type=int, default=0, help="Zero stage", choices=[0, 1, 2]) parser.add_argument("--zero_cpu_offload", default=False, action="store_true") parser.add_argument("--sp_mode", type=str, default="split_gather", choices=["split_gather", "ring", "all_to_all"]) diff --git a/applications/ColossalChat/examples/training_scripts/train_rm.py b/applications/ColossalChat/examples/training_scripts/train_rm.py index 7fbb954f9..d42291802 100755 --- a/applications/ColossalChat/examples/training_scripts/train_rm.py +++ b/applications/ColossalChat/examples/training_scripts/train_rm.py @@ -15,8 +15,7 @@ from coati.dataset import ( from coati.models import LogExpLoss, LogSigLoss, RewardModel, convert_to_lora_module from coati.trainer import RewardModelTrainer from coati.utils import load_checkpoint -from transformers import AutoTokenizer, AutoConfig -from colossalai.shardformer.policies.auto_policy import get_autopolicy +from transformers import AutoConfig, AutoTokenizer import colossalai from colossalai.booster import Booster @@ -24,6 +23,7 @@ from colossalai.booster.plugin import GeminiPlugin, HybridParallelPlugin, LowLev from colossalai.cluster import DistCoordinator from colossalai.nn.lr_scheduler import CosineAnnealingWarmupLR from colossalai.nn.optimizer import HybridAdam +from colossalai.shardformer.policies.auto_policy import get_autopolicy def train(args): @@ -47,7 +47,6 @@ def train(args): # ) init_ctx = nullcontext() - booster_policy = None with init_ctx: if args.use_flash_attn: model = RewardModel( @@ -57,7 +56,7 @@ def train(args): ) coordinator.print_on_master(msg="Flash-attention enabled successfully") else: - model_config = AutoConfig.from_pretrained(args.pretrain) + AutoConfig.from_pretrained(args.pretrain) model = RewardModel( args.pretrain, ) @@ -114,12 +113,12 @@ def train(args): sequence_parallelism_mode=args.sp_mode, zero_stage=args.zero_stage, enable_flash_attention=args.use_flash_attn, - enable_sequence_parallelism=True if args.sp > 1 else False, - cpu_offload=True if args.zero_stage>=1 and args.zero_cpu_offload else False, + enable_sequence_parallelism=args.enable_sequence_parallelism, + cpu_offload=True if args.zero_stage >= 1 and args.zero_cpu_offload else False, parallel_output=False, max_norm=args.grad_clip, precision=args.mixed_precision, - custom_policy=get_autopolicy(model.model) + custom_policy=get_autopolicy(model.model), ) else: raise ValueError(f"Unknown plugin {args.plugin}") @@ -177,7 +176,9 @@ def train(args): shuffle=True, drop_last=True, collate_fn=data_collator, - tp_size=args.tp, + tp_size=plugin.tp_size if hasattr(plugin, "tp_size") else 1, + sp_size=plugin.sp_size if hasattr(plugin, "sp_size") else 1, + pp_size=plugin.pp_size if hasattr(plugin, "pp_size") else 1, ) num_update_steps_per_epoch = len(train_dataloader) // args.accumulation_steps @@ -297,6 +298,7 @@ if __name__ == "__main__": parser.add_argument("--tp", type=int, default=1) parser.add_argument("--pp", type=int, default=1) parser.add_argument("--sp", type=int, default=1) + parser.add_argument("--enable_sequence_parallelism", default=False, action="store_true") parser.add_argument("--zero_stage", type=int, default=0, help="Zero stage", choices=[0, 1, 2]) parser.add_argument("--zero_cpu_offload", default=False, action="store_true") parser.add_argument("--sp_mode", type=str, default="split_gather", choices=["split_gather", "ring", "all_to_all"]) diff --git a/applications/ColossalChat/examples/training_scripts/train_sft.py b/applications/ColossalChat/examples/training_scripts/train_sft.py index e1af3873c..4e78472f8 100755 --- a/applications/ColossalChat/examples/training_scripts/train_sft.py +++ b/applications/ColossalChat/examples/training_scripts/train_sft.py @@ -125,11 +125,12 @@ def train(args): sequence_parallelism_mode=args.sp_mode, zero_stage=args.zero_stage, enable_flash_attention=args.use_flash_attn, - enable_sequence_parallelism=True if args.sp > 1 else False, + enable_sequence_parallelism=args.enable_sequence_parallelism, cpu_offload=True if args.zero_stage >= 1 and args.zero_cpu_offload else False, parallel_output=False, max_norm=args.grad_clip, precision=args.mixed_precision, + microbatch_size=args.batch_size, ) else: raise ValueError(f"Unknown plugin {args.plugin}") @@ -194,7 +195,9 @@ def train(args): shuffle=True, drop_last=True, collate_fn=data_collator, - tp_size=args.tp, + tp_size=plugin.tp_size if hasattr(plugin, "tp_size") else 1, + sp_size=plugin.sp_size if hasattr(plugin, "sp_size") else 1, + pp_size=plugin.pp_size if hasattr(plugin, "pp_size") else 1, ) # print(len(train_dataloader)) # for batch in train_dataloader: @@ -321,6 +324,7 @@ if __name__ == "__main__": parser.add_argument("--tp", type=int, default=1) parser.add_argument("--pp", type=int, default=1) parser.add_argument("--sp", type=int, default=1) + parser.add_argument("--enable_sequence_parallelism", default=False, action="store_true") parser.add_argument("--zero_stage", type=int, default=0, help="Zero stage", choices=[0, 1, 2]) parser.add_argument("--zero_cpu_offload", default=False, action="store_true") parser.add_argument("--sp_mode", type=str, default="split_gather", choices=["split_gather", "ring", "all_to_all"]) diff --git a/applications/ColossalChat/tests/test_train.sh b/applications/ColossalChat/tests/test_train.sh index f965e4a9b..0f69bcaf0 100755 --- a/applications/ColossalChat/tests/test_train.sh +++ b/applications/ColossalChat/tests/test_train.sh @@ -30,6 +30,8 @@ MODEL_SAVE_PATH=$TEMP_DIR/rlhf_models MODELS_DIR=$TEMP_DIR/models_config # Skip those tests due to CI tests timeout MODELS=('llama') +# ADVANCED_PLUGINS=('pp' 'tp_zero2' 'tp_pp' 'sp_split_gather' 'sp_ring' 'sp_all_to_all' '3d' 'gemini' 'gemini_auto' 'zero2' 'zero2_cpu') +ADVANCED_PLUGINS=('tp_zero2' '3d' 'gemini' 'gemini_auto' 'zero2' 'zero2_cpu') PLUGINS=('3d' 'gemini' 'gemini_auto' 'zero2' 'zero2_cpu') LORA_RANK=('0') # skip to reduce CI execution time, can pass all locally @@ -80,6 +82,8 @@ random_choice() { } + + echo "[Test]: testing sft ..." SKIPPED_TESTS=( @@ -91,7 +95,7 @@ SKIPPED_TESTS=( GRAD_CKPTS=('--grad_checkpoint') for lora_rank in ${LORA_RANK[@]}; do for model in ${MODELS[@]}; do - for plugin in ${PLUGINS[@]}; do + for plugin in ${ADVANCED_PLUGINS[@]}; do if [[ " ${SKIPPED_TESTS[*]} " =~ " $model-$plugin-$lora_rank " ]]; then echo "[Test]: Skipped $model-$plugin-$lora_rank" continue @@ -104,10 +108,56 @@ for lora_rank in ${LORA_RANK[@]}; do grad_ckpt=$(random_choice "${GRAD_CKPTS[@]}") tp='1' bs='2' + pp='1' + zero_stage='0' + sp='1' + sp_mode='split_gather' + enable_sequence_parallelism='' if [[ $plugin == "3d" ]]; then tp='4' bs='8' fi + if [[ $plugin == "tp_zero2" ]]; then + tp='4' + bs='8' + zero_stage='2' + plugin='3d' + fi + if [[ $plugin == "tp_pp" ]]; then + tp='2' + bs='8' + pp='2' + plugin='3d' + fi + if [[ $plugin == "pp" ]]; then + bs='8' + pp='4' + plugin='3d' + fi + if [[ $plugin == "sp_split_gather" ]]; then + enable_sequence_parallelism='--enable_sequence_parallelism' + sp_mode='split_gather' + tp='4' + sp='1' + bs='8' + plugin='3d' + fi + if [[ $plugin == "sp_ring" ]]; then + enable_sequence_parallelism='--enable_sequence_parallelism' + sp_mode='ring' + tp='4' + sp='1' + bs='8' + plugin='3d' + fi + if [[ $plugin == "sp_all_to_all" ]]; then + enable_sequence_parallelism='--enable_sequence_parallelism' + sp_mode='all_to_all' + tp='1' + sp='4' + bs='8' + plugin='3d' + fi grad_accu='2' # Check if the plugin is either "gemini_auto" or "gemini" and set grad_accu to '1' if [[ $plugin == "gemini_auto" ]]; then @@ -132,6 +182,11 @@ for lora_rank in ${LORA_RANK[@]}; do --max_epochs 1 \ --accumulation_steps $grad_accu \ --tp $tp \ + --pp $pp \ + --zero_stage $zero_stage \ + --sp $sp \ + --sp_mode $sp_mode \ + $enable_sequence_parallelism \ --lr 2e-5 \ $grad_ckpt \ --max_len 400 \ @@ -226,8 +281,8 @@ echo "[Test]: testing ppo ..." SKIPPED_TESTS=( - llama-3d-20 # 3d plugin doesn't support lora - llama-gemini-20 # gemini doesn't support lora + llama-3d # 3d plugin doesn't support lora + llama-gemini # gemini doesn't support lora ) GRAD_CKPTS=('--grad_checkpoint') From 7ae87b315921d5ec96d034a5ce6af8dc7f19b031 Mon Sep 17 00:00:00 2001 From: YeAnbang Date: Tue, 28 May 2024 08:00:18 +0000 Subject: [PATCH 05/19] fix training script --- .../examples/training_scripts/train_sft.sh | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/applications/ColossalChat/examples/training_scripts/train_sft.sh b/applications/ColossalChat/examples/training_scripts/train_sft.sh index f8d659258..5d0f55f90 100755 --- a/applications/ColossalChat/examples/training_scripts/train_sft.sh +++ b/applications/ColossalChat/examples/training_scripts/train_sft.sh @@ -17,22 +17,22 @@ set_n_least_used_CUDA_VISIBLE_DEVICES() { # export CUDA_VISIBLE_DEVICES=4,5,6 set_n_least_used_CUDA_VISIBLE_DEVICES 2 PROJECT_NAME="sft" -PARENT_SAVE_DIR="/home/yeanbang/data/experiment/output/model" # Path to a folder to save checkpoints -PARENT_TENSORBOARD_DIR="/home/yeanbang/data/experiment/logs/tensorboard" # Path to a folder to save logs -PARENT_CONFIG_FILE="/home/yeanbang/data/experiment/logs/config" # Path to a folder to save training config logs -PRETRAINED_MODEL_PATH="/mnt/jfs-hdd/share/models/Yi-1.5-6B" # huggingface or local model path -PRETRAINED_TOKENIZER_PATH="/mnt/jfs-hdd/share/models/Yi-1.5-6B" # huggingface or local tokenizer path +PARENT_SAVE_DIR="" # Path to a folder to save checkpoints +PARENT_TENSORBOARD_DIR="" # Path to a folder to save logs +PARENT_CONFIG_FILE="" # Path to a folder to save training config logs +PRETRAINED_MODEL_PATH="" # huggingface or local model path +PRETRAINED_TOKENIZER_PATH="" # huggingface or local tokenizer path declare -a dataset=( - /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00000 - /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00001 - /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00002 - /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00003 - /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00004 - /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00005 - /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00006 - /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00007 - /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00008 - /home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B/arrow/part-00009 + YOUR/PREFERENCE/DATA/DIR/arrow/part-00000 + YOUR/PREFERENCE/DATA/DIR/arrow/part-00001 + YOUR/PREFERENCE/DATA/DIR/arrow/part-00002 + YOUR/PREFERENCE/DATA/DIR/arrow/part-00003 + YOUR/PREFERENCE/DATA/DIR/arrow/part-00004 + YOUR/PREFERENCE/DATA/DIR/arrow/part-00005 + YOUR/PREFERENCE/DATA/DIR/arrow/part-00006 + YOUR/PREFERENCE/DATA/DIR/arrow/part-00007 + YOUR/PREFERENCE/DATA/DIR/arrow/part-00008 + YOUR/PREFERENCE/DATA/DIR/arrow/part-00009 ) TIMESTAMP=$(date +%Y-%m-%d-%H-%M-%S) From b1031f7244dd13c66d1cf667f7c737f77820b24a Mon Sep 17 00:00:00 2001 From: YeAnbang Date: Tue, 28 May 2024 08:06:36 +0000 Subject: [PATCH 06/19] fix ci --- .github/workflows/run_chatgpt_examples.yml | 9 +++++---- .github/workflows/run_chatgpt_unit_tests.yml | 11 +++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/run_chatgpt_examples.yml b/.github/workflows/run_chatgpt_examples.yml index ba997f144..88da6e95b 100644 --- a/.github/workflows/run_chatgpt_examples.yml +++ b/.github/workflows/run_chatgpt_examples.yml @@ -4,10 +4,11 @@ on: pull_request: types: [synchronize, opened, reopened] paths: - - "applications/Chat/coati/**" - - "applications/Chat/requirements.txt" - - "applications/Chat/setup.py" - - "applications/Chat/examples/**" + - "applications/ColossalChat/coati/**" + - "applications/ColossalChat/requirements.txt" + - "applications/ColossalChat/setup.py" + - "applications/ColossalChat/examples/**" + - "applications/ColossalChat/tests/**" jobs: tests: diff --git a/.github/workflows/run_chatgpt_unit_tests.yml b/.github/workflows/run_chatgpt_unit_tests.yml index 1d8a53e4f..c0e74ecbb 100644 --- a/.github/workflows/run_chatgpt_unit_tests.yml +++ b/.github/workflows/run_chatgpt_unit_tests.yml @@ -4,12 +4,11 @@ on: pull_request: types: [synchronize, opened, reopened] paths: - - 'applications/Chat/coati/**' - - 'applications/Chat/requirements.txt' - - 'applications/Chat/setup.py' - - 'applications/Chat/requirements-test.txt' - - 'applications/Chat/tests/**' - - 'applications/Chat/pytest.ini' + - 'applications/ColossalChat/coati/**' + - 'applications/ColossalChat/requirements.txt' + - 'applications/ColossalChat/setup.py' + - 'applications/ColossalChat/tests/**' + - 'applications/ColossalChat/pytest.ini' jobs: tests: From 1b880ce09560ab65a55ccf0a6ae1864724651069 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 08:02:42 +0000 Subject: [PATCH 07/19] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../coati/dataset/conversation.py | 4 +- .../coati/dataset/tokenization_utils.py | 27 ++++++----- .../ColossalChat/coati/dataset/utils.py | 6 ++- .../ColossalChat/coati/models/critic.py | 2 +- .../01-ai_Yi-1.5-9B-Chat.json | 2 +- .../Qwen_Qwen1.5-110B-Chat.json | 2 +- .../THUDM_chatglm2-6b.json | 2 +- .../THUDM_chatglm3-6b.json | 2 +- .../baichuan-inc_Baichuan2-13B-Chat.json | 2 +- .../colossal-llama2.json | 2 +- .../deepseek-ai_DeepSeek-V2-Lite.json | 2 +- .../config/conversation_template/llama2.json | 2 +- .../microsoft_phi-2.json | 2 +- .../mistralai_Mixtral-8x7B-Instruct-v0.1.json | 2 +- .../prepare_dataset.py | 2 +- applications/ColossalChat/tests/llama.json | 2 +- .../ColossalChat/tests/test_chat_template.py | 45 ++++++++++--------- .../chat_template/01-ai_Yi-1.5-9B-Chat.json | 2 +- .../test_data/chat_template/01-ai_Yi-34B.json | 2 +- .../chat_template/Qwen_Qwen-7B-Chat.json | 2 +- .../chat_template/THUDM_chatglm2-6b.json | 2 +- .../chat_template/THUDM_chatglm3-6b.json | 2 +- .../baichuan-inc_Baichuan2-13B-Chat.json | 2 +- .../deepseek-ai_DeepSeek-V2-Lite.json | 2 +- .../chat_template/microsoft_phi-2.json | 2 +- .../mistralai_Mixtral-8x7B-Instruct-v0.1.json | 2 +- 26 files changed, 69 insertions(+), 57 deletions(-) diff --git a/applications/ColossalChat/coati/dataset/conversation.py b/applications/ColossalChat/coati/dataset/conversation.py index ec46ea429..37900f3b8 100755 --- a/applications/ColossalChat/coati/dataset/conversation.py +++ b/applications/ColossalChat/coati/dataset/conversation.py @@ -25,7 +25,9 @@ class Conversation: Setup the conversation template from config """ tokenizer.chat_template = config["chat_template"] - conv = cls(tokenizer, config["system_message"], config["chat_template"], config["stop_ids"], config["end_of_assistant"]) + conv = cls( + tokenizer, config["system_message"], config["chat_template"], config["stop_ids"], config["end_of_assistant"] + ) conv.clear() return conv diff --git a/applications/ColossalChat/coati/dataset/tokenization_utils.py b/applications/ColossalChat/coati/dataset/tokenization_utils.py index 0e97d57a1..2debbb757 100755 --- a/applications/ColossalChat/coati/dataset/tokenization_utils.py +++ b/applications/ColossalChat/coati/dataset/tokenization_utils.py @@ -97,8 +97,9 @@ def supervised_tokenize_sft( target_turn = turns[target_turn_index - 1] prompt = template.get_prompt(2 * target_turn) - chunks, require_loss = split_templated_prompt_into_chunks(template.messages[: 2 * target_turn], prompt, - conversation_template.end_of_assistant) + chunks, require_loss = split_templated_prompt_into_chunks( + template.messages[: 2 * target_turn], prompt, conversation_template.end_of_assistant + ) tokenized, starts, ends = tokenize_and_concatenate(tokenizer, chunks, require_loss) labels = [ignore_index] * len(tokenized) @@ -106,7 +107,7 @@ def supervised_tokenize_sft( if end == len(tokenized): tokenized = tokenized + [tokenizer.eos_token_id] labels = labels + [ignore_index] - labels[start : end] = tokenized[start : end] + labels[start:end] = tokenized[start:end] # truncate the sequence at the last token that requires loss calculation to_truncate_len = 0 @@ -139,14 +140,14 @@ def supervised_tokenize_sft( label_decode = [] for i in range(len(labels)): if labels[i] == ignore_index: - if start!=end: - label_decode.append(tokenizer.decode(labels[start+1:i], skip_special_tokens=False)) + if start != end: + label_decode.append(tokenizer.decode(labels[start + 1 : i], skip_special_tokens=False)) start = i end = i else: end = i if i == len(labels) - 1: - label_decode.append(tokenizer.decode(labels[start+1:], skip_special_tokens=False)) + label_decode.append(tokenizer.decode(labels[start + 1 :], skip_special_tokens=False)) except TypeError as e: raise TypeError(str(e) + f"\nUnable to decode input_ids: {tokenized}") @@ -216,8 +217,9 @@ def tokenize_prompt_dataset( # Prepare data prompt = template.get_prompt(target_turn, add_generation_prompt=True) - chunks, require_loss = split_templated_prompt_into_chunks(template.messages[: target_turn], prompt, - conversation_template.end_of_assistant) + chunks, require_loss = split_templated_prompt_into_chunks( + template.messages[:target_turn], prompt, conversation_template.end_of_assistant + ) tokenized, starts, ends = tokenize_and_concatenate(tokenizer, chunks, require_loss) if tokenizer.bos_token_id is not None: if tokenized[0] != tokenizer.bos_token_id: @@ -246,8 +248,9 @@ def apply_rlhf_data_format( ): target_turn = int(len(template.messages) / 2) prompt = template.get_prompt(target_turn * 2) - chunks, require_loss = split_templated_prompt_into_chunks(template.messages[: 2 * target_turn], prompt, - template.end_of_assistant) + chunks, require_loss = split_templated_prompt_into_chunks( + template.messages[: 2 * target_turn], prompt, template.end_of_assistant + ) tokenized, starts, ends = tokenize_and_concatenate(tokenizer, chunks, require_loss) loss_mask = [0] * len(tokenized) mask_token = tokenizer.eos_token_id or tokenizer.pad_token_id @@ -260,8 +263,8 @@ def apply_rlhf_data_format( if end == len(tokenized): tokenized = tokenized + [tokenizer.eos_token_id] loss_mask = loss_mask + [1] - loss_mask[start : end] = [1] * len(loss_mask[start : end]) - label_decode.append(tokenizer.decode(tokenized[start : end], skip_special_tokens=False)) + loss_mask[start:end] = [1] * len(loss_mask[start:end]) + label_decode.append(tokenizer.decode(tokenized[start:end], skip_special_tokens=False)) if tokenizer.bos_token_id is not None: if tokenized[0] != tokenizer.bos_token_id: tokenized = [tokenizer.bos_token_id] + tokenized diff --git a/applications/ColossalChat/coati/dataset/utils.py b/applications/ColossalChat/coati/dataset/utils.py index eaef8af1a..f41a4d772 100755 --- a/applications/ColossalChat/coati/dataset/utils.py +++ b/applications/ColossalChat/coati/dataset/utils.py @@ -121,8 +121,10 @@ def split_templated_prompt_into_chunks(messages: List[Dict[str, str]], prompt: s for line in messages: content_length = len(line["content"]) first_occur = prompt.find(line["content"], start_idx) - if line["role"].lower() == "assistant" and end_of_assistant in prompt[first_occur + content_length:]: - content_length = prompt.find(end_of_assistant, first_occur + content_length) + len(end_of_assistant) - first_occur + if line["role"].lower() == "assistant" and end_of_assistant in prompt[first_occur + content_length :]: + content_length = ( + prompt.find(end_of_assistant, first_occur + content_length) + len(end_of_assistant) - first_occur + ) if prompt[first_occur - 1] != " ": chunks.append(prompt[start_idx:first_occur]) chunks.append(prompt[first_occur : first_occur + content_length]) diff --git a/applications/ColossalChat/coati/models/critic.py b/applications/ColossalChat/coati/models/critic.py index 02bcab8d0..a5761dabe 100755 --- a/applications/ColossalChat/coati/models/critic.py +++ b/applications/ColossalChat/coati/models/critic.py @@ -37,4 +37,4 @@ class Critic(BaseModel): return self.model.get_input_embeddings() def get_output_embeddings(self): - return self.model.get_output_embeddings() \ No newline at end of file + return self.model.get_output_embeddings() diff --git a/applications/ColossalChat/config/conversation_template/01-ai_Yi-1.5-9B-Chat.json b/applications/ColossalChat/config/conversation_template/01-ai_Yi-1.5-9B-Chat.json index 85a726766..455b1e1b3 100644 --- a/applications/ColossalChat/config/conversation_template/01-ai_Yi-1.5-9B-Chat.json +++ b/applications/ColossalChat/config/conversation_template/01-ai_Yi-1.5-9B-Chat.json @@ -5,4 +5,4 @@ 7 ], "end_of_assistant": "<|im_end|>" -} \ No newline at end of file +} diff --git a/applications/ColossalChat/config/conversation_template/Qwen_Qwen1.5-110B-Chat.json b/applications/ColossalChat/config/conversation_template/Qwen_Qwen1.5-110B-Chat.json index d28775ab9..58941a591 100644 --- a/applications/ColossalChat/config/conversation_template/Qwen_Qwen1.5-110B-Chat.json +++ b/applications/ColossalChat/config/conversation_template/Qwen_Qwen1.5-110B-Chat.json @@ -6,4 +6,4 @@ 151643 ], "end_of_assistant": "<|im_end|>" -} \ No newline at end of file +} diff --git a/applications/ColossalChat/config/conversation_template/THUDM_chatglm2-6b.json b/applications/ColossalChat/config/conversation_template/THUDM_chatglm2-6b.json index 9d8531753..809c1d9f9 100644 --- a/applications/ColossalChat/config/conversation_template/THUDM_chatglm2-6b.json +++ b/applications/ColossalChat/config/conversation_template/THUDM_chatglm2-6b.json @@ -5,4 +5,4 @@ 2 ], "end_of_assistant": "<|im_end|>" -} \ No newline at end of file +} diff --git a/applications/ColossalChat/config/conversation_template/THUDM_chatglm3-6b.json b/applications/ColossalChat/config/conversation_template/THUDM_chatglm3-6b.json index d791e1ae8..c39f6e4b1 100644 --- a/applications/ColossalChat/config/conversation_template/THUDM_chatglm3-6b.json +++ b/applications/ColossalChat/config/conversation_template/THUDM_chatglm3-6b.json @@ -5,4 +5,4 @@ 2 ], "end_of_assistant": "<|user|>" -} \ No newline at end of file +} diff --git a/applications/ColossalChat/config/conversation_template/baichuan-inc_Baichuan2-13B-Chat.json b/applications/ColossalChat/config/conversation_template/baichuan-inc_Baichuan2-13B-Chat.json index 9d8531753..809c1d9f9 100644 --- a/applications/ColossalChat/config/conversation_template/baichuan-inc_Baichuan2-13B-Chat.json +++ b/applications/ColossalChat/config/conversation_template/baichuan-inc_Baichuan2-13B-Chat.json @@ -5,4 +5,4 @@ 2 ], "end_of_assistant": "<|im_end|>" -} \ No newline at end of file +} diff --git a/applications/ColossalChat/config/conversation_template/colossal-llama2.json b/applications/ColossalChat/config/conversation_template/colossal-llama2.json index b9c17c1e2..d2f9d8899 100644 --- a/applications/ColossalChat/config/conversation_template/colossal-llama2.json +++ b/applications/ColossalChat/config/conversation_template/colossal-llama2.json @@ -5,4 +5,4 @@ 2 ], "end_of_assistant": "
" -} \ No newline at end of file +} diff --git a/applications/ColossalChat/config/conversation_template/deepseek-ai_DeepSeek-V2-Lite.json b/applications/ColossalChat/config/conversation_template/deepseek-ai_DeepSeek-V2-Lite.json index 89a9aed85..aad482bfb 100644 --- a/applications/ColossalChat/config/conversation_template/deepseek-ai_DeepSeek-V2-Lite.json +++ b/applications/ColossalChat/config/conversation_template/deepseek-ai_DeepSeek-V2-Lite.json @@ -5,4 +5,4 @@ 100001 ], "end_of_assistant": "<|end▁of▁sentence|>" -} \ No newline at end of file +} diff --git a/applications/ColossalChat/config/conversation_template/llama2.json b/applications/ColossalChat/config/conversation_template/llama2.json index 5fbe8b4fc..a6975e640 100644 --- a/applications/ColossalChat/config/conversation_template/llama2.json +++ b/applications/ColossalChat/config/conversation_template/llama2.json @@ -5,4 +5,4 @@ 2 ], "end_of_assistant": "" -} \ No newline at end of file +} diff --git a/applications/ColossalChat/config/conversation_template/microsoft_phi-2.json b/applications/ColossalChat/config/conversation_template/microsoft_phi-2.json index 60ec8b763..096f5138e 100644 --- a/applications/ColossalChat/config/conversation_template/microsoft_phi-2.json +++ b/applications/ColossalChat/config/conversation_template/microsoft_phi-2.json @@ -5,4 +5,4 @@ 50256 ], "end_of_assistant": "<|im_end|>" -} \ No newline at end of file +} diff --git a/applications/ColossalChat/config/conversation_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json b/applications/ColossalChat/config/conversation_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json index 9a7df645d..4e143b537 100644 --- a/applications/ColossalChat/config/conversation_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json +++ b/applications/ColossalChat/config/conversation_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json @@ -5,4 +5,4 @@ 2 ], "end_of_assistant": "" -} \ No newline at end of file +} diff --git a/applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py b/applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py index 04e613d0c..64093f88d 100644 --- a/applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py +++ b/applications/ColossalChat/examples/data_preparation_scripts/prepare_dataset.py @@ -226,7 +226,7 @@ def main(): "max_length": args.max_length, }, keep_in_memory=False, - num_proc= min(len(dataset), cpu_count()), + num_proc=min(len(dataset), cpu_count()), ) dataset = dataset.filter( diff --git a/applications/ColossalChat/tests/llama.json b/applications/ColossalChat/tests/llama.json index 6a7e00560..788a48c91 100644 --- a/applications/ColossalChat/tests/llama.json +++ b/applications/ColossalChat/tests/llama.json @@ -6,4 +6,4 @@ 2 ], "end_of_assistant": "" -} \ No newline at end of file +} diff --git a/applications/ColossalChat/tests/test_chat_template.py b/applications/ColossalChat/tests/test_chat_template.py index 9d6babdec..0df13c066 100644 --- a/applications/ColossalChat/tests/test_chat_template.py +++ b/applications/ColossalChat/tests/test_chat_template.py @@ -1,36 +1,41 @@ -from coati.dataset import setup_conversation_template -from coati.dataset.conversation import Conversation -from coati.dataset.tokenization_utils import supervised_tokenize_sft -from transformers import AutoTokenizer import json import os +from coati.dataset import setup_conversation_template +from coati.dataset.tokenization_utils import supervised_tokenize_sft +from transformers import AutoTokenizer + model_data_mapping = { - 'THUDM/chatglm2-6b': 'THUDM_chatglm2-6b.json', - 'THUDM/chatglm3-6b': 'THUDM_chatglm3-6b.json', - 'baichuan-inc/Baichuan2-13B-Chat': 'baichuan-inc_Baichuan2-13B-Chat.json', - '01-ai/Yi-1.5-9B-Chat': '01-ai_Yi-1.5-9B-Chat.json', - '01-ai/Yi-34B': '01-ai_Yi-34B.json', - 'deepseek-ai/DeepSeek-V2-Lite': 'deepseek-ai_DeepSeek-V2-Lite.json', - 'microsoft/phi-2': 'microsoft_phi-2.json', - 'mistralai/Mixtral-8x7B-Instruct-v0.1': 'mistralai_Mixtral-8x7B-Instruct-v0.1.json' -} -chat_template_config_path = './config/conversation_template' + "THUDM/chatglm2-6b": "THUDM_chatglm2-6b.json", + "THUDM/chatglm3-6b": "THUDM_chatglm3-6b.json", + "baichuan-inc/Baichuan2-13B-Chat": "baichuan-inc_Baichuan2-13B-Chat.json", + "01-ai/Yi-1.5-9B-Chat": "01-ai_Yi-1.5-9B-Chat.json", + "01-ai/Yi-34B": "01-ai_Yi-34B.json", + "deepseek-ai/DeepSeek-V2-Lite": "deepseek-ai_DeepSeek-V2-Lite.json", + "microsoft/phi-2": "microsoft_phi-2.json", + "mistralai/Mixtral-8x7B-Instruct-v0.1": "mistralai_Mixtral-8x7B-Instruct-v0.1.json", +} +chat_template_config_path = "./config/conversation_template" def test_tokenization_sft(): for model in model_data_mapping: print(f"#############{model}#############") - conversation_template_config = os.path.join(chat_template_config_path, model_data_mapping[model]) - messages = [{"from": "human", "content": "What are the three primary colors?"}, + conversation_template_config = os.path.join(chat_template_config_path, model_data_mapping[model]) + messages = [ + {"from": "human", "content": "What are the three primary colors?"}, {"from": "assistant", "content": "The three primary colors are red, blue, and yellow."}, - {"from": "human", "content": "解释个人电脑和服务器之间的区别。"}, - {"from": "assistant", "content": "个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。"}] + {"from": "human", "content": "解释个人电脑和服务器之间的区别。"}, + { + "from": "assistant", + "content": "个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。", + }, + ] chat_template_config = json.load(open(conversation_template_config, "r", encoding="utf8")) tokenizer = AutoTokenizer.from_pretrained(model, use_fast=False, trust_remote_code=True) conversation_template = setup_conversation_template( - tokenizer, chat_template_config=chat_template_config, save_path=conversation_template_config - ) + tokenizer, chat_template_config=chat_template_config, save_path=conversation_template_config + ) output = supervised_tokenize_sft({"messages": messages}, tokenizer, conversation_template) with open(f"./tests/test_data/chat_template/{model_data_mapping[model]}", "r", encoding="utf8") as f: diff --git a/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-1.5-9B-Chat.json b/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-1.5-9B-Chat.json index 52a20f813..c5335fb18 100644 --- a/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-1.5-9B-Chat.json +++ b/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-1.5-9B-Chat.json @@ -582,4 +582,4 @@ ], "seq_length": 286, "seq_category": "None" -} \ No newline at end of file +} diff --git a/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-34B.json b/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-34B.json index 424a737d5..0284c2cea 100644 --- a/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-34B.json +++ b/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-34B.json @@ -604,4 +604,4 @@ ], "seq_length": 297, "seq_category": "None" -} \ No newline at end of file +} diff --git a/applications/ColossalChat/tests/test_data/chat_template/Qwen_Qwen-7B-Chat.json b/applications/ColossalChat/tests/test_data/chat_template/Qwen_Qwen-7B-Chat.json index 1ebfac1d6..0b291a071 100644 --- a/applications/ColossalChat/tests/test_data/chat_template/Qwen_Qwen-7B-Chat.json +++ b/applications/ColossalChat/tests/test_data/chat_template/Qwen_Qwen-7B-Chat.json @@ -600,4 +600,4 @@ ], "seq_length": 295, "seq_category": "None" -} \ No newline at end of file +} diff --git a/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm2-6b.json b/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm2-6b.json index bc421f470..fe3559266 100644 --- a/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm2-6b.json +++ b/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm2-6b.json @@ -712,4 +712,4 @@ ], "seq_length": 351, "seq_category": "None" -} \ No newline at end of file +} diff --git a/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm3-6b.json b/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm3-6b.json index 5aab0073e..10b012fe0 100644 --- a/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm3-6b.json +++ b/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm3-6b.json @@ -582,4 +582,4 @@ ], "seq_length": 286, "seq_category": "None" -} \ No newline at end of file +} diff --git a/applications/ColossalChat/tests/test_data/chat_template/baichuan-inc_Baichuan2-13B-Chat.json b/applications/ColossalChat/tests/test_data/chat_template/baichuan-inc_Baichuan2-13B-Chat.json index 736baf85b..1db9df08b 100644 --- a/applications/ColossalChat/tests/test_data/chat_template/baichuan-inc_Baichuan2-13B-Chat.json +++ b/applications/ColossalChat/tests/test_data/chat_template/baichuan-inc_Baichuan2-13B-Chat.json @@ -694,4 +694,4 @@ ], "seq_length": 342, "seq_category": "None" -} \ No newline at end of file +} diff --git a/applications/ColossalChat/tests/test_data/chat_template/deepseek-ai_DeepSeek-V2-Lite.json b/applications/ColossalChat/tests/test_data/chat_template/deepseek-ai_DeepSeek-V2-Lite.json index 546e95144..147bcb395 100644 --- a/applications/ColossalChat/tests/test_data/chat_template/deepseek-ai_DeepSeek-V2-Lite.json +++ b/applications/ColossalChat/tests/test_data/chat_template/deepseek-ai_DeepSeek-V2-Lite.json @@ -578,4 +578,4 @@ ], "seq_length": 284, "seq_category": "None" -} \ No newline at end of file +} diff --git a/applications/ColossalChat/tests/test_data/chat_template/microsoft_phi-2.json b/applications/ColossalChat/tests/test_data/chat_template/microsoft_phi-2.json index f43ab7f4c..96d62a26a 100644 --- a/applications/ColossalChat/tests/test_data/chat_template/microsoft_phi-2.json +++ b/applications/ColossalChat/tests/test_data/chat_template/microsoft_phi-2.json @@ -2006,4 +2006,4 @@ ], "seq_length": 998, "seq_category": "None" -} \ No newline at end of file +} diff --git a/applications/ColossalChat/tests/test_data/chat_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json b/applications/ColossalChat/tests/test_data/chat_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json index f1979eb52..3849c7438 100644 --- a/applications/ColossalChat/tests/test_data/chat_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json +++ b/applications/ColossalChat/tests/test_data/chat_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json @@ -916,4 +916,4 @@ ], "seq_length": 453, "seq_category": "None" -} \ No newline at end of file +} From b8b5cacf383deabc27fd36e37c0364ad49fae6fc Mon Sep 17 00:00:00 2001 From: YeAnbang Date: Wed, 29 May 2024 00:57:32 +0000 Subject: [PATCH 08/19] fix transformers version --- applications/ColossalChat/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/ColossalChat/requirements.txt b/applications/ColossalChat/requirements.txt index 3ad29e6e1..82586646c 100755 --- a/applications/ColossalChat/requirements.txt +++ b/applications/ColossalChat/requirements.txt @@ -1,4 +1,4 @@ -transformers>=4.37.0 +transformers>=4.36.2 tqdm datasets loralib From 62eb28b929b77c086b2c10eb49ac8fe4645efe1f Mon Sep 17 00:00:00 2001 From: YeAnbang Date: Wed, 29 May 2024 01:45:58 +0000 Subject: [PATCH 09/19] remove duplicated test --- .../examples/training_scripts/train_rm.py | 3 +- .../ColossalChat/tests/test_chat_template.py | 42 - .../chat_template/01-ai_Yi-1.5-9B-Chat.json | 585 ----- .../test_data/chat_template/01-ai_Yi-34B.json | 607 ----- .../chat_template/Qwen_Qwen-7B-Chat.json | 603 ----- .../chat_template/THUDM_chatglm2-6b.json | 715 ------ .../chat_template/THUDM_chatglm3-6b.json | 585 ----- .../baichuan-inc_Baichuan2-13B-Chat.json | 697 ------ .../deepseek-ai_DeepSeek-V2-Lite.json | 581 ----- .../chat_template/microsoft_phi-2.json | 2009 ----------------- .../mistralai_Mixtral-8x7B-Instruct-v0.1.json | 919 -------- 11 files changed, 1 insertion(+), 7345 deletions(-) delete mode 100644 applications/ColossalChat/tests/test_chat_template.py delete mode 100644 applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-1.5-9B-Chat.json delete mode 100644 applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-34B.json delete mode 100644 applications/ColossalChat/tests/test_data/chat_template/Qwen_Qwen-7B-Chat.json delete mode 100644 applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm2-6b.json delete mode 100644 applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm3-6b.json delete mode 100644 applications/ColossalChat/tests/test_data/chat_template/baichuan-inc_Baichuan2-13B-Chat.json delete mode 100644 applications/ColossalChat/tests/test_data/chat_template/deepseek-ai_DeepSeek-V2-Lite.json delete mode 100644 applications/ColossalChat/tests/test_data/chat_template/microsoft_phi-2.json delete mode 100644 applications/ColossalChat/tests/test_data/chat_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json diff --git a/applications/ColossalChat/examples/training_scripts/train_rm.py b/applications/ColossalChat/examples/training_scripts/train_rm.py index d42291802..1fc938bd7 100755 --- a/applications/ColossalChat/examples/training_scripts/train_rm.py +++ b/applications/ColossalChat/examples/training_scripts/train_rm.py @@ -15,7 +15,7 @@ from coati.dataset import ( from coati.models import LogExpLoss, LogSigLoss, RewardModel, convert_to_lora_module from coati.trainer import RewardModelTrainer from coati.utils import load_checkpoint -from transformers import AutoConfig, AutoTokenizer +from transformers import AutoTokenizer import colossalai from colossalai.booster import Booster @@ -56,7 +56,6 @@ def train(args): ) coordinator.print_on_master(msg="Flash-attention enabled successfully") else: - AutoConfig.from_pretrained(args.pretrain) model = RewardModel( args.pretrain, ) diff --git a/applications/ColossalChat/tests/test_chat_template.py b/applications/ColossalChat/tests/test_chat_template.py deleted file mode 100644 index 0df13c066..000000000 --- a/applications/ColossalChat/tests/test_chat_template.py +++ /dev/null @@ -1,42 +0,0 @@ -import json -import os - -from coati.dataset import setup_conversation_template -from coati.dataset.tokenization_utils import supervised_tokenize_sft -from transformers import AutoTokenizer - -model_data_mapping = { - "THUDM/chatglm2-6b": "THUDM_chatglm2-6b.json", - "THUDM/chatglm3-6b": "THUDM_chatglm3-6b.json", - "baichuan-inc/Baichuan2-13B-Chat": "baichuan-inc_Baichuan2-13B-Chat.json", - "01-ai/Yi-1.5-9B-Chat": "01-ai_Yi-1.5-9B-Chat.json", - "01-ai/Yi-34B": "01-ai_Yi-34B.json", - "deepseek-ai/DeepSeek-V2-Lite": "deepseek-ai_DeepSeek-V2-Lite.json", - "microsoft/phi-2": "microsoft_phi-2.json", - "mistralai/Mixtral-8x7B-Instruct-v0.1": "mistralai_Mixtral-8x7B-Instruct-v0.1.json", -} -chat_template_config_path = "./config/conversation_template" - - -def test_tokenization_sft(): - for model in model_data_mapping: - print(f"#############{model}#############") - conversation_template_config = os.path.join(chat_template_config_path, model_data_mapping[model]) - messages = [ - {"from": "human", "content": "What are the three primary colors?"}, - {"from": "assistant", "content": "The three primary colors are red, blue, and yellow."}, - {"from": "human", "content": "解释个人电脑和服务器之间的区别。"}, - { - "from": "assistant", - "content": "个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。", - }, - ] - chat_template_config = json.load(open(conversation_template_config, "r", encoding="utf8")) - tokenizer = AutoTokenizer.from_pretrained(model, use_fast=False, trust_remote_code=True) - conversation_template = setup_conversation_template( - tokenizer, chat_template_config=chat_template_config, save_path=conversation_template_config - ) - - output = supervised_tokenize_sft({"messages": messages}, tokenizer, conversation_template) - with open(f"./tests/test_data/chat_template/{model_data_mapping[model]}", "r", encoding="utf8") as f: - assert json.dumps(json.load(f)) == json.dumps(output), f"model: {model} failed" diff --git a/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-1.5-9B-Chat.json b/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-1.5-9B-Chat.json deleted file mode 100644 index c5335fb18..000000000 --- a/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-1.5-9B-Chat.json +++ /dev/null @@ -1,585 +0,0 @@ -{ - "input_ids": [ - 1, - 59603, - 9334, - 1397, - 562, - 13310, - 2756, - 597, - 663, - 15874, - 10357, - 14135, - 98, - 707, - 14135, - 3641, - 6901, - 97, - 7283, - 97, - 597, - 31081, - 8476, - 592, - 567, - 2756, - 59610, - 59575, - 3275, - 98, - 144, - 144, - 6, - 3903, - 144, - 5697, - 678, - 567, - 1604, - 5789, - 7590, - 100, - 7, - 144, - 6, - 765, - 13611, - 144, - 1263, - 1604, - 5789, - 7590, - 678, - 2894, - 97, - 5083, - 97, - 597, - 10744, - 98, - 7, - 144, - 6, - 3903, - 144, - 7714, - 2897, - 11491, - 59652, - 17504, - 7125, - 13189, - 102, - 7, - 144, - 6, - 765, - 13611, - 144, - 2897, - 11491, - 59652, - 17504, - 59626, - 12295, - 2618, - 24768, - 12780, - 2644, - 101, - 6774, - 10495, - 13189, - 5505, - 23337, - 105, - 17713, - 9217, - 59652, - 9176, - 102, - 59568, - 2897, - 11491, - 101, - 60604, - 59867, - 60084, - 60160, - 101, - 29874, - 2897, - 2253, - 59732, - 23806, - 12780, - 102, - 6774, - 8224, - 4983, - 7304, - 5973, - 105, - 11152, - 44353, - 101, - 1229, - 7252, - 33282, - 32371, - 59652, - 5186, - 102, - 2897, - 11491, - 59599, - 17713, - 9217, - 39485, - 4245, - 3600, - 9217, - 59670, - 23806, - 101, - 3438, - 6985, - 2749, - 2897, - 4195, - 1540, - 23525, - 102, - 59568, - 59732, - 17504, - 15703, - 6748, - 8262, - 4576, - 17107, - 59732, - 23806, - 12780, - 2644, - 101, - 6774, - 8224, - 4983, - 59648, - 4576, - 2479, - 4207, - 4014, - 1893, - 101, - 59738, - 8276, - 105, - 5601, - 24111, - 59652, - 6280, - 18192, - 59748, - 102, - 17504, - 8224, - 1867, - 57898, - 59599, - 17713, - 9217, - 101, - 4502, - 1229, - 17456, - 59719, - 38298, - 59652, - 59509, - 7252, - 102, - 3574, - 17504, - 1867, - 3392, - 8262, - 28830, - 15595, - 101, - 6774, - 8224, - 18802, - 59691, - 60326, - 25829, - 105, - 59647, - 22981, - 25145, - 24724, - 22981, - 43452, - 11553, - 60101, - 101, - 59659, - 3206, - 13890, - 7252, - 7042, - 59652, - 26815, - 102, - 59568, - 20237, - 101, - 2897, - 11491, - 59652, - 17504, - 7125, - 2461, - 13189, - 5505, - 30281, - 23337, - 105, - 17713, - 9217, - 59652, - 9176, - 102, - 2897, - 11491, - 4983, - 2897, - 2253, - 101, - 59732, - 17504, - 4983, - 3392, - 8262, - 28830, - 15595, - 102, - 1893, - 12507, - 17713, - 9217, - 8224, - 59806, - 2897, - 11491, - 16549, - 101, - 59659, - 5731, - 13890, - 9176, - 59652, - 26815, - 102, - 7 - ], - "labels": [ - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - 1263, - 1604, - 5789, - 7590, - 678, - 2894, - 97, - 5083, - 97, - 597, - 10744, - 98, - 7, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - 2897, - 11491, - 59652, - 17504, - 59626, - 12295, - 2618, - 24768, - 12780, - 2644, - 101, - 6774, - 10495, - 13189, - 5505, - 23337, - 105, - 17713, - 9217, - 59652, - 9176, - 102, - 59568, - 2897, - 11491, - 101, - 60604, - 59867, - 60084, - 60160, - 101, - 29874, - 2897, - 2253, - 59732, - 23806, - 12780, - 102, - 6774, - 8224, - 4983, - 7304, - 5973, - 105, - 11152, - 44353, - 101, - 1229, - 7252, - 33282, - 32371, - 59652, - 5186, - 102, - 2897, - 11491, - 59599, - 17713, - 9217, - 39485, - 4245, - 3600, - 9217, - 59670, - 23806, - 101, - 3438, - 6985, - 2749, - 2897, - 4195, - 1540, - 23525, - 102, - 59568, - 59732, - 17504, - 15703, - 6748, - 8262, - 4576, - 17107, - 59732, - 23806, - 12780, - 2644, - 101, - 6774, - 8224, - 4983, - 59648, - 4576, - 2479, - 4207, - 4014, - 1893, - 101, - 59738, - 8276, - 105, - 5601, - 24111, - 59652, - 6280, - 18192, - 59748, - 102, - 17504, - 8224, - 1867, - 57898, - 59599, - 17713, - 9217, - 101, - 4502, - 1229, - 17456, - 59719, - 38298, - 59652, - 59509, - 7252, - 102, - 3574, - 17504, - 1867, - 3392, - 8262, - 28830, - 15595, - 101, - 6774, - 8224, - 18802, - 59691, - 60326, - 25829, - 105, - 59647, - 22981, - 25145, - 24724, - 22981, - 43452, - 11553, - 60101, - 101, - 59659, - 3206, - 13890, - 7252, - 7042, - 59652, - 26815, - 102, - 59568, - 20237, - 101, - 2897, - 11491, - 59652, - 17504, - 7125, - 2461, - 13189, - 5505, - 30281, - 23337, - 105, - 17713, - 9217, - 59652, - 9176, - 102, - 2897, - 11491, - 4983, - 2897, - 2253, - 101, - 59732, - 17504, - 4983, - 3392, - 8262, - 28830, - 15595, - 102, - 1893, - 12507, - 17713, - 9217, - 8224, - 59806, - 2897, - 11491, - 16549, - 101, - 59659, - 5731, - 13890, - 9176, - 59652, - 26815, - 102, - 7 - ], - "inputs_decode": "<|startoftext|> A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n<|im_start|>user\nWhat are the three primary colors?<|im_end|> \n<|im_start|>assistant\nThe three primary colors are red, blue, and yellow.<|im_end|> \n<|im_start|>user\n解释个人电脑和服务器之间的区别。<|im_end|> \n<|im_start|>assistant\n个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|>", - "labels_decode": [ - " The three primary colors are red, blue, and yellow.<|im_end|>", - " 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|>" - ], - "seq_length": 286, - "seq_category": "None" -} diff --git a/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-34B.json b/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-34B.json deleted file mode 100644 index 0284c2cea..000000000 --- a/applications/ColossalChat/tests/test_data/chat_template/01-ai_Yi-34B.json +++ /dev/null @@ -1,607 +0,0 @@ -{ - "input_ids": [ - 1, - 59653, - 34448, - 59651, - 7488, - 55701, - 4422, - 144, - 59603, - 9334, - 1397, - 562, - 13310, - 2756, - 597, - 663, - 15874, - 10357, - 14135, - 98, - 707, - 14135, - 3641, - 6901, - 97, - 7283, - 97, - 597, - 31081, - 8476, - 592, - 567, - 2756, - 59610, - 59575, - 3275, - 98, - 144, - 144, - 144, - 59666, - 1359, - 55701, - 4422, - 144, - 144, - 5697, - 678, - 567, - 1604, - 5789, - 7590, - 100, - 1273, - 59598, - 34448, - 59651, - 707, - 1604, - 5789, - 7590, - 678, - 2894, - 97, - 5083, - 97, - 597, - 10744, - 98, - 59568, - 2, - 1, - 59653, - 34448, - 59651, - 59568, - 7714, - 2897, - 11491, - 59652, - 17504, - 7125, - 13189, - 102, - 1273, - 59598, - 34448, - 59651, - 59568, - 2897, - 11491, - 59652, - 17504, - 59626, - 12295, - 2618, - 24768, - 12780, - 2644, - 101, - 6774, - 10495, - 13189, - 5505, - 23337, - 105, - 17713, - 9217, - 59652, - 9176, - 102, - 59568, - 2897, - 11491, - 101, - 60604, - 59867, - 60084, - 60160, - 101, - 29874, - 2897, - 2253, - 59732, - 23806, - 12780, - 102, - 6774, - 8224, - 4983, - 7304, - 5973, - 105, - 11152, - 44353, - 101, - 1229, - 7252, - 33282, - 32371, - 59652, - 5186, - 102, - 2897, - 11491, - 59599, - 17713, - 9217, - 39485, - 4245, - 3600, - 9217, - 59670, - 23806, - 101, - 3438, - 6985, - 2749, - 2897, - 4195, - 1540, - 23525, - 102, - 59568, - 59732, - 17504, - 15703, - 6748, - 8262, - 4576, - 17107, - 59732, - 23806, - 12780, - 2644, - 101, - 6774, - 8224, - 4983, - 59648, - 4576, - 2479, - 4207, - 4014, - 1893, - 101, - 59738, - 8276, - 105, - 5601, - 24111, - 59652, - 6280, - 18192, - 59748, - 102, - 17504, - 8224, - 1867, - 57898, - 59599, - 17713, - 9217, - 101, - 4502, - 1229, - 17456, - 59719, - 38298, - 59652, - 59509, - 7252, - 102, - 3574, - 17504, - 1867, - 3392, - 8262, - 28830, - 15595, - 101, - 6774, - 8224, - 18802, - 59691, - 60326, - 25829, - 105, - 59647, - 22981, - 25145, - 24724, - 22981, - 43452, - 11553, - 60101, - 101, - 59659, - 3206, - 13890, - 7252, - 7042, - 59652, - 26815, - 102, - 59568, - 20237, - 101, - 2897, - 11491, - 59652, - 17504, - 7125, - 2461, - 13189, - 5505, - 30281, - 23337, - 105, - 17713, - 9217, - 59652, - 9176, - 102, - 2897, - 11491, - 4983, - 2897, - 2253, - 101, - 59732, - 17504, - 4983, - 3392, - 8262, - 28830, - 15595, - 102, - 1893, - 12507, - 17713, - 9217, - 8224, - 59806, - 2897, - 11491, - 16549, - 101, - 59659, - 5731, - 13890, - 9176, - 59652, - 26815, - 102, - 59568, - 2 - ], - "labels": [ - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - 707, - 1604, - 5789, - 7590, - 678, - 2894, - 97, - 5083, - 97, - 597, - 10744, - 98, - 59568, - 2, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - 59568, - 2897, - 11491, - 59652, - 17504, - 59626, - 12295, - 2618, - 24768, - 12780, - 2644, - 101, - 6774, - 10495, - 13189, - 5505, - 23337, - 105, - 17713, - 9217, - 59652, - 9176, - 102, - 59568, - 2897, - 11491, - 101, - 60604, - 59867, - 60084, - 60160, - 101, - 29874, - 2897, - 2253, - 59732, - 23806, - 12780, - 102, - 6774, - 8224, - 4983, - 7304, - 5973, - 105, - 11152, - 44353, - 101, - 1229, - 7252, - 33282, - 32371, - 59652, - 5186, - 102, - 2897, - 11491, - 59599, - 17713, - 9217, - 39485, - 4245, - 3600, - 9217, - 59670, - 23806, - 101, - 3438, - 6985, - 2749, - 2897, - 4195, - 1540, - 23525, - 102, - 59568, - 59732, - 17504, - 15703, - 6748, - 8262, - 4576, - 17107, - 59732, - 23806, - 12780, - 2644, - 101, - 6774, - 8224, - 4983, - 59648, - 4576, - 2479, - 4207, - 4014, - 1893, - 101, - 59738, - 8276, - 105, - 5601, - 24111, - 59652, - 6280, - 18192, - 59748, - 102, - 17504, - 8224, - 1867, - 57898, - 59599, - 17713, - 9217, - 101, - 4502, - 1229, - 17456, - 59719, - 38298, - 59652, - 59509, - 7252, - 102, - 3574, - 17504, - 1867, - 3392, - 8262, - 28830, - 15595, - 101, - 6774, - 8224, - 18802, - 59691, - 60326, - 25829, - 105, - 59647, - 22981, - 25145, - 24724, - 22981, - 43452, - 11553, - 60101, - 101, - 59659, - 3206, - 13890, - 7252, - 7042, - 59652, - 26815, - 102, - 59568, - 20237, - 101, - 2897, - 11491, - 59652, - 17504, - 7125, - 2461, - 13189, - 5505, - 30281, - 23337, - 105, - 17713, - 9217, - 59652, - 9176, - 102, - 2897, - 11491, - 4983, - 2897, - 2253, - 101, - 59732, - 17504, - 4983, - 3392, - 8262, - 28830, - 15595, - 102, - 1893, - 12507, - 17713, - 9217, - 8224, - 59806, - 2897, - 11491, - 16549, - 101, - 59659, - 5731, - 13890, - 9176, - 59652, - 26815, - 102, - 59568, - 2 - ], - "inputs_decode": "<|startoftext|> [INST] <>\nA chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n\n<>\n\nWhat are the three primary colors? [/INST] The three primary colors are red, blue, and yellow. <|endoftext|><|startoftext|> [INST] 解释个人电脑和服务器之间的区别。 [/INST] 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。 <|endoftext|>", - "labels_decode": [ - " The three primary colors are red, blue, and yellow. <|endoftext|>", - " 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。 <|endoftext|>" - ], - "seq_length": 297, - "seq_category": "None" -} diff --git a/applications/ColossalChat/tests/test_data/chat_template/Qwen_Qwen-7B-Chat.json b/applications/ColossalChat/tests/test_data/chat_template/Qwen_Qwen-7B-Chat.json deleted file mode 100644 index 0b291a071..000000000 --- a/applications/ColossalChat/tests/test_data/chat_template/Qwen_Qwen-7B-Chat.json +++ /dev/null @@ -1,603 +0,0 @@ -{ - "input_ids": [ - 151644, - 8948, - 198, - 32, - 6236, - 1948, - 264, - 22208, - 3738, - 323, - 458, - 20443, - 11229, - 17847, - 13, - 576, - 17847, - 6696, - 10950, - 11, - 11682, - 11, - 323, - 47787, - 11253, - 311, - 279, - 3738, - 594, - 4755, - 382, - 151645, - 198, - 151644, - 872, - 198, - 3838, - 525, - 279, - 2326, - 6028, - 7987, - 30, - 151645, - 198, - 151644, - 77091, - 198, - 785, - 2326, - 6028, - 7987, - 525, - 2518, - 11, - 6303, - 11, - 323, - 13753, - 13, - 151645, - 198, - 151644, - 872, - 198, - 104136, - 99605, - 104145, - 33108, - 89047, - 104186, - 102665, - 1773, - 151645, - 198, - 151644, - 77091, - 198, - 99605, - 104145, - 33108, - 89047, - 20412, - 101441, - 99604, - 109963, - 104564, - 72448, - 3837, - 104017, - 104396, - 102665, - 101321, - 105795, - 5373, - 105433, - 85767, - 33108, - 102111, - 1773, - 220, - 99605, - 104145, - 3837, - 99846, - 13072, - 90663, - 64559, - 3837, - 20412, - 17714, - 99605, - 37029, - 68536, - 70500, - 9370, - 104564, - 1773, - 104017, - 102119, - 100751, - 101254, - 104066, - 5373, - 100415, - 33108, - 100134, - 3837, - 73670, - 104001, - 100646, - 99200, - 100535, - 113384, - 33108, - 99329, - 1773, - 99605, - 104145, - 9370, - 105433, - 85767, - 111071, - 101892, - 100142, - 85767, - 36407, - 70500, - 9370, - 3837, - 100632, - 104047, - 100345, - 99605, - 100354, - 71817, - 104790, - 1773, - 8908, - 222, - 234, - 89047, - 104802, - 101929, - 100722, - 20002, - 104378, - 68536, - 70500, - 9370, - 104564, - 72448, - 3837, - 104017, - 102119, - 100751, - 17714, - 110782, - 100646, - 71356, - 47874, - 3837, - 29524, - 100010, - 5373, - 116617, - 33108, - 26898, - 107468, - 49567, - 1773, - 89047, - 102119, - 85106, - 113313, - 9370, - 105433, - 85767, - 90395, - 100136, - 73670, - 105581, - 44636, - 118878, - 33108, - 102612, - 9370, - 104001, - 1773, - 101887, - 89047, - 85106, - 100143, - 100722, - 107494, - 104925, - 3837, - 104017, - 102119, - 102578, - 42140, - 71137, - 111249, - 5373, - 26288, - 106656, - 111390, - 33108, - 26288, - 106656, - 114897, - 102474, - 31548, - 3837, - 23031, - 100627, - 105743, - 104001, - 101149, - 33108, - 108239, - 1773, - 90476, - 119, - 53930, - 3837, - 99605, - 104145, - 33108, - 89047, - 104186, - 99558, - 102665, - 101321, - 104017, - 9370, - 105795, - 5373, - 105433, - 85767, - 33108, - 102111, - 1773, - 99605, - 104145, - 100751, - 99605, - 37029, - 3837, - 68536, - 89047, - 100751, - 100143, - 100722, - 107494, - 104925, - 1773, - 89047, - 9370, - 105433, - 85767, - 102119, - 56006, - 99605, - 104145, - 105377, - 3837, - 23031, - 101907, - 105743, - 102111, - 33108, - 108239, - 1773, - 151645 - ], - "labels": [ - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - 785, - 2326, - 6028, - 7987, - 525, - 2518, - 11, - 6303, - 11, - 323, - 13753, - 13, - 151645, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - 99605, - 104145, - 33108, - 89047, - 20412, - 101441, - 99604, - 109963, - 104564, - 72448, - 3837, - 104017, - 104396, - 102665, - 101321, - 105795, - 5373, - 105433, - 85767, - 33108, - 102111, - 1773, - 220, - 99605, - 104145, - 3837, - 99846, - 13072, - 90663, - 64559, - 3837, - 20412, - 17714, - 99605, - 37029, - 68536, - 70500, - 9370, - 104564, - 1773, - 104017, - 102119, - 100751, - 101254, - 104066, - 5373, - 100415, - 33108, - 100134, - 3837, - 73670, - 104001, - 100646, - 99200, - 100535, - 113384, - 33108, - 99329, - 1773, - 99605, - 104145, - 9370, - 105433, - 85767, - 111071, - 101892, - 100142, - 85767, - 36407, - 70500, - 9370, - 3837, - 100632, - 104047, - 100345, - 99605, - 100354, - 71817, - 104790, - 1773, - 8908, - 222, - 234, - 89047, - 104802, - 101929, - 100722, - 20002, - 104378, - 68536, - 70500, - 9370, - 104564, - 72448, - 3837, - 104017, - 102119, - 100751, - 17714, - 110782, - 100646, - 71356, - 47874, - 3837, - 29524, - 100010, - 5373, - 116617, - 33108, - 26898, - 107468, - 49567, - 1773, - 89047, - 102119, - 85106, - 113313, - 9370, - 105433, - 85767, - 90395, - 100136, - 73670, - 105581, - 44636, - 118878, - 33108, - 102612, - 9370, - 104001, - 1773, - 101887, - 89047, - 85106, - 100143, - 100722, - 107494, - 104925, - 3837, - 104017, - 102119, - 102578, - 42140, - 71137, - 111249, - 5373, - 26288, - 106656, - 111390, - 33108, - 26288, - 106656, - 114897, - 102474, - 31548, - 3837, - 23031, - 100627, - 105743, - 104001, - 101149, - 33108, - 108239, - 1773, - 90476, - 119, - 53930, - 3837, - 99605, - 104145, - 33108, - 89047, - 104186, - 99558, - 102665, - 101321, - 104017, - 9370, - 105795, - 5373, - 105433, - 85767, - 33108, - 102111, - 1773, - 99605, - 104145, - 100751, - 99605, - 37029, - 3837, - 68536, - 89047, - 100751, - 100143, - 100722, - 107494, - 104925, - 1773, - 89047, - 9370, - 105433, - 85767, - 102119, - 56006, - 99605, - 104145, - 105377, - 3837, - 23031, - 101907, - 105743, - 102111, - 33108, - 108239, - 1773, - 151645 - ], - "inputs_decode": "<|im_start|>system\nA chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n<|im_end|>\n<|im_start|>user\nWhat are the three primary colors?<|im_end|>\n<|im_start|>assistant\nThe three primary colors are red, blue, and yellow.<|im_end|>\n<|im_start|>user\n解释个人电脑和服务器之间的区别。<|im_end|>\n<|im_start|>assistant\n个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|>", - "labels_decode": [ - "The three primary colors are red, blue, and yellow.<|im_end|>", - "个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|>" - ], - "seq_length": 295, - "seq_category": "None" -} diff --git a/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm2-6b.json b/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm2-6b.json deleted file mode 100644 index fe3559266..000000000 --- a/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm2-6b.json +++ /dev/null @@ -1,715 +0,0 @@ -{ - "input_ids": [ - 906, - 31007, - 326, - 30962, - 6631, - 31007, - 30994, - 13361, - 13, - 30938, - 8911, - 1074, - 260, - 10976, - 1869, - 293, - 284, - 12060, - 7151, - 9319, - 30930, - 353, - 9319, - 3510, - 6483, - 30932, - 6374, - 30932, - 293, - 25712, - 7115, - 289, - 267, - 1869, - 30953, - 30917, - 2554, - 30930, - 13, - 13, - 31002, - 31007, - 326, - 30962, - 437, - 31007, - 30994, - 13, - 31002, - 31007, - 326, - 30962, - 6631, - 31007, - 30994, - 4865, - 13, - 1266, - 383, - 267, - 1194, - 4390, - 7129, - 30987, - 906, - 31007, - 326, - 30962, - 437, - 31007, - 30994, - 13, - 31002, - 31007, - 326, - 30962, - 6631, - 31007, - 30994, - 530, - 18971, - 13, - 353, - 1194, - 4390, - 7129, - 383, - 2603, - 30932, - 4610, - 30932, - 293, - 8362, - 30930, - 31002, - 31007, - 326, - 30962, - 437, - 31007, - 30994, - 30910, - 13, - 31002, - 31007, - 326, - 30962, - 6631, - 31007, - 30994, - 4865, - 13, - 30910, - 32929, - 31745, - 34032, - 37154, - 55083, - 32695, - 34213, - 31155, - 906, - 31007, - 326, - 30962, - 437, - 31007, - 30994, - 13, - 31002, - 31007, - 326, - 30962, - 6631, - 31007, - 30994, - 530, - 18971, - 13, - 30910, - 31745, - 34032, - 37154, - 55083, - 54532, - 33701, - 31723, - 39141, - 33606, - 31739, - 31123, - 32542, - 33248, - 34213, - 33260, - 35687, - 31201, - 36073, - 33339, - 54542, - 33116, - 31155, - 30910, - 31745, - 34032, - 31123, - 55502, - 54653, - 54872, - 54923, - 31123, - 38391, - 31745, - 31695, - 54617, - 37538, - 33606, - 31155, - 32542, - 32955, - 32419, - 32432, - 32249, - 31201, - 32645, - 44505, - 31123, - 31628, - 32557, - 41054, - 43569, - 54542, - 32033, - 31155, - 31745, - 34032, - 54530, - 36073, - 33339, - 47907, - 32001, - 31858, - 33339, - 54556, - 37538, - 31123, - 31925, - 32591, - 31793, - 31745, - 31987, - 31636, - 36058, - 31155, - 43833, - 38107, - 35231, - 32454, - 32325, - 32053, - 35299, - 54617, - 37538, - 33606, - 31739, - 31123, - 32542, - 32955, - 32419, - 54541, - 49193, - 31986, - 31863, - 31645, - 31123, - 54627, - 32438, - 31201, - 48747, - 54542, - 32410, - 38520, - 54609, - 31155, - 38107, - 32955, - 31665, - 46294, - 54530, - 36073, - 33339, - 31123, - 32187, - 31628, - 35757, - 54589, - 54376, - 54542, - 53144, - 32557, - 31155, - 31949, - 38107, - 31665, - 31818, - 32325, - 39195, - 33967, - 31123, - 32542, - 32955, - 34881, - 54573, - 55110, - 39727, - 31201, - 54539, - 36608, - 40538, - 37251, - 36608, - 52898, - 34861, - 55083, - 31123, - 54548, - 31803, - 34650, - 32557, - 32615, - 54542, - 39941, - 31155, - 30910, - 37169, - 31123, - 31745, - 34032, - 37154, - 55083, - 32695, - 31703, - 34213, - 33260, - 41215, - 35687, - 31201, - 36073, - 33339, - 54542, - 33116, - 31155, - 31745, - 34032, - 32419, - 31745, - 31695, - 31123, - 54617, - 38107, - 32419, - 31818, - 32325, - 39195, - 33967, - 31155, - 31645, - 35949, - 36073, - 33339, - 32955, - 54703, - 31745, - 34032, - 34732, - 31123, - 54548, - 32444, - 34650, - 33116, - 54542, - 39941, - 31155, - 31002, - 31007, - 326, - 30962, - 437, - 31007, - 30994, - 2 - ], - "labels": [ - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - 353, - 1194, - 4390, - 7129, - 383, - 2603, - 30932, - 4610, - 30932, - 293, - 8362, - 30930, - 31002, - 31007, - 326, - 30962, - 437, - 31007, - 30994, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - 30910, - 31745, - 34032, - 37154, - 55083, - 54532, - 33701, - 31723, - 39141, - 33606, - 31739, - 31123, - 32542, - 33248, - 34213, - 33260, - 35687, - 31201, - 36073, - 33339, - 54542, - 33116, - 31155, - 30910, - 31745, - 34032, - 31123, - 55502, - 54653, - 54872, - 54923, - 31123, - 38391, - 31745, - 31695, - 54617, - 37538, - 33606, - 31155, - 32542, - 32955, - 32419, - 32432, - 32249, - 31201, - 32645, - 44505, - 31123, - 31628, - 32557, - 41054, - 43569, - 54542, - 32033, - 31155, - 31745, - 34032, - 54530, - 36073, - 33339, - 47907, - 32001, - 31858, - 33339, - 54556, - 37538, - 31123, - 31925, - 32591, - 31793, - 31745, - 31987, - 31636, - 36058, - 31155, - 43833, - 38107, - 35231, - 32454, - 32325, - 32053, - 35299, - 54617, - 37538, - 33606, - 31739, - 31123, - 32542, - 32955, - 32419, - 54541, - 49193, - 31986, - 31863, - 31645, - 31123, - 54627, - 32438, - 31201, - 48747, - 54542, - 32410, - 38520, - 54609, - 31155, - 38107, - 32955, - 31665, - 46294, - 54530, - 36073, - 33339, - 31123, - 32187, - 31628, - 35757, - 54589, - 54376, - 54542, - 53144, - 32557, - 31155, - 31949, - 38107, - 31665, - 31818, - 32325, - 39195, - 33967, - 31123, - 32542, - 32955, - 34881, - 54573, - 55110, - 39727, - 31201, - 54539, - 36608, - 40538, - 37251, - 36608, - 52898, - 34861, - 55083, - 31123, - 54548, - 31803, - 34650, - 32557, - 32615, - 54542, - 39941, - 31155, - 30910, - 37169, - 31123, - 31745, - 34032, - 37154, - 55083, - 32695, - 31703, - 34213, - 33260, - 41215, - 35687, - 31201, - 36073, - 33339, - 54542, - 33116, - 31155, - 31745, - 34032, - 32419, - 31745, - 31695, - 31123, - 54617, - 38107, - 32419, - 31818, - 32325, - 39195, - 33967, - 31155, - 31645, - 35949, - 36073, - 33339, - 32955, - 54703, - 31745, - 34032, - 34732, - 31123, - 54548, - 32444, - 34650, - 33116, - 54542, - 39941, - 31155, - 31002, - 31007, - 326, - 30962, - 437, - 31007, - 30994, - 2 - ], - "inputs_decode": "<|im_start|>system\nA chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n<|im_end|>\n<|im_start|>user\n What are the three primary colors? <|im_end|>\n<|im_start|>assistant\n The three primary colors are red, blue, and yellow.<|im_end|> \n<|im_start|>user\n 解释个人电脑和服务器之间的区别。 <|im_end|>\n<|im_start|>assistant\n 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|>", - "labels_decode": [ - "The three primary colors are red, blue, and yellow.<|im_end|>", - "个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|>" - ], - "seq_length": 351, - "seq_category": "None" -} diff --git a/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm3-6b.json b/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm3-6b.json deleted file mode 100644 index 10b012fe0..000000000 --- a/applications/ColossalChat/tests/test_data/chat_template/THUDM_chatglm3-6b.json +++ /dev/null @@ -1,585 +0,0 @@ -{ - "input_ids": [ - 64790, - 64792, - 906, - 31007, - 13361, - 31007, - 30994, - 13, - 316, - 8911, - 1074, - 260, - 10976, - 1869, - 293, - 284, - 12060, - 7151, - 9319, - 30930, - 353, - 9319, - 3510, - 6483, - 30932, - 6374, - 30932, - 293, - 25712, - 7115, - 289, - 267, - 1869, - 30953, - 30917, - 2554, - 30930, - 13, - 13, - 64795, - 30910, - 13, - 265, - 5011, - 383, - 267, - 1194, - 4390, - 7129, - 30987, - 64796, - 30910, - 13, - 265, - 1036, - 1194, - 4390, - 7129, - 383, - 2603, - 30932, - 4610, - 30932, - 293, - 8362, - 30930, - 64795, - 30910, - 13, - 265, - 32929, - 31745, - 34032, - 37154, - 55083, - 32695, - 34213, - 31155, - 64796, - 30910, - 13, - 265, - 31745, - 34032, - 37154, - 55083, - 54532, - 33701, - 31723, - 39141, - 33606, - 31739, - 31123, - 32542, - 33248, - 34213, - 33260, - 35687, - 31201, - 36073, - 33339, - 54542, - 33116, - 31155, - 30910, - 31745, - 34032, - 31123, - 55502, - 54653, - 54872, - 54923, - 31123, - 38391, - 31745, - 31695, - 54617, - 37538, - 33606, - 31155, - 32542, - 32955, - 32419, - 32432, - 32249, - 31201, - 32645, - 44505, - 31123, - 31628, - 32557, - 41054, - 43569, - 54542, - 32033, - 31155, - 31745, - 34032, - 54530, - 36073, - 33339, - 47907, - 32001, - 31858, - 33339, - 54556, - 37538, - 31123, - 31925, - 32591, - 31793, - 31745, - 31987, - 31636, - 36058, - 31155, - 43833, - 38107, - 35231, - 32454, - 32325, - 32053, - 35299, - 54617, - 37538, - 33606, - 31739, - 31123, - 32542, - 32955, - 32419, - 54541, - 49193, - 31986, - 31863, - 31645, - 31123, - 54627, - 32438, - 31201, - 48747, - 54542, - 32410, - 38520, - 54609, - 31155, - 38107, - 32955, - 31665, - 46294, - 54530, - 36073, - 33339, - 31123, - 32187, - 31628, - 35757, - 54589, - 54376, - 54542, - 53144, - 32557, - 31155, - 31949, - 38107, - 31665, - 31818, - 32325, - 39195, - 33967, - 31123, - 32542, - 32955, - 34881, - 54573, - 55110, - 39727, - 31201, - 54539, - 36608, - 40538, - 37251, - 36608, - 52898, - 34861, - 55083, - 31123, - 54548, - 31803, - 34650, - 32557, - 32615, - 54542, - 39941, - 31155, - 30910, - 37169, - 31123, - 31745, - 34032, - 37154, - 55083, - 32695, - 31703, - 34213, - 33260, - 41215, - 35687, - 31201, - 36073, - 33339, - 54542, - 33116, - 31155, - 31745, - 34032, - 32419, - 31745, - 31695, - 31123, - 54617, - 38107, - 32419, - 31818, - 32325, - 39195, - 33967, - 31155, - 31645, - 35949, - 36073, - 33339, - 32955, - 54703, - 31745, - 34032, - 34732, - 31123, - 54548, - 32444, - 34650, - 33116, - 54542, - 39941, - 31155, - 2 - ], - "labels": [ - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - 265, - 1036, - 1194, - 4390, - 7129, - 383, - 2603, - 30932, - 4610, - 30932, - 293, - 8362, - 30930, - 64795, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - 265, - 31745, - 34032, - 37154, - 55083, - 54532, - 33701, - 31723, - 39141, - 33606, - 31739, - 31123, - 32542, - 33248, - 34213, - 33260, - 35687, - 31201, - 36073, - 33339, - 54542, - 33116, - 31155, - 30910, - 31745, - 34032, - 31123, - 55502, - 54653, - 54872, - 54923, - 31123, - 38391, - 31745, - 31695, - 54617, - 37538, - 33606, - 31155, - 32542, - 32955, - 32419, - 32432, - 32249, - 31201, - 32645, - 44505, - 31123, - 31628, - 32557, - 41054, - 43569, - 54542, - 32033, - 31155, - 31745, - 34032, - 54530, - 36073, - 33339, - 47907, - 32001, - 31858, - 33339, - 54556, - 37538, - 31123, - 31925, - 32591, - 31793, - 31745, - 31987, - 31636, - 36058, - 31155, - 43833, - 38107, - 35231, - 32454, - 32325, - 32053, - 35299, - 54617, - 37538, - 33606, - 31739, - 31123, - 32542, - 32955, - 32419, - 54541, - 49193, - 31986, - 31863, - 31645, - 31123, - 54627, - 32438, - 31201, - 48747, - 54542, - 32410, - 38520, - 54609, - 31155, - 38107, - 32955, - 31665, - 46294, - 54530, - 36073, - 33339, - 31123, - 32187, - 31628, - 35757, - 54589, - 54376, - 54542, - 53144, - 32557, - 31155, - 31949, - 38107, - 31665, - 31818, - 32325, - 39195, - 33967, - 31123, - 32542, - 32955, - 34881, - 54573, - 55110, - 39727, - 31201, - 54539, - 36608, - 40538, - 37251, - 36608, - 52898, - 34861, - 55083, - 31123, - 54548, - 31803, - 34650, - 32557, - 32615, - 54542, - 39941, - 31155, - 30910, - 37169, - 31123, - 31745, - 34032, - 37154, - 55083, - 32695, - 31703, - 34213, - 33260, - 41215, - 35687, - 31201, - 36073, - 33339, - 54542, - 33116, - 31155, - 31745, - 34032, - 32419, - 31745, - 31695, - 31123, - 54617, - 38107, - 32419, - 31818, - 32325, - 39195, - 33967, - 31155, - 31645, - 35949, - 36073, - 33339, - 32955, - 54703, - 31745, - 34032, - 34732, - 31123, - 54548, - 32444, - 34650, - 33116, - 54542, - 39941, - 31155, - 2 - ], - "inputs_decode": "[gMASK] sop <|system|>\n A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n <|user|> \n What are the three primary colors? <|assistant|> \n The three primary colors are red, blue, and yellow. <|user|> \n 解释个人电脑和服务器之间的区别。 <|assistant|> \n 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。", - "labels_decode": [ - " The three primary colors are red, blue, and yellow. <|user|>", - " 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。" - ], - "seq_length": 286, - "seq_category": "None" -} diff --git a/applications/ColossalChat/tests/test_data/chat_template/baichuan-inc_Baichuan2-13B-Chat.json b/applications/ColossalChat/tests/test_data/chat_template/baichuan-inc_Baichuan2-13B-Chat.json deleted file mode 100644 index 1db9df08b..000000000 --- a/applications/ColossalChat/tests/test_data/chat_template/baichuan-inc_Baichuan2-13B-Chat.json +++ /dev/null @@ -1,697 +0,0 @@ -{ - "input_ids": [ - 1, - 92655, - 92647, - 1418, - 92484, - 13387, - 92647, - 92574, - 24399, - 5, - 92343, - 15161, - 2357, - 1346, - 23815, - 3558, - 1377, - 1452, - 19649, - 11656, - 14002, - 72, - 1481, - 14002, - 6474, - 13629, - 92323, - 11144, - 92323, - 1377, - 70217, - 13514, - 1375, - 1352, - 3558, - 92404, - 92319, - 4852, - 72, - 5, - 5, - 92655, - 92647, - 1418, - 92484, - 1520, - 92647, - 92574, - 5, - 92655, - 92647, - 1418, - 92484, - 13387, - 92647, - 92574, - 8589, - 5, - 3167, - 1484, - 1352, - 2397, - 7721, - 12654, - 74, - 92655, - 92647, - 1418, - 92484, - 1520, - 92647, - 92574, - 5, - 92655, - 92647, - 1418, - 92484, - 13387, - 92647, - 92574, - 1613, - 10685, - 5, - 1524, - 2397, - 7721, - 12654, - 1484, - 5005, - 92323, - 8488, - 92323, - 1377, - 16149, - 72, - 92655, - 92647, - 1418, - 92484, - 1520, - 92647, - 92574, - 5, - 92655, - 92647, - 1418, - 92484, - 13387, - 92647, - 92574, - 8589, - 5, - 5987, - 2076, - 7283, - 18431, - 93107, - 5332, - 8592, - 66, - 92655, - 92647, - 1418, - 92484, - 1520, - 92647, - 92574, - 5, - 92655, - 92647, - 1418, - 92484, - 13387, - 92647, - 92574, - 1613, - 10685, - 5, - 2076, - 7283, - 18431, - 93107, - 92347, - 8653, - 2381, - 22152, - 9403, - 2274, - 65, - 20962, - 2231, - 8592, - 6795, - 13087, - 69, - 18512, - 7587, - 92385, - 8222, - 66, - 92311, - 2076, - 7283, - 65, - 52905, - 65, - 23044, - 2076, - 1964, - 92492, - 17274, - 9403, - 66, - 6085, - 6984, - 4349, - 4161, - 4588, - 69, - 5748, - 30443, - 65, - 1583, - 5155, - 24491, - 48901, - 92385, - 3872, - 66, - 2076, - 7283, - 92333, - 18512, - 7587, - 28068, - 2592, - 2417, - 7587, - 92393, - 17274, - 65, - 2776, - 4463, - 78704, - 3173, - 1697, - 9501, - 66, - 100178, - 31391, - 10551, - 4126, - 4121, - 3723, - 13169, - 92492, - 17274, - 9403, - 2274, - 65, - 6085, - 6984, - 4349, - 57325, - 2099, - 2936, - 2012, - 1760, - 65, - 92467, - 4516, - 69, - 36308, - 92385, - 4733, - 25092, - 92457, - 66, - 31391, - 6984, - 1836, - 49902, - 92333, - 18512, - 7587, - 65, - 3741, - 1583, - 11871, - 92434, - 55317, - 92385, - 41203, - 5155, - 66, - 3035, - 31391, - 1836, - 2590, - 4121, - 30881, - 17136, - 65, - 6085, - 6984, - 10040, - 92418, - 92888, - 40793, - 69, - 92366, - 18178, - 32629, - 18787, - 18178, - 66897, - 14685, - 93107, - 65, - 73411, - 12452, - 5155, - 82905, - 23304, - 66, - 92311, - 14748, - 65, - 2076, - 7283, - 18431, - 93107, - 5332, - 2231, - 8592, - 6795, - 20962, - 13087, - 69, - 18512, - 7587, - 92385, - 8222, - 66, - 2076, - 7283, - 4349, - 2076, - 1964, - 65, - 92492, - 31391, - 4349, - 2590, - 4121, - 30881, - 17136, - 66, - 1760, - 21050, - 18512, - 7587, - 6984, - 92596, - 2076, - 7283, - 10680, - 65, - 57310, - 12452, - 8222, - 92385, - 23304, - 66, - 92655, - 92647, - 1418, - 92484, - 1520, - 92647, - 92574, - 2 - ], - "labels": [ - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - 1524, - 2397, - 7721, - 12654, - 1484, - 5005, - 92323, - 8488, - 92323, - 1377, - 16149, - 72, - 92655, - 92647, - 1418, - 92484, - 1520, - 92647, - 92574, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - 2076, - 7283, - 18431, - 93107, - 92347, - 8653, - 2381, - 22152, - 9403, - 2274, - 65, - 20962, - 2231, - 8592, - 6795, - 13087, - 69, - 18512, - 7587, - 92385, - 8222, - 66, - 92311, - 2076, - 7283, - 65, - 52905, - 65, - 23044, - 2076, - 1964, - 92492, - 17274, - 9403, - 66, - 6085, - 6984, - 4349, - 4161, - 4588, - 69, - 5748, - 30443, - 65, - 1583, - 5155, - 24491, - 48901, - 92385, - 3872, - 66, - 2076, - 7283, - 92333, - 18512, - 7587, - 28068, - 2592, - 2417, - 7587, - 92393, - 17274, - 65, - 2776, - 4463, - 78704, - 3173, - 1697, - 9501, - 66, - 100178, - 31391, - 10551, - 4126, - 4121, - 3723, - 13169, - 92492, - 17274, - 9403, - 2274, - 65, - 6085, - 6984, - 4349, - 57325, - 2099, - 2936, - 2012, - 1760, - 65, - 92467, - 4516, - 69, - 36308, - 92385, - 4733, - 25092, - 92457, - 66, - 31391, - 6984, - 1836, - 49902, - 92333, - 18512, - 7587, - 65, - 3741, - 1583, - 11871, - 92434, - 55317, - 92385, - 41203, - 5155, - 66, - 3035, - 31391, - 1836, - 2590, - 4121, - 30881, - 17136, - 65, - 6085, - 6984, - 10040, - 92418, - 92888, - 40793, - 69, - 92366, - 18178, - 32629, - 18787, - 18178, - 66897, - 14685, - 93107, - 65, - 73411, - 12452, - 5155, - 82905, - 23304, - 66, - 92311, - 14748, - 65, - 2076, - 7283, - 18431, - 93107, - 5332, - 2231, - 8592, - 6795, - 20962, - 13087, - 69, - 18512, - 7587, - 92385, - 8222, - 66, - 2076, - 7283, - 4349, - 2076, - 1964, - 65, - 92492, - 31391, - 4349, - 2590, - 4121, - 30881, - 17136, - 66, - 1760, - 21050, - 18512, - 7587, - 6984, - 92596, - 2076, - 7283, - 10680, - 65, - 57310, - 12452, - 8222, - 92385, - 23304, - 66, - 92655, - 92647, - 1418, - 92484, - 1520, - 92647, - 92574, - 2 - ], - "inputs_decode": " <|im_start|>system\nA chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n<|im_end|>\n<|im_start|>user\nWhat are the three primary colors?<|im_end|>\n<|im_start|>assistant\nThe three primary colors are red, blue, and yellow.<|im_end|>\n<|im_start|>user\n解释个人电脑和服务器之间的区别。<|im_end|>\n<|im_start|>assistant\n个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|>", - "labels_decode": [ - "The three primary colors are red, blue, and yellow.<|im_end|>", - " 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|>" - ], - "seq_length": 342, - "seq_category": "None" -} diff --git a/applications/ColossalChat/tests/test_data/chat_template/deepseek-ai_DeepSeek-V2-Lite.json b/applications/ColossalChat/tests/test_data/chat_template/deepseek-ai_DeepSeek-V2-Lite.json deleted file mode 100644 index 147bcb395..000000000 --- a/applications/ColossalChat/tests/test_data/chat_template/deepseek-ai_DeepSeek-V2-Lite.json +++ /dev/null @@ -1,581 +0,0 @@ -{ - "input_ids": [ - 100000, - 32, - 12465, - 1439, - 245, - 13076, - 3807, - 285, - 274, - 18050, - 15141, - 20308, - 13, - 429, - 20308, - 4380, - 9394, - 11, - 9333, - 11, - 285, - 30513, - 9789, - 276, - 254, - 3807, - 6, - 82, - 4313, - 13, - 185, - 185, - 185, - 185, - 5726, - 25, - 2461, - 418, - 254, - 1853, - 6663, - 8247, - 30, - 185, - 185, - 77398, - 25, - 429, - 1853, - 6663, - 8247, - 418, - 3074, - 11, - 5501, - 11, - 285, - 10421, - 13, - 100001, - 5726, - 25, - 207, - 17882, - 6213, - 19462, - 50209, - 4625, - 17901, - 25628, - 398, - 185, - 185, - 77398, - 25, - 207, - 6213, - 19462, - 50209, - 4625, - 504, - 23807, - 5871, - 53947, - 33939, - 5804, - 19304, - 15047, - 24291, - 25628, - 18752, - 48548, - 537, - 34854, - 15477, - 885, - 16938, - 398, - 207, - 6213, - 19462, - 19304, - 8549, - 2217, - 4118, - 4800, - 19304, - 54533, - 6213, - 5118, - 1306, - 42753, - 33939, - 398, - 15047, - 18867, - 15055, - 16476, - 15982, - 537, - 15615, - 885, - 5782, - 19304, - 1876, - 17135, - 60574, - 98238, - 885, - 8340, - 398, - 6213, - 19462, - 337, - 34854, - 15477, - 72652, - 10263, - 7992, - 15477, - 913, - 42753, - 19304, - 6117, - 13742, - 6857, - 6213, - 9384, - 3421, - 31448, - 398, - 207, - 1306, - 59828, - 31759, - 13211, - 16690, - 8452, - 32512, - 1306, - 42753, - 33939, - 5804, - 19304, - 15047, - 18867, - 15055, - 78963, - 6037, - 8510, - 8083, - 4076, - 19304, - 1415, - 16196, - 537, - 12385, - 53913, - 885, - 18775, - 58875, - 1537, - 398, - 59828, - 18867, - 4012, - 93589, - 337, - 34854, - 15477, - 19304, - 9482, - 1876, - 33688, - 1331, - 5865, - 7438, - 885, - 88642, - 17135, - 398, - 7406, - 59828, - 4012, - 8580, - 16690, - 47322, - 45098, - 19304, - 15047, - 18867, - 27061, - 1059, - 6273, - 47500, - 537, - 748, - 45003, - 56873, - 47107, - 45003, - 81005, - 34136, - 4625, - 19304, - 851, - 8039, - 32672, - 17135, - 13951, - 885, - 59649, - 398, - 207, - 39736, - 19304, - 6213, - 19462, - 50209, - 4625, - 17901, - 5649, - 25628, - 18752, - 63889, - 48548, - 537, - 34854, - 15477, - 885, - 16938, - 398, - 6213, - 19462, - 15055, - 6213, - 5118, - 19304, - 1306, - 59828, - 15055, - 8580, - 16690, - 47322, - 45098, - 398, - 4076, - 40542, - 34854, - 15477, - 18867, - 1769, - 6213, - 19462, - 31729, - 19304, - 851, - 12383, - 32672, - 16938, - 885, - 59649, - 398, - 100001 - ], - "labels": [ - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - 429, - 1853, - 6663, - 8247, - 418, - 3074, - 11, - 5501, - 11, - 285, - 10421, - 13, - 100001, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - 207, - 6213, - 19462, - 50209, - 4625, - 504, - 23807, - 5871, - 53947, - 33939, - 5804, - 19304, - 15047, - 24291, - 25628, - 18752, - 48548, - 537, - 34854, - 15477, - 885, - 16938, - 398, - 207, - 6213, - 19462, - 19304, - 8549, - 2217, - 4118, - 4800, - 19304, - 54533, - 6213, - 5118, - 1306, - 42753, - 33939, - 398, - 15047, - 18867, - 15055, - 16476, - 15982, - 537, - 15615, - 885, - 5782, - 19304, - 1876, - 17135, - 60574, - 98238, - 885, - 8340, - 398, - 6213, - 19462, - 337, - 34854, - 15477, - 72652, - 10263, - 7992, - 15477, - 913, - 42753, - 19304, - 6117, - 13742, - 6857, - 6213, - 9384, - 3421, - 31448, - 398, - 207, - 1306, - 59828, - 31759, - 13211, - 16690, - 8452, - 32512, - 1306, - 42753, - 33939, - 5804, - 19304, - 15047, - 18867, - 15055, - 78963, - 6037, - 8510, - 8083, - 4076, - 19304, - 1415, - 16196, - 537, - 12385, - 53913, - 885, - 18775, - 58875, - 1537, - 398, - 59828, - 18867, - 4012, - 93589, - 337, - 34854, - 15477, - 19304, - 9482, - 1876, - 33688, - 1331, - 5865, - 7438, - 885, - 88642, - 17135, - 398, - 7406, - 59828, - 4012, - 8580, - 16690, - 47322, - 45098, - 19304, - 15047, - 18867, - 27061, - 1059, - 6273, - 47500, - 537, - 748, - 45003, - 56873, - 47107, - 45003, - 81005, - 34136, - 4625, - 19304, - 851, - 8039, - 32672, - 17135, - 13951, - 885, - 59649, - 398, - 207, - 39736, - 19304, - 6213, - 19462, - 50209, - 4625, - 17901, - 5649, - 25628, - 18752, - 63889, - 48548, - 537, - 34854, - 15477, - 885, - 16938, - 398, - 6213, - 19462, - 15055, - 6213, - 5118, - 19304, - 1306, - 59828, - 15055, - 8580, - 16690, - 47322, - 45098, - 398, - 4076, - 40542, - 34854, - 15477, - 18867, - 1769, - 6213, - 19462, - 31729, - 19304, - 851, - 12383, - 32672, - 16938, - 885, - 59649, - 398, - 100001 - ], - "inputs_decode": "<|begin▁of▁sentence|>A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n\n\nUser: What are the three primary colors?\n\nAssistant: The three primary colors are red, blue, and yellow.<|end▁of▁sentence|>User: 解释个人电脑和服务器之间的区别。\n\nAssistant: 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|end▁of▁sentence|>", - "labels_decode": [ - " The three primary colors are red, blue, and yellow.<|end▁of▁sentence|>", - " 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|end▁of▁sentence|>" - ], - "seq_length": 284, - "seq_category": "None" -} diff --git a/applications/ColossalChat/tests/test_data/chat_template/microsoft_phi-2.json b/applications/ColossalChat/tests/test_data/chat_template/microsoft_phi-2.json deleted file mode 100644 index 96d62a26a..000000000 --- a/applications/ColossalChat/tests/test_data/chat_template/microsoft_phi-2.json +++ /dev/null @@ -1,2009 +0,0 @@ -{ - "input_ids": [ - 50256, - 27, - 91, - 320, - 62, - 9688, - 91, - 29, - 10057, - 198, - 32, - 8537, - 1022, - 257, - 11040, - 1692, - 290, - 281, - 11666, - 4430, - 8796, - 13, - 383, - 8796, - 3607, - 7613, - 11, - 6496, - 11, - 290, - 23507, - 7429, - 284, - 262, - 1692, - 338, - 2683, - 13, - 198, - 198, - 27, - 91, - 320, - 62, - 437, - 91, - 29, - 198, - 27, - 91, - 320, - 62, - 9688, - 91, - 29, - 7220, - 198, - 2061, - 389, - 262, - 1115, - 4165, - 7577, - 30, - 27, - 91, - 320, - 62, - 437, - 91, - 29, - 198, - 27, - 91, - 320, - 62, - 9688, - 91, - 29, - 562, - 10167, - 198, - 464, - 1115, - 4165, - 7577, - 389, - 2266, - 11, - 4171, - 11, - 290, - 7872, - 29847, - 91, - 320, - 62, - 437, - 91, - 29, - 198, - 27, - 91, - 320, - 62, - 9688, - 91, - 29, - 7220, - 198, - 164, - 100, - 96, - 34932, - 232, - 10310, - 103, - 21689, - 18796, - 113, - 164, - 226, - 239, - 161, - 240, - 234, - 17312, - 235, - 27950, - 94, - 161, - 247, - 101, - 45298, - 29785, - 112, - 21410, - 44293, - 118, - 26344, - 104, - 16764, - 27, - 91, - 320, - 62, - 437, - 91, - 29, - 198, - 27, - 91, - 320, - 62, - 9688, - 91, - 29, - 562, - 10167, - 198, - 10310, - 103, - 21689, - 18796, - 113, - 164, - 226, - 239, - 161, - 240, - 234, - 17312, - 235, - 27950, - 94, - 161, - 247, - 101, - 42468, - 10310, - 97, - 163, - 100, - 235, - 38834, - 28938, - 234, - 163, - 109, - 119, - 161, - 252, - 233, - 21410, - 164, - 106, - 94, - 163, - 106, - 245, - 17312, - 118, - 163, - 111, - 119, - 163, - 119, - 253, - 171, - 120, - 234, - 22522, - 225, - 20015, - 105, - 21410, - 10310, - 119, - 17358, - 223, - 44293, - 118, - 26344, - 104, - 28839, - 101, - 12859, - 236, - 18796, - 101, - 34460, - 242, - 23513, - 163, - 94, - 105, - 20015, - 114, - 165, - 227, - 235, - 163, - 121, - 106, - 161, - 240, - 234, - 45250, - 100, - 47797, - 121, - 16764, - 220, - 10310, - 103, - 21689, - 18796, - 113, - 164, - 226, - 239, - 171, - 120, - 234, - 165, - 94, - 122, - 28938, - 235, - 45250, - 251, - 20046, - 231, - 171, - 120, - 234, - 42468, - 10310, - 118, - 10310, - 103, - 21689, - 45635, - 18796, - 101, - 32003, - 234, - 164, - 106, - 122, - 164, - 106, - 94, - 21410, - 164, - 106, - 94, - 163, - 106, - 245, - 17312, - 118, - 16764, - 22522, - 225, - 20015, - 105, - 34460, - 248, - 30585, - 116, - 18796, - 101, - 12859, - 236, - 33768, - 98, - 30585, - 116, - 21410, - 32432, - 98, - 43291, - 23513, - 161, - 101, - 109, - 20046, - 238, - 161, - 240, - 234, - 27764, - 99, - 20046, - 254, - 171, - 120, - 234, - 20998, - 107, - 20015, - 98, - 32573, - 238, - 26193, - 234, - 28938, - 226, - 163, - 100, - 235, - 28938, - 226, - 43718, - 115, - 21410, - 41753, - 242, - 18796, - 101, - 163, - 101, - 233, - 41753, - 237, - 161, - 240, - 234, - 162, - 116, - 116, - 22755, - 237, - 16764, - 10310, - 103, - 21689, - 18796, - 113, - 164, - 226, - 239, - 21410, - 163, - 94, - 105, - 20015, - 114, - 165, - 227, - 235, - 163, - 121, - 106, - 31660, - 48958, - 105, - 42468, - 162, - 234, - 231, - 163, - 227, - 100, - 43718, - 229, - 49035, - 228, - 165, - 227, - 235, - 163, - 121, - 106, - 30266, - 98, - 164, - 106, - 122, - 164, - 106, - 94, - 21410, - 171, - 120, - 234, - 38834, - 32573, - 229, - 20046, - 253, - 20998, - 107, - 20015, - 98, - 43718, - 117, - 162, - 235, - 106, - 10310, - 103, - 21689, - 165, - 250, - 222, - 162, - 109, - 224, - 32573, - 249, - 26193, - 234, - 22522, - 248, - 26344, - 114, - 16764, - 5525, - 222, - 234, - 17312, - 235, - 27950, - 94, - 161, - 247, - 101, - 42468, - 10310, - 118, - 12859, - 228, - 162, - 119, - 94, - 164, - 114, - 111, - 32014, - 34932, - 237, - 18796, - 101, - 22755, - 115, - 21410, - 165, - 250, - 222, - 162, - 109, - 224, - 32003, - 234, - 164, - 106, - 122, - 164, - 106, - 94, - 21410, - 164, - 106, - 94, - 163, - 106, - 245, - 17312, - 118, - 163, - 111, - 119, - 163, - 119, - 253, - 171, - 120, - 234, - 22522, - 225, - 20015, - 105, - 34460, - 248, - 30585, - 116, - 18796, - 101, - 12859, - 236, - 10310, - 118, - 18796, - 101, - 22755, - 115, - 162, - 237, - 238, - 160, - 122, - 249, - 28938, - 226, - 163, - 100, - 235, - 163, - 121, - 239, - 163, - 119, - 250, - 17312, - 235, - 27950, - 94, - 171, - 120, - 234, - 36685, - 224, - 163, - 121, - 239, - 44165, - 247, - 23513, - 18796, - 113, - 36310, - 165, - 224, - 106, - 20015, - 114, - 161, - 240, - 234, - 23877, - 229, - 20015, - 114, - 27670, - 254, - 164, - 122, - 241, - 163, - 255, - 231, - 16764, - 17312, - 235, - 27950, - 94, - 161, - 247, - 101, - 34460, - 248, - 30585, - 116, - 165, - 250, - 222, - 17358, - 223, - 165, - 45865, - 45250, - 100, - 47797, - 121, - 21410, - 163, - 94, - 105, - 20015, - 114, - 165, - 227, - 235, - 163, - 121, - 106, - 171, - 120, - 234, - 33176, - 114, - 10310, - 242, - 20998, - 107, - 20015, - 98, - 33699, - 123, - 20998, - 245, - 165, - 45865, - 164, - 112, - 253, - 164, - 121, - 121, - 161, - 240, - 234, - 165, - 243, - 123, - 33768, - 114, - 29785, - 112, - 21410, - 32573, - 238, - 26193, - 234, - 16764, - 18796, - 109, - 12859, - 236, - 17312, - 235, - 27950, - 94, - 161, - 247, - 101, - 165, - 250, - 222, - 17358, - 223, - 162, - 242, - 107, - 162, - 234, - 223, - 32014, - 34932, - 237, - 18796, - 101, - 22755, - 115, - 21410, - 164, - 106, - 123, - 29785, - 106, - 171, - 120, - 234, - 22522, - 225, - 20015, - 105, - 34460, - 248, - 30585, - 116, - 165, - 227, - 235, - 13783, - 229, - 13783, - 248, - 43718, - 116, - 13783, - 226, - 49426, - 228, - 161, - 247, - 101, - 23513, - 32014, - 22522, - 117, - 34932, - 237, - 37863, - 227, - 27764, - 246, - 161, - 240, - 234, - 32014, - 22522, - 117, - 34932, - 237, - 163, - 94, - 105, - 33566, - 246, - 165, - 102, - 109, - 27950, - 101, - 161, - 247, - 101, - 171, - 120, - 234, - 20015, - 98, - 162, - 237, - 238, - 165, - 45865, - 163, - 111, - 119, - 163, - 119, - 253, - 21410, - 32573, - 238, - 26193, - 234, - 34460, - 253, - 41753, - 99, - 161, - 240, - 234, - 163, - 101, - 111, - 22522, - 248, - 45250, - 100, - 16764, - 10545, - 222, - 119, - 45298, - 171, - 120, - 234, - 10310, - 103, - 21689, - 18796, - 113, - 164, - 226, - 239, - 161, - 240, - 234, - 17312, - 235, - 27950, - 94, - 161, - 247, - 101, - 45298, - 29785, - 112, - 21410, - 10310, - 119, - 17358, - 223, - 44293, - 118, - 26344, - 104, - 28839, - 101, - 12859, - 236, - 22522, - 225, - 20015, - 105, - 21410, - 18796, - 101, - 34460, - 242, - 23513, - 163, - 94, - 105, - 20015, - 114, - 165, - 227, - 235, - 163, - 121, - 106, - 161, - 240, - 234, - 45250, - 100, - 47797, - 121, - 16764, - 10310, - 103, - 21689, - 18796, - 113, - 164, - 226, - 239, - 18796, - 101, - 12859, - 236, - 10310, - 103, - 21689, - 45635, - 18796, - 101, - 171, - 120, - 234, - 32003, - 234, - 17312, - 235, - 27950, - 94, - 161, - 247, - 101, - 18796, - 101, - 12859, - 236, - 162, - 242, - 107, - 162, - 234, - 223, - 32014, - 34932, - 237, - 18796, - 101, - 22755, - 115, - 21410, - 164, - 106, - 123, - 29785, - 106, - 16764, - 17312, - 235, - 27950, - 94, - 161, - 247, - 101, - 21410, - 163, - 94, - 105, - 20015, - 114, - 165, - 227, - 235, - 163, - 121, - 106, - 34460, - 248, - 30585, - 116, - 162, - 107, - 242, - 10310, - 103, - 21689, - 18796, - 113, - 164, - 226, - 239, - 162, - 249, - 112, - 165, - 45865, - 171, - 120, - 234, - 20015, - 98, - 46479, - 251, - 46237, - 223, - 163, - 111, - 119, - 163, - 119, - 253, - 21410, - 45250, - 100, - 47797, - 121, - 161, - 240, - 234, - 163, - 101, - 111, - 22522, - 248, - 45250, - 100, - 16764, - 27, - 91, - 320, - 62, - 437, - 91, - 29, - 50256 - ], - "labels": [ - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - 464, - 1115, - 4165, - 7577, - 389, - 2266, - 11, - 4171, - 11, - 290, - 7872, - 29847, - 91, - 320, - 62, - 437, - 91, - 29, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - 10310, - 103, - 21689, - 18796, - 113, - 164, - 226, - 239, - 161, - 240, - 234, - 17312, - 235, - 27950, - 94, - 161, - 247, - 101, - 42468, - 10310, - 97, - 163, - 100, - 235, - 38834, - 28938, - 234, - 163, - 109, - 119, - 161, - 252, - 233, - 21410, - 164, - 106, - 94, - 163, - 106, - 245, - 17312, - 118, - 163, - 111, - 119, - 163, - 119, - 253, - 171, - 120, - 234, - 22522, - 225, - 20015, - 105, - 21410, - 10310, - 119, - 17358, - 223, - 44293, - 118, - 26344, - 104, - 28839, - 101, - 12859, - 236, - 18796, - 101, - 34460, - 242, - 23513, - 163, - 94, - 105, - 20015, - 114, - 165, - 227, - 235, - 163, - 121, - 106, - 161, - 240, - 234, - 45250, - 100, - 47797, - 121, - 16764, - 220, - 10310, - 103, - 21689, - 18796, - 113, - 164, - 226, - 239, - 171, - 120, - 234, - 165, - 94, - 122, - 28938, - 235, - 45250, - 251, - 20046, - 231, - 171, - 120, - 234, - 42468, - 10310, - 118, - 10310, - 103, - 21689, - 45635, - 18796, - 101, - 32003, - 234, - 164, - 106, - 122, - 164, - 106, - 94, - 21410, - 164, - 106, - 94, - 163, - 106, - 245, - 17312, - 118, - 16764, - 22522, - 225, - 20015, - 105, - 34460, - 248, - 30585, - 116, - 18796, - 101, - 12859, - 236, - 33768, - 98, - 30585, - 116, - 21410, - 32432, - 98, - 43291, - 23513, - 161, - 101, - 109, - 20046, - 238, - 161, - 240, - 234, - 27764, - 99, - 20046, - 254, - 171, - 120, - 234, - 20998, - 107, - 20015, - 98, - 32573, - 238, - 26193, - 234, - 28938, - 226, - 163, - 100, - 235, - 28938, - 226, - 43718, - 115, - 21410, - 41753, - 242, - 18796, - 101, - 163, - 101, - 233, - 41753, - 237, - 161, - 240, - 234, - 162, - 116, - 116, - 22755, - 237, - 16764, - 10310, - 103, - 21689, - 18796, - 113, - 164, - 226, - 239, - 21410, - 163, - 94, - 105, - 20015, - 114, - 165, - 227, - 235, - 163, - 121, - 106, - 31660, - 48958, - 105, - 42468, - 162, - 234, - 231, - 163, - 227, - 100, - 43718, - 229, - 49035, - 228, - 165, - 227, - 235, - 163, - 121, - 106, - 30266, - 98, - 164, - 106, - 122, - 164, - 106, - 94, - 21410, - 171, - 120, - 234, - 38834, - 32573, - 229, - 20046, - 253, - 20998, - 107, - 20015, - 98, - 43718, - 117, - 162, - 235, - 106, - 10310, - 103, - 21689, - 165, - 250, - 222, - 162, - 109, - 224, - 32573, - 249, - 26193, - 234, - 22522, - 248, - 26344, - 114, - 16764, - 5525, - 222, - 234, - 17312, - 235, - 27950, - 94, - 161, - 247, - 101, - 42468, - 10310, - 118, - 12859, - 228, - 162, - 119, - 94, - 164, - 114, - 111, - 32014, - 34932, - 237, - 18796, - 101, - 22755, - 115, - 21410, - 165, - 250, - 222, - 162, - 109, - 224, - 32003, - 234, - 164, - 106, - 122, - 164, - 106, - 94, - 21410, - 164, - 106, - 94, - 163, - 106, - 245, - 17312, - 118, - 163, - 111, - 119, - 163, - 119, - 253, - 171, - 120, - 234, - 22522, - 225, - 20015, - 105, - 34460, - 248, - 30585, - 116, - 18796, - 101, - 12859, - 236, - 10310, - 118, - 18796, - 101, - 22755, - 115, - 162, - 237, - 238, - 160, - 122, - 249, - 28938, - 226, - 163, - 100, - 235, - 163, - 121, - 239, - 163, - 119, - 250, - 17312, - 235, - 27950, - 94, - 171, - 120, - 234, - 36685, - 224, - 163, - 121, - 239, - 44165, - 247, - 23513, - 18796, - 113, - 36310, - 165, - 224, - 106, - 20015, - 114, - 161, - 240, - 234, - 23877, - 229, - 20015, - 114, - 27670, - 254, - 164, - 122, - 241, - 163, - 255, - 231, - 16764, - 17312, - 235, - 27950, - 94, - 161, - 247, - 101, - 34460, - 248, - 30585, - 116, - 165, - 250, - 222, - 17358, - 223, - 165, - 45865, - 45250, - 100, - 47797, - 121, - 21410, - 163, - 94, - 105, - 20015, - 114, - 165, - 227, - 235, - 163, - 121, - 106, - 171, - 120, - 234, - 33176, - 114, - 10310, - 242, - 20998, - 107, - 20015, - 98, - 33699, - 123, - 20998, - 245, - 165, - 45865, - 164, - 112, - 253, - 164, - 121, - 121, - 161, - 240, - 234, - 165, - 243, - 123, - 33768, - 114, - 29785, - 112, - 21410, - 32573, - 238, - 26193, - 234, - 16764, - 18796, - 109, - 12859, - 236, - 17312, - 235, - 27950, - 94, - 161, - 247, - 101, - 165, - 250, - 222, - 17358, - 223, - 162, - 242, - 107, - 162, - 234, - 223, - 32014, - 34932, - 237, - 18796, - 101, - 22755, - 115, - 21410, - 164, - 106, - 123, - 29785, - 106, - 171, - 120, - 234, - 22522, - 225, - 20015, - 105, - 34460, - 248, - 30585, - 116, - 165, - 227, - 235, - 13783, - 229, - 13783, - 248, - 43718, - 116, - 13783, - 226, - 49426, - 228, - 161, - 247, - 101, - 23513, - 32014, - 22522, - 117, - 34932, - 237, - 37863, - 227, - 27764, - 246, - 161, - 240, - 234, - 32014, - 22522, - 117, - 34932, - 237, - 163, - 94, - 105, - 33566, - 246, - 165, - 102, - 109, - 27950, - 101, - 161, - 247, - 101, - 171, - 120, - 234, - 20015, - 98, - 162, - 237, - 238, - 165, - 45865, - 163, - 111, - 119, - 163, - 119, - 253, - 21410, - 32573, - 238, - 26193, - 234, - 34460, - 253, - 41753, - 99, - 161, - 240, - 234, - 163, - 101, - 111, - 22522, - 248, - 45250, - 100, - 16764, - 10545, - 222, - 119, - 45298, - 171, - 120, - 234, - 10310, - 103, - 21689, - 18796, - 113, - 164, - 226, - 239, - 161, - 240, - 234, - 17312, - 235, - 27950, - 94, - 161, - 247, - 101, - 45298, - 29785, - 112, - 21410, - 10310, - 119, - 17358, - 223, - 44293, - 118, - 26344, - 104, - 28839, - 101, - 12859, - 236, - 22522, - 225, - 20015, - 105, - 21410, - 18796, - 101, - 34460, - 242, - 23513, - 163, - 94, - 105, - 20015, - 114, - 165, - 227, - 235, - 163, - 121, - 106, - 161, - 240, - 234, - 45250, - 100, - 47797, - 121, - 16764, - 10310, - 103, - 21689, - 18796, - 113, - 164, - 226, - 239, - 18796, - 101, - 12859, - 236, - 10310, - 103, - 21689, - 45635, - 18796, - 101, - 171, - 120, - 234, - 32003, - 234, - 17312, - 235, - 27950, - 94, - 161, - 247, - 101, - 18796, - 101, - 12859, - 236, - 162, - 242, - 107, - 162, - 234, - 223, - 32014, - 34932, - 237, - 18796, - 101, - 22755, - 115, - 21410, - 164, - 106, - 123, - 29785, - 106, - 16764, - 17312, - 235, - 27950, - 94, - 161, - 247, - 101, - 21410, - 163, - 94, - 105, - 20015, - 114, - 165, - 227, - 235, - 163, - 121, - 106, - 34460, - 248, - 30585, - 116, - 162, - 107, - 242, - 10310, - 103, - 21689, - 18796, - 113, - 164, - 226, - 239, - 162, - 249, - 112, - 165, - 45865, - 171, - 120, - 234, - 20015, - 98, - 46479, - 251, - 46237, - 223, - 163, - 111, - 119, - 163, - 119, - 253, - 21410, - 45250, - 100, - 47797, - 121, - 161, - 240, - 234, - 163, - 101, - 111, - 22522, - 248, - 45250, - 100, - 16764, - 27, - 91, - 320, - 62, - 437, - 91, - 29, - 50256 - ], - "inputs_decode": "<|endoftext|><|im_start|>system\nA chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n<|im_end|>\n<|im_start|>user\nWhat are the three primary colors?<|im_end|>\n<|im_start|>assistant\nThe three primary colors are red, blue, and yellow.<|im_end|>\n<|im_start|>user\n解释个人电脑和服务器之间的区别。<|im_end|>\n<|im_start|>assistant\n个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|><|endoftext|>", - "labels_decode": [ - "The three primary colors are red, blue, and yellow.<|im_end|>", - "个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。<|im_end|><|endoftext|>" - ], - "seq_length": 998, - "seq_category": "None" -} diff --git a/applications/ColossalChat/tests/test_data/chat_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json b/applications/ColossalChat/tests/test_data/chat_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json deleted file mode 100644 index 3849c7438..000000000 --- a/applications/ColossalChat/tests/test_data/chat_template/mistralai_Mixtral-8x7B-Instruct-v0.1.json +++ /dev/null @@ -1,919 +0,0 @@ -{ - "input_ids": [ - 1, - 733, - 16289, - 28793, - 28705, - 1824, - 460, - 272, - 1712, - 6258, - 9304, - 28804, - 28705, - 733, - 28748, - 16289, - 28793, - 415, - 1712, - 6258, - 9304, - 460, - 2760, - 28725, - 5045, - 28725, - 304, - 9684, - 28723, - 2, - 733, - 16289, - 28793, - 259, - 29386, - 30334, - 28995, - 29086, - 29742, - 31753, - 29131, - 29430, - 29224, - 29180, - 29332, - 29117, - 28914, - 29209, - 29705, - 28944, - 28705, - 733, - 28748, - 16289, - 28793, - 28705, - 28995, - 29086, - 29742, - 31753, - 29131, - 29430, - 29224, - 29180, - 28971, - 29745, - 29824, - 28988, - 29338, - 29066, - 29173, - 28914, - 29382, - 29481, - 29363, - 29401, - 29531, - 28924, - 29928, - 29550, - 28914, - 29345, - 29059, - 29209, - 29705, - 29010, - 29160, - 28963, - 31787, - 29041, - 31483, - 29011, - 29253, - 29021, - 29131, - 29261, - 29084, - 28944, - 28705, - 28995, - 29086, - 29742, - 31753, - 28924, - 236, - 164, - 193, - 29046, - 30450, - 29476, - 28924, - 28971, - 29003, - 28995, - 29086, - 29154, - 28963, - 29746, - 29081, - 29382, - 28914, - 29382, - 29481, - 29363, - 28944, - 29928, - 29550, - 29217, - 29408, - 28963, - 29160, - 29142, - 29408, - 28914, - 29487, - 29089, - 29041, - 232, - 171, - 180, - 30488, - 29131, - 29500, - 30978, - 28924, - 29052, - 29074, - 29798, - 29037, - 30344, - 29824, - 30344, - 29675, - 28914, - 29298, - 28963, - 29265, - 29313, - 29131, - 30239, - 30727, - 28944, - 28995, - 29086, - 29742, - 31753, - 28914, - 31483, - 29011, - 29253, - 29021, - 28969, - 30812, - 28971, - 29518, - 30131, - 29144, - 30168, - 29253, - 29021, - 29263, - 29081, - 29382, - 28914, - 28924, - 28988, - 29202, - 29537, - 29052, - 29074, - 29521, - 29020, - 28995, - 29086, - 29259, - 29243, - 29258, - 29037, - 29018, - 29251, - 28944, - 28705, - 29746, - 29430, - 29224, - 29180, - 28971, - 29003, - 29105, - 30493, - 30303, - 29050, - 29195, - 28963, - 29106, - 28914, - 29259, - 29243, - 29746, - 29081, - 29382, - 28914, - 29382, - 29481, - 29363, - 29401, - 29531, - 28924, - 29928, - 29550, - 29217, - 29408, - 28963, - 29160, - 29003, - 28963, - 29106, - 29279, - 29954, - 30344, - 29824, - 29533, - 30229, - 29430, - 29224, - 28924, - 29118, - 29533, - 29992, - 29041, - 29742, - 29169, - 30182, - 29011, - 29131, - 29019, - 29011, - 29359, - 29226, - 29414, - 28944, - 29430, - 29224, - 29180, - 29217, - 29408, - 29259, - 29059, - 29366, - 29261, - 29084, - 28914, - 31483, - 29011, - 29253, - 29021, - 28924, - 29457, - 29958, - 29052, - 29074, - 30761, - 30154, - 29366, - 30685, - 29435, - 29131, - 29495, - 29007, - 29117, - 28914, - 29798, - 29037, - 28944, - 29590, - 29160, - 29430, - 29224, - 29180, - 29259, - 29059, - 29428, - 29569, - 29050, - 29195, - 28963, - 29106, - 28914, - 30164, - 29562, - 28924, - 29928, - 29550, - 29217, - 29408, - 29253, - 29613, - 29292, - 30080, - 29326, - 29093, - 29180, - 29041, - 29050, - 29329, - 29195, - 29188, - 29079, - 29131, - 29050, - 29329, - 29195, - 31483, - 30358, - 236, - 172, - 180, - 29129, - 29180, - 28924, - 29074, - 29279, - 29366, - 29401, - 29531, - 28914, - 29798, - 29037, - 30029, - 29184, - 29131, - 234, - 171, - 182, - 29018, - 29261, - 28944, - 28705, - 29758, - 29332, - 28924, - 28995, - 29086, - 29742, - 31753, - 29131, - 29430, - 29224, - 29180, - 29332, - 29117, - 28914, - 29345, - 29059, - 29209, - 29705, - 29010, - 29160, - 29928, - 29550, - 28914, - 28963, - 31787, - 29041, - 31483, - 29011, - 29253, - 29021, - 29131, - 29261, - 29084, - 28944, - 28995, - 29086, - 29742, - 31753, - 28963, - 29160, - 28995, - 29086, - 29154, - 28963, - 28924, - 29746, - 29430, - 29224, - 29180, - 28963, - 29160, - 29428, - 29569, - 29050, - 29195, - 28963, - 29106, - 28914, - 30164, - 29562, - 28944, - 29430, - 29224, - 29180, - 28914, - 31483, - 29011, - 29253, - 29021, - 29217, - 29408, - 29605, - 28995, - 29086, - 29742, - 31753, - 29250, - 29366, - 28924, - 29074, - 29321, - 29425, - 29401, - 29531, - 28914, - 29261, - 29084, - 29131, - 234, - 171, - 182, - 29018, - 29261, - 28944, - 2 - ], - "labels": [ - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - 415, - 1712, - 6258, - 9304, - 460, - 2760, - 28725, - 5045, - 28725, - 304, - 9684, - 28723, - 2, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - -100, - 28705, - 28995, - 29086, - 29742, - 31753, - 29131, - 29430, - 29224, - 29180, - 28971, - 29745, - 29824, - 28988, - 29338, - 29066, - 29173, - 28914, - 29382, - 29481, - 29363, - 29401, - 29531, - 28924, - 29928, - 29550, - 28914, - 29345, - 29059, - 29209, - 29705, - 29010, - 29160, - 28963, - 31787, - 29041, - 31483, - 29011, - 29253, - 29021, - 29131, - 29261, - 29084, - 28944, - 28705, - 28995, - 29086, - 29742, - 31753, - 28924, - 236, - 164, - 193, - 29046, - 30450, - 29476, - 28924, - 28971, - 29003, - 28995, - 29086, - 29154, - 28963, - 29746, - 29081, - 29382, - 28914, - 29382, - 29481, - 29363, - 28944, - 29928, - 29550, - 29217, - 29408, - 28963, - 29160, - 29142, - 29408, - 28914, - 29487, - 29089, - 29041, - 232, - 171, - 180, - 30488, - 29131, - 29500, - 30978, - 28924, - 29052, - 29074, - 29798, - 29037, - 30344, - 29824, - 30344, - 29675, - 28914, - 29298, - 28963, - 29265, - 29313, - 29131, - 30239, - 30727, - 28944, - 28995, - 29086, - 29742, - 31753, - 28914, - 31483, - 29011, - 29253, - 29021, - 28969, - 30812, - 28971, - 29518, - 30131, - 29144, - 30168, - 29253, - 29021, - 29263, - 29081, - 29382, - 28914, - 28924, - 28988, - 29202, - 29537, - 29052, - 29074, - 29521, - 29020, - 28995, - 29086, - 29259, - 29243, - 29258, - 29037, - 29018, - 29251, - 28944, - 28705, - 29746, - 29430, - 29224, - 29180, - 28971, - 29003, - 29105, - 30493, - 30303, - 29050, - 29195, - 28963, - 29106, - 28914, - 29259, - 29243, - 29746, - 29081, - 29382, - 28914, - 29382, - 29481, - 29363, - 29401, - 29531, - 28924, - 29928, - 29550, - 29217, - 29408, - 28963, - 29160, - 29003, - 28963, - 29106, - 29279, - 29954, - 30344, - 29824, - 29533, - 30229, - 29430, - 29224, - 28924, - 29118, - 29533, - 29992, - 29041, - 29742, - 29169, - 30182, - 29011, - 29131, - 29019, - 29011, - 29359, - 29226, - 29414, - 28944, - 29430, - 29224, - 29180, - 29217, - 29408, - 29259, - 29059, - 29366, - 29261, - 29084, - 28914, - 31483, - 29011, - 29253, - 29021, - 28924, - 29457, - 29958, - 29052, - 29074, - 30761, - 30154, - 29366, - 30685, - 29435, - 29131, - 29495, - 29007, - 29117, - 28914, - 29798, - 29037, - 28944, - 29590, - 29160, - 29430, - 29224, - 29180, - 29259, - 29059, - 29428, - 29569, - 29050, - 29195, - 28963, - 29106, - 28914, - 30164, - 29562, - 28924, - 29928, - 29550, - 29217, - 29408, - 29253, - 29613, - 29292, - 30080, - 29326, - 29093, - 29180, - 29041, - 29050, - 29329, - 29195, - 29188, - 29079, - 29131, - 29050, - 29329, - 29195, - 31483, - 30358, - 236, - 172, - 180, - 29129, - 29180, - 28924, - 29074, - 29279, - 29366, - 29401, - 29531, - 28914, - 29798, - 29037, - 30029, - 29184, - 29131, - 234, - 171, - 182, - 29018, - 29261, - 28944, - 28705, - 29758, - 29332, - 28924, - 28995, - 29086, - 29742, - 31753, - 29131, - 29430, - 29224, - 29180, - 29332, - 29117, - 28914, - 29345, - 29059, - 29209, - 29705, - 29010, - 29160, - 29928, - 29550, - 28914, - 28963, - 31787, - 29041, - 31483, - 29011, - 29253, - 29021, - 29131, - 29261, - 29084, - 28944, - 28995, - 29086, - 29742, - 31753, - 28963, - 29160, - 28995, - 29086, - 29154, - 28963, - 28924, - 29746, - 29430, - 29224, - 29180, - 28963, - 29160, - 29428, - 29569, - 29050, - 29195, - 28963, - 29106, - 28914, - 30164, - 29562, - 28944, - 29430, - 29224, - 29180, - 28914, - 31483, - 29011, - 29253, - 29021, - 29217, - 29408, - 29605, - 28995, - 29086, - 29742, - 31753, - 29250, - 29366, - 28924, - 29074, - 29321, - 29425, - 29401, - 29531, - 28914, - 29261, - 29084, - 29131, - 234, - 171, - 182, - 29018, - 29261, - 28944, - 2 - ], - "inputs_decode": " [INST] What are the three primary colors? [/INST] The three primary colors are red, blue, and yellow. [INST] 解释个人电脑和服务器之间的区别。 [/INST] 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。", - "labels_decode": [ - " The three primary colors are red, blue, and yellow.", - " 个人电脑和服务器是两种不同类型的计算机系统,它们的主要区别在于用途、硬件配置和性能。 个人电脑,顾名思义,是为个人使用而设计的计算机。它们通常用于日常的工作、娱乐和学习,可以运行各种各样的应用程序和游戏。个人电脑的硬件配置一般是按照标准配置来设计的,不过也可以根据个人需求进行定制。 而服务器是为了满足大量用户的需求而设计的计算机系统,它们通常用于为用户提供各种网络服务,如网站、电子邮件和文件传输等。服务器通常需要高性能的硬件配置,并且可以承受高负载和长时间的运行。由于服务器需要支持大量用户的访问,它们通常配备多核处理器、大容量内存和大容量硬盘驱动器,以提高系统的运行速度和稳定性。 总之,个人电脑和服务器之间的主要区别在于它们的用途、硬件配置和性能。个人电脑用于个人使用,而服务器用于支持大量用户的访问。服务器的硬件配置通常比个人电脑更高,以保证系统的性能和稳定性。" - ], - "seq_length": 453, - "seq_category": "None" -} From 0bbac158ed5226948d259a4e29c9a9f1da952d23 Mon Sep 17 00:00:00 2001 From: YeAnbang Date: Wed, 29 May 2024 02:03:51 +0000 Subject: [PATCH 10/19] fix datasets version --- applications/ColossalChat/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/ColossalChat/requirements.txt b/applications/ColossalChat/requirements.txt index 82586646c..ef3a5a0e8 100755 --- a/applications/ColossalChat/requirements.txt +++ b/applications/ColossalChat/requirements.txt @@ -1,6 +1,6 @@ transformers>=4.36.2 tqdm -datasets +datasets==2.14.7 loralib colossalai>=0.3.7 torch>=1.12.1 From bf57b13dda4c577aca748d9beb57b0107e106c45 Mon Sep 17 00:00:00 2001 From: YeAnbang Date: Wed, 29 May 2024 02:10:37 +0000 Subject: [PATCH 11/19] remove models that require huggingface auth from ci --- applications/ColossalChat/tests/test_templating.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/applications/ColossalChat/tests/test_templating.sh b/applications/ColossalChat/tests/test_templating.sh index e8e1ed6f9..0d737b3f3 100755 --- a/applications/ColossalChat/tests/test_templating.sh +++ b/applications/ColossalChat/tests/test_templating.sh @@ -6,8 +6,9 @@ TEST_DATA_DIR=$BASE_DIR/tests/test_data DATA_SAVE_PATH=$BASE_TEMP_DIR/tests CONFIG_DIR=$BASE_DIR/config -MODELS=("colossal-llama2" "llama2" "mistral" "chatGLM2" "chatGLM3" "deepseek" "Yi" "baichuan") -# +# MODELS=("colossal-llama2" "llama2" "mistral" "chatGLM2" "chatGLM3" "deepseek" "Yi" "baichuan") +MODELS=("colossal-llama2" "llama2" "chatGLM2" "chatGLM3" "deepseek" "Yi" "baichuan") + get_pretrain() { local model=$1 if [[ $model == "colossal-llama2" ]]; then From 45195ac53d5e8384fde266b6fd7dcfc0bcec59e9 Mon Sep 17 00:00:00 2001 From: YeAnbang Date: Wed, 29 May 2024 02:25:19 +0000 Subject: [PATCH 12/19] remove local data path --- .../prepare_sft_dataset.sh | 17 ++++------------ .../examples/training_scripts/train_sft.sh | 20 +++++++++---------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/applications/ColossalChat/examples/data_preparation_scripts/prepare_sft_dataset.sh b/applications/ColossalChat/examples/data_preparation_scripts/prepare_sft_dataset.sh index 47d828a6c..8562b47ee 100755 --- a/applications/ColossalChat/examples/data_preparation_scripts/prepare_sft_dataset.sh +++ b/applications/ColossalChat/examples/data_preparation_scripts/prepare_sft_dataset.sh @@ -1,22 +1,13 @@ -SAVE_DIR="/home/yeanbang/data/experiment/dataset/alpaca/test/Yi-1.5-6B" +SAVE_DIR="" rm -rf $SAVE_DIR/cache rm -rf $SAVE_DIR/jsonl rm -rf $SAVE_DIR/arrow -# python prepare_dataset.py --type sft \ -# --data_input_dirs /home/yeanbang/data/experiment/dataset/sft_data/test/sft-data \ -# --conversation_template_config /home/yeanbang/data/ColossalAI/applications/ColossalChat/config/conversation_template/THUDM_chatglm3-6b.json \ -# --tokenizer_dir "/mnt/jfs-hdd/home/data/models/ChatGlm-6B" \ -# --data_cache_dir $SAVE_DIR/cache \ -# --data_jsonl_output_dir $SAVE_DIR/jsonl \ -# --data_arrow_output_dir $SAVE_DIR/arrow \ - - python prepare_dataset.py --type sft \ - --data_input_dirs /home/yeanbang/data/experiment/dataset/sft_data/test/sft-data \ - --conversation_template_config /home/yeanbang/data/ColossalAI/applications/ColossalChat/config/conversation_template/01-ai_Yi-1.5-9B-Chat.json \ - --tokenizer_dir "/mnt/jfs-hdd/share/models/Yi-1.5-6B" \ + --data_input_dirs "PATH/TO/SFT/DATA" \ + --conversation_template_config /PATH/TO/CHAT/TEMPLATE/CONFIG.json \ + --tokenizer_dir "" \ --data_cache_dir $SAVE_DIR/cache \ --data_jsonl_output_dir $SAVE_DIR/jsonl \ --data_arrow_output_dir $SAVE_DIR/arrow \ diff --git a/applications/ColossalChat/examples/training_scripts/train_sft.sh b/applications/ColossalChat/examples/training_scripts/train_sft.sh index 5d0f55f90..53c712901 100755 --- a/applications/ColossalChat/examples/training_scripts/train_sft.sh +++ b/applications/ColossalChat/examples/training_scripts/train_sft.sh @@ -23,16 +23,16 @@ PARENT_CONFIG_FILE="" # Path to a folder to save training config logs PRETRAINED_MODEL_PATH="" # huggingface or local model path PRETRAINED_TOKENIZER_PATH="" # huggingface or local tokenizer path declare -a dataset=( - YOUR/PREFERENCE/DATA/DIR/arrow/part-00000 - YOUR/PREFERENCE/DATA/DIR/arrow/part-00001 - YOUR/PREFERENCE/DATA/DIR/arrow/part-00002 - YOUR/PREFERENCE/DATA/DIR/arrow/part-00003 - YOUR/PREFERENCE/DATA/DIR/arrow/part-00004 - YOUR/PREFERENCE/DATA/DIR/arrow/part-00005 - YOUR/PREFERENCE/DATA/DIR/arrow/part-00006 - YOUR/PREFERENCE/DATA/DIR/arrow/part-00007 - YOUR/PREFERENCE/DATA/DIR/arrow/part-00008 - YOUR/PREFERENCE/DATA/DIR/arrow/part-00009 + YOUR/SFT/DATA/DIR/arrow/part-00000 + YOUR/SFT/DATA/DIR/arrow/part-00001 + YOUR/SFT/DATA/DIR/arrow/part-00002 + YOUR/SFT/DATA/DIR/arrow/part-00003 + YOUR/SFT/DATA/DIR/arrow/part-00004 + YOUR/SFT/DATA/DIR/arrow/part-00005 + YOUR/SFT/DATA/DIR/arrow/part-00006 + YOUR/SFT/DATA/DIR/arrow/part-00007 + YOUR/SFT/DATA/DIR/arrow/part-00008 + YOUR/SFT/DATA/DIR/arrow/part-00009 ) TIMESTAMP=$(date +%Y-%m-%d-%H-%M-%S) From e16ccc272a0fd25ee8b6b6856c6b90cf8bcfb6b0 Mon Sep 17 00:00:00 2001 From: YeAnbang Date: Wed, 29 May 2024 02:30:16 +0000 Subject: [PATCH 13/19] update ci --- applications/ColossalChat/tests/test_templating.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/ColossalChat/tests/test_templating.sh b/applications/ColossalChat/tests/test_templating.sh index 0d737b3f3..1ae93bd7e 100755 --- a/applications/ColossalChat/tests/test_templating.sh +++ b/applications/ColossalChat/tests/test_templating.sh @@ -6,7 +6,7 @@ TEST_DATA_DIR=$BASE_DIR/tests/test_data DATA_SAVE_PATH=$BASE_TEMP_DIR/tests CONFIG_DIR=$BASE_DIR/config -# MODELS=("colossal-llama2" "llama2" "mistral" "chatGLM2" "chatGLM3" "deepseek" "Yi" "baichuan") +# MODELS=("colossal-llama2" "llama2" "mistral" "chatGLM2" "chatGLM3" "deepseek" "Yi") MODELS=("colossal-llama2" "llama2" "chatGLM2" "chatGLM3" "deepseek" "Yi" "baichuan") get_pretrain() { From ac1520cb8f453943d0dff9cad6a708116af3c0a6 Mon Sep 17 00:00:00 2001 From: YeAnbang Date: Mon, 3 Jun 2024 05:45:00 +0000 Subject: [PATCH 14/19] remove baichuan from template test due to transformer version conflict --- applications/ColossalChat/tests/test_templating.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/ColossalChat/tests/test_templating.sh b/applications/ColossalChat/tests/test_templating.sh index 1ae93bd7e..bdb447dcf 100755 --- a/applications/ColossalChat/tests/test_templating.sh +++ b/applications/ColossalChat/tests/test_templating.sh @@ -6,8 +6,8 @@ TEST_DATA_DIR=$BASE_DIR/tests/test_data DATA_SAVE_PATH=$BASE_TEMP_DIR/tests CONFIG_DIR=$BASE_DIR/config -# MODELS=("colossal-llama2" "llama2" "mistral" "chatGLM2" "chatGLM3" "deepseek" "Yi") -MODELS=("colossal-llama2" "llama2" "chatGLM2" "chatGLM3" "deepseek" "Yi" "baichuan") +# MODELS=("colossal-llama2" "llama2" "mistral" "chatGLM2" "chatGLM3" "deepseek" "Yi" "baichuan") +MODELS=("colossal-llama2" "llama2" "chatGLM2" "chatGLM3" "deepseek" "Yi") get_pretrain() { local model=$1 From 790e1362a69c826d1150cc416c79be384c6027d1 Mon Sep 17 00:00:00 2001 From: YeAnbang Date: Fri, 7 Jun 2024 07:01:00 +0000 Subject: [PATCH 15/19] merge --- .github/workflows/run_chatgpt_examples.yml | 2 +- applications/ColossalChat/tests/test_train.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_chatgpt_examples.yml b/.github/workflows/run_chatgpt_examples.yml index 88da6e95b..4ea86b609 100644 --- a/.github/workflows/run_chatgpt_examples.yml +++ b/.github/workflows/run_chatgpt_examples.yml @@ -42,7 +42,7 @@ jobs: - name: Install Transformers run: | - pip install transformers==4.34.1 + pip install transformers==4.36.2 - name: Execute Examples run: | diff --git a/applications/ColossalChat/tests/test_train.sh b/applications/ColossalChat/tests/test_train.sh index 0f69bcaf0..bce9d6b86 100755 --- a/applications/ColossalChat/tests/test_train.sh +++ b/applications/ColossalChat/tests/test_train.sh @@ -281,7 +281,7 @@ echo "[Test]: testing ppo ..." SKIPPED_TESTS=( - llama-3d # 3d plugin doesn't support lora + # llama-3d # 3d plugin doesn't support lora llama-gemini # gemini doesn't support lora ) From 0d7ff10ea5a50c99fe31f89e3c8cccafa762b890 Mon Sep 17 00:00:00 2001 From: YeAnbang Date: Fri, 7 Jun 2024 09:43:42 +0000 Subject: [PATCH 16/19] replace the customized dataloader setup with the build-in one --- .../ColossalChat/coati/dataset/__init__.py | 2 - .../ColossalChat/coati/dataset/loader.py | 157 +----------------- .../coati/dataset/tokenization_utils.py | 34 ++-- .../THUDM_chatglm2-6b.json | 6 +- applications/ColossalChat/examples/README.md | 21 +++ .../examples/training_scripts/hostfile | 6 +- .../examples/training_scripts/train_dpo.py | 14 +- .../examples/training_scripts/train_ppo.py | 17 +- .../examples/training_scripts/train_rm.py | 15 +- .../examples/training_scripts/train_sft.py | 14 +- .../ColossalChat/tests/test_templating.sh | 4 +- applications/ColossalChat/tests/test_train.sh | 7 +- 12 files changed, 79 insertions(+), 218 deletions(-) diff --git a/applications/ColossalChat/coati/dataset/__init__.py b/applications/ColossalChat/coati/dataset/__init__.py index e216c37e1..deb7b6d92 100755 --- a/applications/ColossalChat/coati/dataset/__init__.py +++ b/applications/ColossalChat/coati/dataset/__init__.py @@ -5,7 +5,6 @@ from .loader import ( DataCollatorForSupervisedDataset, StatefulDistributedSampler, load_tokenized_dataset, - setup_distributed_dataloader, ) from .tokenization_utils import supervised_tokenize_sft, tokenize_prompt_dataset, tokenize_rlhf @@ -17,7 +16,6 @@ __all__ = [ "DataCollatorForSupervisedDataset", "StatefulDistributedSampler", "load_tokenized_dataset", - "setup_distributed_dataloader", "supervised_tokenize_pretrain", "supervised_tokenize_sft", "tokenize_rlhf", diff --git a/applications/ColossalChat/coati/dataset/loader.py b/applications/ColossalChat/coati/dataset/loader.py index 76cf40f0f..cea1b2dbb 100755 --- a/applications/ColossalChat/coati/dataset/loader.py +++ b/applications/ColossalChat/coati/dataset/loader.py @@ -4,22 +4,16 @@ Dataloader for sft, dpo, ppo """ -import math import os -import random from dataclasses import dataclass -from typing import Callable, Dict, Iterator, List, Optional, Sequence, Union +from typing import Dict, Iterator, List, Optional, Sequence, Union -import numpy as np import torch -import torch.distributed as dist import torch.nn.functional as F from coati.dataset.utils import chuncate_sequence, pad_to_max_len from datasets import Dataset as HFDataset from datasets import dataset_dict, load_from_disk -from torch.distributed import ProcessGroup -from torch.distributed.distributed_c10d import _get_default_group -from torch.utils.data import ConcatDataset, DataLoader, Dataset, DistributedSampler +from torch.utils.data import ConcatDataset, Dataset, DistributedSampler from transformers.tokenization_utils import PreTrainedTokenizer DatasetType = Union[Dataset, ConcatDataset, dataset_dict.Dataset] @@ -236,159 +230,26 @@ class DataCollatorForPreferenceDataset(object): class StatefulDistributedSampler(DistributedSampler): - """ - Stateful distributed sampler for multi-stage training. - """ - def __init__( self, - dataset: DatasetType, + dataset: Dataset, num_replicas: Optional[int] = None, rank: Optional[int] = None, shuffle: bool = True, seed: int = 0, drop_last: bool = False, - tp_size: int = 1, - sp_size: int = 1, - pp_size: int = 1, ) -> None: - if not tp_size > 1: - super().__init__( - dataset=dataset, - num_replicas=num_replicas, - rank=rank, - shuffle=shuffle, - seed=seed, - drop_last=drop_last, - ) - else: - # adapted from https://github.com/pytorch/pytorch/blob/4979f9c0d72490970e2019bb1d2284f83d93f76b/torch/utils/data/distributed.py#L62 - if rank is None: - rank = dist.get_rank() - dist.get_world_size() - # dp_size = world_size // (tp_size * sp_size * pp_size) - dp_rank = int(rank / (tp_size * sp_size * pp_size)) # data parallel rank: - if rank < 0: - raise ValueError(f"Invalid rank {rank}, rank should be in the interval [0, 0]") - self.dataset = dataset - self.num_replicas = num_replicas - self.dp_rank = dp_rank - self.rank = rank - self.epoch = 0 - self.drop_last = drop_last - # If the dataset length is evenly divisible by # of replicas, then there - # is no need to drop any data, since the dataset will be split equally. - if self.drop_last and len(self.dataset) % self.num_replicas != 0: # type: ignore[arg-type] - # Split to nearest available length that is evenly divisible. - # This is to ensure each rank receives the same amount of data when - # using this Sampler. - self.num_samples = math.ceil( - (len(self.dataset) - self.num_replicas) / self.num_replicas # type: ignore[arg-type] - ) - else: - self.num_samples = math.ceil(len(self.dataset) / self.num_replicas) # type: ignore[arg-type] - self.total_size = self.num_samples * self.num_replicas - self.shuffle = shuffle - self.seed = seed - self.start_index = 0 - self.tp_size = tp_size + super().__init__(dataset, num_replicas, rank, shuffle, seed, drop_last) + self.start_index: int = 0 def __iter__(self) -> Iterator: - if self.tp_size > 1: - # TODO Add support for tp_group not equal to 1 - pass - # adpated from https://github.com/pytorch/pytorch/blob/4979f9c0d72490970e2019bb1d2284f83d93f76b/torch/utils/data/distributed.py#L96 - if self.shuffle: - # deterministically shuffle based on epoch and seed - g = torch.Generator() - g.manual_seed(self.seed + self.epoch) - indices = torch.randperm(len(self.dataset), generator=g).tolist() # type: ignore[arg-type] - else: - indices = list(range(len(self.dataset))) # type: ignore[arg-type] - - if not self.drop_last: - # add extra samples to make it evenly divisible - padding_size = self.total_size - len(indices) - if padding_size <= len(indices): - indices += indices[:padding_size] - else: - indices += (indices * math.ceil(padding_size / len(indices)))[:padding_size] - else: - # remove tail of data to make it evenly divisible. - indices = indices[: self.total_size] - assert len(indices) == self.total_size - - # subsample - indices = indices[ - self.dp_rank : self.dp_rank + self.total_size : self.num_replicas - ] # num_replicas=tp_group=1, we only support tp_group==1 for now - assert len(indices) == self.num_samples - return iter(indices) - - else: - iterator = super().__iter__() - indices = list(iterator) - indices = indices[self.start_index :] - return iter(indices) + iterator = super().__iter__() + indices = list(iterator) + indices = indices[self.start_index :] + return iter(indices) def __len__(self) -> int: return self.num_samples - self.start_index def set_start_index(self, start_index: int) -> None: self.start_index = start_index - - -def setup_distributed_dataloader( - dataset: DatasetType, - batch_size: int = 1, - shuffle: bool = False, - seed: int = 1024, - drop_last: bool = False, - pin_memory: bool = False, - num_workers: int = 0, - collate_fn: Callable[[Sequence[Dict[str, Union[str, List[int]]]]], Dict[str, torch.Tensor]] = None, - process_group: Optional[ProcessGroup] = None, - tp_size: Optional[int] = 1, - sp_size: Optional[int] = 1, - pp_size: Optional[int] = 1, - **kwargs, -) -> DataLoader: - """ - Setup dataloader for distributed training. - """ - _kwargs = kwargs.copy() - process_group = process_group or _get_default_group() - # world_size = tp_size * pp_size - assert ( - process_group.size() % tp_size == 0 - ), f"process_group.size()={process_group.size()} must be divisible by tp_size={tp_size}" - sampler = StatefulDistributedSampler( - dataset=dataset, - num_replicas=int(process_group.size() / tp_size), - rank=process_group.rank(), - shuffle=shuffle, - seed=seed, - drop_last=drop_last, - tp_size=tp_size, - sp_size=sp_size, - pp_size=pp_size, - ) - - # Deterministic dataloader - def seed_worker(worker_id: int) -> None: - worker_seed = seed - np.random.seed(worker_seed) - torch.manual_seed(worker_seed) - random.seed(worker_seed) - - return DataLoader( - dataset=dataset, - batch_size=batch_size, - sampler=sampler, - num_workers=num_workers, - collate_fn=collate_fn, - pin_memory=pin_memory, - drop_last=drop_last, - worker_init_fn=seed_worker, - **_kwargs, - ) diff --git a/applications/ColossalChat/coati/dataset/tokenization_utils.py b/applications/ColossalChat/coati/dataset/tokenization_utils.py index 2debbb757..34828cbaf 100755 --- a/applications/ColossalChat/coati/dataset/tokenization_utils.py +++ b/applications/ColossalChat/coati/dataset/tokenization_utils.py @@ -55,8 +55,6 @@ def supervised_tokenize_sft( for mess in messages: from_str = mess["from"] - if from_str is None: - print(mess) if from_str.lower() == "human": from_str = "user" elif from_str.lower() == "assistant": @@ -133,24 +131,20 @@ def supervised_tokenize_sft( labels[-1] = tokenizer.eos_token_id # For some model without bos/eos may raise the following errors - try: - inputs_decode = tokenizer.decode(tokenized) - start = 0 - end = 0 - label_decode = [] - for i in range(len(labels)): - if labels[i] == ignore_index: - if start != end: - label_decode.append(tokenizer.decode(labels[start + 1 : i], skip_special_tokens=False)) - start = i - end = i - else: - end = i - if i == len(labels) - 1: - label_decode.append(tokenizer.decode(labels[start + 1 :], skip_special_tokens=False)) - - except TypeError as e: - raise TypeError(str(e) + f"\nUnable to decode input_ids: {tokenized}") + inputs_decode = tokenizer.decode(tokenized) + start = 0 + end = 0 + label_decode = [] + for i in range(len(labels)): + if labels[i] == ignore_index: + if start != end: + label_decode.append(tokenizer.decode(labels[start + 1 : i], skip_special_tokens=False)) + start = i + end = i + else: + end = i + if i == len(labels) - 1: + label_decode.append(tokenizer.decode(labels[start + 1 :], skip_special_tokens=False)) # Check if all labels are ignored, this may happen when the tokenized length is too long if labels.count(ignore_index) == len(labels): diff --git a/applications/ColossalChat/config/conversation_template/THUDM_chatglm2-6b.json b/applications/ColossalChat/config/conversation_template/THUDM_chatglm2-6b.json index 809c1d9f9..b87a18c8d 100644 --- a/applications/ColossalChat/config/conversation_template/THUDM_chatglm2-6b.json +++ b/applications/ColossalChat/config/conversation_template/THUDM_chatglm2-6b.json @@ -2,7 +2,11 @@ "chat_template": "{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}", "system_message": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n", "stop_ids": [ - 2 + 31007, + 326, + 30962, + 437, + 31007 ], "end_of_assistant": "<|im_end|>" } diff --git a/applications/ColossalChat/examples/README.md b/applications/ColossalChat/examples/README.md index 74865033e..68834f4aa 100755 --- a/applications/ColossalChat/examples/README.md +++ b/applications/ColossalChat/examples/README.md @@ -29,6 +29,7 @@ - [Alternative Option For RLHF: Direct Preference Optimization](#alternative-option-for-rlhf-direct-preference-optimization) - [DPO Stage 1: Supervised Instruction Tuning](#dpo-training-stage1---supervised-instructs-tuning) - [DPO Stage 2: DPO Training](#dpo-training-stage2---dpo-training) + - [List of Supported Models](#) - [Hardware Requirements](#hardware-requirements) - [Inference example](#inference-example) - [Attention](#attention) @@ -744,6 +745,26 @@ For DPO, we recommend using zero2 or zero2-cpu. We tested the VRAM consumption o - 4 H800 GPUs - zero2, batch size=4, VRAM Usage=67544.47 MB +## List of Supported Models + +For SFT, we support the following models/series: +- Colossal-LLaMA-2 +- ChatGLM2 +- ChatGLM3 (only with zero2, zero2_cpu plugin) +- Baichuan2 +- LLaMA2 +- Qwen1.5-7B-Chat (with transformers==4.39.1) +- Yi-1.5 + +For PPO and DPO, we theoratically support the following models/series (without guarantee): +- Colossal-LLaMA-2 (tested) +- ChatGLM2 +- Baichuan2 +- LLaMA2 (tested) +- Qwen1.5-7B-Chat (with transformers==4.39.1) +- Yi-1.5 + +*-* The zero2, zero2_cpu plugin also support a wide range of chat models not listed above. ## Inference example diff --git a/applications/ColossalChat/examples/training_scripts/hostfile b/applications/ColossalChat/examples/training_scripts/hostfile index c46761d14..c7aed75a3 100755 --- a/applications/ColossalChat/examples/training_scripts/hostfile +++ b/applications/ColossalChat/examples/training_scripts/hostfile @@ -1 +1,5 @@ -172.27.183.199 +XXX.XX.XXX.XXX # Your master IP +XXX.XX.XXX.XXX # Your slave IPs +XXX.XX.XXX.XXX # Your slave IPs +XXX.XX.XXX.XXX # Your slave IPs +XXX.XX.XXX.XXX # Your slave IPs diff --git a/applications/ColossalChat/examples/training_scripts/train_dpo.py b/applications/ColossalChat/examples/training_scripts/train_dpo.py index 3c52bec76..a5b4cb3bd 100755 --- a/applications/ColossalChat/examples/training_scripts/train_dpo.py +++ b/applications/ColossalChat/examples/training_scripts/train_dpo.py @@ -5,12 +5,7 @@ import resource from contextlib import nullcontext import torch -from coati.dataset import ( - DataCollatorForPreferenceDataset, - StatefulDistributedSampler, - load_tokenized_dataset, - setup_distributed_dataloader, -) +from coati.dataset import DataCollatorForPreferenceDataset, StatefulDistributedSampler, load_tokenized_dataset from coati.models import convert_to_lora_module, disable_dropout from coati.trainer import DPOTrainer from coati.utils import load_checkpoint @@ -174,15 +169,14 @@ def train(args): mode_map = {"train": "train", "valid": "validation", "test": "test"} train_dataset = load_tokenized_dataset(dataset_paths=args.dataset, mode="train", mode_map=mode_map) data_collator = DataCollatorForPreferenceDataset(tokenizer=tokenizer, max_length=args.max_length) - train_dataloader = setup_distributed_dataloader( + + train_dataloader = plugin.prepare_dataloader( dataset=train_dataset, batch_size=args.batch_size, shuffle=True, drop_last=True, collate_fn=data_collator, - tp_size=plugin.tp_size if hasattr(plugin, "tp_size") else 1, - sp_size=plugin.sp_size if hasattr(plugin, "sp_size") else 1, - pp_size=plugin.pp_size if hasattr(plugin, "pp_size") else 1, + distributed_sampler_cls=StatefulDistributedSampler, ) num_update_steps_per_epoch = len(train_dataloader) // args.accumulation_steps diff --git a/applications/ColossalChat/examples/training_scripts/train_ppo.py b/applications/ColossalChat/examples/training_scripts/train_ppo.py index 92c770561..3da3e9ca6 100755 --- a/applications/ColossalChat/examples/training_scripts/train_ppo.py +++ b/applications/ColossalChat/examples/training_scripts/train_ppo.py @@ -12,7 +12,6 @@ from coati.dataset import ( StatefulDistributedSampler, load_tokenized_dataset, setup_conversation_template, - setup_distributed_dataloader, ) from coati.models import Critic, RewardModel, convert_to_lora_module, disable_dropout from coati.trainer import PPOTrainer @@ -209,6 +208,9 @@ def train(args): max_norm=args.grad_clip, ) elif args.plugin == "3d": + if args.use_flash_attn and (args.tp > 1 or args.pp > 1 or args.sp > 1 or args.enable_sequence_parallelism): + logger.warning("Flash attention cannot be used with 3D parallelism for PPO training. Disabling it.") + args.use_flash_attn = False plugin = HybridParallelPlugin( tp_size=args.tp, pp_size=args.pp, @@ -247,29 +249,26 @@ def train(args): mode_map = {"train": "train", "valid": "validation", "test": "test"} train_prompt_dataset = load_tokenized_dataset(dataset_paths=args.prompt_dataset, mode="train", mode_map=mode_map) data_collator = DataCollatorForPromptDataset(tokenizer=tokenizer, max_length=args.max_length - args.max_seq_len) - train_prompt_dataloader = setup_distributed_dataloader( + + train_prompt_dataloader = plugin.prepare_dataloader( dataset=train_prompt_dataset, batch_size=args.experience_batch_size, shuffle=True, drop_last=True, collate_fn=data_collator, - tp_size=plugin.tp_size if hasattr(plugin, "tp_size") else 1, - sp_size=plugin.sp_size if hasattr(plugin, "sp_size") else 1, - pp_size=plugin.pp_size if hasattr(plugin, "pp_size") else 1, + distributed_sampler_cls=StatefulDistributedSampler, ) if len(args.ptx_dataset) > 0: train_ptx_dataset = load_tokenized_dataset(dataset_paths=args.ptx_dataset, mode="train", mode_map=mode_map) data_collator = DataCollatorForSupervisedDataset(tokenizer=tokenizer, max_length=args.max_length) - train_pretrain_dataloader = setup_distributed_dataloader( + train_pretrain_dataloader = plugin.prepare_dataloader( dataset=train_ptx_dataset, batch_size=args.ptx_batch_size, shuffle=True, drop_last=True, collate_fn=data_collator, - tp_size=plugin.tp_size if hasattr(plugin, "tp_size") else 1, - sp_size=plugin.sp_size if hasattr(plugin, "sp_size") else 1, - pp_size=plugin.pp_size if hasattr(plugin, "pp_size") else 1, + distributed_sampler_cls=StatefulDistributedSampler, ) else: train_pretrain_dataloader = None diff --git a/applications/ColossalChat/examples/training_scripts/train_rm.py b/applications/ColossalChat/examples/training_scripts/train_rm.py index 1fc938bd7..ce0d02b5d 100755 --- a/applications/ColossalChat/examples/training_scripts/train_rm.py +++ b/applications/ColossalChat/examples/training_scripts/train_rm.py @@ -6,12 +6,7 @@ import resource from contextlib import nullcontext import torch -from coati.dataset import ( - DataCollatorForPreferenceDataset, - StatefulDistributedSampler, - load_tokenized_dataset, - setup_distributed_dataloader, -) +from coati.dataset import DataCollatorForPreferenceDataset, StatefulDistributedSampler, load_tokenized_dataset from coati.models import LogExpLoss, LogSigLoss, RewardModel, convert_to_lora_module from coati.trainer import RewardModelTrainer from coati.utils import load_checkpoint @@ -169,17 +164,15 @@ def train(args): mode_map = {"train": "train", "valid": "validation", "test": "test"} train_dataset = load_tokenized_dataset(dataset_paths=args.dataset, mode="train", mode_map=mode_map) data_collator = DataCollatorForPreferenceDataset(tokenizer=tokenizer, max_length=args.max_length) - train_dataloader = setup_distributed_dataloader( + + train_dataloader = plugin.prepare_dataloader( dataset=train_dataset, batch_size=args.batch_size, shuffle=True, drop_last=True, collate_fn=data_collator, - tp_size=plugin.tp_size if hasattr(plugin, "tp_size") else 1, - sp_size=plugin.sp_size if hasattr(plugin, "sp_size") else 1, - pp_size=plugin.pp_size if hasattr(plugin, "pp_size") else 1, + distributed_sampler_cls=StatefulDistributedSampler, ) - num_update_steps_per_epoch = len(train_dataloader) // args.accumulation_steps math.ceil(args.max_epochs * num_update_steps_per_epoch) diff --git a/applications/ColossalChat/examples/training_scripts/train_sft.py b/applications/ColossalChat/examples/training_scripts/train_sft.py index 4e78472f8..ee0db250c 100755 --- a/applications/ColossalChat/examples/training_scripts/train_sft.py +++ b/applications/ColossalChat/examples/training_scripts/train_sft.py @@ -8,7 +8,7 @@ import sys from contextlib import nullcontext import torch -from coati.dataset import DataCollatorForSupervisedDataset, load_tokenized_dataset, setup_distributed_dataloader +from coati.dataset import DataCollatorForSupervisedDataset, StatefulDistributedSampler, load_tokenized_dataset from coati.models import convert_to_lora_module from coati.trainer import SFTTrainer from coati.utils import load_checkpoint @@ -189,21 +189,15 @@ def train(args): ) dataset = load_tokenized_dataset(dataset_paths=args.dataset, mode="train") data_collator = DataCollatorForSupervisedDataset(tokenizer=tokenizer, max_length=args.max_len) - train_dataloader = setup_distributed_dataloader( + + train_dataloader = plugin.prepare_dataloader( dataset=dataset, batch_size=args.batch_size, shuffle=True, drop_last=True, collate_fn=data_collator, - tp_size=plugin.tp_size if hasattr(plugin, "tp_size") else 1, - sp_size=plugin.sp_size if hasattr(plugin, "sp_size") else 1, - pp_size=plugin.pp_size if hasattr(plugin, "pp_size") else 1, + distributed_sampler_cls=StatefulDistributedSampler, ) - # print(len(train_dataloader)) - # for batch in train_dataloader: - # print(dist.get_rank(), tokenizer.batch_decode(batch["input_ids"])) - # break - coordinator.print_on_master( f"Max CUDA memory after data loader: {torch.cuda.max_memory_allocated() / 1024 ** 2:.2f} MB" ) diff --git a/applications/ColossalChat/tests/test_templating.sh b/applications/ColossalChat/tests/test_templating.sh index bdb447dcf..e4033a961 100755 --- a/applications/ColossalChat/tests/test_templating.sh +++ b/applications/ColossalChat/tests/test_templating.sh @@ -6,8 +6,8 @@ TEST_DATA_DIR=$BASE_DIR/tests/test_data DATA_SAVE_PATH=$BASE_TEMP_DIR/tests CONFIG_DIR=$BASE_DIR/config -# MODELS=("colossal-llama2" "llama2" "mistral" "chatGLM2" "chatGLM3" "deepseek" "Yi" "baichuan") -MODELS=("colossal-llama2" "llama2" "chatGLM2" "chatGLM3" "deepseek" "Yi") +MODELS=("colossal-llama2" "llama2" "mistral" "chatGLM2" "chatGLM3" "deepseek" "Yi" "baichuan") # for local test +# MODELS=("colossal-llama2" "llama2" "chatGLM2" "chatGLM3" "deepseek" "Yi") get_pretrain() { local model=$1 diff --git a/applications/ColossalChat/tests/test_train.sh b/applications/ColossalChat/tests/test_train.sh index bce9d6b86..d1a685174 100755 --- a/applications/ColossalChat/tests/test_train.sh +++ b/applications/ColossalChat/tests/test_train.sh @@ -30,8 +30,7 @@ MODEL_SAVE_PATH=$TEMP_DIR/rlhf_models MODELS_DIR=$TEMP_DIR/models_config # Skip those tests due to CI tests timeout MODELS=('llama') -# ADVANCED_PLUGINS=('pp' 'tp_zero2' 'tp_pp' 'sp_split_gather' 'sp_ring' 'sp_all_to_all' '3d' 'gemini' 'gemini_auto' 'zero2' 'zero2_cpu') -ADVANCED_PLUGINS=('tp_zero2' '3d' 'gemini' 'gemini_auto' 'zero2' 'zero2_cpu') +ADVANCED_PLUGINS=('sp_split_gather' 'sp_ring' 'sp_all_to_all' 'tp_zero2' '3d' 'gemini' 'gemini_auto' 'zero2' 'zero2_cpu') # pp is still buggy PLUGINS=('3d' 'gemini' 'gemini_auto' 'zero2' 'zero2_cpu') LORA_RANK=('0') # skip to reduce CI execution time, can pass all locally @@ -281,7 +280,7 @@ echo "[Test]: testing ppo ..." SKIPPED_TESTS=( - # llama-3d # 3d plugin doesn't support lora + llama-3d # 3d plugin doesn't support lora llama-gemini # gemini doesn't support lora ) @@ -359,7 +358,7 @@ for lora_rank in ${LORA_RANK[@]}; do $grad_ckpt \ --max_len 400 \ --max_seq_len 10 \ - --use_flash_attn + # --use_flash_attn passed=$? if [ $passed -eq 0 ]; then rm -rf $MODEL_SAVE_PATH/* From 77db21610a283e8b9f81b12bdb102a8fdb7ee3b8 Mon Sep 17 00:00:00 2001 From: YeAnbang Date: Fri, 7 Jun 2024 09:44:25 +0000 Subject: [PATCH 17/19] replace the customized dataloader setup with the build-in one --- applications/ColossalChat/tests/test_templating.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/ColossalChat/tests/test_templating.sh b/applications/ColossalChat/tests/test_templating.sh index e4033a961..d033c07f5 100755 --- a/applications/ColossalChat/tests/test_templating.sh +++ b/applications/ColossalChat/tests/test_templating.sh @@ -6,8 +6,8 @@ TEST_DATA_DIR=$BASE_DIR/tests/test_data DATA_SAVE_PATH=$BASE_TEMP_DIR/tests CONFIG_DIR=$BASE_DIR/config -MODELS=("colossal-llama2" "llama2" "mistral" "chatGLM2" "chatGLM3" "deepseek" "Yi" "baichuan") # for local test -# MODELS=("colossal-llama2" "llama2" "chatGLM2" "chatGLM3" "deepseek" "Yi") +# MODELS=("colossal-llama2" "llama2" "mistral" "chatGLM2" "chatGLM3" "deepseek" "Yi" "baichuan") # for local test +MODELS=("colossal-llama2" "llama2" "chatGLM2" "chatGLM3" "deepseek" "Yi") get_pretrain() { local model=$1 From 2abdede1d7902ba7be44413dd82fa752f95bccf1 Mon Sep 17 00:00:00 2001 From: YeAnbang Date: Mon, 10 Jun 2024 01:08:42 +0000 Subject: [PATCH 18/19] fix readme --- applications/ColossalChat/examples/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/ColossalChat/examples/README.md b/applications/ColossalChat/examples/README.md index 68834f4aa..a29fc7508 100755 --- a/applications/ColossalChat/examples/README.md +++ b/applications/ColossalChat/examples/README.md @@ -29,7 +29,7 @@ - [Alternative Option For RLHF: Direct Preference Optimization](#alternative-option-for-rlhf-direct-preference-optimization) - [DPO Stage 1: Supervised Instruction Tuning](#dpo-training-stage1---supervised-instructs-tuning) - [DPO Stage 2: DPO Training](#dpo-training-stage2---dpo-training) - - [List of Supported Models](#) + - [List of Supported Models](#list-of-supported-models) - [Hardware Requirements](#hardware-requirements) - [Inference example](#inference-example) - [Attention](#attention) From 84eab1307845674a278dddb86fdf50b8b87aacab Mon Sep 17 00:00:00 2001 From: YeAnbang Date: Tue, 11 Jun 2024 02:44:20 +0000 Subject: [PATCH 19/19] update sft trainning script --- .../examples/training_scripts/train_sft.py | 35 ++++--------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/applications/ColossalChat/examples/training_scripts/train_sft.py b/applications/ColossalChat/examples/training_scripts/train_sft.py index ee0db250c..08e7550df 100755 --- a/applications/ColossalChat/examples/training_scripts/train_sft.py +++ b/applications/ColossalChat/examples/training_scripts/train_sft.py @@ -1,10 +1,8 @@ import argparse -import inspect import json import math import os import resource -import sys from contextlib import nullcontext import torch @@ -26,8 +24,6 @@ logger = get_dist_logger() def train(args): - print(colossalai.__version__, inspect.getfile(colossalai)) - print(sys.executable) # check lora compatibility if "gemini" in args.plugin and args.lora_rank > 0: raise ValueError("LoRA is not supported in GeminiPlugin. Please use other plugin") @@ -44,38 +40,19 @@ def train(args): # ============================== init_ctx = nullcontext() with init_ctx: - model = AutoModelForCausalLM.from_pretrained( - args.pretrain, - torch_dtype=torch.bfloat16 if args.mixed_precision == "bf16" else torch.float16, - trust_remote_code=True, - ) - # check if the hybrid parallel plugin is compatible with the model - try: - from colossalai.shardformer.policies.auto_policy import get_autopolicy - - policy = get_autopolicy(model) - if policy is not None: - if args.plugin in ["zero2", "zero2_cpu"]: - # if compatible, set the plugin to hybrid, which use colo-attention - args.plugin = "3d" - args.zero_stage = 2 - if args.plugin == "zero2_cpu": - args.zero_cpu_offload = True - else: - args.zero_cpu_offload = False - logger.info( - f"Model is compatible with hybrid parallel plugin, set plugin to {args.plugin} with zero_stage {args.zero_stage} and zero_cpu_offload {args.zero_cpu_offload}" - ) - except NotImplementedError: - logger.warning(f"Unable to find a policy for the model, use {args.plugin} plugin instead") if args.use_flash_attn: - del model model = AutoModelForCausalLM.from_pretrained( args.pretrain, torch_dtype=torch.bfloat16 if args.mixed_precision == "bf16" else torch.float16, attn_implementation="flash_attention_2", trust_remote_code=True, ) + else: + model = AutoModelForCausalLM.from_pretrained( + args.pretrain, + torch_dtype=torch.bfloat16 if args.mixed_precision == "bf16" else torch.float16, + trust_remote_code=True, + ) if args.lora_rank > 0: model = convert_to_lora_module(model, args.lora_rank, lora_train_bias=args.lora_train_bias)