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

[core] Fix possibility to passNoneType objects in prepare #1561

Merged
merged 2 commits into from
Jun 8, 2023
Merged

Conversation

younesbelkada
Copy link
Contributor

What does this PR do?

Fixes huggingface/trl#413 and the current CI in TRL :D https://github.com/lvwerra/trl/actions/runs/5204023029/jobs/9387749684?pr=412

Before #1555 it was possible to pass NoneType objects into prepare and that function would do nothing with it and return it.

Adding a simple check if item is not None: before setting the _is_accelerate_prepare attribute circumvents the bug

cc @sgugger @muellerzr

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jun 8, 2023

The documentation is not available anymore as the PR was closed or merged.

@younesbelkada younesbelkada changed the title [core] add possibility to pass nonetype objects in prepare [core] Fix possibility to passNoneType objects in prepare Jun 8, 2023
Copy link
Contributor

@pacman100 pacman100 left a comment

Choose a reason for hiding this comment

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

Thank you for the fix!

Copy link
Collaborator

@muellerzr muellerzr left a comment

Choose a reason for hiding this comment

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

Thanks!

@sgugger
Copy link
Collaborator

sgugger commented Jun 8, 2023

Can you also add a test where None is passed to Accelerator.prepare? If you rely on this behavior, we need to make sure it's tested so there is no future regression.

@younesbelkada
Copy link
Contributor Author

younesbelkada commented Jun 8, 2023

sure, adding it now
EDT: done!

@younesbelkada younesbelkada requested a review from sgugger June 8, 2023 12:44
Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Thanks!

@younesbelkada younesbelkada merged commit f1e84de into main Jun 8, 2023
@younesbelkada younesbelkada deleted the temp2 branch June 8, 2023 12:56
sgugger pushed a commit that referenced this pull request Jun 8, 2023
* add possibility to pass nonetype objects

* adds nice test
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.

AttributeError: 'NoneType' object has no attribute '_is_accelerate_prepared'
5 participants