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

hf: warn of deprecating internal callback #740

Merged
merged 27 commits into from
Feb 27, 2024
Merged

Conversation

dberenbaum
Copy link
Contributor

@dberenbaum dberenbaum commented Nov 17, 2023

Adds a deprecation notice about the internal HF callback and suggests to use the new external callback, which will be available in the next release of https://github.com/huggingface/transformers.

Also adds the external callback to tests since there weren't similar tests in the transformers library, and updates the example notebook.

@dberenbaum dberenbaum added ⌛ status: wait-core-merge Waiting for related product PR merge/release upstream Issues which need to be resolved in an upstream dependency labels Nov 17, 2023
@codecov-commenter
Copy link

codecov-commenter commented Nov 17, 2023

Codecov Report

Attention: 30 lines in your changes are missing coverage. Please review.

Comparison is base (8406920) 88.79% compared to head (8e9afeb) 95.53%.
Report is 9 commits behind head on main.

Files Patch % Lines
src/dvclive/fabric.py 82.66% 10 Missing and 3 partials ⚠️
tests/frameworks/test_fabric.py 83.33% 6 Missing ⚠️
src/dvclive/lightning.py 70.58% 3 Missing and 2 partials ⚠️
src/dvclive/utils.py 79.16% 4 Missing and 1 partial ⚠️
tests/frameworks/test_lightning.py 94.11% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #740      +/-   ##
==========================================
+ Coverage   88.79%   95.53%   +6.73%     
==========================================
  Files          53       55       +2     
  Lines        3357     3513     +156     
  Branches      294      312      +18     
==========================================
+ Hits         2981     3356     +375     
+ Misses        337      110     -227     
- Partials       39       47       +8     

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

@dberenbaum dberenbaum removed ⌛ status: wait-core-merge Waiting for related product PR merge/release upstream Issues which need to be resolved in an upstream dependency labels Dec 12, 2023
@dberenbaum dberenbaum marked this pull request as ready for review December 12, 2023 20:16
@dberenbaum
Copy link
Contributor Author

Docs PR: iterative/dvc.org#4994

The dvclive callback has now been released in both upstream packages:

This one is ready to merge

@dberenbaum
Copy link
Contributor Author

dberenbaum commented Dec 12, 2023

Tests need an updated version of transformers from huggingface/transformers#27983 to pass

@dberenbaum
Copy link
Contributor Author

@shcheklein A new hf transformers release was finally published and all tests are now passing. Could you take a look so we can get this merged please?

},
"outputs": [],
"source": [
"from dvclive.huggingface import DVCLiveCallback\n",
Copy link
Member

Choose a reason for hiding this comment

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

q: is it expected that we use our own callback in this example?

Copy link
Member

@shcheklein shcheklein left a comment

Choose a reason for hiding this comment

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

thanks @dberenbaum ! One item caught my attention - using an internal callback in the notebook. I didn't check also the details of the code.

@dberenbaum
Copy link
Contributor Author

One item caught my attention - using an internal callback in the notebook. I didn't check also the details of the code.

Fixed that but also found a new issue and will now need to wait for huggingface/transformers#28653 and one more release for the added test to pass ☹️.

Comment on lines +20 to +22
from transformers.integrations import DVCLiveCallback as ExternalCallback

from dvclive.huggingface import DVCLiveCallback
from dvclive.huggingface import DVCLiveCallback as InternalCallback
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test old callback (inside dvclive) and new callback (inside transformers)

trainer = Trainer(
model,
args,
train_dataset=data[0],
eval_dataset=data[1],
compute_metrics=compute_metrics,
)
callback = DVCLiveCallback()
live = callback.live
Copy link
Contributor Author

Choose a reason for hiding this comment

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

callback.live is not initialized yet in the external callback

@@ -125,8 +126,6 @@ def test_huggingface_integration(tmp_dir, model, args, data, mocker):

logs, _ = parse_metrics(live)

assert len(logs) == 10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This does not seem like a good test to have in dvclive since it relies on how many metrics hf automatically logs, including system metrics over which dvclive has no control.

Comment on lines -171 to +183
if log_model == "last":
if log_model is True:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This condition was never met since the expected value is True, not "last"

@@ -164,11 +175,12 @@ def test_huggingface_log_model(tmp_dir, model, data, mocker, log_model, best):
expected_call_count = {
"all": 2,
True: 1,
False: 0,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

False is also a valid value for log_model



@pytest.mark.parametrize("report_to", ["all", "dvclive", "none"])
def test_huggingface_report_to(model, report_to):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since there are no real tests for the callbacks in transformers, added a test here to ensure report_to adds the dvclive callback when expected

@mattseddon
Copy link
Member

Will take a look after the tests are passing 🙏🏻.

@dberenbaum
Copy link
Contributor Author

Will take a look after the tests are passing 🙏🏻.

👍 Tests pass on the upstream version of transformers, so just waiting for the next release from them.

@dberenbaum
Copy link
Contributor Author

@mattseddon The next release of transformers is out and tests are passing. Do you still want to take a look?

@@ -24,6 +24,11 @@ def __init__(
log_model: Optional[Union[Literal["all"], bool]] = None,
**kwargs,
):
logger.warning(
"This callback will be deprecated in DVCLive 4.0 in favor of"
Copy link
Member

Choose a reason for hiding this comment

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

[Q] Do you want to deprecate it now and remove it in 4.0?

@dberenbaum dberenbaum merged commit a45efba into main Feb 27, 2024
14 checks passed
@dberenbaum dberenbaum deleted the hf-deprecation-warning branch February 27, 2024 21:24
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.

None yet

4 participants