Commit 64e3ba3
authored
[CPU] Add native LTX-Video RoPE kernel and enable the fusion (#37141)
### Details
LTX-Video's 3-axis RoPE was left decomposed on CPU because the fusion
was disabled, the existing interleaved executor can't handle LTX's 3D
layout with separate full-width cos/sin tables.
This PR adds a native RoPEExecutorLtxVideo that computes the rotation in
f32 and rounds once to the output type, enables RoPEFusionLtxVideo on
CPU (same fused op as GPU), and instantiates the shared RoPETestLtxVideo
test for CPU.
RoPE subgraph, seq 2520 × 2048, median CPU latency, fused vs decomposed:
| precision | decomposed | fused | speedup |
|-----------|------------|--------|---------|
| f32 | 23.05 ms | 11.26 ms | **2.05×** |
| bf16 | 23.19 ms | 14.69 ms | **1.58×** |
f16 stays on the decomposed path for now. unlike bf16, its pipeline runs
ConvertPrecision before RoPEFusion, so the fusion doesn't fire. Enabling
f16 fusion is a follow-up. and is anyways producing NaN as of now (ref
#37039).
```mermaid
flowchart LR
subgraph Before["Before — decomposed (~8 ops)"]
direction LR
x1[x] --> R1[Reshape]
R1 --> SP[Split]
SP -->|imag| NEG["Multiply(-1)"]
NEG --> CC[Concat]
SP -->|real| CC
CC --> R2[Reshape]
x1 --> MC["Multiply · cos"]
cos1[cos] --> MC
R2 --> MS["Multiply · sin"]
sin1[sin] --> MS
MC --> ADD[Add]
MS --> ADD
ADD --> o1[out]
end
subgraph After["After — fused"]
direction LR
x2[x] --> ROPE["RoPE(is_ltx_video)"]
cos2[cos] --> ROPE
sin2[sin] --> ROPE
ROPE --> o2[out]
end
```
### AI Assistance:
- *AI assistance used: no / yes* yes
- *If yes, summarize how AI was used and what human validation was
performed (build/tests/manual checks).*1 parent be0a889 commit 64e3ba3
4 files changed
Lines changed: 59 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
247 | 287 | | |
248 | 288 | | |
249 | 289 | | |
| |||
470 | 510 | | |
471 | 511 | | |
472 | 512 | | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
473 | 524 | | |
474 | 525 | | |
475 | 526 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1139 | 1139 | | |
1140 | 1140 | | |
1141 | 1141 | | |
1142 | | - | |
1143 | 1142 | | |
1144 | 1143 | | |
1145 | 1144 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
96 | 102 | | |
97 | 103 | | |
0 commit comments