Taking Trainium3 to the Track: Generating Videos with LTX-2.5

本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。

Taking Trainium3 to the Track: Generating Videos with LTX-2.5

回到文章:将 Trainium3 带上赛道:使用 LTX-2.5 生成视频。发布于 2026 年 11 月 27 日。GitHub 更新,点赞 11 +5。作者:David Corvoysier (dacorvo)、Jingya Huang (Jingya)、Sayak Paul (sayakpaul)。

Thanks to our partnership with AWS, we were lucky enough to get access to a Trainium3 machine (trn3.48xlarge, 64 NeuronCores) for a month. We spent most of the month testing Hugging Face models on it, and getting more of them to work. With five days left, I allowed myself a little fun. When you have a Ferrari, every now and then you want to take it out on the track. So I asked myself: what if I tried to generate videos?

多亏了我们与 AWS 的合作,我们有幸获得了一台 Trainium3 机器(trn3.48xlarge,64 个 NeuronCore)一个月的访问权限。我们花了一个月的大部分时间在上面测试 Hugging Face 模型,并让更多的模型能够运行。在剩下五天的时候,我让自己享受了一点乐趣。当你拥有一辆法拉利时,偶尔总想把它开上赛道。所以我问自己:如果我尝试生成视频会怎样?

I picked LTX-2.5 from Lightricks, which generates video and sound together. By the end, once the models were loaded, a 10-second clip with sound took 22 to 23 s to generate, on half of the machine. Here is the result. A seal dreams of warm sand. Generated entirely on Trainium3.

我选择了 Lightricks 的 LTX-2.5,它可以同时生成视频和声音。最终,在模型加载完成后,在机器的一半算力上,生成一段 10 秒带声音的剪辑需要 22 到 23 秒。这是结果:一只海豹梦见温暖的沙滩。完全在 Trainium3 上生成。

Two goals I had two goals. The first was to see how easy it is to generate videos with diffusers on Trainium3. Not the simple clips from the examples: I wanted to make short films from a script, closer to a real use case, like drafting a movie. The second was performance. I wanted to get close to what you get with CUDA, or with LTX’s own API.

我有两个目标。第一个是看看在 Trainium3 上使用 diffusers 生成视频有多容易。不是示例中那种简单的剪辑:我想根据剧本制作短片,更接近真实的用例,就像起草一部电影一样。第二个是性能。我想接近使用 CUDA 或 LTX 自身 API 所能达到的效果。

For CUDA, I found no real figure to compare against. The only one is LTX’s claim of 6.8 s for a 10-second 720p clip on four B200 GPUs, with no detail on how it was measured. So I set CUDA aside and compared with LTX’s online API instead, which LTX says makes a 10-second 1080p clip in 23.7 s.

对于 CUDA,我没有找到可以对比的真实数据。唯一的数据是 LTX 声称在四块 B200 GPU 上生成 10 秒 720p 剪辑需要 6.8 秒,但没有说明测量细节。所以我搁置了 CUDA,转而与 LTX 的在线 API 进行比较,LTX 称其生成 10 秒 1080p 剪辑需要 23.7 秒。

In the end, the setup matches it, and even beats it by about a second: 22 to 23 s for a 10-second clip at 2048×1024, once the models are loaded, on half of the machine. Not bad, considering how little time I had to optimize the pipelines.

最终,该设置与它持平,甚至快了约一秒:在模型加载后,利用机器的一半算力,生成 2048×1024 分辨率的 10 秒剪辑仅需 22 到 23 秒。考虑到我优化流水线的时间非常有限,这还不错。

How it works The input is a film: a JSON list of shots, each with a name and a prompt, much like a storyboard. LTX-2.5 does better with long prompts, so each prompt is a paragraph on the style, the subject, the motion, the camera, the light and the sound.

工作原理:输入是一部“电影”:一个包含镜头名称和提示词的 JSON 列表,非常像分镜脚本。LTX-2.5 在处理长提示词时表现更好,因此每个提示词都是一段关于风格、主体、动作、摄像机、光线和声音的描述。

Here is the seal film’s file, with the prompts shortened: [ {“name”: “dream”, “prompt”: “Style: cinematic, realistic, shallow depth of field. A plump seal … is fast asleep on warm golden sand under palm trees …”, “seed”: 3}, {“name”: “nap”, “prompt”: “Style: cinematic, realistic, wide-angle lens. … a plump grey seal is fast asleep on a small ice floe …”, “seed”: 1, “to”: {“shot”: “iceberg”, “frames”: 9}}, {“name”: “iceberg”, “prompt”: “Style: cinematic, realistic, wide-angle lens. … the whole iceberg slowly rolls over … and washes over the seal. …”}, {“name”: “shake”, “prompt”: “Style: cinematic, realistic, wide-angle lens. … It slowly shakes its head and body … and flops down on its belly on the floe, …”, “from”: {“shot”: “iceberg”, “frames”: 25}} ]

这是海豹电影的文件,提示词已缩短:[ {“name”: “dream”, “prompt”: “风格:电影感,写实,浅景深。一只胖乎乎的海豹……在棕榈树下的温暖金沙上熟睡……”, “seed”: 3}, {“name”: “nap”, “prompt”: “风格:电影感,写实,广角镜头。……一只胖乎乎的灰海豹在小浮冰上熟睡……”, “seed”: 1, “to”: {“shot”: “iceberg”, “frames”: 9}}, {“name”: “iceberg”, “prompt”: “风格:电影感,写实,广角镜头。……整座冰山缓慢翻转……并冲刷着海豹。……”}, {“name”: “shake”, “prompt”: “风格:电影感,写实,广角镜头。……它缓慢地摇动头部和身体……然后趴在浮冰上……”, “from”: {“shot”: “iceberg”, “frames”: 25}} ]

Each shot has a name and a prompt, and can have a seed, to keep the take I picked among several. Shots are chained with two keys. This chaining is the point, since prompts alone do not keep a subject from one shot to the next: from: the shot starts from the last frames of an earlier shot. Starting from the earlier shot’s last frame keeps a subject’s look across a cut; starting from its last 25 frames (1 s) also continues the motion. to: the shot ends on the first frames of a later shot, so that it leads into it. A shot can also be trimmed, or have a caption drawn over it.

每个镜头都有名称、提示词,还可以有种子值,以保留我在多次尝试中选定的那一个。镜头通过两个键进行链接。这种链接是关键,因为仅靠提示词无法保持主体在不同镜头间的一致性:from:镜头从前一个镜头的最后几帧开始。从前一个镜头的最后一帧开始可以保持主体在剪辑间的外观;从最后 25 帧(1 秒)开始还可以延续动作。to:镜头以下一个镜头的开头几帧结束,从而实现过渡。镜头还可以被裁剪,或在上面添加字幕。

Making a film from shots works like animation, which has two ways to go. Straight ahead, each shot continues the one before. Pose to pose, you make the key shot first, until you get one you like; then the shots before it end on its first frames (to), and the shots after it start from its last frames (from). When a film builds up to a payoff (the moment everything was leading to), the payoff is the key shot.

用镜头制作电影就像动画,有两种方式。顺向制作(Straight ahead),每个镜头延续前一个镜头。姿态到姿态(Pose to pose),你先制作关键镜头,直到得到满意的结果;然后它之前的镜头以它的开头几帧结束(to),它之后的镜头从它的最后几帧开始(from)。当电影铺垫到一个高潮(一切导向的时刻)时,这个高潮就是关键镜头。

I found this order by trial and error, and made the seal film pose to pose, starting from iceberg. The payoff is iceberg: the iceberg rolls over, and its wave drenches the seal. nap, the sleeping seal, ends on the first 9 frames of iceberg (to), so that the seal, the floe and the iceberg stay the same into the payoff. shake starts from the last 25 frames of iceberg (from): the dripping seal shakes off the water and flops down on the floe. The dream is made on its own, and a cut joins it to the rest.

我通过反复试验找到了这个顺序,并以“姿态到姿态”的方式制作了海豹电影,从 iceberg 开始。高潮是 iceberg:冰山翻转,海浪浸湿了海豹。nap(睡觉的海豹)以 iceberg 的前 9 帧结束(to),这样海豹、浮冰和冰山在进入高潮时保持一致。shake 从 iceberg 的最后 25 帧开始(from):湿漉漉的海豹甩掉水,趴在浮冰上。dream 是独立制作的,通过剪辑与其余部分连接。

The seal film’s shot chain. iceberg, the payoff, is made first; nap ends on its first 9 frames and shake starts from its last 25, so the seal, the floe and the iceberg stay the same. On the diffusers side, three pipelines share the models of LTX-2.5. LTX2Pipeline makes the shots from their prompt alone, and LTX2ConditionPipeline makes the shots that start or end on frames of another shot. These two follow the two-stage distilled recipe of the model card: 8 steps, then the third pipeline, LTX2LatentUpsamplePipeline, upscales the latents ×2 before 3 final steps.

海豹电影的镜头链。iceberg(高潮)首先制作;nap 以其前 9 帧结束,shake 从其最后 25 帧开始,因此海豹、浮冰和冰山保持不变。在 diffusers 方面,三个流水线共享 LTX-2.5 的模型。LTX2Pipeline 仅根据提示词制作镜头,LTX2ConditionPipeline 制作以另一个镜头的帧开始或结束的镜头。这两者遵循模型卡中两阶段蒸馏配方:8 步,然后是第三个流水线 LTX2LatentUpsamplePipeline,在最后 3 步之前将潜在空间放大 2 倍。

The diffusers pipelines do all of the generation. The film part is about 160 lines of Python on top: read the film file, order the shots so each keyframe exists before the shot that needs it, and cut the frames to hand over; then trim, caption, even out the sound and assemble the film. The code is in dacorvo/video-generation. The films I kept are in the dacorvo/video-generation bucket, with their JSON files: the seal, the fox, and the goat, which trims two of its shots and draws a caption over its payoff.

diffusers 流水线负责所有生成工作。电影部分大约有 160 行 Python 代码:读取电影文件,对镜头排序以确保每个关键帧在需要它的镜头之前存在,并剪切帧进行传递;然后进行裁剪、添加字幕、平衡声音并组装电影。代码位于 dacorvo/video-generation。我保留的电影在 dacorvo/video-generation 存储桶中,包含它们的 JSON 文件:海豹、狐狸和山羊,其中山羊剪辑了两个镜头并在高潮处添加了字幕。

The fox film: a walk in the snow, made “straight ahead”: each shot continues the one before. The goat film: two trimmed shots, and a caption drawn over the payoff. Running on Trainium3 Out of the box, the model does not run on the NeuronCores: the transformer does not fit on one, and diffusers has no plan to split it. The first attempt that ran (the model card’s pipeline, with the transformer split over 4 cores and a few patches) took about 5 min 20 s for a 10-second clip, and the NeuronCores were actually computing for only about 45 s of it. What’s more, the target resolution wa

狐狸电影:雪中漫步,采用“顺向制作”:每个镜头延续前一个镜头。山羊电影:两个裁剪过的镜头,并在高潮处添加了字幕。在 Trainium3 上运行:开箱即用,该模型无法在 NeuronCore 上运行:Transformer 无法放入一个核心,而 diffusers 也没有拆分它的计划。第一次运行的尝试(模型卡的流水线,将 Transformer 拆分到 4 个核心并打了一些补丁)生成 10 秒剪辑花费了约 5 分 20 秒,而 NeuronCore 实际计算时间仅约 45 秒。此外,目标分辨率……