Repository navigation
Conversation
With only the transformer on the accelerator, the LTX-2 pipelines run on the accelerator (#14383), but they gave the text encoder, the connectors, the duration head, the VAE, the audio VAE and the vocoder their inputs on that device. They failed as soon as one of these components stayed on the CPU. Move the inputs of each component to its own device, as #14739 does for other pipelines, and add an opt-in test that runs a pipeline with only its denoiser on the accelerator. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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. |
huggingface/diffusers#15420 gives each component of the LTX-2 pipelines its inputs on its own device, which would remove the need to pin the pipeline to the host. The paragraph no longer says the planned `_tp_plan` would make the first workaround unnecessary. The LTX-2.5 attention normalizes the queries and keys over all the heads, so a plan alone does not replace its attention processor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JingyaHuang
left a comment
There was a problem hiding this comment.
thanks for adding the fix to ltx-2! just a small nit for the test helper.
|
|
||
| def test_split_device_forward_pass(self, base_pipe_output, expected_max_diff=1e-4): | ||
| pipe = self.get_pipeline() | ||
| denoiser = getattr(pipe, "transformer", None) or getattr(pipe, "unet", None) |
There was a problem hiding this comment.
maybe we should make this more configurable, so a pipeline can choose which components go on the accelerator instead of only the denoiser?
There was a problem hiding this comment.
I don't understand the test. How does it show that the pipeline has split device setting?
There was a problem hiding this comment.
I modified the mixin to make it more generic and the test class instantiations to better show what is on the device.
| text_encoder_hidden_states = text_encoder_outputs.hidden_states | ||
| text_encoder_hidden_states = torch.stack(text_encoder_hidden_states, dim=-1) | ||
| prompt_embeds = text_encoder_hidden_states.flatten(2, 3).to(dtype=dtype) # Pack to 3D | ||
| prompt_embeds = text_encoder_hidden_states.flatten(2, 3).to(device=device, dtype=dtype) # Pack to 3D |
There was a problem hiding this comment.
Should it not be model_device?
There was a problem hiding this comment.
@sayakpaul that's the pattern drawn by @JingyaHuang that I replicate here: model_device is where the text encoder runs, so only its inputs go there. The embeddings go to the pipeline device.
| text_encoder_hidden_states = torch.stack(text_encoder_hidden_states, dim=-1) | ||
| prompt_embeds = text_encoder_hidden_states.flatten(2, 3).to(dtype=dtype) # Pack to 3D | ||
| prompt_embeds = text_encoder_hidden_states.flatten(2, 3).to(device=device, dtype=dtype) # Pack to 3D | ||
| prompt_attention_mask = prompt_attention_mask.to(device) |
|
|
||
| def test_split_device_forward_pass(self, base_pipe_output, expected_max_diff=1e-4): | ||
| pipe = self.get_pipeline() | ||
| denoiser = getattr(pipe, "transformer", None) or getattr(pipe, "unet", None) |
There was a problem hiding this comment.
I don't understand the test. How does it show that the pipeline has split device setting?
`SplitDeviceTesterMixin` places the components named in `accelerator_components` on the accelerator, instead of looking up the transformer or the unet. It defaults to the transformer, so the LTX-2 tests keep the same placement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`SplitDeviceTesterMixin` no longer defaults `accelerator_components` to the transformer. Each LTX-2 test class sets it, so the test shows which components it places on the accelerator. The class docstrings name the transformer instead of the denoiser. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem
#14739 lets a pipeline run with its components on different devices, for example the denoiser on the accelerator and the text encoder and VAEs on the CPU. It didn't cover the LTX-2 pipelines. With such a split they run on the accelerator (#14383), but they still move the inputs of every component there. So they fail as soon as the text encoder, the connectors, the duration head, the VAE, the audio VAE or the vocoder stays on the CPU.
What this PR does
get_module_execution_device, and its outputs go back to the pipeline's device.SplitDeviceTesterMixinto the pipeline test utils. It runs a pipeline with only its denoiser on the accelerator, and compares the output with the run where everything is on the accelerator. It's opt-in, because the pipelines [core] Fix component device placement for split-device pipelines #14739 didn't fix would fail it. Each LTX-2 test file composes it.How to use it
Testing
maintoo, even with every component on the core (in the scheduler's noise draw). So its split path is untested there.🤖 Generated with Claude Code