8000 adds Accelerate full-state (opt, lr_sched, params) by JamesKunstle · Pull Request #235 · instructlab/training · GitHub
[go: up one dir, main page]

Skip to content

adds Accelerate full-state (opt, lr_sched, params) - #235

Merged
JamesKunstle merged 1 commit into
instructlab:mainfrom
JamesKunstle:fullstate_saving
Oct 1, 2024
Merged

JamesKunstle merged 1 commit into
instructlab:mainfrom
JamesKunstle:fullstate_saving

Conversation

@JamesKunstle
Copy link
Copy Markdown
Contributor

Saving and reloading for deepspeed.

Todo:

  • Need to save LoRA model correctly
  • choose whether the save the transformers model config + tokenizer with the model.
  • make sure this also handles dolomite correctly
  • run w/ CPU offloading
  • choose how to resume w/ samples_seen and between epochs. e.g. if we save a checkpoint at the end of an epoch, do we always save with the metadata for the next epoch and samples_seen=0?

@RobotSail RobotSail left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I left a few comments but overall it looks good


global_grad_norm = None
for epoch in range(args.num_epochs):
for epoch in range(args.current_epoch, args.num_epochs):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Needs to be

Suggested change
for epoch in range(args.current_epoch, args.num_epochs):
for epoch in range(args.current_epoch, args.num_epochs+1):

Since range(start, stop) only goes from start, ..., stop - 1

return

# picks checkpoint with the largest number of samples seen, by name.
checkpoint_list = sorted(list(output_dir.iterdir()), reverse=True)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this necessarily true? If the list is a list of strings then how does it handle a case like samples_1000 vs samples_99999

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Usually hash of the string or sum of the string characters, so 9999 > 1000.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would advise passing a custom comparison function to sorted here, see the following code snippet:

lst = ["hf_format_1", "hf_format_10", "hf_format_2"]
sorted_lst = sorted(lst)
print(sorted_lst)
> ['hf_format_1', 'hf_format_10', 'hf_format_2']

You can pass a custom function that simply splits on the _ character and casts the last part of the string into a number, this should do what you want it to.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will get sorted to work how you want it to:

Suggested change
checkpoint_list = sorted(list(output_dir.iterdir()), reverse=True)
checkpoint_list = sorted(list(output_dir.iterdir()), reverse=True, key=lambda d: int(d.split('_')[-1]))

return


latest = checkpoint_list[0]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are we guaranteed to have at least one element when we check this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah because the check above checks for len 0

…ng for DeepSpeed and FSDP.

Signed-off-by: James Kunstle <jkunstle@redhat.com>
@mergify mergify Bot removed the ci-failure label Oct 1, 2024
@JamesKunstle
JamesKunstle marked this pull request as ready for review October 1, 2024 07:05
@Maxusmusti Maxusmusti left a comment
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

EL GEE TEE EM

@mergify mergify Bot added the one-approval label Oct 1, 2024
@JamesKunstle
JamesKunstle merged commit 8b252d8 into instructlab:main Oct 1, 2024
@JamesKunstle
JamesKunstle deleted the fullstate_saving branch October 1, 2024 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0