liangsu9988 commited on
Commit
71f6eaa
·
verified ·
1 Parent(s): 4bf391d

Promote latest kernel artifacts to main

Browse files
Files changed (33) hide show
  1. .gitattributes +3 -35
  2. README.md +0 -9
  3. benchmarks/benchmark_q_norm_rope.py +398 -0
  4. build/torch211-cxx11-cu126-x86_64-linux/__init__.py +168 -0
  5. build/torch211-cxx11-cu126-x86_64-linux/_flashrt_vla_video_cuda_c4d802d.abi3.so +3 -0
  6. build/torch211-cxx11-cu126-x86_64-linux/_ops.py +9 -0
  7. build/torch211-cxx11-cu126-x86_64-linux/flashrt_vla_video/__init__.py +26 -0
  8. build/torch211-cxx11-cu126-x86_64-linux/metadata.json +20 -0
  9. build/torch211-cxx11-cu128-x86_64-linux/__init__.py +168 -0
  10. build/torch211-cxx11-cu128-x86_64-linux/_flashrt_vla_video_cuda_c4d802d.abi3.so +3 -0
  11. build/torch211-cxx11-cu128-x86_64-linux/_ops.py +9 -0
  12. build/torch211-cxx11-cu128-x86_64-linux/flashrt_vla_video/__init__.py +26 -0
  13. build/torch211-cxx11-cu128-x86_64-linux/metadata.json +23 -0
  14. build/torch211-cxx11-cu130-x86_64-linux/__init__.py +168 -0
  15. build/torch211-cxx11-cu130-x86_64-linux/_flashrt_vla_video_cuda_c4d802d.abi3.so +3 -0
  16. build/torch211-cxx11-cu130-x86_64-linux/_ops.py +9 -0
  17. build/torch211-cxx11-cu130-x86_64-linux/flashrt_vla_video/__init__.py +26 -0
  18. build/torch211-cxx11-cu130-x86_64-linux/metadata.json +22 -0
  19. build/torch212-cxx11-cu126-x86_64-linux/__init__.py +168 -0
  20. build/torch212-cxx11-cu126-x86_64-linux/_flashrt_vla_video_cuda_c4d802d.abi3.so +3 -0
  21. build/torch212-cxx11-cu126-x86_64-linux/_ops.py +9 -0
  22. build/torch212-cxx11-cu126-x86_64-linux/flashrt_vla_video/__init__.py +26 -0
  23. build/torch212-cxx11-cu126-x86_64-linux/metadata.json +20 -0
  24. build/torch212-cxx11-cu130-x86_64-linux/__init__.py +168 -0
  25. build/torch212-cxx11-cu130-x86_64-linux/_flashrt_vla_video_cuda_c4d802d.abi3.so +3 -0
  26. build/torch212-cxx11-cu130-x86_64-linux/_ops.py +9 -0
  27. build/torch212-cxx11-cu130-x86_64-linux/flashrt_vla_video/__init__.py +26 -0
  28. build/torch212-cxx11-cu130-x86_64-linux/metadata.json +22 -0
  29. build/torch212-cxx11-cu132-x86_64-linux/__init__.py +168 -0
  30. build/torch212-cxx11-cu132-x86_64-linux/_flashrt_vla_video_cuda_c4d802d.abi3.so +3 -0
  31. build/torch212-cxx11-cu132-x86_64-linux/_ops.py +9 -0
  32. build/torch212-cxx11-cu132-x86_64-linux/flashrt_vla_video/__init__.py +26 -0
  33. build/torch212-cxx11-cu132-x86_64-linux/metadata.json +22 -0
.gitattributes CHANGED
@@ -1,35 +1,3 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
1
+ *.so filter=lfs diff=lfs merge=lfs -text
2
+ *.pyd filter=lfs diff=lfs merge=lfs -text
3
+ *.dylib filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md DELETED
@@ -1,9 +0,0 @@
1
- # flashrt/flashrt-vla-video
2
-
3
- This repository is a compatibility mirror for older `kernels` clients
4
- that resolve repositories through the default Hugging Face model repo API.
5
-
6
- Canonical Kernel Hub repo: https://huggingface.co/kernels/flashrt/flashrt-vla-video
7
-
8
- Do not edit this mirror by hand. It is generated from the Kernel Hub
9
- `vN` branches and contains the same `build/**` artifacts.
 
 
 
 
 
 
 
 
 
 
benchmarks/benchmark_q_norm_rope.py ADDED
@@ -0,0 +1,398 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+
3
+ from kernels.benchmark import Benchmark
4
+
5
+
6
+ _original_allclose = torch.allclose
7
+
8
+
9
+ def _flashrt_allclose(input, other, rtol=1e-05, atol=1e-08, equal_nan=False):
10
+ if input.dtype == torch.bfloat16 and other.dtype == torch.bfloat16:
11
+ abs_err = (input.float() - other.float()).abs()
12
+ rel_err = abs_err / other.float().abs().clamp_min(1.0)
13
+ return bool(abs_err.max().item() <= 0.03125 and rel_err.max().item() <= 0.05)
14
+ return _original_allclose(input, other, rtol=rtol, atol=atol, equal_nan=equal_nan)
15
+
16
+
17
+ torch.allclose = _flashrt_allclose
18
+
19
+
20
+ def _reference_norm_rope(x, weight, cos, sin, eps=1e-6):
21
+ half = x.shape[-1] // 2
22
+ rstd = torch.rsqrt(x.float().square().mean(dim=-1, keepdim=True) + eps)
23
+ normed = x.float() * rstd * weight.float()
24
+ lo = normed[..., :half]
25
+ hi = normed[..., half:]
26
+ out_lo = lo * cos.float() - hi * sin.float()
27
+ out_hi = hi * cos.float() + lo * sin.float()
28
+ return torch.cat([out_lo, out_hi], dim=-1).to(torch.bfloat16)
29
+
30
+
31
+ def _reference_qkv_split_norm_rope(
32
+ packed_qkv, norm_q_weight, norm_k_weight, freqs_re, freqs_im, heads, head_dim, eps=1e-6
33
+ ):
34
+ batch, tokens, _ = packed_qkv.shape
35
+ dim = heads * head_dim
36
+ q = packed_qkv[..., :dim].reshape(batch, tokens, heads, head_dim)
37
+ k = packed_qkv[..., dim : 2 * dim].reshape(batch, tokens, heads, head_dim)
38
+ qf = q.float()
39
+ kf = k.float()
40
+ qn = qf * torch.rsqrt((qf * qf).mean(dim=(-2, -1), keepdim=True) + eps)
41
+ kn = kf * torch.rsqrt((kf * kf).mean(dim=(-2, -1), keepdim=True) + eps)
42
+ qn = qn * norm_q_weight.reshape(1, 1, heads, head_dim).float()
43
+ kn = kn * norm_k_weight.reshape(1, 1, heads, head_dim).float()
44
+
45
+ def rope(x):
46
+ xr = x[..., 0::2].float()
47
+ xi = x[..., 1::2].float()
48
+ fr = freqs_re[:tokens][None, :, None, :]
49
+ fi = freqs_im[:tokens][None, :, None, :]
50
+ out = torch.empty_like(x, dtype=torch.float32)
51
+ out[..., 0::2] = xr * fr - xi * fi
52
+ out[..., 1::2] = xr * fi + xi * fr
53
+ return out.to(torch.bfloat16)
54
+
55
+ return rope(qn), rope(kn)
56
+
57
+
58
+ class QNormRopeBenchmark(Benchmark):
59
+ seed = 11
60
+
61
+ def _setup_heads(self, n_heads: int) -> None:
62
+ self.q = torch.randn(
63
+ (n_heads, 128), device=self.device, dtype=torch.bfloat16
64
+ ).contiguous()
65
+ self.weight = torch.randn(
66
+ (128,), device=self.device, dtype=torch.bfloat16
67
+ ).contiguous()
68
+ self.cos = torch.randn((64,), device=self.device, dtype=torch.bfloat16)
69
+ self.sin = torch.randn((64,), device=self.device, dtype=torch.bfloat16)
70
+ self.out = torch.empty_like(self.q)
71
+
72
+ def _reference(self):
73
+ return _reference_norm_rope(self.q, self.weight, self.cos, self.sin)
74
+
75
+ def setup_heads1(self):
76
+ self._setup_heads(1)
77
+
78
+ def benchmark_heads1(self):
79
+ self.kernel.q_norm_rope_bf16(
80
+ self.q, self.weight, self.cos, self.sin, out=self.out
81
+ )
82
+
83
+ def verify_heads1(self):
84
+ return self._reference()
85
+
86
+ def setup_heads4(self):
87
+ self._setup_heads(4)
88
+
89
+ def benchmark_heads4(self):
90
+ self.kernel.q_norm_rope_bf16(
91
+ self.q, self.weight, self.cos, self.sin, out=self.out
92
+ )
93
+
94
+ def verify_heads4(self):
95
+ return self._reference()
96
+
97
+ def setup_heads8(self):
98
+ self._setup_heads(8)
99
+
100
+ def benchmark_heads8(self):
101
+ self.kernel.q_norm_rope_bf16(
102
+ self.q, self.weight, self.cos, self.sin, out=self.out
103
+ )
104
+
105
+ def verify_heads8(self):
106
+ return self._reference()
107
+
108
+ def setup_heads16(self):
109
+ self._setup_heads(16)
110
+
111
+ def benchmark_heads16(self):
112
+ self.kernel.q_norm_rope_bf16(
113
+ self.q, self.weight, self.cos, self.sin, out=self.out
114
+ )
115
+
116
+ def verify_heads16(self):
117
+ return self._reference()
118
+
119
+ def setup_heads24(self):
120
+ self._setup_heads(24)
121
+
122
+ def benchmark_heads24(self):
123
+ self.kernel.q_norm_rope_bf16(
124
+ self.q, self.weight, self.cos, self.sin, out=self.out
125
+ )
126
+
127
+ def verify_heads24(self):
128
+ return self._reference()
129
+
130
+ def setup_heads32(self):
131
+ self._setup_heads(32)
132
+
133
+ def benchmark_heads32(self):
134
+ self.kernel.q_norm_rope_bf16(
135
+ self.q, self.weight, self.cos, self.sin, out=self.out
136
+ )
137
+
138
+ def verify_heads32(self):
139
+ return self._reference()
140
+
141
+ def setup_heads48(self):
142
+ self._setup_heads(48)
143
+
144
+ def benchmark_heads48(self):
145
+ self.kernel.q_norm_rope_bf16(
146
+ self.q, self.weight, self.cos, self.sin, out=self.out
147
+ )
148
+
149
+ def verify_heads48(self):
150
+ return self._reference()
151
+
152
+
153
+ class QKVSplitNormRopeBenchmark(Benchmark):
154
+ seed = 13
155
+
156
+ def _setup_tokens(self, tokens: int) -> None:
157
+ self.heads = 24
158
+ self.head_dim = 128
159
+ dim = self.heads * self.head_dim
160
+ self.packed_qkv = torch.randn(
161
+ (1, tokens, 3 * dim), device=self.device, dtype=torch.bfloat16
162
+ ).contiguous()
163
+ self.norm_q_weight = torch.randn(
164
+ (dim,), device=self.device, dtype=torch.bfloat16
165
+ ).contiguous()
166
+ self.norm_k_weight = torch.randn(
167
+ (dim,), device=self.device, dtype=torch.bfloat16
168
+ ).contiguous()
169
+ self.freqs_re = torch.randn(
170
+ (4096, self.head_dim // 2), device=self.device, dtype=torch.float32
171
+ ).contiguous()
172
+ self.freqs_im = torch.randn(
173
+ (4096, self.head_dim // 2), device=self.device, dtype=torch.float32
174
+ ).contiguous()
175
+ self.q_out = torch.empty(
176
+ (1, tokens, self.heads, self.head_dim),
177
+ device=self.device,
178
+ dtype=torch.bfloat16,
179
+ )
180
+ self.k_out = torch.empty_like(self.q_out)
181
+ self.out = self.q_out
182
+
183
+ def _reference_pair(self):
184
+ return _reference_qkv_split_norm_rope(
185
+ self.packed_qkv,
186
+ self.norm_q_weight,
187
+ self.norm_k_weight,
188
+ self.freqs_re,
189
+ self.freqs_im,
190
+ self.heads,
191
+ self.head_dim,
192
+ )
193
+
194
+ def _reference(self):
195
+ return self._reference_pair()[0]
196
+
197
+ def _benchmark(self):
198
+ self.kernel.qkv_split_norm_rope_bf16(
199
+ self.packed_qkv,
200
+ self.norm_q_weight,
201
+ self.norm_k_weight,
202
+ self.freqs_re,
203
+ self.freqs_im,
204
+ heads=self.heads,
205
+ head_dim=self.head_dim,
206
+ q_out=self.q_out,
207
+ k_out=self.k_out,
208
+ )
209
+
210
+ def setup_tokens1(self):
211
+ self._setup_tokens(1)
212
+
213
+ def benchmark_tokens1(self):
214
+ self._benchmark()
215
+
216
+ def verify_tokens1(self):
217
+ return self._reference()
218
+
219
+ def setup_tokens4(self):
220
+ self._setup_tokens(4)
221
+
222
+ def benchmark_tokens4(self):
223
+ self._benchmark()
224
+
225
+ def verify_tokens4(self):
226
+ return self._reference()
227
+
228
+ def setup_tokens16(self):
229
+ self._setup_tokens(16)
230
+
231
+ def benchmark_tokens16(self):
232
+ self._benchmark()
233
+
234
+ def verify_tokens16(self):
235
+ return self._reference()
236
+
237
+ def setup_tokens64(self):
238
+ self._setup_tokens(64)
239
+
240
+ def benchmark_tokens64(self):
241
+ self._benchmark()
242
+
243
+ def verify_tokens64(self):
244
+ return self._reference()
245
+
246
+ def setup_tokens256(self):
247
+ self._setup_tokens(256)
248
+
249
+ def benchmark_tokens256(self):
250
+ self._benchmark()
251
+
252
+ def verify_tokens256(self):
253
+ return self._reference()
254
+
255
+ def setup_tokens1024(self):
256
+ self._setup_tokens(1024)
257
+
258
+ def benchmark_tokens1024(self):
259
+ self._benchmark()
260
+
261
+ def verify_tokens1024(self):
262
+ return self._reference()
263
+
264
+ def setup_tokens2520(self):
265
+ self._setup_tokens(2520)
266
+
267
+ def benchmark_tokens2520(self):
268
+ self._benchmark()
269
+
270
+ def verify_tokens2520(self):
271
+ return self._reference()
272
+
273
+ def setup_tokens4096(self):
274
+ self._setup_tokens(4096)
275
+
276
+ def benchmark_tokens4096(self):
277
+ self._benchmark()
278
+
279
+ def verify_tokens4096(self):
280
+ return self._reference()
281
+
282
+
283
+ class QKVSplitNormRopeKBenchmark(QKVSplitNormRopeBenchmark):
284
+ seed = 14
285
+
286
+ def _setup_tokens(self, tokens: int) -> None:
287
+ super()._setup_tokens(tokens)
288
+ self.out = self.k_out
289
+
290
+ def _reference(self):
291
+ return self._reference_pair()[1]
292
+
293
+
294
+ class KNormRopeVCacheBenchmark(Benchmark):
295
+ seed = 12
296
+
297
+ def _setup_heads(self, n_heads: int) -> None:
298
+ self.k = torch.randn(
299
+ (n_heads, 128), device=self.device, dtype=torch.bfloat16
300
+ ).contiguous()
301
+ self.v = torch.randn(
302
+ (n_heads, 128), device=self.device, dtype=torch.bfloat16
303
+ ).contiguous()
304
+ self.weight = torch.randn(
305
+ (128,), device=self.device, dtype=torch.bfloat16
306
+ ).contiguous()
307
+ self.cos = torch.randn((64,), device=self.device, dtype=torch.bfloat16)
308
+ self.sin = torch.randn((64,), device=self.device, dtype=torch.bfloat16)
309
+ self.k_out = torch.empty_like(self.k)
310
+ self.v_out = torch.empty_like(self.v)
311
+ self.out = self.k_out
312
+
313
+ def _reference(self):
314
+ return _reference_norm_rope(self.k, self.weight, self.cos, self.sin)
315
+
316
+ def setup_heads1(self):
317
+ self._setup_heads(1)
318
+
319
+ def benchmark_heads1(self):
320
+ self.kernel.k_norm_rope_v_cache_bf16(
321
+ self.k, self.v, self.weight, self.cos, self.sin,
322
+ k_out=self.k_out, v_out=self.v_out
323
+ )
324
+
325
+ def verify_heads1(self):
326
+ return self._reference()
327
+
328
+ def setup_heads4(self):
329
+ self._setup_heads(4)
330
+
331
+ def benchmark_heads4(self):
332
+ self.kernel.k_norm_rope_v_cache_bf16(
333
+ self.k, self.v, self.weight, self.cos, self.sin,
334
+ k_out=self.k_out, v_out=self.v_out
335
+ )
336
+
337
+ def verify_heads4(self):
338
+ return self._reference()
339
+
340
+ def setup_heads8(self):
341
+ self._setup_heads(8)
342
+
343
+ def benchmark_heads8(self):
344
+ self.kernel.k_norm_rope_v_cache_bf16(
345
+ self.k, self.v, self.weight, self.cos, self.sin,
346
+ k_out=self.k_out, v_out=self.v_out
347
+ )
348
+
349
+ def verify_heads8(self):
350
+ return self._reference()
351
+
352
+ def setup_heads16(self):
353
+ self._setup_heads(16)
354
+
355
+ def benchmark_heads16(self):
356
+ self.kernel.k_norm_rope_v_cache_bf16(
357
+ self.k, self.v, self.weight, self.cos, self.sin,
358
+ k_out=self.k_out, v_out=self.v_out
359
+ )
360
+
361
+ def verify_heads16(self):
362
+ return self._reference()
363
+
364
+ def setup_heads24(self):
365
+ self._setup_heads(24)
366
+
367
+ def benchmark_heads24(self):
368
+ self.kernel.k_norm_rope_v_cache_bf16(
369
+ self.k, self.v, self.weight, self.cos, self.sin,
370
+ k_out=self.k_out, v_out=self.v_out
371
+ )
372
+
373
+ def verify_heads24(self):
374
+ return self._reference()
375
+
376
+ def setup_heads32(self):
377
+ self._setup_heads(32)
378
+
379
+ def benchmark_heads32(self):
380
+ self.kernel.k_norm_rope_v_cache_bf16(
381
+ self.k, self.v, self.weight, self.cos, self.sin,
382
+ k_out=self.k_out, v_out=self.v_out
383
+ )
384
+
385
+ def verify_heads32(self):
386
+ return self._reference()
387
+
388
+ def setup_heads48(self):
389
+ self._setup_heads(48)
390
+
391
+ def benchmark_heads48(self):
392
+ self.kernel.k_norm_rope_v_cache_bf16(
393
+ self.k, self.v, self.weight, self.cos, self.sin,
394
+ k_out=self.k_out, v_out=self.v_out
395
+ )
396
+
397
+ def verify_heads48(self):
398
+ return self._reference()
build/torch211-cxx11-cu126-x86_64-linux/__init__.py ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """FlashRT VLA, vision, video, and diffusion kernels."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Optional
6
+
7
+ import torch
8
+
9
+ from ._ops import add_op_namespace_prefix, ops
10
+
11
+
12
+ @torch.library.register_fake(add_op_namespace_prefix("q_norm_rope_bf16"))
13
+ def _q_norm_rope_bf16_fake(
14
+ q: torch.Tensor,
15
+ weight: torch.Tensor,
16
+ cos: torch.Tensor,
17
+ sin: torch.Tensor,
18
+ out: torch.Tensor,
19
+ eps: float = 1e-6,
20
+ ) -> None:
21
+ if out.shape != q.shape:
22
+ raise RuntimeError("out shape must match q shape")
23
+ return None
24
+
25
+
26
+ @torch.library.register_fake(add_op_namespace_prefix("k_norm_rope_v_cache_bf16"))
27
+ def _k_norm_rope_v_cache_bf16_fake(
28
+ k: torch.Tensor,
29
+ v: torch.Tensor,
30
+ weight: torch.Tensor,
31
+ cos: torch.Tensor,
32
+ sin: torch.Tensor,
33
+ k_out: torch.Tensor,
34
+ v_out: torch.Tensor,
35
+ eps: float = 1e-6,
36
+ ) -> None:
37
+ if k_out.shape != k.shape or v_out.shape != v.shape:
38
+ raise RuntimeError("k_out and v_out shapes must match k and v")
39
+ return None
40
+
41
+
42
+ @torch.library.register_fake(add_op_namespace_prefix("qkv_split_norm_rope_bf16"))
43
+ def _qkv_split_norm_rope_bf16_fake(
44
+ packed_qkv: torch.Tensor,
45
+ norm_q_weight: torch.Tensor,
46
+ norm_k_weight: torch.Tensor,
47
+ freqs_re: torch.Tensor,
48
+ freqs_im: torch.Tensor,
49
+ q_out: torch.Tensor,
50
+ k_out: torch.Tensor,
51
+ heads: int,
52
+ head_dim: int,
53
+ seq_len: int,
54
+ eps: float = 1e-6,
55
+ ) -> None:
56
+ expected = (packed_qkv.shape[0], packed_qkv.shape[1], heads, head_dim)
57
+ if q_out.shape != expected or k_out.shape != expected:
58
+ raise RuntimeError(
59
+ "q_out and k_out shapes must be (batch, tokens, heads, head_dim)"
60
+ )
61
+ return None
62
+
63
+
64
+ def q_norm_rope_bf16(
65
+ q: torch.Tensor,
66
+ weight: torch.Tensor,
67
+ cos: torch.Tensor,
68
+ sin: torch.Tensor,
69
+ out: Optional[torch.Tensor] = None,
70
+ *,
71
+ eps: float = 1e-6,
72
+ ) -> torch.Tensor:
73
+ """Compute per-row RMSNorm plus rotate-half RoPE for BF16 Q heads.
74
+
75
+ ``q`` must be contiguous BF16 with shape ``(..., 128)``. ``weight`` must
76
+ have shape ``(128,)``. ``cos`` and ``sin`` must have shape ``(64,)`` for
77
+ the current decode position. If ``out`` is omitted, a BF16 tensor with the
78
+ same shape as ``q`` is allocated.
79
+ """
80
+
81
+ if out is None:
82
+ out = torch.empty_like(q)
83
+ ops.q_norm_rope_bf16(q, weight, cos, sin, out, eps)
84
+ return out
85
+
86
+
87
+ def k_norm_rope_v_cache_bf16(
88
+ k: torch.Tensor,
89
+ v: torch.Tensor,
90
+ weight: torch.Tensor,
91
+ cos: torch.Tensor,
92
+ sin: torch.Tensor,
93
+ k_out: Optional[torch.Tensor] = None,
94
+ v_out: Optional[torch.Tensor] = None,
95
+ *,
96
+ eps: float = 1e-6,
97
+ ) -> tuple[torch.Tensor, torch.Tensor]:
98
+ """Compute K RMSNorm plus RoPE and copy V into cache-shaped outputs.
99
+
100
+ ``k`` and ``v`` must be contiguous BF16 tensors with shape ``(..., 128)``.
101
+ ``weight`` must have shape ``(128,)``. ``cos`` and ``sin`` must have shape
102
+ ``(64,)`` for the current decode position. If outputs are omitted, BF16
103
+ tensors with the same shape as ``k`` are allocated.
104
+ """
105
+
106
+ if k_out is None:
107
+ k_out = torch.empty_like(k)
108
+ if v_out is None:
109
+ v_out = torch.empty_like(v)
110
+ ops.k_norm_rope_v_cache_bf16(k, v, weight, cos, sin, k_out, v_out, eps)
111
+ return k_out, v_out
112
+
113
+
114
+ def qkv_split_norm_rope_bf16(
115
+ packed_qkv: torch.Tensor,
116
+ norm_q_weight: torch.Tensor,
117
+ norm_k_weight: torch.Tensor,
118
+ freqs_re: torch.Tensor,
119
+ freqs_im: torch.Tensor,
120
+ *,
121
+ heads: int,
122
+ head_dim: int,
123
+ seq_len: Optional[int] = None,
124
+ q_out: Optional[torch.Tensor] = None,
125
+ k_out: Optional[torch.Tensor] = None,
126
+ eps: float = 1e-6,
127
+ ) -> tuple[torch.Tensor, torch.Tensor]:
128
+ """Split packed QKV, RMS-normalize Q/K, and apply interleaved RoPE.
129
+
130
+ ``packed_qkv`` must be contiguous BF16 with shape
131
+ ``(batch, tokens, 3 * heads * head_dim)``. ``norm_q_weight`` and
132
+ ``norm_k_weight`` must have shape ``(heads * head_dim,)``. ``freqs_re`` and
133
+ ``freqs_im`` must be contiguous FP32 tensors with shape
134
+ ``(seq_len_table, head_dim // 2)``. Outputs have shape
135
+ ``(batch, tokens, heads, head_dim)``.
136
+ """
137
+
138
+ if seq_len is None:
139
+ seq_len = packed_qkv.shape[1]
140
+ if q_out is None:
141
+ q_out = torch.empty(
142
+ (packed_qkv.shape[0], packed_qkv.shape[1], heads, head_dim),
143
+ device=packed_qkv.device,
144
+ dtype=packed_qkv.dtype,
145
+ )
146
+ if k_out is None:
147
+ k_out = torch.empty_like(q_out)
148
+ ops.qkv_split_norm_rope_bf16(
149
+ packed_qkv,
150
+ norm_q_weight,
151
+ norm_k_weight,
152
+ freqs_re,
153
+ freqs_im,
154
+ q_out,
155
+ k_out,
156
+ heads,
157
+ head_dim,
158
+ seq_len,
159
+ eps,
160
+ )
161
+ return q_out, k_out
162
+
163
+
164
+ __all__ = [
165
+ "q_norm_rope_bf16",
166
+ "k_norm_rope_v_cache_bf16",
167
+ "qkv_split_norm_rope_bf16",
168
+ ]
build/torch211-cxx11-cu126-x86_64-linux/_flashrt_vla_video_cuda_c4d802d.abi3.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fdb35ae012cfcdb2bd77a66cc3e19eb4e4e1d05892d57a877362fadfbab3f19b
3
+ size 323344
build/torch211-cxx11-cu126-x86_64-linux/_ops.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from . import _flashrt_vla_video_cuda_c4d802d
3
+ ops = torch.ops._flashrt_vla_video_cuda_c4d802d
4
+
5
+ def add_op_namespace_prefix(op_name: str):
6
+ """
7
+ Prefix op by namespace.
8
+ """
9
+ return f"_flashrt_vla_video_cuda_c4d802d::{op_name}"
build/torch211-cxx11-cu126-x86_64-linux/flashrt_vla_video/__init__.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ctypes
2
+ import importlib.util
3
+ import sys
4
+ from pathlib import Path
5
+ from types import ModuleType
6
+
7
+
8
+ def _import_from_path(file_path: Path) -> ModuleType:
9
+ # We cannot use the module name as-is, after adding it to `sys.modules`,
10
+ # it would also be used for other imports. So, we make a module name that
11
+ # depends on the path for it to be unique using the hex-encoded hash of
12
+ # the path.
13
+ path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
14
+ module_name = path_hash
15
+ spec = importlib.util.spec_from_file_location(module_name, file_path)
16
+ if spec is None:
17
+ raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
18
+ module = importlib.util.module_from_spec(spec)
19
+ if module is None:
20
+ raise ImportError(f"Cannot load module {module_name} from spec")
21
+ sys.modules[module_name] = module
22
+ spec.loader.exec_module(module) # type: ignore
23
+ return module
24
+
25
+
26
+ globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))
build/torch211-cxx11-cu126-x86_64-linux/metadata.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "flashrt-vla-video",
3
+ "id": "_flashrt_vla_video_cuda_c4d802d",
4
+ "version": 1,
5
+ "license": "Apache-2.0",
6
+ "python-depends": [],
7
+ "backend": {
8
+ "type": "cuda",
9
+ "archs": [
10
+ "7.0",
11
+ "7.2",
12
+ "7.5",
13
+ "8.0",
14
+ "8.6",
15
+ "8.7",
16
+ "8.9",
17
+ "9.0+PTX"
18
+ ]
19
+ }
20
+ }
build/torch211-cxx11-cu128-x86_64-linux/__init__.py ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """FlashRT VLA, vision, video, and diffusion kernels."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Optional
6
+
7
+ import torch
8
+
9
+ from ._ops import add_op_namespace_prefix, ops
10
+
11
+
12
+ @torch.library.register_fake(add_op_namespace_prefix("q_norm_rope_bf16"))
13
+ def _q_norm_rope_bf16_fake(
14
+ q: torch.Tensor,
15
+ weight: torch.Tensor,
16
+ cos: torch.Tensor,
17
+ sin: torch.Tensor,
18
+ out: torch.Tensor,
19
+ eps: float = 1e-6,
20
+ ) -> None:
21
+ if out.shape != q.shape:
22
+ raise RuntimeError("out shape must match q shape")
23
+ return None
24
+
25
+
26
+ @torch.library.register_fake(add_op_namespace_prefix("k_norm_rope_v_cache_bf16"))
27
+ def _k_norm_rope_v_cache_bf16_fake(
28
+ k: torch.Tensor,
29
+ v: torch.Tensor,
30
+ weight: torch.Tensor,
31
+ cos: torch.Tensor,
32
+ sin: torch.Tensor,
33
+ k_out: torch.Tensor,
34
+ v_out: torch.Tensor,
35
+ eps: float = 1e-6,
36
+ ) -> None:
37
+ if k_out.shape != k.shape or v_out.shape != v.shape:
38
+ raise RuntimeError("k_out and v_out shapes must match k and v")
39
+ return None
40
+
41
+
42
+ @torch.library.register_fake(add_op_namespace_prefix("qkv_split_norm_rope_bf16"))
43
+ def _qkv_split_norm_rope_bf16_fake(
44
+ packed_qkv: torch.Tensor,
45
+ norm_q_weight: torch.Tensor,
46
+ norm_k_weight: torch.Tensor,
47
+ freqs_re: torch.Tensor,
48
+ freqs_im: torch.Tensor,
49
+ q_out: torch.Tensor,
50
+ k_out: torch.Tensor,
51
+ heads: int,
52
+ head_dim: int,
53
+ seq_len: int,
54
+ eps: float = 1e-6,
55
+ ) -> None:
56
+ expected = (packed_qkv.shape[0], packed_qkv.shape[1], heads, head_dim)
57
+ if q_out.shape != expected or k_out.shape != expected:
58
+ raise RuntimeError(
59
+ "q_out and k_out shapes must be (batch, tokens, heads, head_dim)"
60
+ )
61
+ return None
62
+
63
+
64
+ def q_norm_rope_bf16(
65
+ q: torch.Tensor,
66
+ weight: torch.Tensor,
67
+ cos: torch.Tensor,
68
+ sin: torch.Tensor,
69
+ out: Optional[torch.Tensor] = None,
70
+ *,
71
+ eps: float = 1e-6,
72
+ ) -> torch.Tensor:
73
+ """Compute per-row RMSNorm plus rotate-half RoPE for BF16 Q heads.
74
+
75
+ ``q`` must be contiguous BF16 with shape ``(..., 128)``. ``weight`` must
76
+ have shape ``(128,)``. ``cos`` and ``sin`` must have shape ``(64,)`` for
77
+ the current decode position. If ``out`` is omitted, a BF16 tensor with the
78
+ same shape as ``q`` is allocated.
79
+ """
80
+
81
+ if out is None:
82
+ out = torch.empty_like(q)
83
+ ops.q_norm_rope_bf16(q, weight, cos, sin, out, eps)
84
+ return out
85
+
86
+
87
+ def k_norm_rope_v_cache_bf16(
88
+ k: torch.Tensor,
89
+ v: torch.Tensor,
90
+ weight: torch.Tensor,
91
+ cos: torch.Tensor,
92
+ sin: torch.Tensor,
93
+ k_out: Optional[torch.Tensor] = None,
94
+ v_out: Optional[torch.Tensor] = None,
95
+ *,
96
+ eps: float = 1e-6,
97
+ ) -> tuple[torch.Tensor, torch.Tensor]:
98
+ """Compute K RMSNorm plus RoPE and copy V into cache-shaped outputs.
99
+
100
+ ``k`` and ``v`` must be contiguous BF16 tensors with shape ``(..., 128)``.
101
+ ``weight`` must have shape ``(128,)``. ``cos`` and ``sin`` must have shape
102
+ ``(64,)`` for the current decode position. If outputs are omitted, BF16
103
+ tensors with the same shape as ``k`` are allocated.
104
+ """
105
+
106
+ if k_out is None:
107
+ k_out = torch.empty_like(k)
108
+ if v_out is None:
109
+ v_out = torch.empty_like(v)
110
+ ops.k_norm_rope_v_cache_bf16(k, v, weight, cos, sin, k_out, v_out, eps)
111
+ return k_out, v_out
112
+
113
+
114
+ def qkv_split_norm_rope_bf16(
115
+ packed_qkv: torch.Tensor,
116
+ norm_q_weight: torch.Tensor,
117
+ norm_k_weight: torch.Tensor,
118
+ freqs_re: torch.Tensor,
119
+ freqs_im: torch.Tensor,
120
+ *,
121
+ heads: int,
122
+ head_dim: int,
123
+ seq_len: Optional[int] = None,
124
+ q_out: Optional[torch.Tensor] = None,
125
+ k_out: Optional[torch.Tensor] = None,
126
+ eps: float = 1e-6,
127
+ ) -> tuple[torch.Tensor, torch.Tensor]:
128
+ """Split packed QKV, RMS-normalize Q/K, and apply interleaved RoPE.
129
+
130
+ ``packed_qkv`` must be contiguous BF16 with shape
131
+ ``(batch, tokens, 3 * heads * head_dim)``. ``norm_q_weight`` and
132
+ ``norm_k_weight`` must have shape ``(heads * head_dim,)``. ``freqs_re`` and
133
+ ``freqs_im`` must be contiguous FP32 tensors with shape
134
+ ``(seq_len_table, head_dim // 2)``. Outputs have shape
135
+ ``(batch, tokens, heads, head_dim)``.
136
+ """
137
+
138
+ if seq_len is None:
139
+ seq_len = packed_qkv.shape[1]
140
+ if q_out is None:
141
+ q_out = torch.empty(
142
+ (packed_qkv.shape[0], packed_qkv.shape[1], heads, head_dim),
143
+ device=packed_qkv.device,
144
+ dtype=packed_qkv.dtype,
145
+ )
146
+ if k_out is None:
147
+ k_out = torch.empty_like(q_out)
148
+ ops.qkv_split_norm_rope_bf16(
149
+ packed_qkv,
150
+ norm_q_weight,
151
+ norm_k_weight,
152
+ freqs_re,
153
+ freqs_im,
154
+ q_out,
155
+ k_out,
156
+ heads,
157
+ head_dim,
158
+ seq_len,
159
+ eps,
160
+ )
161
+ return q_out, k_out
162
+
163
+
164
+ __all__ = [
165
+ "q_norm_rope_bf16",
166
+ "k_norm_rope_v_cache_bf16",
167
+ "qkv_split_norm_rope_bf16",
168
+ ]
build/torch211-cxx11-cu128-x86_64-linux/_flashrt_vla_video_cuda_c4d802d.abi3.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c12707a599fc0483cc4807e9cd9143d9ada51076eafae6462f33d0d18fa119ba
3
+ size 434240
build/torch211-cxx11-cu128-x86_64-linux/_ops.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from . import _flashrt_vla_video_cuda_c4d802d
3
+ ops = torch.ops._flashrt_vla_video_cuda_c4d802d
4
+
5
+ def add_op_namespace_prefix(op_name: str):
6
+ """
7
+ Prefix op by namespace.
8
+ """
9
+ return f"_flashrt_vla_video_cuda_c4d802d::{op_name}"
build/torch211-cxx11-cu128-x86_64-linux/flashrt_vla_video/__init__.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ctypes
2
+ import importlib.util
3
+ import sys
4
+ from pathlib import Path
5
+ from types import ModuleType
6
+
7
+
8
+ def _import_from_path(file_path: Path) -> ModuleType:
9
+ # We cannot use the module name as-is, after adding it to `sys.modules`,
10
+ # it would also be used for other imports. So, we make a module name that
11
+ # depends on the path for it to be unique using the hex-encoded hash of
12
+ # the path.
13
+ path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
14
+ module_name = path_hash
15
+ spec = importlib.util.spec_from_file_location(module_name, file_path)
16
+ if spec is None:
17
+ raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
18
+ module = importlib.util.module_from_spec(spec)
19
+ if module is None:
20
+ raise ImportError(f"Cannot load module {module_name} from spec")
21
+ sys.modules[module_name] = module
22
+ spec.loader.exec_module(module) # type: ignore
23
+ return module
24
+
25
+
26
+ globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))
build/torch211-cxx11-cu128-x86_64-linux/metadata.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "flashrt-vla-video",
3
+ "id": "_flashrt_vla_video_cuda_c4d802d",
4
+ "version": 1,
5
+ "license": "Apache-2.0",
6
+ "python-depends": [],
7
+ "backend": {
8
+ "type": "cuda",
9
+ "archs": [
10
+ "10.0",
11
+ "10.1",
12
+ "12.0+PTX",
13
+ "7.0",
14
+ "7.2",
15
+ "7.5",
16
+ "8.0",
17
+ "8.6",
18
+ "8.7",
19
+ "8.9",
20
+ "9.0"
21
+ ]
22
+ }
23
+ }
build/torch211-cxx11-cu130-x86_64-linux/__init__.py ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """FlashRT VLA, vision, video, and diffusion kernels."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Optional
6
+
7
+ import torch
8
+
9
+ from ._ops import add_op_namespace_prefix, ops
10
+
11
+
12
+ @torch.library.register_fake(add_op_namespace_prefix("q_norm_rope_bf16"))
13
+ def _q_norm_rope_bf16_fake(
14
+ q: torch.Tensor,
15
+ weight: torch.Tensor,
16
+ cos: torch.Tensor,
17
+ sin: torch.Tensor,
18
+ out: torch.Tensor,
19
+ eps: float = 1e-6,
20
+ ) -> None:
21
+ if out.shape != q.shape:
22
+ raise RuntimeError("out shape must match q shape")
23
+ return None
24
+
25
+
26
+ @torch.library.register_fake(add_op_namespace_prefix("k_norm_rope_v_cache_bf16"))
27
+ def _k_norm_rope_v_cache_bf16_fake(
28
+ k: torch.Tensor,
29
+ v: torch.Tensor,
30
+ weight: torch.Tensor,
31
+ cos: torch.Tensor,
32
+ sin: torch.Tensor,
33
+ k_out: torch.Tensor,
34
+ v_out: torch.Tensor,
35
+ eps: float = 1e-6,
36
+ ) -> None:
37
+ if k_out.shape != k.shape or v_out.shape != v.shape:
38
+ raise RuntimeError("k_out and v_out shapes must match k and v")
39
+ return None
40
+
41
+
42
+ @torch.library.register_fake(add_op_namespace_prefix("qkv_split_norm_rope_bf16"))
43
+ def _qkv_split_norm_rope_bf16_fake(
44
+ packed_qkv: torch.Tensor,
45
+ norm_q_weight: torch.Tensor,
46
+ norm_k_weight: torch.Tensor,
47
+ freqs_re: torch.Tensor,
48
+ freqs_im: torch.Tensor,
49
+ q_out: torch.Tensor,
50
+ k_out: torch.Tensor,
51
+ heads: int,
52
+ head_dim: int,
53
+ seq_len: int,
54
+ eps: float = 1e-6,
55
+ ) -> None:
56
+ expected = (packed_qkv.shape[0], packed_qkv.shape[1], heads, head_dim)
57
+ if q_out.shape != expected or k_out.shape != expected:
58
+ raise RuntimeError(
59
+ "q_out and k_out shapes must be (batch, tokens, heads, head_dim)"
60
+ )
61
+ return None
62
+
63
+
64
+ def q_norm_rope_bf16(
65
+ q: torch.Tensor,
66
+ weight: torch.Tensor,
67
+ cos: torch.Tensor,
68
+ sin: torch.Tensor,
69
+ out: Optional[torch.Tensor] = None,
70
+ *,
71
+ eps: float = 1e-6,
72
+ ) -> torch.Tensor:
73
+ """Compute per-row RMSNorm plus rotate-half RoPE for BF16 Q heads.
74
+
75
+ ``q`` must be contiguous BF16 with shape ``(..., 128)``. ``weight`` must
76
+ have shape ``(128,)``. ``cos`` and ``sin`` must have shape ``(64,)`` for
77
+ the current decode position. If ``out`` is omitted, a BF16 tensor with the
78
+ same shape as ``q`` is allocated.
79
+ """
80
+
81
+ if out is None:
82
+ out = torch.empty_like(q)
83
+ ops.q_norm_rope_bf16(q, weight, cos, sin, out, eps)
84
+ return out
85
+
86
+
87
+ def k_norm_rope_v_cache_bf16(
88
+ k: torch.Tensor,
89
+ v: torch.Tensor,
90
+ weight: torch.Tensor,
91
+ cos: torch.Tensor,
92
+ sin: torch.Tensor,
93
+ k_out: Optional[torch.Tensor] = None,
94
+ v_out: Optional[torch.Tensor] = None,
95
+ *,
96
+ eps: float = 1e-6,
97
+ ) -> tuple[torch.Tensor, torch.Tensor]:
98
+ """Compute K RMSNorm plus RoPE and copy V into cache-shaped outputs.
99
+
100
+ ``k`` and ``v`` must be contiguous BF16 tensors with shape ``(..., 128)``.
101
+ ``weight`` must have shape ``(128,)``. ``cos`` and ``sin`` must have shape
102
+ ``(64,)`` for the current decode position. If outputs are omitted, BF16
103
+ tensors with the same shape as ``k`` are allocated.
104
+ """
105
+
106
+ if k_out is None:
107
+ k_out = torch.empty_like(k)
108
+ if v_out is None:
109
+ v_out = torch.empty_like(v)
110
+ ops.k_norm_rope_v_cache_bf16(k, v, weight, cos, sin, k_out, v_out, eps)
111
+ return k_out, v_out
112
+
113
+
114
+ def qkv_split_norm_rope_bf16(
115
+ packed_qkv: torch.Tensor,
116
+ norm_q_weight: torch.Tensor,
117
+ norm_k_weight: torch.Tensor,
118
+ freqs_re: torch.Tensor,
119
+ freqs_im: torch.Tensor,
120
+ *,
121
+ heads: int,
122
+ head_dim: int,
123
+ seq_len: Optional[int] = None,
124
+ q_out: Optional[torch.Tensor] = None,
125
+ k_out: Optional[torch.Tensor] = None,
126
+ eps: float = 1e-6,
127
+ ) -> tuple[torch.Tensor, torch.Tensor]:
128
+ """Split packed QKV, RMS-normalize Q/K, and apply interleaved RoPE.
129
+
130
+ ``packed_qkv`` must be contiguous BF16 with shape
131
+ ``(batch, tokens, 3 * heads * head_dim)``. ``norm_q_weight`` and
132
+ ``norm_k_weight`` must have shape ``(heads * head_dim,)``. ``freqs_re`` and
133
+ ``freqs_im`` must be contiguous FP32 tensors with shape
134
+ ``(seq_len_table, head_dim // 2)``. Outputs have shape
135
+ ``(batch, tokens, heads, head_dim)``.
136
+ """
137
+
138
+ if seq_len is None:
139
+ seq_len = packed_qkv.shape[1]
140
+ if q_out is None:
141
+ q_out = torch.empty(
142
+ (packed_qkv.shape[0], packed_qkv.shape[1], heads, head_dim),
143
+ device=packed_qkv.device,
144
+ dtype=packed_qkv.dtype,
145
+ )
146
+ if k_out is None:
147
+ k_out = torch.empty_like(q_out)
148
+ ops.qkv_split_norm_rope_bf16(
149
+ packed_qkv,
150
+ norm_q_weight,
151
+ norm_k_weight,
152
+ freqs_re,
153
+ freqs_im,
154
+ q_out,
155
+ k_out,
156
+ heads,
157
+ head_dim,
158
+ seq_len,
159
+ eps,
160
+ )
161
+ return q_out, k_out
162
+
163
+
164
+ __all__ = [
165
+ "q_norm_rope_bf16",
166
+ "k_norm_rope_v_cache_bf16",
167
+ "qkv_split_norm_rope_bf16",
168
+ ]
build/torch211-cxx11-cu130-x86_64-linux/_flashrt_vla_video_cuda_c4d802d.abi3.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3ab10c2106f9d6a959339749c004f57e8ed53bc0a0aa3fcefebe8248c9eb366b
3
+ size 425368
build/torch211-cxx11-cu130-x86_64-linux/_ops.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from . import _flashrt_vla_video_cuda_c4d802d
3
+ ops = torch.ops._flashrt_vla_video_cuda_c4d802d
4
+
5
+ def add_op_namespace_prefix(op_name: str):
6
+ """
7
+ Prefix op by namespace.
8
+ """
9
+ return f"_flashrt_vla_video_cuda_c4d802d::{op_name}"
build/torch211-cxx11-cu130-x86_64-linux/flashrt_vla_video/__init__.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ctypes
2
+ import importlib.util
3
+ import sys
4
+ from pathlib import Path
5
+ from types import ModuleType
6
+
7
+
8
+ def _import_from_path(file_path: Path) -> ModuleType:
9
+ # We cannot use the module name as-is, after adding it to `sys.modules`,
10
+ # it would also be used for other imports. So, we make a module name that
11
+ # depends on the path for it to be unique using the hex-encoded hash of
12
+ # the path.
13
+ path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
14
+ module_name = path_hash
15
+ spec = importlib.util.spec_from_file_location(module_name, file_path)
16
+ if spec is None:
17
+ raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
18
+ module = importlib.util.module_from_spec(spec)
19
+ if module is None:
20
+ raise ImportError(f"Cannot load module {module_name} from spec")
21
+ sys.modules[module_name] = module
22
+ spec.loader.exec_module(module) # type: ignore
23
+ return module
24
+
25
+
26
+ globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))
build/torch211-cxx11-cu130-x86_64-linux/metadata.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "flashrt-vla-video",
3
+ "id": "_flashrt_vla_video_cuda_c4d802d",
4
+ "version": 1,
5
+ "license": "Apache-2.0",
6
+ "python-depends": [],
7
+ "backend": {
8
+ "type": "cuda",
9
+ "archs": [
10
+ "10.0",
11
+ "11.0",
12
+ "12.0",
13
+ "12.1+PTX",
14
+ "7.5",
15
+ "8.0",
16
+ "8.6",
17
+ "8.7",
18
+ "8.9",
19
+ "9.0"
20
+ ]
21
+ }
22
+ }
build/torch212-cxx11-cu126-x86_64-linux/__init__.py ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """FlashRT VLA, vision, video, and diffusion kernels."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Optional
6
+
7
+ import torch
8
+
9
+ from ._ops import add_op_namespace_prefix, ops
10
+
11
+
12
+ @torch.library.register_fake(add_op_namespace_prefix("q_norm_rope_bf16"))
13
+ def _q_norm_rope_bf16_fake(
14
+ q: torch.Tensor,
15
+ weight: torch.Tensor,
16
+ cos: torch.Tensor,
17
+ sin: torch.Tensor,
18
+ out: torch.Tensor,
19
+ eps: float = 1e-6,
20
+ ) -> None:
21
+ if out.shape != q.shape:
22
+ raise RuntimeError("out shape must match q shape")
23
+ return None
24
+
25
+
26
+ @torch.library.register_fake(add_op_namespace_prefix("k_norm_rope_v_cache_bf16"))
27
+ def _k_norm_rope_v_cache_bf16_fake(
28
+ k: torch.Tensor,
29
+ v: torch.Tensor,
30
+ weight: torch.Tensor,
31
+ cos: torch.Tensor,
32
+ sin: torch.Tensor,
33
+ k_out: torch.Tensor,
34
+ v_out: torch.Tensor,
35
+ eps: float = 1e-6,
36
+ ) -> None:
37
+ if k_out.shape != k.shape or v_out.shape != v.shape:
38
+ raise RuntimeError("k_out and v_out shapes must match k and v")
39
+ return None
40
+
41
+
42
+ @torch.library.register_fake(add_op_namespace_prefix("qkv_split_norm_rope_bf16"))
43
+ def _qkv_split_norm_rope_bf16_fake(
44
+ packed_qkv: torch.Tensor,
45
+ norm_q_weight: torch.Tensor,
46
+ norm_k_weight: torch.Tensor,
47
+ freqs_re: torch.Tensor,
48
+ freqs_im: torch.Tensor,
49
+ q_out: torch.Tensor,
50
+ k_out: torch.Tensor,
51
+ heads: int,
52
+ head_dim: int,
53
+ seq_len: int,
54
+ eps: float = 1e-6,
55
+ ) -> None:
56
+ expected = (packed_qkv.shape[0], packed_qkv.shape[1], heads, head_dim)
57
+ if q_out.shape != expected or k_out.shape != expected:
58
+ raise RuntimeError(
59
+ "q_out and k_out shapes must be (batch, tokens, heads, head_dim)"
60
+ )
61
+ return None
62
+
63
+
64
+ def q_norm_rope_bf16(
65
+ q: torch.Tensor,
66
+ weight: torch.Tensor,
67
+ cos: torch.Tensor,
68
+ sin: torch.Tensor,
69
+ out: Optional[torch.Tensor] = None,
70
+ *,
71
+ eps: float = 1e-6,
72
+ ) -> torch.Tensor:
73
+ """Compute per-row RMSNorm plus rotate-half RoPE for BF16 Q heads.
74
+
75
+ ``q`` must be contiguous BF16 with shape ``(..., 128)``. ``weight`` must
76
+ have shape ``(128,)``. ``cos`` and ``sin`` must have shape ``(64,)`` for
77
+ the current decode position. If ``out`` is omitted, a BF16 tensor with the
78
+ same shape as ``q`` is allocated.
79
+ """
80
+
81
+ if out is None:
82
+ out = torch.empty_like(q)
83
+ ops.q_norm_rope_bf16(q, weight, cos, sin, out, eps)
84
+ return out
85
+
86
+
87
+ def k_norm_rope_v_cache_bf16(
88
+ k: torch.Tensor,
89
+ v: torch.Tensor,
90
+ weight: torch.Tensor,
91
+ cos: torch.Tensor,
92
+ sin: torch.Tensor,
93
+ k_out: Optional[torch.Tensor] = None,
94
+ v_out: Optional[torch.Tensor] = None,
95
+ *,
96
+ eps: float = 1e-6,
97
+ ) -> tuple[torch.Tensor, torch.Tensor]:
98
+ """Compute K RMSNorm plus RoPE and copy V into cache-shaped outputs.
99
+
100
+ ``k`` and ``v`` must be contiguous BF16 tensors with shape ``(..., 128)``.
101
+ ``weight`` must have shape ``(128,)``. ``cos`` and ``sin`` must have shape
102
+ ``(64,)`` for the current decode position. If outputs are omitted, BF16
103
+ tensors with the same shape as ``k`` are allocated.
104
+ """
105
+
106
+ if k_out is None:
107
+ k_out = torch.empty_like(k)
108
+ if v_out is None:
109
+ v_out = torch.empty_like(v)
110
+ ops.k_norm_rope_v_cache_bf16(k, v, weight, cos, sin, k_out, v_out, eps)
111
+ return k_out, v_out
112
+
113
+
114
+ def qkv_split_norm_rope_bf16(
115
+ packed_qkv: torch.Tensor,
116
+ norm_q_weight: torch.Tensor,
117
+ norm_k_weight: torch.Tensor,
118
+ freqs_re: torch.Tensor,
119
+ freqs_im: torch.Tensor,
120
+ *,
121
+ heads: int,
122
+ head_dim: int,
123
+ seq_len: Optional[int] = None,
124
+ q_out: Optional[torch.Tensor] = None,
125
+ k_out: Optional[torch.Tensor] = None,
126
+ eps: float = 1e-6,
127
+ ) -> tuple[torch.Tensor, torch.Tensor]:
128
+ """Split packed QKV, RMS-normalize Q/K, and apply interleaved RoPE.
129
+
130
+ ``packed_qkv`` must be contiguous BF16 with shape
131
+ ``(batch, tokens, 3 * heads * head_dim)``. ``norm_q_weight`` and
132
+ ``norm_k_weight`` must have shape ``(heads * head_dim,)``. ``freqs_re`` and
133
+ ``freqs_im`` must be contiguous FP32 tensors with shape
134
+ ``(seq_len_table, head_dim // 2)``. Outputs have shape
135
+ ``(batch, tokens, heads, head_dim)``.
136
+ """
137
+
138
+ if seq_len is None:
139
+ seq_len = packed_qkv.shape[1]
140
+ if q_out is None:
141
+ q_out = torch.empty(
142
+ (packed_qkv.shape[0], packed_qkv.shape[1], heads, head_dim),
143
+ device=packed_qkv.device,
144
+ dtype=packed_qkv.dtype,
145
+ )
146
+ if k_out is None:
147
+ k_out = torch.empty_like(q_out)
148
+ ops.qkv_split_norm_rope_bf16(
149
+ packed_qkv,
150
+ norm_q_weight,
151
+ norm_k_weight,
152
+ freqs_re,
153
+ freqs_im,
154
+ q_out,
155
+ k_out,
156
+ heads,
157
+ head_dim,
158
+ seq_len,
159
+ eps,
160
+ )
161
+ return q_out, k_out
162
+
163
+
164
+ __all__ = [
165
+ "q_norm_rope_bf16",
166
+ "k_norm_rope_v_cache_bf16",
167
+ "qkv_split_norm_rope_bf16",
168
+ ]
build/torch212-cxx11-cu126-x86_64-linux/_flashrt_vla_video_cuda_c4d802d.abi3.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8828e693387a0d14594dc73d3cea8a63539e256e61a8aced1816a4f9912fc6d4
3
+ size 329368
build/torch212-cxx11-cu126-x86_64-linux/_ops.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from . import _flashrt_vla_video_cuda_c4d802d
3
+ ops = torch.ops._flashrt_vla_video_cuda_c4d802d
4
+
5
+ def add_op_namespace_prefix(op_name: str):
6
+ """
7
+ Prefix op by namespace.
8
+ """
9
+ return f"_flashrt_vla_video_cuda_c4d802d::{op_name}"
build/torch212-cxx11-cu126-x86_64-linux/flashrt_vla_video/__init__.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ctypes
2
+ import importlib.util
3
+ import sys
4
+ from pathlib import Path
5
+ from types import ModuleType
6
+
7
+
8
+ def _import_from_path(file_path: Path) -> ModuleType:
9
+ # We cannot use the module name as-is, after adding it to `sys.modules`,
10
+ # it would also be used for other imports. So, we make a module name that
11
+ # depends on the path for it to be unique using the hex-encoded hash of
12
+ # the path.
13
+ path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
14
+ module_name = path_hash
15
+ spec = importlib.util.spec_from_file_location(module_name, file_path)
16
+ if spec is None:
17
+ raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
18
+ module = importlib.util.module_from_spec(spec)
19
+ if module is None:
20
+ raise ImportError(f"Cannot load module {module_name} from spec")
21
+ sys.modules[module_name] = module
22
+ spec.loader.exec_module(module) # type: ignore
23
+ return module
24
+
25
+
26
+ globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))
build/torch212-cxx11-cu126-x86_64-linux/metadata.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "flashrt-vla-video",
3
+ "id": "_flashrt_vla_video_cuda_c4d802d",
4
+ "version": 1,
5
+ "license": "Apache-2.0",
6
+ "python-depends": [],
7
+ "backend": {
8
+ "type": "cuda",
9
+ "archs": [
10
+ "7.0",
11
+ "7.2",
12
+ "7.5",
13
+ "8.0",
14
+ "8.6",
15
+ "8.7",
16
+ "8.9",
17
+ "9.0+PTX"
18
+ ]
19
+ }
20
+ }
build/torch212-cxx11-cu130-x86_64-linux/__init__.py ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """FlashRT VLA, vision, video, and diffusion kernels."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Optional
6
+
7
+ import torch
8
+
9
+ from ._ops import add_op_namespace_prefix, ops
10
+
11
+
12
+ @torch.library.register_fake(add_op_namespace_prefix("q_norm_rope_bf16"))
13
+ def _q_norm_rope_bf16_fake(
14
+ q: torch.Tensor,
15
+ weight: torch.Tensor,
16
+ cos: torch.Tensor,
17
+ sin: torch.Tensor,
18
+ out: torch.Tensor,
19
+ eps: float = 1e-6,
20
+ ) -> None:
21
+ if out.shape != q.shape:
22
+ raise RuntimeError("out shape must match q shape")
23
+ return None
24
+
25
+
26
+ @torch.library.register_fake(add_op_namespace_prefix("k_norm_rope_v_cache_bf16"))
27
+ def _k_norm_rope_v_cache_bf16_fake(
28
+ k: torch.Tensor,
29
+ v: torch.Tensor,
30
+ weight: torch.Tensor,
31
+ cos: torch.Tensor,
32
+ sin: torch.Tensor,
33
+ k_out: torch.Tensor,
34
+ v_out: torch.Tensor,
35
+ eps: float = 1e-6,
36
+ ) -> None:
37
+ if k_out.shape != k.shape or v_out.shape != v.shape:
38
+ raise RuntimeError("k_out and v_out shapes must match k and v")
39
+ return None
40
+
41
+
42
+ @torch.library.register_fake(add_op_namespace_prefix("qkv_split_norm_rope_bf16"))
43
+ def _qkv_split_norm_rope_bf16_fake(
44
+ packed_qkv: torch.Tensor,
45
+ norm_q_weight: torch.Tensor,
46
+ norm_k_weight: torch.Tensor,
47
+ freqs_re: torch.Tensor,
48
+ freqs_im: torch.Tensor,
49
+ q_out: torch.Tensor,
50
+ k_out: torch.Tensor,
51
+ heads: int,
52
+ head_dim: int,
53
+ seq_len: int,
54
+ eps: float = 1e-6,
55
+ ) -> None:
56
+ expected = (packed_qkv.shape[0], packed_qkv.shape[1], heads, head_dim)
57
+ if q_out.shape != expected or k_out.shape != expected:
58
+ raise RuntimeError(
59
+ "q_out and k_out shapes must be (batch, tokens, heads, head_dim)"
60
+ )
61
+ return None
62
+
63
+
64
+ def q_norm_rope_bf16(
65
+ q: torch.Tensor,
66
+ weight: torch.Tensor,
67
+ cos: torch.Tensor,
68
+ sin: torch.Tensor,
69
+ out: Optional[torch.Tensor] = None,
70
+ *,
71
+ eps: float = 1e-6,
72
+ ) -> torch.Tensor:
73
+ """Compute per-row RMSNorm plus rotate-half RoPE for BF16 Q heads.
74
+
75
+ ``q`` must be contiguous BF16 with shape ``(..., 128)``. ``weight`` must
76
+ have shape ``(128,)``. ``cos`` and ``sin`` must have shape ``(64,)`` for
77
+ the current decode position. If ``out`` is omitted, a BF16 tensor with the
78
+ same shape as ``q`` is allocated.
79
+ """
80
+
81
+ if out is None:
82
+ out = torch.empty_like(q)
83
+ ops.q_norm_rope_bf16(q, weight, cos, sin, out, eps)
84
+ return out
85
+
86
+
87
+ def k_norm_rope_v_cache_bf16(
88
+ k: torch.Tensor,
89
+ v: torch.Tensor,
90
+ weight: torch.Tensor,
91
+ cos: torch.Tensor,
92
+ sin: torch.Tensor,
93
+ k_out: Optional[torch.Tensor] = None,
94
+ v_out: Optional[torch.Tensor] = None,
95
+ *,
96
+ eps: float = 1e-6,
97
+ ) -> tuple[torch.Tensor, torch.Tensor]:
98
+ """Compute K RMSNorm plus RoPE and copy V into cache-shaped outputs.
99
+
100
+ ``k`` and ``v`` must be contiguous BF16 tensors with shape ``(..., 128)``.
101
+ ``weight`` must have shape ``(128,)``. ``cos`` and ``sin`` must have shape
102
+ ``(64,)`` for the current decode position. If outputs are omitted, BF16
103
+ tensors with the same shape as ``k`` are allocated.
104
+ """
105
+
106
+ if k_out is None:
107
+ k_out = torch.empty_like(k)
108
+ if v_out is None:
109
+ v_out = torch.empty_like(v)
110
+ ops.k_norm_rope_v_cache_bf16(k, v, weight, cos, sin, k_out, v_out, eps)
111
+ return k_out, v_out
112
+
113
+
114
+ def qkv_split_norm_rope_bf16(
115
+ packed_qkv: torch.Tensor,
116
+ norm_q_weight: torch.Tensor,
117
+ norm_k_weight: torch.Tensor,
118
+ freqs_re: torch.Tensor,
119
+ freqs_im: torch.Tensor,
120
+ *,
121
+ heads: int,
122
+ head_dim: int,
123
+ seq_len: Optional[int] = None,
124
+ q_out: Optional[torch.Tensor] = None,
125
+ k_out: Optional[torch.Tensor] = None,
126
+ eps: float = 1e-6,
127
+ ) -> tuple[torch.Tensor, torch.Tensor]:
128
+ """Split packed QKV, RMS-normalize Q/K, and apply interleaved RoPE.
129
+
130
+ ``packed_qkv`` must be contiguous BF16 with shape
131
+ ``(batch, tokens, 3 * heads * head_dim)``. ``norm_q_weight`` and
132
+ ``norm_k_weight`` must have shape ``(heads * head_dim,)``. ``freqs_re`` and
133
+ ``freqs_im`` must be contiguous FP32 tensors with shape
134
+ ``(seq_len_table, head_dim // 2)``. Outputs have shape
135
+ ``(batch, tokens, heads, head_dim)``.
136
+ """
137
+
138
+ if seq_len is None:
139
+ seq_len = packed_qkv.shape[1]
140
+ if q_out is None:
141
+ q_out = torch.empty(
142
+ (packed_qkv.shape[0], packed_qkv.shape[1], heads, head_dim),
143
+ device=packed_qkv.device,
144
+ dtype=packed_qkv.dtype,
145
+ )
146
+ if k_out is None:
147
+ k_out = torch.empty_like(q_out)
148
+ ops.qkv_split_norm_rope_bf16(
149
+ packed_qkv,
150
+ norm_q_weight,
151
+ norm_k_weight,
152
+ freqs_re,
153
+ freqs_im,
154
+ q_out,
155
+ k_out,
156
+ heads,
157
+ head_dim,
158
+ seq_len,
159
+ eps,
160
+ )
161
+ return q_out, k_out
162
+
163
+
164
+ __all__ = [
165
+ "q_norm_rope_bf16",
166
+ "k_norm_rope_v_cache_bf16",
167
+ "qkv_split_norm_rope_bf16",
168
+ ]
build/torch212-cxx11-cu130-x86_64-linux/_flashrt_vla_video_cuda_c4d802d.abi3.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f0f4113617507b20bbaf6c944c6e9530d7b81092895ffccea6d1ad4bc39256f6
3
+ size 431440
build/torch212-cxx11-cu130-x86_64-linux/_ops.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from . import _flashrt_vla_video_cuda_c4d802d
3
+ ops = torch.ops._flashrt_vla_video_cuda_c4d802d
4
+
5
+ def add_op_namespace_prefix(op_name: str):
6
+ """
7
+ Prefix op by namespace.
8
+ """
9
+ return f"_flashrt_vla_video_cuda_c4d802d::{op_name}"
build/torch212-cxx11-cu130-x86_64-linux/flashrt_vla_video/__init__.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ctypes
2
+ import importlib.util
3
+ import sys
4
+ from pathlib import Path
5
+ from types import ModuleType
6
+
7
+
8
+ def _import_from_path(file_path: Path) -> ModuleType:
9
+ # We cannot use the module name as-is, after adding it to `sys.modules`,
10
+ # it would also be used for other imports. So, we make a module name that
11
+ # depends on the path for it to be unique using the hex-encoded hash of
12
+ # the path.
13
+ path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
14
+ module_name = path_hash
15
+ spec = importlib.util.spec_from_file_location(module_name, file_path)
16
+ if spec is None:
17
+ raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
18
+ module = importlib.util.module_from_spec(spec)
19
+ if module is None:
20
+ raise ImportError(f"Cannot load module {module_name} from spec")
21
+ sys.modules[module_name] = module
22
+ spec.loader.exec_module(module) # type: ignore
23
+ return module
24
+
25
+
26
+ globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))
build/torch212-cxx11-cu130-x86_64-linux/metadata.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "flashrt-vla-video",
3
+ "id": "_flashrt_vla_video_cuda_c4d802d",
4
+ "version": 1,
5
+ "license": "Apache-2.0",
6
+ "python-depends": [],
7
+ "backend": {
8
+ "type": "cuda",
9
+ "archs": [
10
+ "10.0",
11
+ "11.0",
12
+ "12.0",
13
+ "12.1+PTX",
14
+ "7.5",
15
+ "8.0",
16
+ "8.6",
17
+ "8.7",
18
+ "8.9",
19
+ "9.0"
20
+ ]
21
+ }
22
+ }
build/torch212-cxx11-cu132-x86_64-linux/__init__.py ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """FlashRT VLA, vision, video, and diffusion kernels."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Optional
6
+
7
+ import torch
8
+
9
+ from ._ops import add_op_namespace_prefix, ops
10
+
11
+
12
+ @torch.library.register_fake(add_op_namespace_prefix("q_norm_rope_bf16"))
13
+ def _q_norm_rope_bf16_fake(
14
+ q: torch.Tensor,
15
+ weight: torch.Tensor,
16
+ cos: torch.Tensor,
17
+ sin: torch.Tensor,
18
+ out: torch.Tensor,
19
+ eps: float = 1e-6,
20
+ ) -> None:
21
+ if out.shape != q.shape:
22
+ raise RuntimeError("out shape must match q shape")
23
+ return None
24
+
25
+
26
+ @torch.library.register_fake(add_op_namespace_prefix("k_norm_rope_v_cache_bf16"))
27
+ def _k_norm_rope_v_cache_bf16_fake(
28
+ k: torch.Tensor,
29
+ v: torch.Tensor,
30
+ weight: torch.Tensor,
31
+ cos: torch.Tensor,
32
+ sin: torch.Tensor,
33
+ k_out: torch.Tensor,
34
+ v_out: torch.Tensor,
35
+ eps: float = 1e-6,
36
+ ) -> None:
37
+ if k_out.shape != k.shape or v_out.shape != v.shape:
38
+ raise RuntimeError("k_out and v_out shapes must match k and v")
39
+ return None
40
+
41
+
42
+ @torch.library.register_fake(add_op_namespace_prefix("qkv_split_norm_rope_bf16"))
43
+ def _qkv_split_norm_rope_bf16_fake(
44
+ packed_qkv: torch.Tensor,
45
+ norm_q_weight: torch.Tensor,
46
+ norm_k_weight: torch.Tensor,
47
+ freqs_re: torch.Tensor,
48
+ freqs_im: torch.Tensor,
49
+ q_out: torch.Tensor,
50
+ k_out: torch.Tensor,
51
+ heads: int,
52
+ head_dim: int,
53
+ seq_len: int,
54
+ eps: float = 1e-6,
55
+ ) -> None:
56
+ expected = (packed_qkv.shape[0], packed_qkv.shape[1], heads, head_dim)
57
+ if q_out.shape != expected or k_out.shape != expected:
58
+ raise RuntimeError(
59
+ "q_out and k_out shapes must be (batch, tokens, heads, head_dim)"
60
+ )
61
+ return None
62
+
63
+
64
+ def q_norm_rope_bf16(
65
+ q: torch.Tensor,
66
+ weight: torch.Tensor,
67
+ cos: torch.Tensor,
68
+ sin: torch.Tensor,
69
+ out: Optional[torch.Tensor] = None,
70
+ *,
71
+ eps: float = 1e-6,
72
+ ) -> torch.Tensor:
73
+ """Compute per-row RMSNorm plus rotate-half RoPE for BF16 Q heads.
74
+
75
+ ``q`` must be contiguous BF16 with shape ``(..., 128)``. ``weight`` must
76
+ have shape ``(128,)``. ``cos`` and ``sin`` must have shape ``(64,)`` for
77
+ the current decode position. If ``out`` is omitted, a BF16 tensor with the
78
+ same shape as ``q`` is allocated.
79
+ """
80
+
81
+ if out is None:
82
+ out = torch.empty_like(q)
83
+ ops.q_norm_rope_bf16(q, weight, cos, sin, out, eps)
84
+ return out
85
+
86
+
87
+ def k_norm_rope_v_cache_bf16(
88
+ k: torch.Tensor,
89
+ v: torch.Tensor,
90
+ weight: torch.Tensor,
91
+ cos: torch.Tensor,
92
+ sin: torch.Tensor,
93
+ k_out: Optional[torch.Tensor] = None,
94
+ v_out: Optional[torch.Tensor] = None,
95
+ *,
96
+ eps: float = 1e-6,
97
+ ) -> tuple[torch.Tensor, torch.Tensor]:
98
+ """Compute K RMSNorm plus RoPE and copy V into cache-shaped outputs.
99
+
100
+ ``k`` and ``v`` must be contiguous BF16 tensors with shape ``(..., 128)``.
101
+ ``weight`` must have shape ``(128,)``. ``cos`` and ``sin`` must have shape
102
+ ``(64,)`` for the current decode position. If outputs are omitted, BF16
103
+ tensors with the same shape as ``k`` are allocated.
104
+ """
105
+
106
+ if k_out is None:
107
+ k_out = torch.empty_like(k)
108
+ if v_out is None:
109
+ v_out = torch.empty_like(v)
110
+ ops.k_norm_rope_v_cache_bf16(k, v, weight, cos, sin, k_out, v_out, eps)
111
+ return k_out, v_out
112
+
113
+
114
+ def qkv_split_norm_rope_bf16(
115
+ packed_qkv: torch.Tensor,
116
+ norm_q_weight: torch.Tensor,
117
+ norm_k_weight: torch.Tensor,
118
+ freqs_re: torch.Tensor,
119
+ freqs_im: torch.Tensor,
120
+ *,
121
+ heads: int,
122
+ head_dim: int,
123
+ seq_len: Optional[int] = None,
124
+ q_out: Optional[torch.Tensor] = None,
125
+ k_out: Optional[torch.Tensor] = None,
126
+ eps: float = 1e-6,
127
+ ) -> tuple[torch.Tensor, torch.Tensor]:
128
+ """Split packed QKV, RMS-normalize Q/K, and apply interleaved RoPE.
129
+
130
+ ``packed_qkv`` must be contiguous BF16 with shape
131
+ ``(batch, tokens, 3 * heads * head_dim)``. ``norm_q_weight`` and
132
+ ``norm_k_weight`` must have shape ``(heads * head_dim,)``. ``freqs_re`` and
133
+ ``freqs_im`` must be contiguous FP32 tensors with shape
134
+ ``(seq_len_table, head_dim // 2)``. Outputs have shape
135
+ ``(batch, tokens, heads, head_dim)``.
136
+ """
137
+
138
+ if seq_len is None:
139
+ seq_len = packed_qkv.shape[1]
140
+ if q_out is None:
141
+ q_out = torch.empty(
142
+ (packed_qkv.shape[0], packed_qkv.shape[1], heads, head_dim),
143
+ device=packed_qkv.device,
144
+ dtype=packed_qkv.dtype,
145
+ )
146
+ if k_out is None:
147
+ k_out = torch.empty_like(q_out)
148
+ ops.qkv_split_norm_rope_bf16(
149
+ packed_qkv,
150
+ norm_q_weight,
151
+ norm_k_weight,
152
+ freqs_re,
153
+ freqs_im,
154
+ q_out,
155
+ k_out,
156
+ heads,
157
+ head_dim,
158
+ seq_len,
159
+ eps,
160
+ )
161
+ return q_out, k_out
162
+
163
+
164
+ __all__ = [
165
+ "q_norm_rope_bf16",
166
+ "k_norm_rope_v_cache_bf16",
167
+ "qkv_split_norm_rope_bf16",
168
+ ]
build/torch212-cxx11-cu132-x86_64-linux/_flashrt_vla_video_cuda_c4d802d.abi3.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6f530557368343b1ffb1b5760b2d73521c4964408e1a6e1899bb389784797c1d
3
+ size 431440
build/torch212-cxx11-cu132-x86_64-linux/_ops.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from . import _flashrt_vla_video_cuda_c4d802d
3
+ ops = torch.ops._flashrt_vla_video_cuda_c4d802d
4
+
5
+ def add_op_namespace_prefix(op_name: str):
6
+ """
7
+ Prefix op by namespace.
8
+ """
9
+ return f"_flashrt_vla_video_cuda_c4d802d::{op_name}"
build/torch212-cxx11-cu132-x86_64-linux/flashrt_vla_video/__init__.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ctypes
2
+ import importlib.util
3
+ import sys
4
+ from pathlib import Path
5
+ from types import ModuleType
6
+
7
+
8
+ def _import_from_path(file_path: Path) -> ModuleType:
9
+ # We cannot use the module name as-is, after adding it to `sys.modules`,
10
+ # it would also be used for other imports. So, we make a module name that
11
+ # depends on the path for it to be unique using the hex-encoded hash of
12
+ # the path.
13
+ path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value)
14
+ module_name = path_hash
15
+ spec = importlib.util.spec_from_file_location(module_name, file_path)
16
+ if spec is None:
17
+ raise ImportError(f"Cannot load spec for {module_name} from {file_path}")
18
+ module = importlib.util.module_from_spec(spec)
19
+ if module is None:
20
+ raise ImportError(f"Cannot load module {module_name} from spec")
21
+ sys.modules[module_name] = module
22
+ spec.loader.exec_module(module) # type: ignore
23
+ return module
24
+
25
+
26
+ globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))
build/torch212-cxx11-cu132-x86_64-linux/metadata.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "flashrt-vla-video",
3
+ "id": "_flashrt_vla_video_cuda_c4d802d",
4
+ "version": 1,
5
+ "license": "Apache-2.0",
6
+ "python-depends": [],
7
+ "backend": {
8
+ "type": "cuda",
9
+ "archs": [
10
+ "10.0",
11
+ "11.0",
12
+ "12.0",
13
+ "12.1+PTX",
14
+ "7.5",
15
+ "8.0",
16
+ "8.6",
17
+ "8.7",
18
+ "8.9",
19
+ "9.0"
20
+ ]
21
+ }
22
+ }