Fix LTX-2 context parallel plan and Ulysses attn mask head sharding - #14317
Open
PaulFidika wants to merge 1 commit into
Open
PaulFidika wants to merge 1 commit into
PaulFidika wants to merge 1 commit into
Conversation
NancyFyong
added a commit
to NancyFyong/diffusers
that referenced
this pull request
Sep 23, 2026
Helios gathers activations inside every block, so its replicated residual stream receives gradients that no reduction across context-parallel ranks can correct. Raise on backward instead of producing wrong gradients; inference is unaffected. Ulysses Anything scatters heads but not a per-head mask dimension, which LTX and LTX2 produce. Raise a clear error before communication instead of a shape mismatch inside the attention backend. Drop the LTX2 parity suite, whose context-parallel plan is fixed separately in huggingface#14317, and run LTX without its per-head mask. Document that replicated parameter gradients must be summed across context-parallel ranks. AI assistance (pi coding agent) was used for this change. Co-authored-by: pi coding agent Signed-off-by: NancyFyong <88076188+NancyFyong@users.noreply.github.com>
9 tasks
DN6
reviewed
Sep 28, 2026
| 0: ContextParallelInput(split_dim=1, expected_dims=3, split_output=True), | ||
| 1: ContextParallelInput(split_dim=1, expected_dims=3, split_output=True), | ||
| } | ||
| self._cp_plan = { |
Collaborator
There was a problem hiding this comment.
I don't think we need to make this an instance attribute. If we set
_rope_cp_plan = {
0: ContextParallelInput(split_dim=-2, expected_dims=None, split_output=True),
1: ContextParallelInput(split_dim=-2, expected_dims=None, split_output=True),
}this should work for both layouts and with the existing class attribute cp plan.
This branch has not been deployed
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.
LTX-2's
_cp_planwas a copy of LTX-1's, soenable_parallelism()crashed on the per-token timestep and never sharded the audio stream or 3 of the 4 RoPE modules — and sharding video only would be silently wrong for the bidirectional a2v/v2a cross-attention. The plan is now set in__init__because the RoPE sequence dim depends on config:(B, T, D)forrope_type="interleaved"vs(B, H, T, D//2)for"split"(what the released checkpoint uses). Two adjacent fixes this surfaced:TemplatedUlyssesAttentionnow shards a 4-D attn mask's head axis to match the post-all-to-all QKV heads, and the CP hook now skips planned params the caller didn't pass (LTX-2's optionalaudio_timestep) instead of raising.CPU repro from #14316 on this branch (2 ranks, gloo, built-in plan, both rope types):
Also validated on 2xH100 (NVLink) with the released
Lightricks/LTX-2checkpoint (LTX2Pipeline, 1280x704, 121 frames, bf16): a single transformer forward underulysses_degree=2matches single-GPU exactly (fp32 max|delta| <= 4.2e-7, bf16 bitwise on a small config), and the full 20-step run produces the same video+audio take with bf16 accumulation drift 4-9x below the delta between two seeds (latent rel-RMS 0.21 vs 0.92 video, 0.07 vs 0.62 audio).The two remaining gaps stay tracked in #14316: the
(B, T_v, T_v)IC-LoRA self-attention mask (not expressible as a plan entry) and theulysses_anythingmask path. Fixes #14316.