Skip to content

[WIP] Processor moves to device in __call__ - #43249

Open
zucchini-nlp wants to merge 1 commit into
huggingface:mainfrom
zucchini-nlp:device-batch-features
Open

zucchini-nlp wants to merge 1 commit into
huggingface:mainfrom
zucchini-nlp:device-batch-features

Conversation

@zucchini-nlp

@zucchini-nlp zucchini-nlp commented Jan 13, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

This PR allows users to pass the device to processor call and get all inputs in the requested device. Currently the device arg is used only in fast image/video processors. But users get confused by the following case

inputs = processor(images, text, device='cuda', return_tensors='pt')

# Before the PR
print(inputs.input_ids.device) # "cpu"
print(inputs.pixel_values.device) # "cuda"

# After the PR
print(inputs.input_ids.device) # "cuda"
print(inputs.pixel_values.device) # "cuda

Now we will allow either to pass device and get all inputs initialized already on device, or to move to device manually by inputs.to(device)

Fixes #42722

@github-actions

Copy link
Copy Markdown
Contributor

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43249&sha=703f75

@ArthurZucker

Copy link
Copy Markdown
Collaborator

Closing this WIP: the image-processor backend refactor removed image_processing_utils_fast.py and the *_fast processors it edits, so it can't be rebased as it is. Moving outputs to device in __call__ is still a good idea if we want to pick it up again on the new backend layout.

@zucchini-nlp

Copy link
Copy Markdown
Member Author

wait dont close, i will forget it ever existed otherwise 😆 This is my reminder

@zucchini-nlp zucchini-nlp reopened this Oct 21, 2026

This branch has not been deployed

No deployments
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.

Ensure that OneFormerProcessor place text task_inputs to the same device as other inputs

2 participants