返回资讯中心
外部精选
软件工程
#开发者实时流

Hugging Face在Trainium3上跑通LTX-2.5,10秒带声视频生成仅需22秒

来源标题:Taking Trainium3 to the Track: Generating Videos with LTX-2.5

Hugging Face团队利用AWS提供的Trainium3机器(trn3.48xlarge,64个NeuronCore),成功让Lightricks的LTX-2.5模型生成带声音的视频。在模型加载完成后,使用半台机器生成一段10秒带声视频仅需22至23秒。该项目源于团队一个月测试期的最后五天,此前主要精力用于测试并适配更多Hugging Face模型。

Hacker News 最新dacorvo2026/11/27 · 今天30 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

Back to Articles

a]:hidden">

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

Published November 27, 2026

Update on GitHub

Upvote -

David Corvoysier dacorvo Follow

Jingya Huang Jingya Follow

Sayak Paul sayakpaul Follow

:last-child]:mb-0"> Two goals

How it works

Running on Trainium3 What it took to make it work

What it took to make it fast

Lessons learned

Professional use cases

From films to world models

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.

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:

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.

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.

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.

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.

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

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →