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

Fix a bug for Python 3.8 #230

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions deepspeed_consolidate_fp16.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
import sys

from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint

import torch


assert len(sys.argv) == 2
model_path = sys.argv[1]
print(f"model_path = {model_path}")

state_dict = get_fp32_state_dict_from_zero_checkpoint(model_path)
for key in state_dict:
state_dict[key] = state_dict[key].half()

output_path = os.path.join(model_path, "pytorch_model.bin")
torch.save(state_dict, output_path)
print(f"{output_path} is saved successfully.")
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ torch
sentencepiece
tokenizers>=0.13.3
wandb
deepspeed>=0.9.1
accelerate
azureml-sdk
2 changes: 1 addition & 1 deletion train.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def train():

data_module = make_supervised_data_module(tokenizer=tokenizer, data_args=data_args)
trainer = Trainer(model=model, tokenizer=tokenizer, args=training_args, **data_module)
trainer.train()
trainer.train(resume_from_checkpoint=training_args.resume_from_checkpoint)
trainer.save_state()
trainer.save_model(output_dir=training_args.output_dir)

Expand Down
4 changes: 2 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sys
import time
import json
from typing import Optional, Sequence, Union
from typing import Dict, Optional, Sequence, Union

import openai
import tqdm
Expand Down Expand Up @@ -37,7 +37,7 @@ class OpenAIDecodingArguments(object):


def openai_completion(
prompts: Union[str, Sequence[str], Sequence[dict[str, str]], dict[str, str]],
prompts: Union[str, Sequence[str], Sequence[Dict[str, str]], Dict[str, str]],
decoding_args: OpenAIDecodingArguments,
model_name="text-davinci-003",
sleep_time=2,
Expand Down