diff --git a/minimax-h3/h3.py b/minimax-h3/h3.py index 8baa8862..32f74765 100644 --- a/minimax-h3/h3.py +++ b/minimax-h3/h3.py @@ -1539,24 +1539,26 @@ async def vae_round_trip( frames = steps // LATENTS_PER_CHUNK * FRAMES_PER_CHUNK + 5 kept: list[Tensor] = [] index: list[int] = [] + # The decode lands each chunk's RGB8 frames on the host and nothing else: the MP4 is written after it (`save_video`), + # so `vae_decode` times the VAE, not a host's video encoder running beside it (gate 44090355818's pod: 7.8 s, 4.5 s on + # another), as ComfyUI's VAEDecode is timed. + landed: list[Tensor] = [] with tel.stage("vae_decode"): - stream = _VideoStream(torch, out, frames=frames, waveform=None, sample_rate=0, cancel=ctx.raise_if_cancelled, - progress=ctx.progress) # fmt: skip def push(chunk: Tensor) -> None: - first = stream.landed + first = sum(int(piece.shape[0]) for piece in landed) for at in range(-first % _KEPT_EVERY, int(chunk.shape[0]), _KEPT_EVERY): kept.append(chunk[at].float().cpu()) index.append(first + at) - stream.push(chunk) + landed.append(chunk.clamp(0, 1).mul(255).round().to(torch.uint8).cpu()) - try: - base_model.decode_latents(latents.to(str(base_model.device), torch.float32), on_chunk=push) - except BaseException: - stream.abandon() - raise + base_model.decode_latents(latents.to(str(base_model.device), torch.float32), on_chunk=push) + stream = _VideoStream(torch, out, frames=frames, waveform=None, sample_rate=0, cancel=ctx.raise_if_cancelled, + progress=ctx.progress) # fmt: skip try: with tel.stage("save_video"): + for piece in landed: + stream.push(piece.float().div_(255)) saved = stream.finish(ctx.progress) except BaseException: stream.abandon() diff --git a/minimax-h3/pyproject.toml b/minimax-h3/pyproject.toml index 9d0c1ba2..f033619a 100644 --- a/minimax-h3/pyproject.toml +++ b/minimax-h3/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "minimax-h3" -version = "0.16.0rc1" +version = "0.16.0rc2" description = "MiniMax H3 video with sound: a shot of any length, an edit of a plate, and its upscale" requires-python = ">=3.12,<3.15" dependencies = [ diff --git a/minimax-h3/uv.lock b/minimax-h3/uv.lock index 1420b7f4..08241ee5 100644 --- a/minimax-h3/uv.lock +++ b/minimax-h3/uv.lock @@ -354,7 +354,7 @@ wheels = [ [[package]] name = "minimax-h3" -version = "0.16.0rc1" +version = "0.16.0rc2" source = { editable = "." } dependencies = [ { name = "cozy-runtime", extra = ["adapters", "media"] },