Skip to content

[cache] fix HybridCache init when device is passed#37718

Merged
gante merged 1 commit intohuggingface:mainfrom
gante:hybrid_cache_device_arg
Apr 24, 2025
Merged

[cache] fix HybridCache init when device is passed#37718
gante merged 1 commit intohuggingface:mainfrom
gante:hybrid_cache_device_arg

Conversation

@gante
Copy link
Copy Markdown
Contributor

@gante gante commented Apr 23, 2025

What does this PR do?

The following example, where we initialize the model with the device argument, results in cuda graph skips. It can be traced to a stray change in #37007, where the device initialization was incorrectly changed. This PR reverts it.

from transformers import pipeline
import torch

pipe = pipeline(
    "image-text-to-text",
    model="google/gemma-3-4b-it",
    device="cuda",
    torch_dtype=torch.bfloat16
)

output = pipe(text="Write a poem on Hugging Face, the company", max_new_tokens=10)
print(output)

@gante gante requested a review from zucchini-nlp April 23, 2025 15:44
@github-actions github-actions Bot marked this pull request as draft April 23, 2025 15:44
@github-actions
Copy link
Copy Markdown
Contributor

Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the Ready for review button (at the bottom of the PR page). This will assign reviewers and trigger CI.

@gante gante marked this pull request as ready for review April 23, 2025 15:45
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Copy Markdown
Member

@zucchini-nlp zucchini-nlp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@gante gante merged commit 9f927c8 into huggingface:main Apr 24, 2025
22 checks passed
zucchini-nlp pushed a commit to zucchini-nlp/transformers that referenced this pull request May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants