Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Title: Resolve In-Place Operation Error in ESM Embeddings
Description:
This pull request addresses a critical issue concerning in-place operations within the ESM embeddings module which was causing a
RuntimeError
during the backward pass when training with certain configurations. The error message being encountered was:The modifications in this pull request ensure that in-place operations are replaced with out-of-place operations to comply with the PyTorch autograd's requirement, which disallows in-place operations on tensor views to ensure correct gradient computation.
Changes:
modeling_esm.py
with their out-of-place counterparts.RuntimeError
.These changes have been tested and verified to resolve the error during the training phase, thus improving the robustness of the ESM module for a wider variety of training configurations.
This resolution is crucial for researchers and practitioners working with ESM models, ensuring smooth training and utilization of the models provided within the Transformers library.
It's important to note that while resolving the in-place operation error is crucial for correct functionality, the switch from in-place to out-of-place operations may have a slight impact on computational efficiency and memory usage. In-place operations are usually more memory-efficient as they don't require additional memory allocation for storing the results; they directly update the values in the original tensors. On the other hand, out-of-place operations create new tensors to store the results, which can increase the memory footprint of the model.
However, due to the fact that the ESM-2 models are now compatible with QLoRA, this seems negligible and a good compromise.
Fixes # (issue)
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
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.