Skip to content

Conversation

@charchit7
Copy link
Contributor

What does this PR do?

Fixes #9477

Before submitting

Who can review?

@sayakpaul @LinB203

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

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

Thanks!

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

if is_transformers_available():
import transformers

if transformers.deepspeed.is_deepspeed_zero3_enabled():
Copy link
Contributor

Choose a reason for hiding this comment

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

transformers.deepspeed is deprecated and will be removed in a near future release. Could you look into the alternative transformers.integrations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, give me sometime.

context_manager = deepspeed.zero.GatheredParameters(parameters, modifier_rank=None)

with context_manager():
with context_manager:
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 correct for GatheredParameters but I think will fail in non-DeepSpeed scenarious where nullcontext is used. Could you create the context_manager object too?

context_manager = contextlib.nullcontext()
if deepspeed enabled:
    context_manager = GatheredParameters(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it.

Copy link
Contributor

@a-r-r-o-w a-r-r-o-w left a comment

Choose a reason for hiding this comment

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

Thanks for fixing. But, now line 464 will fail which also needs to be taken into account, since it makes use of the same context_manager object.

Please change with context_manager(): to with context_manager:.

These changes need to be made carefully and all easy to verify code paths should be tested, otherwise it will lead to many more bug reports down the line.

image

@charchit7
Copy link
Contributor Author

Got it, @a-r-r-o-w, thanks.
I missed this one.

@a-r-r-o-w a-r-r-o-w requested a review from yiyixuxu October 15, 2024 12:19
@a-r-r-o-w a-r-r-o-w merged commit 29a2c5d into huggingface:main Oct 16, 2024
15 checks passed
sayakpaul pushed a commit that referenced this pull request Dec 23, 2024
* gatherparams bug

* calling context lib object

* fix

---------

Co-authored-by: Aryan <aryan@huggingface.co>
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.

[BUG] 'GatheredParameters' object is not callable

4 participants