Skip to content

[diffusion] Support LTX-2.5 - #34471

Merged
mickqian merged 27 commits into
sgl-project:mainfrom
AgainstEntropy:feat/ltx-2.5-support
Aug 15, 2026
Merged

mickqian merged 27 commits into
sgl-project:mainfrom
AgainstEntropy:feat/ltx-2.5-support

Conversation

@AgainstEntropy

@AgainstEntropy AgainstEntropy commented Aug 11, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Modifications

This PR covered:

  • Distilled and dev (full) ckpt
  • Two-stage upscaler
  • T2I, T2AV, I2AV
  • TP
  • SP
  • CFG parallel
  • Online FP8
  • BCG
  • DiT layerwise offload
  • Cache-DiT
  • Duration head (new)
  • Diffusion video decoder (new)
    • tiling
  • Cookbook

Accuracy Tests

ltx25-fox-121frames-defaults.mp4

Speed Tests and Profiling

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ✅ Run #31859829635
Latest PR Test (Extra): ❌ Run #31859829513

AgainstEntropy and others added 3 commits August 11, 2026 22:46
Both loaders called `load_state_dict(..., strict=False)` and then either
discarded the result (connector) or only logged a count (vocoder), so a
wrong config or a stale weight-name mapping left tensors uninitialized and
showed up much later as garbage embeddings or plausible-but-wrong audio.
Neither loader applied `param_names_mapping` at all.

- apply `param_names_mapping` in both loaders, and raise on any missing or
  unexpected key. `strict=False` is still required: a connector checkpoint
  carries either the shared `text_proj_in` or the per-modality projections,
  never both.
- teach `AdapterLoader` to read sharded connectors via
  `diffusion_pytorch_model.safetensors.index.json`. It previously demanded
  exactly one `.safetensors`, so a sharded connector could not load.
- let `_normalize_archs` fall back to `_ALIAS_TO_MODEL`. The `_aliases`
  mechanism existed but no `resolve_model_cls` caller consulted it, so a
  checkpoint naming a renamed-but-equivalent class was rejected.

Co-Authored-By: Claude Opus 5 <[email protected]>
LTX-2.5 turns out to be the LTX-2.3 architecture rather than a new one, so
it reuses the existing pipeline class, stages and sigma path. Verified by
building each module on the meta device and diffing `state_dict()` against
the checkpoint by name and shape: DiT 4091/4091, connectors 262/262, video
VAE 170/170, vocoder 1227/1227.

Integrates against `Lightricks/LTX-2.5-Diffusers`, which ships a full
diffusers layout. `Lightricks/LTX-2.5` is a ComfyUI-style split pack of bare
safetensors and would need a model overlay first, so it is not registered.

New configs: `LTX25ArchConfig`/`LTX25Config`, `LTX25VideoVAEArchConfig`,
`Gemma4UnifiedConfig`, `LTX25PipelineConfig`, `LTX25SamplingParams`.

Shared LTX-2 code, all defaulting to existing behaviour:

- `ff_bias` / `audio_ff_bias`: 2.5 drops the bias on the video feed-forward
  but keeps it on the audio one.
- `use_keyframes_abs_pos_embedding`: allocates the parameter so the
  checkpoint round-trips. Upstream zero-inits it and the denoising forward
  never reads it.
- `upsample_type` on the VAE decoder: 2.5 mixes spatial-only and
  temporal-only decoder stages instead of upsampling every stage in all
  three dimensions. Note upstream indexes this list in decoder order while
  the sibling per-stage lists are given in encoder order, so unlike them it
  must not be reversed.
- the DiT now takes `param_names_mapping` from its own arch config instead
  of a class attribute pinned to `LTX2ArchConfig`, so a variant can extend
  it. Without this the 2.5 `prompt_adaln` rename never reached the loader,
  which then fell back to diffusers and failed on an unrelated adaLN shape.
- the connector arch config derives its feature-extractor dims from the
  diffusers `per_modality_projections` / `*_hidden_dim` names, so both
  LTX-2 and LTX-2.5 configure themselves from their own `config.json`.
- `LTX2Vocoder` gains an `LTX2VocoderWithBWE` alias and builds its nested
  BWE config from the flat diffusers fields.

The distilled DiT that `model_index.json` points at runs unguided off a
fixed sigma schedule rather than a step count, so `PipelineConfig` grows
`default_sigmas` and the sigma stage honours it.

Verified end to end on 1xH200: 960x544, 121 frames, 8 steps, coherent video
plus 48 kHz stereo audio. LTX-2.3 re-verified unbroken.

Co-Authored-By: Claude Opus 5 <[email protected]>
The LTX-2.5 text encoder loads through `TextEncoderLoader.load_native`, i.e.
`transformers.from_pretrained`, which never consults SGLang's
`param_names_mapping`. `GEMMA_4_UNIFIED_PARAM_NAMES_MAPPING` was therefore
never applied; loading works because `from_pretrained` tolerates the 10-key
vision-embedder drift, and text-to-video never runs the vision path. Removed
it and recorded the required renames in the class docstring so a future
customized (FSDP/TP) encoder can restore them.

Add `test_ltx2_5_config.py`, covering the places where LTX-2.5 diverges from
LTX-2 and where a regression would silently corrupt output rather than raise:

- video-only feed-forward bias
- `param_names_mapping` extends LTX-2's and the prompt_adaln rename round-trips
- decoder upsampler strides follow `upsample_type` in decoder order. This one
  reproduces the bug I hit: reversing that list, like its sibling per-stage
  lists are reversed, silently builds the wrong strides.
- connector derives its feature-extractor dims from the diffusers
  `per_modality_projections` names, so LTX-2 keeps the shared `text_proj_in`
  branch and LTX-2.5 takes the per-modality one
- vocoder builds its nested BWE config from the flat diffusers fields, and
  `LTX2VocoderWithBWE` resolves through the alias
- the pinned distilled sigma schedule, and that LTX-2.5 stays an `ltx_2`
  variant (it uses the LTX-2 linspace sigma path despite sharing 2.3's
  architecture)

All CPU/meta-device: no weights, no GPU.

Co-Authored-By: Claude Opus 5 <[email protected]>
AgainstEntropy and others added 4 commits August 12, 2026 00:00
I2V needed two fixes:

- `LTX25PipelineConfig.task_type` was T2V, which rejects `--image-path`
  outright. LTX-2.5 is one checkpoint driving both, same as LTX-2, so it is
  TI2V. With that, the existing `LTX2ImageEncodingStage` handles 2.5 as-is.
- conditioning images are re-compressed to match training compression, and the
  CRF was hardcoded to 33. LTX-2.5 trained at 18. Upstream keys this off the
  text-encoder generation (`resolve_default_image_crf`), the only signal that
  separates them; `_resolve_image_conditioning_crf` does the same via the
  encoder config prefix. Getting it wrong does not raise -- it just feeds
  conditioning from the wrong compression distribution.

Verified: frame 0 of an I2V run correlates 0.9918 with the conditioning image
and later frames diverge as motion develops.

Duration head (`LTX2DurationHead`, LTX-2.5 onward, optional) predicts the shot
length a caption implies, from the connector outputs. Ported natively; loads
19/19 weights and reproduces the reference prediction exactly (3.28125 s ->
73 frames on the same connector tokens).

- `AdapterLoader` now serves `duration_head` as well as `connectors`, picking
  the arch config per component.
- `_BaseLTX2Pipeline` requires `duration_head` only when `model_index.json`
  declares it, so LTX-2 / 2.3 are unaffected (verified by a 2.3 run).
- `LTX2DurationStage` runs after the connectors and before latent preparation,
  since it rewrites `num_frames`. It is a no-op unless the request opts in.
- `auto_duration` lives on the base `SamplingParams` so `--auto-duration` is
  accepted everywhere and simply ignored by models without a head. Upstream
  expresses the same thing by omitting `num_frames`.
- `duration_head` joins `vocoder` / `connectors` in the LTX special case that
  maps their `ltx2` library string to `diffusers`; `ltx2` is not importable and
  SGLang implements all three natively.

End to end: `--auto-duration` predicts 73 frames and the output has 73.

Co-Authored-By: Claude Opus 5 <[email protected]>
Ports `LTX2VideoDiffusionDecoderModel`, the decoder LTX-2.5 introduces as an
alternative to the convolutional VAE decoder. It is a diffusion model in its
own right: stages 1-4 upsample the latent into a context volume with 3D
neighborhood attention, and stage 5 denoises patchified pixels conditioned on
that context. As shipped (`x0`, one step) stage 5 runs once and its prediction
is the output.

407/407 weights load, and a decode matches the diffusers reference on the same
latent and the same `x_t`: context rel 4.9e-3, output rel 3.5e-3 with
correlation 0.99992 and no bias -- bf16 rounding.

Neighborhood attention is the interesting part. Each query attends a window
that shifts inward at the grid borders so it always covers exactly
`kernel_size` positions. Upstream calls NATTEN's `na3d` and keeps a
FlexAttention block mask as a portable fallback; this port implements only the
FlexAttention path, so it needs no Hub kernel.

That path only works compiled. `flex_attention` called eagerly falls back to
materializing the full S x S score matrix -- 72 GiB at a 17x64x64 stage, which
is why the reference OOMs there on this machine while this does not. The
compile is a correctness-of-resources requirement, not a speed knob, so it is
not optional.

Wiring:
- `AdapterLoader` gains `diffusion_decoder`; it is the same shape as the other
  adapters (config.json plus safetensors) and inherits their strict loading.
- `_BaseLTX2Pipeline` requires it only when `model_index.json` declares it, the
  same treatment the duration head gets, so LTX-2 / 2.3 are untouched.
- `--use-diffusion-decoder` selects it in `LTX2AVDecodingStage`; the latents and
  their denormalization are identical either way. Default stays the VAE decoder,
  matching `LTX2Pipeline` upstream.

Verified end to end at 960x544x25, and both the LTX-2.5 VAE-decode path and
LTX-2.3 still run.

Co-Authored-By: Claude Opus 5 <[email protected]>
The existing `LatentUpsampler` already fits LTX-2.5's `latent_upsampler/`
exactly (72/72 weights); what did not fit was the config normalization and the
two-stage pipeline's assumptions about distillation.

- `_normalize_config` inferred `rational_resampler=True` from the mere presence
  of `rational_spatial_scale`, which held for LTX-2 / 2.3 because they carry no
  explicit flag. LTX-2.5 carries `use_rational_resampler: false`, and assuming
  True builds a different module than the checkpoint holds (3 missing /
  2 unexpected tensors). The explicit key now wins; absent, the old inference
  stands.

- `LTX2TwoStagePipeline` unconditionally required `--distilled-lora-path`. That
  is an LTX-2 / 2.3 shape, where two-stage merges a distilled LoRA onto the dev
  DiT per stage. LTX-2.5 ships an already-distilled transformer and its
  two-stage recipe is stage 1, x2 latent upsample, then a 3-sigma tail, with no
  LoRA anywhere. The requirement, and the LoRA switching itself, now stand down
  when the DiT is pre-distilled. `switch_lora_phase` is guarded at that one
  choke point so every caller is covered, including the refinement stage.

Resolution convention is unchanged: the request names the final size and stage 1
runs at half, so 1088x1920 gives upstream's 544x960 stage 1.

Verified: LTX-2.5 two-stage produces real 1920x1088 detail from a 960x544 stage
1, and LTX-2.3 two-stage still runs with its distilled LoRA.

Co-Authored-By: Claude Opus 5 <[email protected]>
`--model-variant dev` (also `full` / `sft`) serves `transformer_full/`, the
full / SFT DiT. `model_index.json` deliberately omits it, so it has to be
selected explicitly.

It is not distilled, so two things that the distilled path relies on have to be
undone: the pinned distilled sigma schedule is dropped so a step count drives
denoising again, and the dynamic shifting that `scheduler/` turns off for the
distilled DiT is re-enabled (`use_dynamic_shifting=True, shift_terminal=0.1`),
matching the override upstream documents. Callers supply
`--num-inference-steps` and `--guidance-scale`, since unlike the distilled DiT
this one wants CFG.

An explicit `--component-paths.transformer` still wins, and asking for the
variant without the weights present fails with a message that says why -- a
partial snapshot download skips `transformer_full/` because
`from_pretrained` only fetches what the index lists.

Verified end to end at 30 steps / CFG 3.0: coherent video plus 48 kHz audio.
The distilled default is unchanged (no routing, schedule still pinned).

Docs: new LTX2.5 cookbook page covering text-to-video, image-to-video,
auto-duration, two-stage, the dev variant and the diffusion decoder, with a
table of the defaults that differ from LTX-2 / 2.3 so an LTX-2.3 command is not
copied verbatim. Registered in the nav and in the compatibility matrix.

Co-Authored-By: Claude Opus 5 <[email protected]>
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Aug 12, 2026
AgainstEntropy and others added 3 commits August 12, 2026 01:28
`_ipc_input_a2a_qkv` sizes one staging slot from `q` and then writes q, k and v
into three `n`-sized spans of it. That holds only when all three share a
sequence length, i.e. self-attention. Handed cross-attention where the keys and
values are a different length, the copy extents disagree and it raises:

    size of tensor a (1566720) must match tensor b (44032)

which is LTX-2.5's video-to-audio block under `--ulysses-degree 2`: 1530 video
tokens per rank against 43 audio ones.

`_usp_input_all_to_all_qkv` already guards the same precondition
(`q.shape == k.shape == v.shape` in `_can_use_packed_qkv_a2a_4d`) and falls
back to three independent exchanges, so the fix is to apply the same test to
the IPC fast path and return None, which routes the caller there.

This is why the earlier hypotheses missed: the difference was never a config
flag, sharding choice or resolution, but that this fast path is self-attention
only and nothing said so.

LTX-2.5 sequence parallelism now works, and matches the single-GPU result
(correlation 0.994 on the same seed -- attention shards, so the reduction order
differs). LTX-2, LTX-2.3 and LTX-2.5 tensor parallelism all still run.

Co-Authored-By: Claude Opus 5 <[email protected]>
- Deployment section restructured to match the LTX-2 / LTX-2.3 page: basic
  config, configuration tips with pipeline-class and feature-compatibility
  tables, then multi-GPU presets.
- Says plainly what does *not* carry over from LTX-2.3, since that page is the
  obvious thing to copy from: no HQ pipeline class, no `--distilled-lora-path`,
  no `--ltx2-two-stage-device-mode` (all of those exist to swap a distilled LoRA
  between stages, and LTX-2.5's DiT is already distilled), and no CFG
  parallelism, because an unguided model has no negative branch to split.
- Auto-duration and the diffusion decoder are the two genuinely new
  capabilities, so they now get a card pair up front and NEW badges on their
  sections, plus a sentence on when you would actually reach for each.
- NEW tag on the LTX nav group, matching MiniMax-H3.

Co-Authored-By: Claude Opus 5 <[email protected]>
- Add `LTX25Deployment`, an interactive command generator in the shape of the
  existing `LTXDeployment` one. Its axes are the choices that actually exist for
  2.5: deployment target, distilled vs dev weights, one- vs two-stage, VAE vs
  diffusion decoder, fixed vs auto duration. Server-side choices land on
  `sglang serve`; per-request ones are listed separately rather than being
  emitted onto the serve command where they do not belong.

- Rewrite the model introduction from the model card -- what LTX-2.5 is and how
  it is built -- instead of the previous paragraph about repository layout,
  which explained our integration choice rather than the model.

- Replace the thin "what differs" list with three sections that together
  describe the model rather than a handful of deltas: the new capabilities, a
  component table covering every subfolder and what turns it on, and a
  three-way LTX-2 / 2.3 / 2.5 comparison. The last one now also states the
  consequences that bite: `--num-inference-steps` is ignored on the distilled
  path, `--enable-cfg-parallel` buys nothing on an unguided model, and the
  two-stage LoRA flags do not apply.

Co-Authored-By: Claude Opus 5 <[email protected]>

@mickqian mickqian left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you clean the document a bit?

AgainstEntropy and others added 7 commits August 12, 2026 01:58
The comparison table described only the distilled path, which reads as though
that is all LTX-2.5 is. It ships both a distilled DiT (the default) and a full /
SFT one, and several rows differ between them: step counts and guidance are
ignored on one and honoured on the other, dynamic shifting is off then on, and
CFG parallelism is useless on one but fine on the other.

Split them into their own columns, and lead with the actual source of the
surprises: LTX-2 / 2.3 default to a full DiT with a distilled LoRA merged per
stage, while LTX-2.5 defaults to distilled weights. Fixed the same conflation in
the multi-GPU warning and the two-stage note.

Also dropped the feature-compatibility matrix -- every cell was "Yes", so it
carried no information; one sentence says the same thing.

Co-Authored-By: Claude Opus 5 <[email protected]>
It was a migration aid for readers arriving from the LTX-2.3 page, but every
row that mattered operationally is already stated where it applies: the
pipeline-class and LoRA notes in 3.2, CFG parallelism in 3.3, and the dev
variant in 4.5. Kept the one fact that has nowhere else to live -- that the
default distilled DiT ignores `--num-inference-steps` and `--guidance-scale` --
and moved it next to the basic text-to-video command, where someone would
actually hit it.

Co-Authored-By: Claude Opus 5 <[email protected]>
The diffusion decoder was spending nearly all of its time in attention: a
121-frame 960x544 decode did not finish inside ten minutes. Three changes,
each measured on that grid:

Use NATTEN's fused `na3d` for neighborhood attention, as upstream does,
falling back to the compiled FlexAttention block mask when NATTEN is
missing. `project_qkv` already produces NATTEN's layout, so the fast path
needs no reshaping -- and no block mask at all, which removes an O(S^2)
construction that dominated the stage. Measured 4.8x on the stage-5 grid
alone.

Cache the fallback's block masks across decodes, so a server answering
repeated requests at one resolution builds each mask once rather than
per request.

Port upstream's tiling for the last deterministic stage and the diffusion
blocks, under a new `--diffusion-decoder-tiling` (default on, mirroring
`--vae-tiling`). At 121 frames it holds peak memory to 78 GB where the
untiled path needs 110 GB, which is the difference between fitting on an
80 GB card and not.

121-frame decode: 219.7s -> 6.8s. Output parity against the diffusers
reference is unchanged (correlation 0.99993, relative error 3.5e-3);
na3d and the FlexAttention fallback agree to bf16 rounding
(correlation 0.999998), border clamping included.

Two sglang fused kernels were tried and rejected on measurement:
`fused_rmsnorm_scale_shift_bitexact` requires hidden 2048 or 4096 and the
hot blocks are 256-wide, and `silu_and_mul` needs a `cat` of the separate
gate and up projections that costs more than the fusion saves (0.55x).

Co-Authored-By: Claude Opus 5 <[email protected]>
`--quantization fp8` failed on the first denoising step with a bare
`AssertionError: 'x' is not contiguous` from the per-token activation
quantization kernel.

`maybe_pack_latents` ends in a permute followed by two flattens that are
both views, so the packed latents keep the permuted strides: token stride
1, channel stride S. That is a column-major layout. `torch.matmul`
absorbs it, which is why bf16 never noticed, but fp8's per-token
activation quantization asserts on a contiguous input, and the packed
latents feed `patchify_proj` -- the very first quantized linear.

Materialise the row-major copy once at pack time rather than per step
inside the denoising loop. The audio pack already lands contiguous (its
flatten cannot be a view), so it needs nothing.

LTX-2.5 at 960x544, 49 frames: fp8 loads the DiT in 18.11 GB against
35.37 GB for bf16 and peaks at 53.5 GB against 71.1 GB, with denoising
time unchanged. Output is a clean sample of the same scene.

Co-Authored-By: Claude Opus 5 <[email protected]>
Only sequence parallelism splits the latent frame axis across ranks.
Tensor, data and CFG parallelism all replicate that axis, so padding the
clip to be divisible by `num_gpus` stretched the request for parallelism
that does not shard it.

The visible effect was on the LTX-2.5 dev transformer under CFG parallel:
a 49-frame request is 7 latent frames, 7 is not divisible by 2, so the
clip was silently padded to 57 frames. That both wasted an eighth latent
frame of compute and made the same seed produce a different sample on 2
GPUs than on 1 -- the initial noise had a different sequence length.

Align to `sp_degree` instead, which is exactly what is left of `num_gpus`
after TP, DP and CFG parallel.

With this, a 49-frame CFG-parallel run starts from latents bit-identical
to the single-GPU run, and denoising drops from 9.07s to 5.37s (1.69x on
2 GPUs). The two runs still land on visibly different samples, and that
is expected rather than a defect: with identical inputs the conditional
branch differs by 4.2e-3 relative (correlation 1.0000, about half a bf16
ulp, from batch-1 versus batch-2 kernel reductions), guidance scale 3.0
amplifies that to 1.3e-2 in the combined prediction, and 20 denoising
steps amplify it the rest of the way.

Co-Authored-By: Claude Opus 5 <[email protected]>
Both now work, so give them a place in the deployment guidance: an fp8
section with the measured memory numbers, a CFG-parallel row for the dev
weights, and matching controls in the interactive generator. The generator
also warns when CFG parallel is picked alongside the distilled weights,
which run unguided and have no negative branch to split.

Co-Authored-By: Claude Opus 5 <[email protected]>
@AgainstEntropy

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Aug 12, 2026
AgainstEntropy and others added 2 commits August 12, 2026 05:05
The merge with main brought in centralized offload placement, replacing
this loader's `get_local_torch_device()` with a policy lookup. That
rewrite hardcoded `"connectors"` as the component name, which was correct
on main -- `AdapterLoader` served only that one component -- but this
branch extended it to also serve `duration_head` and `diffusion_decoder`,
and the policy answers differently for them: `connectors` follows
`dit_cpu_offload`, while the other two default to staying resident.

So under `--dit-cpu-offload` the duration head and the diffusion decoder
were placed on the CPU against policy, and `--cpu-offload-components
diffusion_decoder` was silently ignored. Pass `component_name`, which is
what every other line in the method and the sibling loaders already use.

Co-Authored-By: Claude Opus 5 <[email protected]>
`mint broken-links --check-anchors` failed with 4 broken links on this
page. Two causes, both in the headings the links point at:

The inline NEW badges were JSX inside the heading text, and that text
feeds the generated anchor slug -- `### 4.3 Auto-duration <span>NEW</span>`
resolves to `sgl-project#4-3-auto-duration-new`, not `sgl-project#4-3-auto-duration`. Moved the
badges to the first line of each section body, so they still render but no
longer sit in the slug. No other cookbook page puts JSX in a heading, and
the nav-level `"tag": "NEW"` in docs.json already marks the group.

`### 4.5 Full / SFT (dev) transformer` mangles its slug through the slash
and parentheses. Retitled to `### 4.5 The dev transformer` and repointed
its two links; the body still names the full / SFT weights.

Verified with the exact CI command: no broken links found.

Co-Authored-By: Claude Opus 5 <[email protected]>
AgainstEntropy and others added 4 commits August 12, 2026 19:04
Both tests failed in CI while passing locally. They went through
`get_model_info` / `ServerArgs`, which read `model_index.json` from the
Hub to resolve the pipeline class; where that fetch fails the resolution
falls back to the generic diffusers config, so `LTX25PipelineConfig`
became `DiffusersTI2VPipelineConfig` and CRF 18 became 33. Locally the
model is cached, so the fetch succeeded and the tests passed.

Neither test is about Hub resolution. Target the layers that actually
carry the behaviour: `_get_config_info` for the path-to-config mapping
(pure string matching) and `_resolve_image_conditioning_crf` given a
config directly (it only reads `text_encoder_configs`).

Also drop a claim the old test did not check. It asserted the LTX-2
detector must exclude the point releases, but all three official paths
are exact-match registry entries and never reach detector code. Replaced
with a case that reflects how derived repos actually resolve -- by
longest registered path stem.

Verified by reproducing the CI condition locally with the Hub caches
redirected and HF_HUB_OFFLINE=1: 35 passed either way.

Co-Authored-By: Claude Opus 5 <[email protected]>
… GPU count"

This reverts commit 6edcddc.

The change was right in principle -- only sequence parallelism splits the
frame axis, so aligning to `num_gpus` pads for parallelism that does not
shard -- but it silently altered LTX-2 output, which does not belong in an
LTX-2.5 support PR.

The CI case requests `seconds=1`, i.e. 24 frames at 24 fps. LTX's valid
temporal grid is 8k+1 (17, 25, 33...) and `adjust_num_frames` does not
snap to it, so 24 frames decode to only 17. Aligning to `num_gpus=2` was
accidentally rounding 24 up to 25 and landing back on the grid; aligning
to `sp_degree=1` removed that accident. Verified locally: main renders 25
frames, the change rendered 17, correlation 0.217 -- matching the
consistency failure CI reported.

The underlying wart is real and predates this branch: on one GPU, asking
LTX-2 for 24 frames already returns 17 today. Fixing that properly means
snapping to the temporal grid regardless of GPU count and regenerating
the affected ground truth, which deserves its own PR.

Co-Authored-By: Claude Opus 5 <[email protected]>
…he producer

`--quantization fp8` fails in the per-token activation quantization
kernel, which indexes its input as row-major and asserts on it. LTX-2
packs its latents with a permute plus two view-flattens, so they reach
the first quantized linear channel-major.

The previous fix normalised the layout where the latents are packed. That
worked, but it also changed which GEMM kernel the *unquantized* path
picks, and two-stage denoising amplified the resulting bf16 difference
into a visibly different sample: LTX-2 two-stage output stopped matching
main, correlation 0.767 against a CI threshold of 30 dB PSNR.

Do it in the fp8 apply instead. Only the quantized path pays the copy,
and it is a no-op when the activation is already contiguous. This also
covers any other diffusion backbone that hands a linear a permuted view,
rather than fixing them one producer at a time.

Verified locally: LTX-2 two-stage on 2 GPUs is now bitwise identical to
main, and LTX-2.5 fp8 still runs and produces the same output as before.

Co-Authored-By: Claude Opus 5 <[email protected]>
The previous 1.69x was measured with the frame-alignment change that has
since been reverted, where the one- and two-GPU runs happened to render
the same frame count. Re-measured at 57 frames, which is eight latent
frames and so needs no padding on either configuration: 15.1s to 8.5s,
1.77x. Stated the resolution, frame count and step count alongside it so
the number is checkable.

Co-Authored-By: Claude Opus 5 <[email protected]>
AgainstEntropy and others added 2 commits August 12, 2026 19:39
…n decoder

The decoder's stages run 3D neighborhood attention, and the fast path is
NATTEN's fused `na3d`. NATTEN is not a dependency of `sglang[diffusion]`,
so out of the box the decoder silently takes the FlexAttention fallback --
same result to bf16 rounding, but about 5x slower on its largest grid,
plus the block-mask construction the fused kernel does not need.

Its wheels are pinned to a torch and CUDA build, so point at natten.org
for the right combination rather than suggesting a bare `pip install
natten`, and give one worked example.

Also drops "minutes rather than seconds" from the surrounding paragraph:
that predated the `na3d` and tiling work, and a 121-frame decode now takes
under seven seconds.

Co-Authored-By: Claude Opus 5 <[email protected]>

@mickqian mickqian left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, how does it work with cache-dit?

…ecoder

Replaces the last diffusers import in the decoder with
`LTX2PixArtAlphaCombinedTimestepSizeEmbeddings`, already in the LTX-2 DiT.
The decoder only ever used the timestep path (`size_emb_dim=0`), which is
exactly what the native module implements, and it also makes the embedder
TP-aware via `ColumnParallelLinear`.

Safe to swap on both counts:

- Parameters. Both expose `timestep_embedder.linear_1 / linear_2`, so the
  checkpoint keys are unchanged and the component still loads with no
  missing or unexpected tensors.
- Math. The native `timestep_embedding` helper is bit-identical to
  diffusers' `Timesteps(256, flip_sin_to_cos=True, downscale_freq_shift=0)`
  (max|delta| = 0 over a range of timesteps), so the sin/cos convention
  matches rather than merely resembling it.

Verified end to end: a 49-frame decode is bitwise identical to the output
before this change.

Note the native module builds `ColumnParallelLinear`, so constructing the
decoder now requires the tensor-parallel group to exist. Every pipeline
path initialises it; only a bare standalone instantiation would need to.

Co-Authored-By: Claude Opus 5 <[email protected]>
@mickqian
mickqian merged commit 5c0ace3 into sgl-project:main Aug 15, 2026
130 of 141 checks passed
saturn-acc pushed a commit to saturn-acc/sglang that referenced this pull request Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diffusion SGLang Diffusion documentation Improvements or additions to documentation run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants