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

QOL improvements and doc updates #1318

Merged
merged 10 commits into from
Jan 12, 2024
Merged

QOL improvements and doc updates #1318

merged 10 commits into from
Jan 12, 2024

Conversation

pacman100
Copy link
Contributor

@pacman100 pacman100 commented Jan 3, 2024

What does this PR do?

  1. Improves doc string for TaskType
  2. Adds cast_non_trainable_to_dtype to cast all non-trainable parameters of the model to the given dtype.
    This is meant to reduce the GPU memory usage when using PEFT methods by using half-precision dtype for non-trainable parameters.

@pacman100 pacman100 changed the title Smangrul/doc updates 1 QOL improvements and doc updates Jan 3, 2024
@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

@BenjaminBossan BenjaminBossan 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 updating the docs and adding the convenience function. Regarding that, I have a question, see the comment.

src/peft/utils/other.py Outdated Show resolved Hide resolved
Copy link
Member

@stevhliu stevhliu 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 the updates! I would also add a short Utilities section in the LoRA API reference like this:

## Utilities

[[autodoc]] utils.get_linear_layer_names

docs/source/developer_guides/lora.md Outdated Show resolved Hide resolved
docs/source/developer_guides/lora.md Outdated Show resolved Hide resolved
Copy link
Member

@BenjaminBossan BenjaminBossan 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 for updating the PR. It is almost good to go, just found a typo and have two small comments.

src/peft/utils/other.py Outdated Show resolved Hide resolved
src/peft/__init__.py Outdated Show resolved Hide resolved
@@ -498,3 +498,23 @@ def id_tensor_storage(tensor: torch.Tensor) -> Tuple[torch.device, int, int]:
unique_id = storage_ptr(tensor)

return tensor.device, unique_id, storage_size(tensor)


def cast_non_trainable_to_dtype(model, dtype):
Copy link
Member

Choose a reason for hiding this comment

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

Just noticing that we may want to use a different name, since the trainable parameters will also be cast. The name could give the impression that trainable parameters are left untouched.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the PR to use cast_mixed_precision_params, let me know if you have better naming suggestions.

pacman100 and others added 4 commits January 12, 2024 14:26
Copy link
Member

@BenjaminBossan BenjaminBossan 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, LGTM.

@pacman100 pacman100 merged commit c6bcf91 into main Jan 12, 2024
14 checks passed
@pacman100 pacman100 deleted the smangrul/doc-updates-1 branch February 20, 2024 05:49
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