Skip to content

Commit a90e143

Browse files
committed
remove helper.so and add a new way to compile it when start training
1 parent e605817 commit a90e143

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

mft_peft_hf/src/data/gpt2_multi_task_dataset.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,3 +353,16 @@ def load_dataset_from_jsonl(args, shard_data=False, world_size=1, global_rank=0,
353353
blending_valid_dataset = GPT2BlendableDataset(all_valid_datasets, valid_sample_weights, global_valid_num, local_valid_num)
354354

355355
return blending_train_dataset, blending_valid_dataset
356+
357+
358+
def compile_helper():
359+
"""Compile helper function at runtime. Make sure this
360+
is invoked on a single process."""
361+
import os
362+
import subprocess
363+
path = os.path.abspath(os.path.dirname(__file__))
364+
ret = subprocess.run(["make", "-C", path])
365+
if ret.returncode != 0:
366+
print("Making C++ dataset helpers module failed, exiting.")
367+
import sys
368+
sys.exit(1)
Binary file not shown.

mft_peft_hf/src/pefts/mft_accelerate.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from accelerate.logging import get_logger
4545

4646
sys.path.append("..")
47-
from data.gpt2_multi_task_dataset import load_dataset_from_jsonl
47+
from data.gpt2_multi_task_dataset import load_dataset_from_jsonl, compile_helper
4848
from utils.common_utils import generate_task_id, TASK2ID, ID2TASK
4949
from train_utils import accelerate_train
5050
from model_mapping import MODEL_TYPES, QLORA_TARGETING_MODULES, MODEL_SPECIAL_TOKENS
@@ -226,9 +226,12 @@ def main():
226226
if accelerator.is_local_main_process:
227227
datasets.utils.logging.set_verbosity_warning()
228228
transformers.utils.logging.set_verbosity_info()
229+
compile_helper()
230+
time.sleep(10)
229231
else:
230232
datasets.utils.logging.set_verbosity_error()
231233
transformers.utils.logging.set_verbosity_error()
234+
time.sleep(10)
232235

233236
if args.seed is not None:
234237
set_seed(args.seed)

0 commit comments

Comments
 (0)