Skip to content

Pythia (GPTNeoXForCausalLM) Regression (inference time) in transformers 4.35.0 #28360

Description

@JonasGeiping

System Info

  • transformers version: 4.35.0
  • Platform: Linux-5.16.19-76051619-generic-x86_64-with-glibc2.35
  • Python version: 3.10.11
  • Huggingface_hub version: 0.17.3
  • Safetensors version: 0.3.1
  • Accelerate version: 0.25.0
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.3.0.dev20240104 (True)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using GPU in script?: Yes
  • Using distributed or parallel set-up in script?: No

The Problem

The Pythia models, and by extension the GPTNeoXForCausalLM implementation don't appear to be working correctly in 4.35. I've attached a simple reproduction snippet below. This code works on 4.34, but produces NaNs on 4.35 during the forward pass. The token ids are not particularly anomalous.

The problem is likely related to the report at #28316, but this issue shows that any effects on reward modeling might be 2nd-order effects and that changes between 4.34 and 4.35 are the problem.

@ArthurZucker @younesbelkada

Reproduction

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

model_name_or_path = "EleutherAI/pythia-70m"
model = AutoModelForCausalLM.from_pretrained(model_name_or_path, torch_dtype=torch.float16)


input_ids = [29, 93, 303, 64, 5478, 49651, 10394, 187, 34, 12939, 875]  # this is '<|im_start|>system\nA chat between' 
# alternative: tokenizer('<|im_start|>system\nA chat between')
input_ids = torch.as_tensor(input_ids)[None]

model.cuda()
input_ids = input_ids.cuda()
model(input_ids)["logits"]  # has NaNs?

Expected behavior

Normal forward pass, without NaNs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions