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

[Break BC] Create training directory, move checkpointing #1432

Merged
merged 5 commits into from
Aug 30, 2024

Conversation

RdoubleA
Copy link
Contributor

Context

The big kahuna of refactors.

Motivation is discussed extensively in #1421. Here, we only move the checkpointing directory into training. This should break most cycles since it depends on models. Unfortunately, this touches all configs... will run a few to make sure none break.

All references to torchtune.utils.FullModelXXXCheckpointer now becomes torchtune.training.FullModelXXXCheckpointer

Test plan

Please make sure to do each of the following if applicable to your PR. (If you're not sure about any one of these just ask and we will happily help. We also have a contributing page for some guidance on contributing.)

  • run pre-commit hooks and linters (make sure you've first installed via pre-commit install)
  • add unit tests for any new functionality
  • update docstrings for any new or updated methods or classes
  • run unit tests via pytest tests
  • run recipe tests via pytest tests -m integration_test
  • manually run any new or modified recipes with sufficient proof of correctness
  • include relevant commands and any other artifacts in this summary (pastes of loss curves, eval results, etc.)

UX

If your function changed a public API, please add a dummy example of what the user experience will look like when calling it.
Example of docstring:


Example in our docs: https://pytorch.org/torchtune/main/tutorials/qat_finetune.html#applying-qat-to-llama3-models

  • I did not change any public API;
  • I have added an example to docs or docstrings;

Copy link

pytorch-bot bot commented Aug 28, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/torchtune/1432

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 9dfe15f with merge base 929a45a (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 28, 2024
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 14.61538% with 111 lines in your changes missing coverage. Please review.

Project coverage is 72.24%. Comparing base (badca1c) to head (4ce3be1).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
torchtune/training/checkpointing/_checkpointer.py 31.57% 26 Missing ⚠️
recipes/ppo_full_finetune_single_device.py 0.00% 13 Missing ⚠️
recipes/lora_finetune_distributed.py 0.00% 11 Missing ⚠️
recipes/lora_finetune_single_device.py 0.00% 11 Missing ⚠️
recipes/full_finetune_single_device.py 0.00% 10 Missing ⚠️
recipes/lora_dpo_distributed.py 0.00% 10 Missing ⚠️
recipes/lora_dpo_single_device.py 0.00% 10 Missing ⚠️
recipes/full_finetune_distributed.py 0.00% 8 Missing ⚠️
recipes/qat_distributed.py 0.00% 8 Missing ⚠️
recipes/eleuther_eval.py 0.00% 2 Missing ⚠️
... and 2 more
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1432       +/-   ##
===========================================
+ Coverage   27.00%   72.24%   +45.23%     
===========================================
  Files         268      269        +1     
  Lines       12923    12930        +7     
===========================================
+ Hits         3490     9341     +5851     
+ Misses       9433     3589     -5844     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@ebsmothers ebsmothers left a comment

Choose a reason for hiding this comment

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

A few small comments, but modulo resolving merge conflicts and (still) green CI this looks good to me

Comment on lines 26 to 43
__all__ = [
"FullModelHFCheckpointer",
"FullModelMetaCheckpointer",
"FullModelTorchTuneCheckpointer",
"ModelType",
"Checkpointer",
"update_state_dict_for_classifier",
"ADAPTER_CONFIG",
"ADAPTER_KEY",
"EPOCHS_KEY",
"MAX_STEPS_KEY",
"MODEL_KEY",
"OPT_KEY",
"RNG_KEY",
"SEED_KEY",
"STEPS_KEY",
"TOTAL_EPOCHS_KEY",
]
Copy link
Contributor

Choose a reason for hiding this comment

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

This is different than what we do now, right? Rn we don't include checkpointer APIs in the parent's __all__. Not saying it's wrong to do it this way but just wanna understand the rationale for the change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mainly to keep it consistent, but not opposed to removing these

@@ -5,12 +5,12 @@
# LICENSE file in the root directory of this source tree.
from typing import Union

from torchtune.utils._checkpointing._checkpointer import (
from torchtune.training.checkpointing._checkpointer import (
Copy link
Contributor

Choose a reason for hiding this comment

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

Where'd my underscore go

@@ -381,7 +381,7 @@ looks something like this:
checkpointer:

# checkpointer to use
_component_: torchtune.utils.FullModelHFCheckpointer
Copy link
Contributor

Choose a reason for hiding this comment

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

L430 too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dam good eye

@@ -13,13 +13,13 @@

import torch
from safetensors.torch import save_file
from torchtune import utils
from torchtune import training
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a huge deal (given the scope of other stuff you're doing here) but it's a little weird to me that we use training.MODEL_KEY etc. when all these things are literally defined in the local directory. Feels like needless indirection to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

eh, later problem

@RdoubleA RdoubleA merged commit 5e2046f into pytorch:main Aug 30, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants