We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
transformers
vision models: @amyeroberts, @qubvel
examples
Run this script:
from transformers import AutoImageProcessor, ConvNextV2Model import torch import torch.nn as nn import time from datasets import load_dataset
dataset = load_dataset("huggingface/cats-image") image = dataset["test"]["image"][0]
image_processor = AutoImageProcessor.from_pretrained("facebook/convnextv2-large-1k-224") model = ConvNextV2Model.from_pretrained("facebook/convnextv2-large-1k-224")
inputs = image_processor(image, return_tensors="pt")
start_time = time.time()
model.train()
logits = model(**inputs).last_hidden_state.mean(dim=1) # [batch_size, hidden_size] criterion = nn.BCEWithLogitsLoss()
fake_logits = torch.randn_like(logits)
loss = criterion(logits, fake_logits) loss.backward()
print(time.time() - start_time)
It seems there is performance degradation between version 4.50.* and 4.51.*. Tried pytorch version 2.4 & 2.7.
In my testing, 4.51.* is about 4x slower than the previous version. Using the script attached:
The text was updated successfully, but these errors were encountered:
While duration is longer, GPU utilization is much higher too, from average of 30% in 4.50.* to 90% in 4.51.*, while running this script.
Sorry, something went wrong.
No branches or pull requests
System Info
transformers
version: 4.51.3Who can help?
vision models: @amyeroberts, @qubvel
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
Run this script:
from transformers import AutoImageProcessor, ConvNextV2Model
import torch
import torch.nn as nn
import time
from datasets import load_dataset
dataset = load_dataset("huggingface/cats-image")
image = dataset["test"]["image"][0]
image_processor = AutoImageProcessor.from_pretrained("facebook/convnextv2-large-1k-224")
model = ConvNextV2Model.from_pretrained("facebook/convnextv2-large-1k-224")
inputs = image_processor(image, return_tensors="pt")
start_time = time.time()
model.train()
logits = model(**inputs).last_hidden_state.mean(dim=1) # [batch_size, hidden_size]
criterion = nn.BCEWithLogitsLoss()
fake_logits = torch.randn_like(logits)
loss = criterion(logits, fake_logits)
loss.backward()
print(time.time() - start_time)
Expected behavior
It seems there is performance degradation between version 4.50.* and 4.51.*. Tried pytorch version 2.4 & 2.7.
In my testing, 4.51.* is about 4x slower than the previous version. Using the script attached:
The text was updated successfully, but these errors were encountered: