[Model] Add LTX-2.5 support (#6070)
Signed-off-by: lishunyang12 <lishunyang12@163.com>
This commit is contained in:
1 parent
f39b8684eb
commit
ce6ab0ca46
47 files changed
+4558
-218
No files matched your search
@@ -202,3 +202,68 @@ def test_prepare_audio_latents_rejects_incompatible_provided_length():
|
||||
device=torch.device("cpu"),
|
||||
latents=latents,
|
||||
)
|
||||
|
||||
|
||||
def test_create_noised_state_matches_official_fp32_lerp():
|
||||
latents = torch.linspace(-2, 2, 4096, dtype=torch.bfloat16).reshape(1, 32, 128)
|
||||
expected_generator = torch.Generator().manual_seed(42)
|
||||
noise = torch.randn(latents.shape, generator=expected_generator, dtype=latents.dtype)
|
||||
expected = torch.lerp(latents.float(), noise.float(), torch.tensor(0.15, dtype=torch.bfloat16).float()).to(
|
||||
latents.dtype
|
||||
)
|
||||
|
||||
actual = latent_ops.create_noised_state(
|
||||
latents,
|
||||
torch.tensor(0.15, dtype=torch.bfloat16),
|
||||
torch.Generator().manual_seed(42),
|
||||
)
|
||||
|
||||
torch.testing.assert_close(actual, expected, rtol=0, atol=0)
|
||||
|
||||
|
||||
def test_create_conditioned_noised_state_matches_official_two_lerps():
|
||||
latents = torch.linspace(-2, 2, 24, dtype=torch.bfloat16).reshape(1, 3, 8)
|
||||
clean_latents = latents.clone()
|
||||
clean_latents[:, 0] = 3.0
|
||||
denoise_mask = torch.tensor([[[0.0], [1.0], [1.0]]])
|
||||
expected_generator = torch.Generator().manual_seed(42)
|
||||
noise = torch.randn(latents.shape, generator=expected_generator, dtype=latents.dtype)
|
||||
noised = torch.lerp(latents.float(), noise.float(), 0.909375)
|
||||
expected = torch.lerp(clean_latents.float(), noised, denoise_mask).to(latents.dtype)
|
||||
|
||||
actual = latent_ops.create_conditioned_noised_state(
|
||||
latents,
|
||||
clean_latents,
|
||||
denoise_mask,
|
||||
0.909375,
|
||||
torch.Generator().manual_seed(42),
|
||||
)
|
||||
|
||||
torch.testing.assert_close(actual, expected, rtol=0, atol=0)
|
||||
|
||||
|
||||
def test_prepare_supplied_video_latents_uses_official_token_major_layout():
|
||||
pipeline = _make_pipeline(LTX2Pipeline)
|
||||
supplied = torch.arange(512, dtype=torch.float32).reshape(1, 32, 16)
|
||||
actual_video = pipeline.prepare_latents(
|
||||
batch_size=1,
|
||||
num_channels_latents=4,
|
||||
height=64,
|
||||
width=64,
|
||||
num_frames=9,
|
||||
dtype=torch.float32,
|
||||
device=torch.device("cpu"),
|
||||
latents=supplied,
|
||||
)
|
||||
|
||||
torch.testing.assert_close(actual_video, supplied, rtol=0, atol=0)
|
||||
assert actual_video.stride()[1:] == (1, actual_video.shape[1])
|
||||
|
||||
|
||||
def test_clear_audio_padding_keeps_padding_outside_sampler_state():
|
||||
updated = torch.tensor([[[1.0, 2.0], [3.0, 4.0], [99.0, -99.0]]])
|
||||
|
||||
actual = latent_ops.clear_audio_padding(updated, 2)
|
||||
|
||||
torch.testing.assert_close(actual[:, :2], updated[:, :2])
|
||||
torch.testing.assert_close(actual[:, 2:], torch.zeros_like(actual[:, 2:]))
|
||||
Reference in new issue
Block a user