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

[AIR] HuggingFaceTrainer&Predictor implementation #23876

Merged
merged 89 commits into from
Apr 29, 2022

Conversation

Yard1
Copy link
Member

@Yard1 Yard1 commented Apr 12, 2022

Why are these changes needed?

Implements HuggingFaceTrainer & HuggingFacePredictor.

Related issue number

Checks

  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@Yard1 Yard1 requested review from clarkzinzow and ericl April 27, 2022 21:09
@Yard1 Yard1 removed the @author-action-required The PR author is responsible for the next step. Remove tag to send back to the reviewer. label Apr 27, 2022
@Yard1 Yard1 requested a review from sven1977 as a code owner April 28, 2022 20:33
Copy link
Contributor

@amogkam amogkam left a comment

Choose a reason for hiding this comment

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

LGTM! Just some minor nits

python/ray/ml/tests/test_huggingface_predictor.py Outdated Show resolved Hide resolved
model_config = AutoConfig.from_pretrained(model_checkpoint)
model = AutoModelForCausalLM.from_config(model_config)
predictor = HuggingFacePredictor(
pipeline=pipeline(
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, loving the use of pipeline!

python/ray/ml/utils/huggingface_checkpoint_utils.py Outdated Show resolved Hide resolved
python/ray/ml/utils/huggingface_checkpoint_utils.py Outdated Show resolved Hide resolved

def get_train_dataloader(self):
if self.train_dataset is None:
raise ValueError("Trainer: training requires a train_dataset.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this error message exposed to users? If so, can we have a better message here?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the same message & validation as in HuggingFace.

if resume_from_checkpoint:
self._param_dict[
"resume_from_checkpoint"
] = self._convert_directory_checkpoint_to_sync(resume_from_checkpoint)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see we need this in both as_trainable and setup since we have to support both user-specified resuming and Tune resuming.

If we change the logic here a little bit: https://github.com/ray-project/ray/blob/master/python/ray/ml/trainer.py#L347-L352

to be like this instead

if checkpoint_dir:
    config["resume_from_checkpoint"] = Checkpoint.from_directory(checkpoint_dir)
trainer = trainer_cls(**config)

then _convert_directory_checkpoint_to_sync only needs to be called in init, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Correct— my suggestion would still resolve both cases right?

Copy link
Member Author

Choose a reason for hiding this comment

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

That should work, yeah. Not sure if this change should be made here though, as it would impact all trainers (possibly in unforeseen ways). Let's do that in a followup PR

Yard1 and others added 3 commits April 29, 2022 20:34
@amogkam amogkam merged commit ff0ced1 into ray-project:master Apr 29, 2022
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

7 participants