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

ENH Layer/model status shows devices now #1743

Conversation

BenjaminBossan
Copy link
Member

For each adapter, show all the devices of this adapter's parameters.

Also, while working on this, found a very minor bug in VeRA as its linear layer didn't implement its own __repr__.

For each adapter, show all the devices of this adapter's parameters.

Also, while working on this, found a very minor bug in VeRA as its
linear layer didn't implement its own __repr__.
@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.

@BenjaminBossan
Copy link
Member Author

ping @sayakpaul maybe also interesting for diffusers

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.

Just a single comment. I like this feature a lot!

The tests are very comprehensive.

Would you mind adding a note about this (once this is merged) to https://huggingface.co/docs/diffusers/main/en/tutorials/using_peft_for_inference?

Comment on lines +2522 to +2525
elif (
isinstance(adapter_module, torch.nn.ParameterDict)
or (adapter_module.__class__.__name__ == "BufferDict") # VeRA
):
Copy link
Member

Choose a reason for hiding this comment

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

Should this be covered for DoRA too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this works for DoRA too. As DoRA is just a LoraModel, the shown status will be almost the same for LoRA and DoRA, except that DoRA has a few more parameters.

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 @BenjaminBossan for adding the features for showing model and layer adapter details and improving that to add the device details! Left a couple nits.

TunerLayerStatus(name='text_model.encoder.layers.0.self_attn.v_proj',
module_type='lora.Linear',
enabled=True,
active_adapters=['adapter-2'],
merged_adapters=[],
requires_grad={'adapter-1': False, 'adapter-2': True},
available_adapters=['adapter-1', 'adapter-2']),
devices={'adapter-1': ['cpu'], 'adapter-2': ['cuda]}),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
devices={'adapter-1': ['cpu'], 'adapter-2': ['cuda]}),
devices={'adapter-1': ['cpu'], 'adapter-2': ['cuda']},

@@ -244,5 +246,6 @@ TunerModelStatus(
merged_adapters=[],
requires_grad={'adapter-1': False, 'adapter-2': True},
available_adapters=['adapter-1', 'adapter-2'],
devices={'adapter-1': ['cpu'], 'adapter-2': ['cuda],
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
devices={'adapter-1': ['cpu'], 'adapter-2': ['cuda],
devices={'adapter-1': ['cpu'], 'adapter-2': ['cuda']},

Copy link
Collaborator

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

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

Thanks a lot !

@BenjaminBossan BenjaminBossan merged commit 691bc22 into huggingface:main May 21, 2024
14 checks passed
@BenjaminBossan BenjaminBossan deleted the enh-layer-and-model-status-adapter-device branch May 21, 2024 13:35
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

5 participants