Skip to content

Commit

Permalink
FIX: Adjust transformers version check for bloom (#1992)
Browse files Browse the repository at this point in the history
The fix to the bloom architecture was not actually released in
transformers 4.43.3, which makes the version check invalid. Instead, now
checking an attribute on the BloomPreTrainedModel.
  • Loading branch information
BenjaminBossan authored Aug 6, 2024
1 parent b926030 commit 4611034
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/peft/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import packaging.version
import torch
import transformers
from transformers import BloomPreTrainedModel


# needed for prefix-tuning of bloom model
Expand Down Expand Up @@ -46,9 +45,10 @@ def starcoder_model_postprocess_past_key_value(past_key_values):
"gpt_bigcode": starcoder_model_postprocess_past_key_value,
}

if packaging.version.parse(transformers.__version__) <= packaging.version.parse("4.43.3"):
if hasattr(BloomPreTrainedModel, "_convert_to_standard_cache"):
# special handling for bloom architecture was fixed in:
# https://github.com/huggingface/transformers/pull/31445
# the _convert_to_standard_cache method is removed in the PR and thus serves as an indicator
TRANSFORMERS_MODELS_TO_PREFIX_TUNING_POSTPROCESS_MAPPING["bloom"] = bloom_model_postprocess_past_key_value

TRANSFORMERS_MODELS_TO_LNTUNING_TARGET_MODULES_MAPPING = {
Expand Down

0 comments on commit 4611034

Please sign in to comment.