Skip to content

[Feature] LTX-2.x: per-token audio timesteps from the denoise mask, so a DGL script can hold audio latents in one sample call #2469

Done

Description

@tmac1973

Following up on #2399. As suggested there, I continued LTX-2.5 videos from several frames with a DGL script instead of a code change, along the lines of the MiniMax-H3 example in #2440. It works well. The video holds the last 25 frames of the previous clip, the audio holds the same second of sound, and motion and speech carry on across the join. One part of it is slow, though, and I think a small change in sd.cpp would fix it.

The problem

When sample gets a denoise_mask, LTX video tokens get their own timestep from the mask (process_ltxav_video_timesteps), but the whole audio stream gets a single one, the current sigma (separate_audio_time in src/dgl/models/dit.cpp, where audio_time is built from base_times). So with mask_input = true, held audio latents go in clean while the model is told they are as noisy as everything else. In practice the new audio comes out nearly silent: in three tries, speech after the held second was at 1–40% of the source clip's loudness. Holding only the video gives normal speech, but the voice no longer carries over.

The workaround, and what it costs

I run the Euler steps one at a time with fold, one sample call per step. Each call gets a base where the held video is clean and the held audio is add_noised to that step's sigma, and at the end the exact held latents are put back. That gives the right result: the speech continues in the same voice, and in two of three tries the join can't be heard.

The cost shows up when memory is tight. On a 32 GB R9700 with a 23 GiB --max-vram (to imitate a 24 GB card), 121 frames at 1280×720 with the text encoder on the CPU, the DiT doesn't fit beside the compute buffers, so it is streamed in segments. One 8-step sample call plans that once. Eight one-step calls stream the weights again every time: 52 s per step instead of about 8 s, and 470 s for the clip instead of 152 s. With the whole card it's 6 s per step either way.

The request

When a mask is given, derive audio timesteps per audio token from the audio part of the mask, the same way it's already done for video tokens: mask × t. Held audio could then go in clean with mask_input = true in a single sample call, as the video already does.

As far as I can see, the LTX model in src/model/diffusion/ltxv.hpp already takes an audio_timesteps tensor. It's only ever filled with one value. Two things to check:

  • The audio-to-video cross-attention modulation repeats the audio timestep as a scalar (repeat_scalar_timestep_like(ctx, effective_audio_timestep, timestep) in ltxv.hpp). It needs a rule for per-token audio timesteps, for example the timestep of the tokens being generated.
  • An alternative that changes less would be a mask_input per stream, or an option to give audio the noised base, as in the H3 example. But per-token timesteps would match how LTX handles video conditioning.

Setup

I can test a patch on the R9700 and on an RTX A4000.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions