Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[New Features] add llm pretrain & lora & sft & prefix_tuning testing scripts #7056

Merged
merged 9 commits into from
Sep 20, 2023

Conversation

wj-Mcat
Copy link
Contributor

@wj-Mcat wj-Mcat commented Sep 18, 2023

PR types

New features

PR changes

Others

Description

添加 LLM 目录下的finetuning 单测脚本

  • llama
  • chatglm
  • chatglm2
  • bloom
  • opt
  • gpt-3
  • ernie-se-3.5

@codecov
Copy link

codecov bot commented Sep 18, 2023

Codecov Report

Merging #7056 (5e2c23a) into develop (321faf3) will decrease coverage by 0.07%.
Report is 6 commits behind head on develop.
The diff coverage is n/a.

@@             Coverage Diff             @@
##           develop    #7056      +/-   ##
===========================================
- Coverage    59.91%   59.84%   -0.07%     
===========================================
  Files          556      557       +1     
  Lines        82035    82150     +115     
===========================================
+ Hits         49148    49161      +13     
- Misses       32887    32989     +102     

see 6 files with indirect coverage changes

@wj-Mcat wj-Mcat changed the title [New Features] add llm finetune testing [New Features] add llm pretrain & lora & sft & prefix_tuning testing scripts Sep 18, 2023
@wj-Mcat wj-Mcat marked this pull request as ready for review September 19, 2023 12:09
Comment on lines 2 to 29
"dataset_name_or_path": "./data",
"output_dir": "./checkpoints/chatglm_sft_ckpts",
"per_device_train_batch_size": 4,
"gradient_accumulation_steps": 4,
"per_device_eval_batch_size": 8,
"eval_accumulation_steps":16,
"num_train_epochs": 3,
"learning_rate": 3e-05,
"warmup_steps": 30,
"logging_steps": 1,
"evaluation_strategy": "epoch",
"save_strategy": "epoch",
"src_length": 1024,
"max_length": 2048,
"fp16": true,
"fp16_opt_level": "O2",
"do_train": true,
"do_eval": true,
"disable_tqdm": true,
"load_best_model_at_end": true,
"eval_with_do_generation": false,
"metric_for_best_model": "accuracy",
"recompute": true,
"save_total_limit": 1,
"tensor_parallel_degree": 4,
"pipeline_parallel_degree": 1
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是 pre-commit 给 format 的

Comment on lines +29 to +30
llama:
model_name_or_path: __internal_testing__/tiny-random-llama
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加个baichuan的吧,带alibi的那种

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个交给 @wtmlon 来添加吧。

llama:
model_name_or_path: __internal_testing__/tiny-random-llama
chatglm:
model_name_or_path: __internal_testing__/tiny-fused-chatglm
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny-fused-chatglm这里的fused指的是什么

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

因为 fused 模型中的 head_dim 必须是在:10,26,32,64,128 .... 中的一个,所以为了不影响之前的单测,就直接新创建了一个tiny-random 的模型专门用来做 非 fused & fuse 相关的单测

tests/llm/test_lora.py Outdated Show resolved Hide resolved
pipeline_parallel_degree: 1
default:
llama:
model_name_or_path: __internal_testing__/tiny-random-llama
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的random和fused区别点是什么?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

因为 fused 模型中的 head_dim 必须是在:10,26,32,64,128 .... 中的一个,所以为了不影响之前的单测,就直接新创建了一个tiny-random 的模型专门用来做 非 fused & fuse 相关的单测

model_type: llama
model_name_or_path: __internal_testing__/tiny-random-llama
chatglm:
model_type: chatglm
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chatglm有预训练流程吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是没有的,然后 fine-tune 这里也没有配置 chatglm,我可以把它先删掉。

LLMTest.tearDown(self)
shutil.rmtree(self.data_dir)

def test_pretrain(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数看起是来做finetune

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy 过来的还没有改,我来调整一下。

self.data_dir = tempfile.mkdtemp()
sys.path.insert(0, self.model_dir)

# Run pretrain
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注释部分看起来有点问题

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我来改一下。

use_few_examples("dev.json")
use_few_examples("validation.json")

def tearDown(self) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

除了删除data文件外,模型文件需要删除吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

因为是 from_pretrained 的,所以会缓存在 .paddlenlp/models 目录下,应该也没必要删除吧。

self.data_dir = os.path.join(self.data_dir, "data")
self.use_small_datasets()

def use_small_datasets(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数看看是否可以复用

self.data_dir = os.path.join(self.data_dir, "data")
self.use_small_datasets()

def use_small_datasets(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上


merge()

if self.model_dir not in ["chatglm2"]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是说chatglm2没有办法动转静然后预测是吗?这里记个TODO吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chatglm2 还没有支持 细粒度 op,所以这里需要给移除掉

@sijunhe sijunhe merged commit a150627 into PaddlePaddle:develop Sep 20, 2023
7 of 9 checks passed
@wj-Mcat wj-Mcat deleted the add-llm-chatglm-testing branch September 20, 2023 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants