[core] DiffusionPipeline.device deduction for split-device pipelines - #14383
Open
JingyaHuang wants to merge 2 commits into
Open
[core] DiffusionPipeline.device deduction for split-device pipelines#14383JingyaHuang wants to merge 2 commits into
DiffusionPipeline.device deduction for split-device pipelines#14383JingyaHuang wants to merge 2 commits into
Conversation
|
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. |
sayakpaul
reviewed
Aug 4, 2026
Comment on lines
+1975
to
+1977
| # With every component on CPU there is no accelerator to prefer. | ||
| sd.to("cpu") | ||
| assert sd.device.type == "cpu" |
Member
There was a problem hiding this comment.
But will we be able to run the pipeline with this configuration? For the test, I would also try to mimic the scenario in which this will be used in a minimal manner.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
What does this PR do?
Follow-up to the discussion in #13718 (cc @sayakpaul @DN6), split out as requested.
DiffusionPipeline.devicereturns the device of the first module component in alphabetical order of the__init__signature (eg.text_encoderfor Flux, Flux.2, Qwen-Image). When a pipeline is deliberately split across devices,DiffusionPipeline.devicereports the device where locates the text encoder, for example:This PR prefers any non-CPU, non-meta component, falling back to the previous first-component behaviour when there is nothing else to prefer. Backend-agnostic CUDA, XPU, and other accelerators, including TP-sharded models whose DTensor
parameters report their local shard device.