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

Fix quantization w/ DeepSpeed not working #32640

Closed
wants to merge 2 commits into from
Closed

Conversation

muellerzr
Copy link
Contributor

What does this PR do?

This PR tweaks the logic check introduced in #32299 to specifically exclude when Zero-3 is enabled and we're using a quantization method (which skips this chunk of the zero3 init use)

Fixes # (issue)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@SunMarc can you check if what I've done here makes sense given the comment we're trying to fix?

#32299 (comment)

I believe so and I think the test makes sense, but you're quant eyes would be appreciated :)

@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.

@jphme
Copy link
Contributor

jphme commented Aug 13, 2024

This fixed the issue with finetuning I reported here, thanks!

Copy link
Member

@SunMarc SunMarc 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 this ! Left a comment

Comment on lines +441 to +445
if (
not (hasattr(model, "hf_quantizer") and model.hf_quantizer.is_trainable)
and is_deepspeed_zero3_enabled()
and not getattr(model, "_transformers_zero3_init_used", True)
):
Copy link
Member

Choose a reason for hiding this comment

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

What's the difference when the model is quantized vs no quantized ?

@amyeroberts
Copy link
Collaborator

For my own understanding - why doesn't the user need to create the model after TrainingArguments in the quantized case but does in the unquantized case?

@muellerzr
Copy link
Contributor Author

muellerzr commented Aug 13, 2024

Quantized weights aren't thrown into the zero_init context manager and instead are using init_empty_weights (I think this answers both your questions)

@muellerzr
Copy link
Contributor Author

Closing since we're doing a full revert

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.

5 participants