Skip to content

Missing _use_flash_attention_2 in Llama Model with ContrastVecLlamaForCausalLM #56

@slfg

Description

@slfg

Hello, I encountered an error while following the honesty_contrast_vec_TQA_mc example. When using the ContrastVecLlamaForCausalLM class with the Llama-2-7b-hf model (I also tested with Llama-2-7b-chat-hf), I received the following error:

   1727             if name in modules:
   1728                 return modules[name]
-> 1729         raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
   1730 
   1731     def __setattr__(self, name: str, value: Union[Tensor, 'Module']) -> None:

AttributeError: 'LlamaModel' object has no attribute '_use_flash_attention_2'

This error occurred at the following line:

model_baseline_acc = get_tqa_accuracy(model, questions, answers, labels, tokenizer, batch_size=batch_size)

I tried downgrading and upgrading the relevant packages (transformers, torch and accelerate) without success.

Environment Details

  • Transformers version: Between 4.45.2 and 4.42.3
  • Torch version: Between 2.5.0+cu124 and 2.4.0
  • Accelerate version: Between 1.0.1 and 0.31.0
  • torch_dtype: bfloat16 and float16

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions