Skip to content

BetterTransformer not supporting CodeGen2 #1050

Description

@ganler

System Info

Name: optimum
Version: 1.8.4
Summary: Optimum Library is an extension of the Hugging Face Transformers library, providing a framework to integrate third-party libraries from Hardware Partners and interface with their specific functionality.
Home-page: https://github.com/huggingface/optimum
Author: HuggingFace Inc. Special Ops Team
Author-email: [email protected]
License: Apache
Location: /home/jiawei/.conda/envs/g/lib/python3.8/site-packages
Requires: coloredlogs, datasets, huggingface-hub, numpy, packaging, sympy, torch, torchvision, transformers
Required-by: 
Ubuntu 20.04; Python 3.8; 4xA6000 GPUs

Who can help?

@fx

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

from transformers import AutoTokenizer, AutoModelForCausalLM
from optimum.bettertransformer import BetterTransformer

tokenizer = AutoTokenizer.from_pretrained("Salesforce/codegen2-16B")
model = AutoModelForCausalLM.from_pretrained(
    "Salesforce/codegen2-16B", trust_remote_code=True, revision="main"
)
model = BetterTransformer.transform(model, keep_original_model=True)

text = "def hello_world():"
input_ids = tokenizer(text, return_tensors="pt").input_ids
generated_ids = model.generate(input_ids, max_length=512)
print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))

Expected behavior

image

It should work as this is basically the codegen architecture which is stated to be supported in https://huggingface.co/docs/optimum/v1.8.3/bettertransformer/overview

However, it will fail by throwing an exception saying None has no attribute of ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions