得益于我们与 AWS 的合作,我们幸运地获得了一台 Trainium3 机器(trn.48xlarge,64 个 NeuronCores)一个月的使用权。我们花了大部分时间在上面测试 Hugging Face 的模型,并让越来越多的模型能够正常运行。
在还剩五天的时候,我允许自己稍微放松一下,找点乐子。当你拥有一辆法拉利时,偶尔你会想把它开上赛道。于是我问自己:如果我尝试生成视频会怎样?
我选择了 Lightricks 的 LTX-2.5,它可以同时生成视频和声音。最终,在模型加载完成后,使用半台机器生成一段带有声音的 10 秒片段仅需 22 到 23 秒。以下是结果。
一只海豹梦想着温暖的沙滩。完全由 Trainium3 生成。
两个目标
我有两个目标。第一个是看看在 Trainium3 上使用 diffusers 生成视频有多容易。不是示例中那些简单的片段:我想从剧本制作短片,更接近实际用例,比如起草一部电影。第二个目标是性能。我想接近使用 CUDA 或 LTX 自有 API 时所能达到的水平。
对于 CUDA,我找不到任何可比较的实际数据。唯一的数据是 LTX 声称在四块 B200 GPU 上生成一段 10 秒的 720p 片段仅需 6.8 秒,但未说明具体的测量方式。因此,我将 CUDA 放在一边,转而与 LTX 的在线 API 进行比较,LTX 称其能在 23.7 秒内生成一段 10 秒的 1080p 片段。最终,该配置达到了这一水平,甚至快了约一秒:在模型加载后,使用半台机器生成一段 2048×1024 分辨率的 10 秒片段仅需 22 到 23 秒。考虑到我优化管道的时间非常有限,这已经相当不错了。
工作原理
输入是一部电影:一个 JSON 格式的镜头列表,每个镜头都有一个名称和一个提示词,类似于分镜脚本。LTX-2.5 在处理长提示词时表现更好,因此每个提示词都是一段关于风格、主体、动作、摄像机、光线和声音的描述。以下是海豹电影的配置文件,提示词已缩短:
[
{ "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 } }
]
每个镜头都有一个名称和一个提示词,还可以有一个种子值(seed),以便在多个生成结果中保留我选择的那个。镜头通过两个键进行链接。这种链接是关键所在,因为仅靠提示词无法保证主体从一个镜头到下一个镜头的一致性:
from:镜头从之前镜头的最后几帧开始。以前一镜头的最后一帧为起点,可以保持主体在剪辑中的外观一致性;以前一镜头的最后 25 帧(1 秒)为起点,则可以延续动作。
to:镜头结束于后续镜头的前几帧,从而自然过渡到下一个镜头。
镜头还可以被裁剪,或者在其上叠加字幕。
通过镜头制作电影类似于动画制作,有两种方式。逐帧推进(Straight ahead),每个镜头接续前一个镜头;关键帧定位(Pose to pose),你先制作关键镜头,直到满意为止;然后,它之前的镜头结束于该镜头的前几帧(to),之后的镜头从该镜头的最后几帧开始(from)。当电影推向高潮(即所有铺垫所指向的时刻)时,高潮部分就是关键镜头。我是通过试错找到这个顺序的,并以“iceberg”为起点,采用关键帧定位的方式制作了海豹电影。
回报是冰山:冰山翻滚,其激起的波浪淹没了海豹。小憩(nap)以冰山的第1至9帧结束,因此海豹、浮冰和冰山在回报部分保持不变。摇晃(shake)从冰山的最后25帧开始:滴水落下的海豹甩掉水分,瘫倒在浮冰上。梦境是独立制作的,并通过剪辑将其与其余部分连接起来。
海豹影片的镜头链。冰山(iceberg),即回报部分,最先制作;小憩以其前9帧结束,摇晃以其最后25帧开始,因此海豹、浮冰和冰山保持不变。
在Diffusers方面,三个管道共享LTX-2.5的模型。LTX2Pipeline仅根据提示生成镜头,而LTX2ConditionPipeline生成以另一个镜头的帧开始或结束的镜头。这两个遵循模型卡中的两阶段蒸馏配方:8步,然后第三个管道LTX2LatentUpsamplePipeline在最后的3步之前将潜在变量放大×2倍。
Diffusers管道完成了所有的生成工作。影片部分在上面增加了约160行Python代码:读取影片文件,对镜头进行排序以确保每个关键帧在需要它的镜头之前存在,并切割帧以移交;然后修剪、添加字幕、均衡声音并组装影片。代码位于dacorvo/video-generation中。我保留的影片存放在dacorvo/video-generation存储桶中,带有它们的JSON文件:海豹、狐狸和山羊,其中山羊修剪了两个镜头并在其回报部分绘制了字幕。
狐狸影片:雪中漫步,采用“直进式”制作:每个镜头延续前一个镜头。
山羊影片:两个修剪过的镜头,并在回报部分绘制了字幕。
在Trainium3上运行
开箱即用,该模型无法在NeuronCores上运行:Transformer无法适配单个核心,且Diffusers没有拆分它的计划。首次运行的尝试(使用模型卡中的管道,将Transformer分布在4个核心上并打了一些补丁)对于10秒的片段耗时约5分20秒,而NeuronCores实际计算的时间仅约为45秒。此外,目标分辨率也无法达到。
五天后:
带声音的10秒片段
NeuronCores
总耗时
在NeuronCores上
vs. 首次尝试
首次尝试,960×544
4
5分20秒
45秒
1×
优化后,2048×1024(约多4倍像素)
32
22至23秒
15秒
14×
实现这一目标需要三种类型的工作:使模型在NeuronCores上运行(需要张量并行),将其分布在更多的核心上(序列并行),并使主机能够跟上它们的步伐。
TP-4 × SP-8:一个片段上的32个核心。权重以4路拆分,每层的每个核心分配一个波段;视频令牌以8路拆分,片段的每一部分分配给一个芯片。
下面的大多数修复都在设备上,这也是大部分精力所在。最大的端到端节省来自主机:这是显而易见的浪费之处,因此是容易解决的难题。
使其工作所需的内容
问题
变通方法
结果
Transformer无法适配单个NeuronCore,且Diffusers没有为其制定张量并行计划
一个计划,以及在一个秩的头(heads)上运行的注意力处理器
Transformer在4个核心上运行
文本编码器无法适配Transformer旁边的NeuronCore,因此它在CPU上运行。Diffusers支持以这种方式拆分管道,但其LTX-2管道将文本编码器的输入放置在NeuronCores上
将管道固定在主机上,并将Transformer的输入移至核心,输出移回
管道在其Transformer位于核心的情况下运行
作为一个图编译时,Transformer在某个尺寸返回NaN,且每个新进程都重新追踪它,即使缓存中有所有图
使用compile_repeated_blocks编译一个块
输出有限,追踪时间从388秒降至18秒
torch-neuronx完全以bf16计算bf16 GELU,包括常量(#1049)
以fp32计算GELUs
Transformer相对于fp32的错误:0.297 → 0.158(CPU bf16:0.160)
在 2048×1024 分辨率下,分 4 路的 Transformer 块图无法加载。将视频 token 在顶部按 8 路分割(序列并行):在 diffusers 的 set_attn_processor hook 上使用两个自定义注意力处理器,每个处理器在其集体调用周围进行几次张量重塑(代码)。第二阶段在 4 × 8 = 32 个核心上运行,每步耗时 3.0 秒。
一个从帧开始的镜头具有每个视频 token 的时间步,其块图无法加载。仅嵌入两个时间步,并为每个 token 选择一个(代码)。从帧生成的镜头所需时间与从提示词生成的镜头大致相同。
使其变快的过程
问题
变通方法
收益
每个等级(每个 NeuronCore 一个进程)运行整个管道,并且它们都在一个插槽的 CPU 上编码提示词。仅在 rank 0 上运行管道,并将每次调用的参数发送给其他等级。提示词编码:约 205 秒 → 7.5 秒。
torch-neuronx 的分配器使其大部分内存段未被使用(#1052)。将参数打包为最多 1 GiB 的缓冲区。每个核心的内存:22.96 GiB → 10.2 GiB。
除非序列长度是 128 个 token 的倍数,否则注意力以普通算子运行。在 1024×512(每帧 512 个 token)下生成,设置 NEURON_LOGICAL_NC_CONFIG=2。Transformer 步长:4.3 秒 → 3.0 秒。
视频解码在 CPU 上很慢,增加 CPU 核心数也无济于事。在 NeuronCores 上按帧分割进行解码,并通过共享内存将帧传递给 rank 0。在 2048×1024 下解码:357 秒 → 1.6 秒。
步长切片复制到设备时,由设备上缓慢的复制填充(#1050)。在复制前调用 .contiguous()。在 16 个核心上运行步长:5.6 秒 → 1.0 秒。
仅 rank 0 运行管道的 CPU 阶段(文本编码器、上采样器、声码器),但每个等级都获得一个节点级的 torch 线程池,导致 31 个等级使其饥饿。将 rank 0 的线程固定到其他等级不使用的 CPU 上,并将其他等级的线程限制在其公平份额内(代码)。提示词编码:7.4 秒 → 3.3 秒。第一阶段步长:0.9 秒 → 0.6 秒。
管道将提示词填充至 1024 个 token,而 CPU 上的文本编码器也对填充部分进行编码。仅在提示词的 token 上运行文本编码器。提示词编码:3.4 秒 → 1.4 秒。
有三个问题从未得到解释:作为单个图编译的 Transformer 在某个尺寸下返回了 NaN;每个新进程中最后一个镜头以关键帧结尾时速度较慢(即使缓存中已有所有图);且潜在上采样器无法与 Transformer 一起加载,因此它停留在 CPU 上。
其中一些正在上游修复中。diffusers#15420(开放)修复了 LTX-2 管道,这将使上述第二个变通方法变得不必要。diffusers#14725(仍开放)将张量并行和上下文并行引入一个 ParallelConfig ,并计划为 LTX-2.5 提供 _tp_plan。
经验教训
双方都遭受了重创:主机和设备。一旦运行,一段视频的主机时间从约 280 秒降至约 8 秒(约 35 倍),其在 NeuronCores 上的时间从 45 秒降至 15 秒(3 倍,像素量是四倍,且由于第二阶段首次尝试甚至无法加载)。
序列并行是一段视频使用机器的方式。张量并行是由内存决定的(Transformer 无法放入单个核心)并受限于 32 个注意力头。将序列分割到更多核心上是将 64 个 NeuronCores 中的 32 个用于单段视频的原因,也是通过缩小每个核心的图使其能够加载从而实现 2048×1024 分辨率的关键。
在 Trainium 上,需规划图的大小。形状决定了注意力是否采用快速内核,而过大的图无法加载。
首先与 CPU 进行对比检查。在设备上运行之前,模型的每个分割部分都在 CPU 上进行了检查,与 CPU 的对比发现了 GELU 问题。
保持追踪代码的稳定。在我使用的构建中,torch-neuronx 的缓存密钥包含了每个追踪算子的文件和行号,因此一次编辑可能触发每个图长达 30 分钟的重新编译。我已经报告了该问题(aws-neuron/torch-neuronx#1027),且该问题现已关闭。
电影的制作远不止于提示词。仅靠提示词无法保证角色或场景在镜头之间保持一致,因此每个镜头的开头或结尾会衔接其他镜头的画面。此外,每个镜头都固定在单一视角:在一部早期版本的狐狸电影中,当镜头试图将狐狸从森林移动到湖泊时,模型却生成了一个交叉淡入效果,画面变成了另一只狐狸。
为每个镜头制作多个版本。模型经常出错:同一个提示词在四次尝试中有三次让山羊长出了滑稽的角。我为每个新镜头制作了四个版本,并挑选了其中一个。
专业应用场景
在性能方面,一旦模型加载完成,生成一段带有声音的 10 秒、2048×1024 分辨率的视频片段仅需 22 到 23 秒。这一表现可与 LTX 付费 API 相媲美,且仅占用其一半的实例资源。服务商会保持进程运行,因为加载模型需要约 3 分钟,而生成第一个视频片段则需要 80 秒。
在功能方面,diffusers 库具备制作电影的基础能力。镜头由提示词生成,并通过在开头或结尾衔接其他镜头的画面来确保主体在不同镜头间的一致性。不同版本的区别在于随机种子(seed),影片文件会保存我所选定的那个种子。使用相同的代码和影片文件重新运行,你将得到完全相同的影片,字节级一致。镜头也可以从图像开始,例如故事板帧或角色设定图,条件处理管线会以对待画面帧的方式处理这些图像(我未在电影中尝试过此功能)。
使其仍停留在草稿阶段的原因包括:
模型仍然会出错,因此每个新镜头都需要多个版本。
每个镜头都会生成自己的声音。影片会平衡背景音量,但声音不会从一个镜头延续到下一个镜头。
一个镜头最长持续 20 秒,这是模型的极限。
从电影到世界模型
LTX 将 LTX-2.5 称为世界模型,并指出机器人技术是其新兴的应用场景。机器人、汽车和无人机通过观看摄像头拍摄的视频进行学习,而世界模型可以生成更多的视频,包括那些过于罕见或风险过高而无法实地拍摄的事件。因此,我也尝试将其应用于真实 footage(素材),使用相同的代码:镜头可以从真实摄像机片段的第一秒开始,并推演接下来发生的事情。仅靠一帧是不够的,因为模型无法从中判断物体的运动速度。
以下是 Fourier GR1-T2 人形机器人的头部摄像头画面(源自 NVIDIA 的 GR1-100 视频片段),镜头向下俯视一张桌子。在真实的 6 秒片段中,机器人的左手从盘子里拿起一个橙子并放入托盘中。模型仅能看到该片段的第一秒(此时双手举起,尚未发生任何移动),并自行推演其余部分。实际发生的情况与模型推演的结果对比如下:
GR1-T2 人形机器人头部摄像头的真实素材,旁边是 LTX-2.5 基于其第一秒内容推演出的后续画面。
同一场景,同一动作:模型自行推演出抓取的动作,并保持桌子、双手和水果与真实素材一致。更有趣的是那些并未发生的替代事件。从同一秒开始,仅更改提示词,一个人俯身也去抓橙子,人手和机械手共同将橙子放入托盘。我生成了五个版本,其中第一个为真实素材:
真实片段,随后是五个生成版本,展示一个人帮助机器人搬运橙子的情景。
每个人物的手势和时机在每个版本中都不同,机器人的手臂也随之适应。这正是其在训练中的吸引力所在:不是单一的视频延续,而是多种可能性的分布,每个版本都可以通过其影片文件和种子复现。
存储桶的 robotics 文件夹中包含了这五个版本及其 JSON 文件,以及第二个来自暴风雪中汽车前置摄像头的例子(Boreas),其中替代事件是路过的卡车溅起的雪泥打在镜头上。当被要求让汽车加速时,模型保持了原有速度:提示词无法覆盖第一秒素材所隐含的信息。
这些视频遵循的是提示词,而非机器人或汽车的指令:训练设置需要基于这些动作进行条件生成。为此,团队会在 LTX-2.5 的预训练检查点上,使用其自身机器人的帧和动作数据进行微调。
法拉利赛车仅靠一半的气缸便完成了赛道一圈的行驶。
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?
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.
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.
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. 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.
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. 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 } }
]
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.
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. 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.
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.
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.
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 was out of reach.
Five days later:
10-second clip with sound
NeuronCores
Wall time
On the NeuronCores
vs. first attempt
First attempt, 960×544
4
5 min 20 s
45 s
1×
Optimized, 2048×1024 (~4× more pixels)
32
22 to 23 s
15 s
14×
Getting there took three kinds of work: making the model run on the NeuronCores (requires tensor parallelism), splitting it over more of them (sequence parallelism), and making the host keep up with them.
TP-4 × SP-8: 32 cores on one clip. The weights split 4 ways, one band of every layer per core; the video tokens split 8 ways, one stretch of the clip per chip.
Most of the fixes below are on the device, and that is where most of the effort went. The biggest end-to-end savings came from the host: the low-hanging fruit, since that is obviously where the waste was.
What it took to make it work
Problem
Workaround
Result
The transformer does not fit on one NeuronCore, and diffusers has no tensor-parallel plan for it
A plan , and an attention processor that runs on the heads of one rank
The transformer runs on 4 cores
The text encoder does not fit on a NeuronCore next to the transformer, so it runs on the CPUs. diffusers supports a pipeline split this way, but its LTX-2 pipelines give the text encoder its inputs on the NeuronCores
Pin the pipeline to the host, and move the transformer's inputs to the cores and its outputs back
The pipeline runs with its transformer on the cores
Compiled as one graph, the transformer returned NaN at one size, and each new process traced it again, even with every graph in the cache
Compile one block with compile_repeated_blocks
Finite outputs, and tracing falls from 388 s to 18 s
torch-neuronx computes a bf16 GELU entirely in bf16, constants included ( #1049 )
Compute the GELUs in fp32
Transformer error against fp32: 0.297 → 0.158 (CPU bf16: 0.160)
At 2048×1024, the block graph of the transformer split 4 ways fails to load
Split the video tokens 8 ways on top (sequence parallelism): two custom attention processors on diffusers' set_attn_processor hook, each a few tensor reshapes around its collective calls ( code )
Stage 2 runs on 4 × 8 = 32 cores, at 3.0 s a step
A shot that starts from frames has a timestep per video token, and its block graph fails to load
Embed only the two timesteps, and pick one for each token ( code )
A shot from frames takes about as long as one from a prompt
What it took to make it fast
Problem
Workaround
Gain
Each rank (one process per NeuronCore) ran the whole pipeline, and they all encoded the prompt on the CPUs of one socket
Run the pipeline on rank 0 only, and send the other ranks the arguments of each call
Prompt encoding: about 205 s → 7.5 s
torch-neuronx's allocator leaves most of its memory segments unused ( #1052 )
Pack the parameters into buffers of at most 1 GiB
Memory per core: 22.96 GiB → 10.2 GiB
The attention runs as plain ops unless the sequence length is a multiple of 128 tokens
Generate at 1024×512 (512 tokens per frame), with NEURON_LOGICAL_NC_CONFIG=2
Transformer step: 4.3 s → 3.0 s
The video decode is slow on CPU, and more CPU cores do not help
Decode on the NeuronCores, split by frames, and pass the frames to rank 0 through shared memory
Decode at 2048×1024: 357 s → 1.6 s
A strided slice copied to the device is filled by a slow copy on the device ( #1050 )
.contiguous() before the copy
Step on 16 cores: 5.6 s → 1.0 s
Rank 0 alone runs the pipeline's CPU stages (text encoder, upsampler, vocoder), but every rank gets a node-wide torch thread pool, and 31 ranks starve it
Pin rank 0's threads to the CPUs no other rank uses, and cap the other ranks' threads to their fair share ( code )
Prompt encoding: 7.4 s → 3.3 s. Stage 1 step: 0.9 s → 0.6 s
The pipeline pads the prompt to 1024 tokens, and the text encoder, on CPU, encodes the padding too
Run the text encoder on the tokens of the prompt only
Prompt encoding: 3.4 s → 1.4 s
Three issues were never explained: the transformer compiled as one graph returned NaN at one size, the first shot that ends on keyframes was slow in each new process (even with every graph in the cache), and the latent upsampler fails to load next to the transformer, so it stays on the CPU.
Some of this is being fixed upstream. diffusers#15420 (open) fixes the LTX-2 pipelines, which would make the second workaround above unnecessary. diffusers#14725 (still open) brings tensor and context parallelism into one ParallelConfig , and a _tp_plan for LTX-2.5 is planned.
Lessons learned
Both sides fell hard: the host and the device. Once running, a clip's host time fell from about 280 s to about 8 s (~35×), and its time on the NeuronCores from 45 s to 15 s (3×, at four times the pixels, and with a second stage the first attempt could not even load).
Sequence parallelism is how one clip uses the machine. Tensor parallelism is imposed by memory (the transformer does not fit on one core) and capped by the 32 attention heads. Splitting the sequence over more cores is what puts 32 of the 64 NeuronCores on a single clip, and what made 2048×1024 possible at all, by shrinking each core's graph until it loaded.
On Trainium, plan for the size of the graphs. The shapes decide whether the attention takes the fast kernel, and graphs that are too large fail to load.
Check against the CPU first. Each split of the models was checked on CPU before it ran on the device, and the comparison with CPU found the GELU issue.
Keep the traced code stable. In the build I used, torch-neuronx's cache key included the file and line of each traced op, so an edit could trigger a recompile of up to 30 minutes per graph. I had already reported it ( aws-neuron/torch-neuronx#1027 ), and the issue is now closed.
A film needs more than prompts. Prompts alone do not keep a character, or a mountain, from one shot to the next, so shots start or end on frames of other shots. Each shot also stays in one place: when a shot in an early version of the fox film took the fox from the forest to the lake, the model made a cross-dissolve to another fox.
Make several takes of each shot. The model often gets a detail wrong: the same prompt gave the goat funny horns in 3 takes out of 4. I made 4 takes of each new shot and picked one.
Professional use cases
On the performance side, once the models are loaded, a 10-second 2048×1024 clip with sound takes 22 to 23 s. That rivals LTX's paid API, on half of the instance. A service would keep its processes up, as they take about 3 minutes to load the models, and 80 s for their first clip.
On the feature side, diffusers has what it takes to draft a movie. The shots come from prompts, and keep their subject from one shot to the next by starting or ending on frames of other shots. Takes differ by their seed, and the film file keeps the one I picked. Re-run with the same code and film file, and you get the same film back, byte for byte. A shot can also start from an image, such as a storyboard frame or a character sheet, which the condition pipeline takes the same way as frames (I did not try it in a film).
What keeps it at drafts:
The model still gets details wrong, so each new shot needs several takes.
Each shot makes its own sound. The film evens out the background level, but the sound does not carry over from one shot to the next.
A shot lasts at most 20 s, the model's limit.
From films to world models
LTX calls LTX-2.5 a world model, with robotics as an emerging use. Robots, cars and drones learn from videos of what their cameras see, and a world model can make more of them, including events too rare or too risky to film. So I also tried it on real footage, with the same code: a shot can start from the first second of a real camera clip and invent what happens next. One frame was not enough, as the model cannot tell from it how fast things move.
Here is the head camera of a Fourier GR1-T2 humanoid robot (a clip from NVIDIA's GR1-100 ), looking down at a table. In the real 6-second clip, the robot's left hand picks an orange from a plate and drops it in a tray. The model only sees the first second of that clip (the hands raised, before anything moves) and invents the rest. What really happened, next to its invention:
Real footage from the head camera of a GR1-T2 humanoid, next to the continuation LTX-2.5 invented from its first second.
Same scene, same pick: the model invents the grab on its own, and keeps the table, the hands and the fruit consistent with the real footage. More interesting are the events that did not happen. From the same second, with only the prompt changed, a person leans over and grabs the orange too, and the human hand and the robot hand carry it to the tray together. Five takes, with the real footage first:
The real clip, then five generated takes of a person helping the robot carry the orange.
The person's gestures and timing differ in each take, and the robot's arm adapts to them. That is the appeal for training: not one continuation of a clip, but a distribution of them, each reproducible from its film file and seed.
The robotics folder of the bucket has the five takes with their JSON files, and a second example from the front camera of a car in a snowstorm ( Boreas ), where the alternate event is slush thrown on the lens by a passing truck. Asked to make the car accelerate instead, the model kept its speed: the prompt does not override what the first second of footage already implies.
These videos follow prompts, not the robot's or car's commands: a training setup would need generation conditioned on those actions. For that, a team fine-tunes the pre-trained checkpoint of LTX-2.5 on the frames and actions of its own robots.
The Ferrari made it around the track, on half of its cylinders.
首次收录 · 2026-11-28 · 9.95 分