Fix PriorTransformer Group Offloading Bug - #14695
Conversation
`PriorTransformer` holds `clip_mean` / `clip_std` as parameters of the model
itself rather than of a submodule, so group offloading gathers them into the
"unmatched group" whose hook wraps the top-level `forward`. They are therefore
onloaded only for the duration of `forward`, while `post_process_latents` runs
after the denoising loop and saw them back on the offload device:
RuntimeError: Expected all tensors to be on the same device, but found at
least two devices, cuda:0 and cpu!
Move them to the latents' device explicitly.
This also fixes the same failure in the three Kandinsky prior pipelines, whose
strict xfail markers now XPASS, so remove them along with the overrides that
existed only to carry them. Their `PIPELINE_GROUP_OFFLOAD_XFAIL_REASON` was a
misdiagnosis: the model-level parameters are onloaded for `forward`, and the
pipeline-level test was failing on `post_process_latents` like the others.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Self-Review ReportSelf-reviewDiff reviewed: Blocking issuesNone. Non-blocking issues1. The
The deleted xfail 2. Same bug class, same pipeline, left unfixed
Dead code (advisory)
Suggestions / additional infoAgent-doc proposal (per Checked and clean — so the reviewer knows these were considered:
VerificationThe two SummaryA one-line device fix in shared model code, plus removal of the strict xfail scaffolding it obsoletes in three Kandinsky prior test files — which is mandatory, not optional, since strict XPASS reports as a CI failure. The change follows the file's existing input-derived-cast idiom and the Verdict: READY
|
|
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. |
|
/diffusers-bot pytest tests/pipelines/stable_unclip/test_stable_unclip.py tests/pipelines/kandinsky/test_kandinsky_prior.py tests/pipelines/kandinsky2_2/test_kandinsky_prior.py tests/pipelines/kandinsky2_2/test_kandinsky_prior_emb2emb.py -k "group_offloading" |
|
✅ |
|
Merging as the GPU test run from #14695 (comment) is green and the CI failures are unrelated. |
What does this PR do?
This PR fixes a group offloading bug in pipelines that use a
PriorTransformercomponent: because these pipelines callPriorTransformer.post_process_latentsafterPriorTransformer.forward, andpost_process_latentsuses theclip_meanandclip_stdparameters directly, if group offloading is active, these parameters will be offloaded (since the offload hook is onforwardand has fired), which causes a device mismatch error. This affects the following pipelines, whose group offloading tests should now pass:mainon GPU)pytest tests/pipelines/stable_unclip/test_stable_unclip.py -k "group_offloading"main)pytest tests/pipelines/kandinsky/test_kandinsky_prior.py -k "group_offloading"pytest tests/pipelines/kandinsky2_2/test_kandinsky_prior.py -k "group_offloading"pytest tests/pipelines/kandinsky2_2/test_kandinsky_prior_emb2emb.py -k "group_offloading"See #14635 (comment) for more info.
Before submitting
self-reviewskill on the diff?documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@sayakpaul
@DN6