Skip to content

Conversation

@hlky
Copy link
Contributor

@hlky hlky commented Apr 9, 2025

What does this PR do?

Fixes recent test failures https://github.com/huggingface/diffusers/actions/runs/14350349538/job/40227817766?pr=11238#step:6:33917 caused by transformers deprecation of GenerationMixin on PretrainedModel. We have to use GPT2LMHeadModel instead, this does create a warning Expected types for language_model: (<class 'transformers.models.gpt2.modeling_gpt2.GPT2LMHeadModel'>,), got <class 'transformers.models.gpt2.modeling_gpt2.GPT2Model'>. from the expected type checker as the pretraiend checkpoints have GPT2Model. Unconfirmed but likely increases VRAM usage as a result of output_hidden_states=True - this can be fixed in the future after huggingface/transformers#33705 lands/is extended to other models.

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.

@hlky hlky requested a review from sayakpaul April 9, 2025 07:24
Comment on lines +262 to +265
device_str = device_type
if gpu_id or torch_device.index:
device_str = f"{device_str}:{gpu_id or torch_device.index}"
device = torch.device(device_str)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note this is a partial fix to enable_model_cpu_offload. This may have been known as this won't be tested from fast tests.

Comment on lines +519 to +529
@unittest.skip("Not supported yet due to CLAPModel.")
def test_sequential_offload_forward_pass_twice(self):
pass

@unittest.skip("Not supported yet, the second forward has mixed devices and `vocoder` is not offloaded.")
def test_cpu_offload_forward_pass_twice(self):
pass

@unittest.skip("Not supported yet. `vocoder` is not offloaded.")
def test_model_cpu_offload_forward_pass(self):
pass
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As above these may have been known, added a skip for now.

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

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! Okay for me to investigate the skipped tests in a latter PR.

@hlky
Copy link
Contributor Author

hlky commented Apr 9, 2025

To be clear model_cpu_offload is now working from an end user's perspective, vocoder is small ~0.5gb so not a big problem. For test_cpu_offload_forward_pass_twice the second call of enable_model_cpu_offload is the issue and an end user is unlikely to do that, it works for a second forward when we don't do a second call of enable_model_cpu_offload. Fixing the transformers deprecation is the important thing, best to have this pipeline fixed for today's release.

@DN6 DN6 merged commit 9ee3dd3 into huggingface:main Apr 9, 2025
11 of 12 checks passed
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.

4 participants