liangsu9988 commited on
Commit
c1157ee
·
verified ·
1 Parent(s): 0b20b8e

Promote latest kernel artifacts to main

Browse files
README.md CHANGED
@@ -1,9 +1,62 @@
1
- # flashrt/transformer-fused-ops
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/transformer-fused-ops
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.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # transformer-fused-ops
2
 
3
+ FlashRT native CUDA fused helper kernels for transformer hot paths.
 
4
 
5
+ ## Functions
6
 
7
+ - `rms_norm_gated_silu_bf16`
8
+ - `silu_mul_bf16`
9
+ - `sigmoid_mul_bf16`
10
+ - `embedding_lookup_bf16`
11
+ - `partial_rope_qk_bf16`
12
+ - `argmax_bf16`
13
+ - `spec_accept_greedy_bf16`
14
+ - `nexn2_lin_split_qkv_broadcast_bf16`
15
+ - `nexn2_split_q_gate_bf16`
16
+ - `nexn2_router_topk_bf16`
17
+ - `router_topk_bf16`
18
+ - `moe_weighted_sum_bf16_to_fp32`
19
+ - `relu2_quantize_fp8_static_bf16(input, scale, out=None)`
20
+ - `rms_norm_fp16(x, weight, eps=1e-6, out=None)`
21
+ - `layer_norm_fp16(x, weight, bias, eps=1e-6, out=None)`
22
+ - `layer_norm_quant_fp8_static_fp16(x, weight, bias, scale, eps=1e-6, out=None)`
23
+ - `rope_rotate_half_fp16_(x, cos, sin)`
24
+ - `quantize_fp8_static_fp16(x, scale, out=None)`
25
+ - `quantize_fp8_static_bf16(x, scale, out=None)`
26
+ - `layer_norm_quant_fp8_static_bf16(x, weight, bias, scale, eps=1e-6, out=None)`
27
+ - `gate_geglu_merged_quant_fp8_static_bf16(merged, scale, out=None)`
28
+ - `residual_add_fp16_(residual, x)`
29
+ - `repeat_interleave_heads_fp16(x, repeat, out=None)`
30
+
31
+ These are Tensor APIs meant for static-buffer runtimes and CUDA Graph friendly
32
+ model demos. Unsupported shapes fail explicitly.
33
+
34
+ `relu2_quantize_fp8_static_bf16` fuses ReLU-squared and static-scale FP8 E4M3
35
+ quantization. Pass `out=` for static-buffer and CUDA Graph runtimes.
36
+
37
+ `router_topk_bf16` is the model-neutral alias for the existing deterministic
38
+ router contract. `moe_weighted_sum_bf16_to_fp32` gathers routed expert rows and
39
+ accumulates router-weighted BF16 expert outputs into an FP32 token output.
40
+
41
+ The FP16 vector family is the native GROOT N1.7 Thor hot path. It covers
42
+ ViT/LLM normalization, split-half RoPE, FP8 production, residual update, and
43
+ GQA head expansion. These entries require SM110 and CUDA 13; unsupported
44
+ architectures fail before launch. Static `out=` buffers and the in-place
45
+ entries are suitable for CUDA Graph replay.
46
+
47
+ The additive SM110 BF16 producer family covers PI0.5 prefill and SigLIP hot
48
+ paths. `quantize_fp8_static_bf16` computes
49
+ `clamp(x / scale, -448, 448)` into FP8 E4M3. The LayerNorm entry performs FP32
50
+ statistics, rounds the normalized value to BF16, and emits FP8 without an
51
+ intermediate tensor. The merged GeGLU entry splits `(M,2H)` into gate/up,
52
+ applies the native tanh-GELU approximation, multiplies by up, and emits static
53
+ FP8 `(M,H)`. All three require SM110 and support static `out=` buffers.
54
+
55
+ ## Validation
56
+
57
+ ```bash
58
+ python transformer-fused-ops/tests/test_transformer_fused_ops.py --backend source --mode full
59
+ ```
60
+
61
+ The full SM110 grid includes non-vector-aligned tails and PI0.5/SigLIP shapes,
62
+ plus `torch.compile(fullgraph=True)` and CUDA Graph replay gates.
build/torch211-cxx11-cu128-x86_64-linux/__init__.py CHANGED
@@ -143,18 +143,21 @@ def _relu2_quantize_fp8_static_fake(
143
 
144
 
145
  @torch.library.register_fake(add_op_namespace_prefix("rms_norm_fp16"))
 
146
  def _rms_norm_fp16_fake(x, weight, eps: float, out) -> None:
147
  if x.dim() != 2 or weight.shape != (x.shape[1],) or out.shape != x.shape:
148
  raise RuntimeError("expected x/out (rows,dim), weight (dim,)")
149
 
150
 
151
  @torch.library.register_fake(add_op_namespace_prefix("layer_norm_fp16"))
 
152
  def _layer_norm_fp16_fake(x, weight, bias, eps: float, out) -> None:
153
  if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape or out.shape != x.shape:
154
  raise RuntimeError("expected x/out (rows,dim), weight/bias (dim,)")
155
 
156
 
157
  @torch.library.register_fake(add_op_namespace_prefix("layer_norm_quant_fp8_static_fp16"))
 
158
  def _layer_norm_quant_fp8_static_fp16_fake(x, weight, bias, scale, eps: float, out) -> None:
159
  if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape or out.shape != x.shape:
160
  raise RuntimeError("expected x/out (rows,dim), weight/bias (dim,)")
@@ -163,24 +166,50 @@ def _layer_norm_quant_fp8_static_fp16_fake(x, weight, bias, scale, eps: float, o
163
 
164
 
165
  @torch.library.register_fake(add_op_namespace_prefix("rope_rotate_half_fp16_"))
 
166
  def _rope_rotate_half_fp16_fake(x, cos, sin) -> None:
167
  if x.dim() != 3 or cos.shape != (x.shape[0], x.shape[2]) or sin.shape != cos.shape:
168
  raise RuntimeError("expected x (sequence,heads,head_dim), cos/sin (sequence,head_dim)")
169
 
170
 
171
  @torch.library.register_fake(add_op_namespace_prefix("quantize_fp8_static_fp16"))
 
172
  def _quantize_fp8_static_fp16_fake(x, scale, out) -> None:
173
  if scale.numel() != 1 or out.shape != x.shape:
174
  raise RuntimeError("output must match x and scale must contain one value")
175
 
176
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  @torch.library.register_fake(add_op_namespace_prefix("residual_add_fp16_"))
 
178
  def _residual_add_fp16_fake(residual, x) -> None:
179
  if residual.shape != x.shape:
180
  raise RuntimeError("residual and x must have the same shape")
181
 
182
 
183
  @torch.library.register_fake(add_op_namespace_prefix("repeat_interleave_heads_fp16"))
 
184
  def _repeat_interleave_heads_fp16_fake(x, repeat: int, out) -> None:
185
  if x.dim() != 3 or out.shape != (x.shape[0], x.shape[1] * repeat, x.shape[2]):
186
  raise RuntimeError("output shape must be (sequence, heads * repeat, head_dim)")
@@ -322,6 +351,13 @@ def rms_norm_fp16(x, weight, *, eps: float = 1e-6, out=None):
322
  return out
323
 
324
 
 
 
 
 
 
 
 
325
  def layer_norm_fp16(x, weight, bias, *, eps: float = 1e-6, out=None):
326
  if out is None:
327
  out = torch.empty_like(x)
@@ -329,6 +365,13 @@ def layer_norm_fp16(x, weight, bias, *, eps: float = 1e-6, out=None):
329
  return out
330
 
331
 
 
 
 
 
 
 
 
332
  def layer_norm_quant_fp8_static_fp16(
333
  x, weight, bias, scale, *, eps: float = 1e-6, out=None
334
  ):
@@ -340,11 +383,27 @@ def layer_norm_quant_fp8_static_fp16(
340
  return out
341
 
342
 
 
 
 
 
 
 
 
 
 
 
 
343
  def rope_rotate_half_fp16_(x, cos, sin):
344
  ops.rope_rotate_half_fp16_(x, cos, sin)
345
  return x
346
 
347
 
 
 
 
 
 
348
  def quantize_fp8_static_fp16(x, scale, *, out=None):
349
  if out is None:
350
  out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
@@ -352,11 +411,55 @@ def quantize_fp8_static_fp16(x, scale, *, out=None):
352
  return out
353
 
354
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
355
  def residual_add_fp16_(residual, x):
356
  ops.residual_add_fp16_(residual, x)
357
  return residual
358
 
359
 
 
 
 
 
 
360
  def repeat_interleave_heads_fp16(x, repeat: int, *, out=None):
361
  if out is None:
362
  out = torch.empty(
@@ -368,6 +471,17 @@ def repeat_interleave_heads_fp16(x, repeat: int, *, out=None):
368
  return out
369
 
370
 
 
 
 
 
 
 
 
 
 
 
 
371
  __all__ = [
372
  "argmax_bf16",
373
  "embedding_lookup_bf16",
@@ -383,10 +497,20 @@ __all__ = [
383
  "router_topk_bf16",
384
  "moe_weighted_sum_bf16_to_fp32",
385
  "layer_norm_fp16",
 
 
386
  "layer_norm_quant_fp8_static_fp16",
387
  "quantize_fp8_static_fp16",
 
 
 
 
388
  "repeat_interleave_heads_fp16",
 
389
  "residual_add_fp16_",
 
390
  "rms_norm_fp16",
 
391
  "rope_rotate_half_fp16_",
 
392
  ]
 
143
 
144
 
145
  @torch.library.register_fake(add_op_namespace_prefix("rms_norm_fp16"))
146
+ @torch.library.register_fake(add_op_namespace_prefix("rms_norm_fp16_vec"))
147
  def _rms_norm_fp16_fake(x, weight, eps: float, out) -> None:
148
  if x.dim() != 2 or weight.shape != (x.shape[1],) or out.shape != x.shape:
149
  raise RuntimeError("expected x/out (rows,dim), weight (dim,)")
150
 
151
 
152
  @torch.library.register_fake(add_op_namespace_prefix("layer_norm_fp16"))
153
+ @torch.library.register_fake(add_op_namespace_prefix("layer_norm_fp16_vec"))
154
  def _layer_norm_fp16_fake(x, weight, bias, eps: float, out) -> None:
155
  if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape or out.shape != x.shape:
156
  raise RuntimeError("expected x/out (rows,dim), weight/bias (dim,)")
157
 
158
 
159
  @torch.library.register_fake(add_op_namespace_prefix("layer_norm_quant_fp8_static_fp16"))
160
+ @torch.library.register_fake(add_op_namespace_prefix("layer_norm_fp8_static_fp16_vec"))
161
  def _layer_norm_quant_fp8_static_fp16_fake(x, weight, bias, scale, eps: float, out) -> None:
162
  if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape or out.shape != x.shape:
163
  raise RuntimeError("expected x/out (rows,dim), weight/bias (dim,)")
 
166
 
167
 
168
  @torch.library.register_fake(add_op_namespace_prefix("rope_rotate_half_fp16_"))
169
+ @torch.library.register_fake(add_op_namespace_prefix("rope_rotate_half_fp16_vec"))
170
  def _rope_rotate_half_fp16_fake(x, cos, sin) -> None:
171
  if x.dim() != 3 or cos.shape != (x.shape[0], x.shape[2]) or sin.shape != cos.shape:
172
  raise RuntimeError("expected x (sequence,heads,head_dim), cos/sin (sequence,head_dim)")
173
 
174
 
175
  @torch.library.register_fake(add_op_namespace_prefix("quantize_fp8_static_fp16"))
176
+ @torch.library.register_fake(add_op_namespace_prefix("quantize_fp8_static_fp16_vec"))
177
  def _quantize_fp8_static_fp16_fake(x, scale, out) -> None:
178
  if scale.numel() != 1 or out.shape != x.shape:
179
  raise RuntimeError("output must match x and scale must contain one value")
180
 
181
 
182
+ @torch.library.register_fake(add_op_namespace_prefix("quantize_fp8_static_bf16"))
183
+ def _quantize_fp8_static_bf16_fake(x, scale, out) -> None:
184
+ if scale.numel() != 1 or out.shape != x.shape:
185
+ raise RuntimeError("output must match x and scale must contain one value")
186
+
187
+
188
+ @torch.library.register_fake(add_op_namespace_prefix("layer_norm_quant_fp8_static_bf16"))
189
+ def _layer_norm_quant_fp8_static_bf16_fake(x, weight, bias, scale, eps: float, out) -> None:
190
+ if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape:
191
+ raise RuntimeError("expected x (rows,dim), weight/bias (dim,)")
192
+ if scale.numel() != 1 or out.shape != x.shape:
193
+ raise RuntimeError("output must match x and scale must contain one value")
194
+
195
+
196
+ @torch.library.register_fake(add_op_namespace_prefix("gate_geglu_merged_quant_fp8_static_bf16"))
197
+ def _gate_geglu_merged_quant_fp8_static_bf16_fake(merged, scale, out) -> None:
198
+ if merged.dim() != 2 or merged.shape[1] % 2:
199
+ raise RuntimeError("merged must have shape (rows, 2 * hidden)")
200
+ if scale.numel() != 1 or out.shape != (merged.shape[0], merged.shape[1] // 2):
201
+ raise RuntimeError("output must have shape (rows, hidden) and scale must be scalar")
202
+
203
+
204
  @torch.library.register_fake(add_op_namespace_prefix("residual_add_fp16_"))
205
+ @torch.library.register_fake(add_op_namespace_prefix("residual_add_fp16_vec"))
206
  def _residual_add_fp16_fake(residual, x) -> None:
207
  if residual.shape != x.shape:
208
  raise RuntimeError("residual and x must have the same shape")
209
 
210
 
211
  @torch.library.register_fake(add_op_namespace_prefix("repeat_interleave_heads_fp16"))
212
+ @torch.library.register_fake(add_op_namespace_prefix("gpu_repeat_interleave_heads_vec"))
213
  def _repeat_interleave_heads_fp16_fake(x, repeat: int, out) -> None:
214
  if x.dim() != 3 or out.shape != (x.shape[0], x.shape[1] * repeat, x.shape[2]):
215
  raise RuntimeError("output shape must be (sequence, heads * repeat, head_dim)")
 
351
  return out
352
 
353
 
354
+ def rms_norm_fp16_vec(x, weight, *, eps: float = 1e-6, out=None):
355
+ if out is None:
356
+ out = torch.empty_like(x)
357
+ ops.rms_norm_fp16_vec(x, weight, float(eps), out)
358
+ return out
359
+
360
+
361
  def layer_norm_fp16(x, weight, bias, *, eps: float = 1e-6, out=None):
362
  if out is None:
363
  out = torch.empty_like(x)
 
365
  return out
366
 
367
 
368
+ def layer_norm_fp16_vec(x, weight, bias, *, eps: float = 1e-6, out=None):
369
+ if out is None:
370
+ out = torch.empty_like(x)
371
+ ops.layer_norm_fp16_vec(x, weight, bias, float(eps), out)
372
+ return out
373
+
374
+
375
  def layer_norm_quant_fp8_static_fp16(
376
  x, weight, bias, scale, *, eps: float = 1e-6, out=None
377
  ):
 
383
  return out
384
 
385
 
386
+ def layer_norm_fp8_static_fp16_vec(
387
+ x, weight, bias, scale, *, eps: float = 1e-6, out=None
388
+ ):
389
+ if out is None:
390
+ out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
391
+ ops.layer_norm_fp8_static_fp16_vec(
392
+ x, weight, bias, scale, float(eps), out
393
+ )
394
+ return out
395
+
396
+
397
  def rope_rotate_half_fp16_(x, cos, sin):
398
  ops.rope_rotate_half_fp16_(x, cos, sin)
399
  return x
400
 
401
 
402
+ def rope_rotate_half_fp16_vec(x, cos, sin):
403
+ ops.rope_rotate_half_fp16_vec(x, cos, sin)
404
+ return x
405
+
406
+
407
  def quantize_fp8_static_fp16(x, scale, *, out=None):
408
  if out is None:
409
  out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
 
411
  return out
412
 
413
 
414
+ def quantize_fp8_static_fp16_vec(x, scale, *, out=None):
415
+ if out is None:
416
+ out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
417
+ ops.quantize_fp8_static_fp16_vec(x, scale, out)
418
+ return out
419
+
420
+
421
+ def quantize_fp8_static_bf16(x, scale, *, out=None):
422
+ """Quantize contiguous BF16 input with a static FP32 scale."""
423
+ if out is None:
424
+ out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
425
+ ops.quantize_fp8_static_bf16(x, scale, out)
426
+ return out
427
+
428
+
429
+ def layer_norm_quant_fp8_static_bf16(
430
+ x, weight, bias, scale, *, eps: float = 1e-6, out=None
431
+ ):
432
+ """LayerNorm BF16 input and emit static-scale FP8 without an intermediate."""
433
+ if out is None:
434
+ out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
435
+ ops.layer_norm_quant_fp8_static_bf16(
436
+ x, weight, bias, scale, float(eps), out
437
+ )
438
+ return out
439
+
440
+
441
+ def gate_geglu_merged_quant_fp8_static_bf16(merged, scale, *, out=None):
442
+ """Apply tanh-approximate GeGLU to merged BF16 gate/up and emit FP8."""
443
+ if out is None:
444
+ out = torch.empty(
445
+ (merged.shape[0], merged.shape[1] // 2),
446
+ device=merged.device,
447
+ dtype=torch.float8_e4m3fn,
448
+ )
449
+ ops.gate_geglu_merged_quant_fp8_static_bf16(merged, scale, out)
450
+ return out
451
+
452
+
453
  def residual_add_fp16_(residual, x):
454
  ops.residual_add_fp16_(residual, x)
455
  return residual
456
 
457
 
458
+ def residual_add_fp16_vec(residual, x):
459
+ ops.residual_add_fp16_vec(residual, x)
460
+ return residual
461
+
462
+
463
  def repeat_interleave_heads_fp16(x, repeat: int, *, out=None):
464
  if out is None:
465
  out = torch.empty(
 
471
  return out
472
 
473
 
474
+ def gpu_repeat_interleave_heads_vec(x, repeat: int, *, out=None):
475
+ if out is None:
476
+ out = torch.empty(
477
+ (x.shape[0], x.shape[1] * repeat, x.shape[2]),
478
+ device=x.device,
479
+ dtype=x.dtype,
480
+ )
481
+ ops.gpu_repeat_interleave_heads_vec(x, int(repeat), out)
482
+ return out
483
+
484
+
485
  __all__ = [
486
  "argmax_bf16",
487
  "embedding_lookup_bf16",
 
497
  "router_topk_bf16",
498
  "moe_weighted_sum_bf16_to_fp32",
499
  "layer_norm_fp16",
500
+ "layer_norm_fp16_vec",
501
+ "layer_norm_fp8_static_fp16_vec",
502
  "layer_norm_quant_fp8_static_fp16",
503
  "quantize_fp8_static_fp16",
504
+ "quantize_fp8_static_fp16_vec",
505
+ "quantize_fp8_static_bf16",
506
+ "layer_norm_quant_fp8_static_bf16",
507
+ "gate_geglu_merged_quant_fp8_static_bf16",
508
  "repeat_interleave_heads_fp16",
509
+ "gpu_repeat_interleave_heads_vec",
510
  "residual_add_fp16_",
511
+ "residual_add_fp16_vec",
512
  "rms_norm_fp16",
513
+ "rms_norm_fp16_vec",
514
  "rope_rotate_half_fp16_",
515
+ "rope_rotate_half_fp16_vec",
516
  ]
build/torch211-cxx11-cu128-x86_64-linux/_ops.py CHANGED
@@ -1,9 +1,9 @@
1
  import torch
2
- from . import _transformer_fused_ops_cuda_8a66d8b
3
- ops = torch.ops._transformer_fused_ops_cuda_8a66d8b
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
- return f"_transformer_fused_ops_cuda_8a66d8b::{op_name}"
 
1
  import torch
2
+ from . import _transformer_fused_ops_cuda_6ab0803
3
+ ops = torch.ops._transformer_fused_ops_cuda_6ab0803
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
+ return f"_transformer_fused_ops_cuda_6ab0803::{op_name}"
build/torch211-cxx11-cu128-x86_64-linux/{_transformer_fused_ops_cuda_8a66d8b.abi3.so → _transformer_fused_ops_cuda_6ab0803.abi3.so} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:0a57fd82524162fdc6ba902b3c66a23fc781b94abd8d7908dcbc6ca1bb76d57d
3
- size 1334184
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:03e9157b8c1f8cdd1d3df022da2c813f03e1846393fb4a80395cd0dea041952e
3
+ size 1344152
build/torch211-cxx11-cu128-x86_64-linux/metadata.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "transformer-fused-ops",
3
- "id": "_transformer_fused_ops_cuda_8a66d8b",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],
 
1
  {
2
  "name": "transformer-fused-ops",
3
+ "id": "_transformer_fused_ops_cuda_6ab0803",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],
build/torch211-cxx11-cu130-x86_64-linux/__init__.py CHANGED
@@ -143,18 +143,21 @@ def _relu2_quantize_fp8_static_fake(
143
 
144
 
145
  @torch.library.register_fake(add_op_namespace_prefix("rms_norm_fp16"))
 
146
  def _rms_norm_fp16_fake(x, weight, eps: float, out) -> None:
147
  if x.dim() != 2 or weight.shape != (x.shape[1],) or out.shape != x.shape:
148
  raise RuntimeError("expected x/out (rows,dim), weight (dim,)")
149
 
150
 
151
  @torch.library.register_fake(add_op_namespace_prefix("layer_norm_fp16"))
 
152
  def _layer_norm_fp16_fake(x, weight, bias, eps: float, out) -> None:
153
  if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape or out.shape != x.shape:
154
  raise RuntimeError("expected x/out (rows,dim), weight/bias (dim,)")
155
 
156
 
157
  @torch.library.register_fake(add_op_namespace_prefix("layer_norm_quant_fp8_static_fp16"))
 
158
  def _layer_norm_quant_fp8_static_fp16_fake(x, weight, bias, scale, eps: float, out) -> None:
159
  if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape or out.shape != x.shape:
160
  raise RuntimeError("expected x/out (rows,dim), weight/bias (dim,)")
@@ -163,24 +166,50 @@ def _layer_norm_quant_fp8_static_fp16_fake(x, weight, bias, scale, eps: float, o
163
 
164
 
165
  @torch.library.register_fake(add_op_namespace_prefix("rope_rotate_half_fp16_"))
 
166
  def _rope_rotate_half_fp16_fake(x, cos, sin) -> None:
167
  if x.dim() != 3 or cos.shape != (x.shape[0], x.shape[2]) or sin.shape != cos.shape:
168
  raise RuntimeError("expected x (sequence,heads,head_dim), cos/sin (sequence,head_dim)")
169
 
170
 
171
  @torch.library.register_fake(add_op_namespace_prefix("quantize_fp8_static_fp16"))
 
172
  def _quantize_fp8_static_fp16_fake(x, scale, out) -> None:
173
  if scale.numel() != 1 or out.shape != x.shape:
174
  raise RuntimeError("output must match x and scale must contain one value")
175
 
176
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  @torch.library.register_fake(add_op_namespace_prefix("residual_add_fp16_"))
 
178
  def _residual_add_fp16_fake(residual, x) -> None:
179
  if residual.shape != x.shape:
180
  raise RuntimeError("residual and x must have the same shape")
181
 
182
 
183
  @torch.library.register_fake(add_op_namespace_prefix("repeat_interleave_heads_fp16"))
 
184
  def _repeat_interleave_heads_fp16_fake(x, repeat: int, out) -> None:
185
  if x.dim() != 3 or out.shape != (x.shape[0], x.shape[1] * repeat, x.shape[2]):
186
  raise RuntimeError("output shape must be (sequence, heads * repeat, head_dim)")
@@ -322,6 +351,13 @@ def rms_norm_fp16(x, weight, *, eps: float = 1e-6, out=None):
322
  return out
323
 
324
 
 
 
 
 
 
 
 
325
  def layer_norm_fp16(x, weight, bias, *, eps: float = 1e-6, out=None):
326
  if out is None:
327
  out = torch.empty_like(x)
@@ -329,6 +365,13 @@ def layer_norm_fp16(x, weight, bias, *, eps: float = 1e-6, out=None):
329
  return out
330
 
331
 
 
 
 
 
 
 
 
332
  def layer_norm_quant_fp8_static_fp16(
333
  x, weight, bias, scale, *, eps: float = 1e-6, out=None
334
  ):
@@ -340,11 +383,27 @@ def layer_norm_quant_fp8_static_fp16(
340
  return out
341
 
342
 
 
 
 
 
 
 
 
 
 
 
 
343
  def rope_rotate_half_fp16_(x, cos, sin):
344
  ops.rope_rotate_half_fp16_(x, cos, sin)
345
  return x
346
 
347
 
 
 
 
 
 
348
  def quantize_fp8_static_fp16(x, scale, *, out=None):
349
  if out is None:
350
  out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
@@ -352,11 +411,55 @@ def quantize_fp8_static_fp16(x, scale, *, out=None):
352
  return out
353
 
354
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
355
  def residual_add_fp16_(residual, x):
356
  ops.residual_add_fp16_(residual, x)
357
  return residual
358
 
359
 
 
 
 
 
 
360
  def repeat_interleave_heads_fp16(x, repeat: int, *, out=None):
361
  if out is None:
362
  out = torch.empty(
@@ -368,6 +471,17 @@ def repeat_interleave_heads_fp16(x, repeat: int, *, out=None):
368
  return out
369
 
370
 
 
 
 
 
 
 
 
 
 
 
 
371
  __all__ = [
372
  "argmax_bf16",
373
  "embedding_lookup_bf16",
@@ -383,10 +497,20 @@ __all__ = [
383
  "router_topk_bf16",
384
  "moe_weighted_sum_bf16_to_fp32",
385
  "layer_norm_fp16",
 
 
386
  "layer_norm_quant_fp8_static_fp16",
387
  "quantize_fp8_static_fp16",
 
 
 
 
388
  "repeat_interleave_heads_fp16",
 
389
  "residual_add_fp16_",
 
390
  "rms_norm_fp16",
 
391
  "rope_rotate_half_fp16_",
 
392
  ]
 
143
 
144
 
145
  @torch.library.register_fake(add_op_namespace_prefix("rms_norm_fp16"))
146
+ @torch.library.register_fake(add_op_namespace_prefix("rms_norm_fp16_vec"))
147
  def _rms_norm_fp16_fake(x, weight, eps: float, out) -> None:
148
  if x.dim() != 2 or weight.shape != (x.shape[1],) or out.shape != x.shape:
149
  raise RuntimeError("expected x/out (rows,dim), weight (dim,)")
150
 
151
 
152
  @torch.library.register_fake(add_op_namespace_prefix("layer_norm_fp16"))
153
+ @torch.library.register_fake(add_op_namespace_prefix("layer_norm_fp16_vec"))
154
  def _layer_norm_fp16_fake(x, weight, bias, eps: float, out) -> None:
155
  if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape or out.shape != x.shape:
156
  raise RuntimeError("expected x/out (rows,dim), weight/bias (dim,)")
157
 
158
 
159
  @torch.library.register_fake(add_op_namespace_prefix("layer_norm_quant_fp8_static_fp16"))
160
+ @torch.library.register_fake(add_op_namespace_prefix("layer_norm_fp8_static_fp16_vec"))
161
  def _layer_norm_quant_fp8_static_fp16_fake(x, weight, bias, scale, eps: float, out) -> None:
162
  if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape or out.shape != x.shape:
163
  raise RuntimeError("expected x/out (rows,dim), weight/bias (dim,)")
 
166
 
167
 
168
  @torch.library.register_fake(add_op_namespace_prefix("rope_rotate_half_fp16_"))
169
+ @torch.library.register_fake(add_op_namespace_prefix("rope_rotate_half_fp16_vec"))
170
  def _rope_rotate_half_fp16_fake(x, cos, sin) -> None:
171
  if x.dim() != 3 or cos.shape != (x.shape[0], x.shape[2]) or sin.shape != cos.shape:
172
  raise RuntimeError("expected x (sequence,heads,head_dim), cos/sin (sequence,head_dim)")
173
 
174
 
175
  @torch.library.register_fake(add_op_namespace_prefix("quantize_fp8_static_fp16"))
176
+ @torch.library.register_fake(add_op_namespace_prefix("quantize_fp8_static_fp16_vec"))
177
  def _quantize_fp8_static_fp16_fake(x, scale, out) -> None:
178
  if scale.numel() != 1 or out.shape != x.shape:
179
  raise RuntimeError("output must match x and scale must contain one value")
180
 
181
 
182
+ @torch.library.register_fake(add_op_namespace_prefix("quantize_fp8_static_bf16"))
183
+ def _quantize_fp8_static_bf16_fake(x, scale, out) -> None:
184
+ if scale.numel() != 1 or out.shape != x.shape:
185
+ raise RuntimeError("output must match x and scale must contain one value")
186
+
187
+
188
+ @torch.library.register_fake(add_op_namespace_prefix("layer_norm_quant_fp8_static_bf16"))
189
+ def _layer_norm_quant_fp8_static_bf16_fake(x, weight, bias, scale, eps: float, out) -> None:
190
+ if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape:
191
+ raise RuntimeError("expected x (rows,dim), weight/bias (dim,)")
192
+ if scale.numel() != 1 or out.shape != x.shape:
193
+ raise RuntimeError("output must match x and scale must contain one value")
194
+
195
+
196
+ @torch.library.register_fake(add_op_namespace_prefix("gate_geglu_merged_quant_fp8_static_bf16"))
197
+ def _gate_geglu_merged_quant_fp8_static_bf16_fake(merged, scale, out) -> None:
198
+ if merged.dim() != 2 or merged.shape[1] % 2:
199
+ raise RuntimeError("merged must have shape (rows, 2 * hidden)")
200
+ if scale.numel() != 1 or out.shape != (merged.shape[0], merged.shape[1] // 2):
201
+ raise RuntimeError("output must have shape (rows, hidden) and scale must be scalar")
202
+
203
+
204
  @torch.library.register_fake(add_op_namespace_prefix("residual_add_fp16_"))
205
+ @torch.library.register_fake(add_op_namespace_prefix("residual_add_fp16_vec"))
206
  def _residual_add_fp16_fake(residual, x) -> None:
207
  if residual.shape != x.shape:
208
  raise RuntimeError("residual and x must have the same shape")
209
 
210
 
211
  @torch.library.register_fake(add_op_namespace_prefix("repeat_interleave_heads_fp16"))
212
+ @torch.library.register_fake(add_op_namespace_prefix("gpu_repeat_interleave_heads_vec"))
213
  def _repeat_interleave_heads_fp16_fake(x, repeat: int, out) -> None:
214
  if x.dim() != 3 or out.shape != (x.shape[0], x.shape[1] * repeat, x.shape[2]):
215
  raise RuntimeError("output shape must be (sequence, heads * repeat, head_dim)")
 
351
  return out
352
 
353
 
354
+ def rms_norm_fp16_vec(x, weight, *, eps: float = 1e-6, out=None):
355
+ if out is None:
356
+ out = torch.empty_like(x)
357
+ ops.rms_norm_fp16_vec(x, weight, float(eps), out)
358
+ return out
359
+
360
+
361
  def layer_norm_fp16(x, weight, bias, *, eps: float = 1e-6, out=None):
362
  if out is None:
363
  out = torch.empty_like(x)
 
365
  return out
366
 
367
 
368
+ def layer_norm_fp16_vec(x, weight, bias, *, eps: float = 1e-6, out=None):
369
+ if out is None:
370
+ out = torch.empty_like(x)
371
+ ops.layer_norm_fp16_vec(x, weight, bias, float(eps), out)
372
+ return out
373
+
374
+
375
  def layer_norm_quant_fp8_static_fp16(
376
  x, weight, bias, scale, *, eps: float = 1e-6, out=None
377
  ):
 
383
  return out
384
 
385
 
386
+ def layer_norm_fp8_static_fp16_vec(
387
+ x, weight, bias, scale, *, eps: float = 1e-6, out=None
388
+ ):
389
+ if out is None:
390
+ out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
391
+ ops.layer_norm_fp8_static_fp16_vec(
392
+ x, weight, bias, scale, float(eps), out
393
+ )
394
+ return out
395
+
396
+
397
  def rope_rotate_half_fp16_(x, cos, sin):
398
  ops.rope_rotate_half_fp16_(x, cos, sin)
399
  return x
400
 
401
 
402
+ def rope_rotate_half_fp16_vec(x, cos, sin):
403
+ ops.rope_rotate_half_fp16_vec(x, cos, sin)
404
+ return x
405
+
406
+
407
  def quantize_fp8_static_fp16(x, scale, *, out=None):
408
  if out is None:
409
  out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
 
411
  return out
412
 
413
 
414
+ def quantize_fp8_static_fp16_vec(x, scale, *, out=None):
415
+ if out is None:
416
+ out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
417
+ ops.quantize_fp8_static_fp16_vec(x, scale, out)
418
+ return out
419
+
420
+
421
+ def quantize_fp8_static_bf16(x, scale, *, out=None):
422
+ """Quantize contiguous BF16 input with a static FP32 scale."""
423
+ if out is None:
424
+ out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
425
+ ops.quantize_fp8_static_bf16(x, scale, out)
426
+ return out
427
+
428
+
429
+ def layer_norm_quant_fp8_static_bf16(
430
+ x, weight, bias, scale, *, eps: float = 1e-6, out=None
431
+ ):
432
+ """LayerNorm BF16 input and emit static-scale FP8 without an intermediate."""
433
+ if out is None:
434
+ out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
435
+ ops.layer_norm_quant_fp8_static_bf16(
436
+ x, weight, bias, scale, float(eps), out
437
+ )
438
+ return out
439
+
440
+
441
+ def gate_geglu_merged_quant_fp8_static_bf16(merged, scale, *, out=None):
442
+ """Apply tanh-approximate GeGLU to merged BF16 gate/up and emit FP8."""
443
+ if out is None:
444
+ out = torch.empty(
445
+ (merged.shape[0], merged.shape[1] // 2),
446
+ device=merged.device,
447
+ dtype=torch.float8_e4m3fn,
448
+ )
449
+ ops.gate_geglu_merged_quant_fp8_static_bf16(merged, scale, out)
450
+ return out
451
+
452
+
453
  def residual_add_fp16_(residual, x):
454
  ops.residual_add_fp16_(residual, x)
455
  return residual
456
 
457
 
458
+ def residual_add_fp16_vec(residual, x):
459
+ ops.residual_add_fp16_vec(residual, x)
460
+ return residual
461
+
462
+
463
  def repeat_interleave_heads_fp16(x, repeat: int, *, out=None):
464
  if out is None:
465
  out = torch.empty(
 
471
  return out
472
 
473
 
474
+ def gpu_repeat_interleave_heads_vec(x, repeat: int, *, out=None):
475
+ if out is None:
476
+ out = torch.empty(
477
+ (x.shape[0], x.shape[1] * repeat, x.shape[2]),
478
+ device=x.device,
479
+ dtype=x.dtype,
480
+ )
481
+ ops.gpu_repeat_interleave_heads_vec(x, int(repeat), out)
482
+ return out
483
+
484
+
485
  __all__ = [
486
  "argmax_bf16",
487
  "embedding_lookup_bf16",
 
497
  "router_topk_bf16",
498
  "moe_weighted_sum_bf16_to_fp32",
499
  "layer_norm_fp16",
500
+ "layer_norm_fp16_vec",
501
+ "layer_norm_fp8_static_fp16_vec",
502
  "layer_norm_quant_fp8_static_fp16",
503
  "quantize_fp8_static_fp16",
504
+ "quantize_fp8_static_fp16_vec",
505
+ "quantize_fp8_static_bf16",
506
+ "layer_norm_quant_fp8_static_bf16",
507
+ "gate_geglu_merged_quant_fp8_static_bf16",
508
  "repeat_interleave_heads_fp16",
509
+ "gpu_repeat_interleave_heads_vec",
510
  "residual_add_fp16_",
511
+ "residual_add_fp16_vec",
512
  "rms_norm_fp16",
513
+ "rms_norm_fp16_vec",
514
  "rope_rotate_half_fp16_",
515
+ "rope_rotate_half_fp16_vec",
516
  ]
build/torch211-cxx11-cu130-x86_64-linux/_ops.py CHANGED
@@ -1,9 +1,9 @@
1
  import torch
2
- from . import _transformer_fused_ops_cuda_8a66d8b
3
- ops = torch.ops._transformer_fused_ops_cuda_8a66d8b
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
- return f"_transformer_fused_ops_cuda_8a66d8b::{op_name}"
 
1
  import torch
2
+ from . import _transformer_fused_ops_cuda_6ab0803
3
+ ops = torch.ops._transformer_fused_ops_cuda_6ab0803
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
+ return f"_transformer_fused_ops_cuda_6ab0803::{op_name}"
build/torch211-cxx11-cu130-x86_64-linux/{_transformer_fused_ops_cuda_8a66d8b.abi3.so → _transformer_fused_ops_cuda_6ab0803.abi3.so} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:cc056c44ce9eac90550ce8a453a48fb7c2fa4d415a6d9fded9781af19ba3831e
3
- size 1457632
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:849e913f333d358de0aaf889e745c66909a2821a959872c3c1d3d76de1b969af
3
+ size 1533912
build/torch211-cxx11-cu130-x86_64-linux/metadata.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "transformer-fused-ops",
3
- "id": "_transformer_fused_ops_cuda_8a66d8b",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],
 
1
  {
2
  "name": "transformer-fused-ops",
3
+ "id": "_transformer_fused_ops_cuda_6ab0803",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],
build/torch212-cxx11-cu130-x86_64-linux/__init__.py CHANGED
@@ -143,18 +143,21 @@ def _relu2_quantize_fp8_static_fake(
143
 
144
 
145
  @torch.library.register_fake(add_op_namespace_prefix("rms_norm_fp16"))
 
146
  def _rms_norm_fp16_fake(x, weight, eps: float, out) -> None:
147
  if x.dim() != 2 or weight.shape != (x.shape[1],) or out.shape != x.shape:
148
  raise RuntimeError("expected x/out (rows,dim), weight (dim,)")
149
 
150
 
151
  @torch.library.register_fake(add_op_namespace_prefix("layer_norm_fp16"))
 
152
  def _layer_norm_fp16_fake(x, weight, bias, eps: float, out) -> None:
153
  if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape or out.shape != x.shape:
154
  raise RuntimeError("expected x/out (rows,dim), weight/bias (dim,)")
155
 
156
 
157
  @torch.library.register_fake(add_op_namespace_prefix("layer_norm_quant_fp8_static_fp16"))
 
158
  def _layer_norm_quant_fp8_static_fp16_fake(x, weight, bias, scale, eps: float, out) -> None:
159
  if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape or out.shape != x.shape:
160
  raise RuntimeError("expected x/out (rows,dim), weight/bias (dim,)")
@@ -163,24 +166,50 @@ def _layer_norm_quant_fp8_static_fp16_fake(x, weight, bias, scale, eps: float, o
163
 
164
 
165
  @torch.library.register_fake(add_op_namespace_prefix("rope_rotate_half_fp16_"))
 
166
  def _rope_rotate_half_fp16_fake(x, cos, sin) -> None:
167
  if x.dim() != 3 or cos.shape != (x.shape[0], x.shape[2]) or sin.shape != cos.shape:
168
  raise RuntimeError("expected x (sequence,heads,head_dim), cos/sin (sequence,head_dim)")
169
 
170
 
171
  @torch.library.register_fake(add_op_namespace_prefix("quantize_fp8_static_fp16"))
 
172
  def _quantize_fp8_static_fp16_fake(x, scale, out) -> None:
173
  if scale.numel() != 1 or out.shape != x.shape:
174
  raise RuntimeError("output must match x and scale must contain one value")
175
 
176
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  @torch.library.register_fake(add_op_namespace_prefix("residual_add_fp16_"))
 
178
  def _residual_add_fp16_fake(residual, x) -> None:
179
  if residual.shape != x.shape:
180
  raise RuntimeError("residual and x must have the same shape")
181
 
182
 
183
  @torch.library.register_fake(add_op_namespace_prefix("repeat_interleave_heads_fp16"))
 
184
  def _repeat_interleave_heads_fp16_fake(x, repeat: int, out) -> None:
185
  if x.dim() != 3 or out.shape != (x.shape[0], x.shape[1] * repeat, x.shape[2]):
186
  raise RuntimeError("output shape must be (sequence, heads * repeat, head_dim)")
@@ -322,6 +351,13 @@ def rms_norm_fp16(x, weight, *, eps: float = 1e-6, out=None):
322
  return out
323
 
324
 
 
 
 
 
 
 
 
325
  def layer_norm_fp16(x, weight, bias, *, eps: float = 1e-6, out=None):
326
  if out is None:
327
  out = torch.empty_like(x)
@@ -329,6 +365,13 @@ def layer_norm_fp16(x, weight, bias, *, eps: float = 1e-6, out=None):
329
  return out
330
 
331
 
 
 
 
 
 
 
 
332
  def layer_norm_quant_fp8_static_fp16(
333
  x, weight, bias, scale, *, eps: float = 1e-6, out=None
334
  ):
@@ -340,11 +383,27 @@ def layer_norm_quant_fp8_static_fp16(
340
  return out
341
 
342
 
 
 
 
 
 
 
 
 
 
 
 
343
  def rope_rotate_half_fp16_(x, cos, sin):
344
  ops.rope_rotate_half_fp16_(x, cos, sin)
345
  return x
346
 
347
 
 
 
 
 
 
348
  def quantize_fp8_static_fp16(x, scale, *, out=None):
349
  if out is None:
350
  out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
@@ -352,11 +411,55 @@ def quantize_fp8_static_fp16(x, scale, *, out=None):
352
  return out
353
 
354
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
355
  def residual_add_fp16_(residual, x):
356
  ops.residual_add_fp16_(residual, x)
357
  return residual
358
 
359
 
 
 
 
 
 
360
  def repeat_interleave_heads_fp16(x, repeat: int, *, out=None):
361
  if out is None:
362
  out = torch.empty(
@@ -368,6 +471,17 @@ def repeat_interleave_heads_fp16(x, repeat: int, *, out=None):
368
  return out
369
 
370
 
 
 
 
 
 
 
 
 
 
 
 
371
  __all__ = [
372
  "argmax_bf16",
373
  "embedding_lookup_bf16",
@@ -383,10 +497,20 @@ __all__ = [
383
  "router_topk_bf16",
384
  "moe_weighted_sum_bf16_to_fp32",
385
  "layer_norm_fp16",
 
 
386
  "layer_norm_quant_fp8_static_fp16",
387
  "quantize_fp8_static_fp16",
 
 
 
 
388
  "repeat_interleave_heads_fp16",
 
389
  "residual_add_fp16_",
 
390
  "rms_norm_fp16",
 
391
  "rope_rotate_half_fp16_",
 
392
  ]
 
143
 
144
 
145
  @torch.library.register_fake(add_op_namespace_prefix("rms_norm_fp16"))
146
+ @torch.library.register_fake(add_op_namespace_prefix("rms_norm_fp16_vec"))
147
  def _rms_norm_fp16_fake(x, weight, eps: float, out) -> None:
148
  if x.dim() != 2 or weight.shape != (x.shape[1],) or out.shape != x.shape:
149
  raise RuntimeError("expected x/out (rows,dim), weight (dim,)")
150
 
151
 
152
  @torch.library.register_fake(add_op_namespace_prefix("layer_norm_fp16"))
153
+ @torch.library.register_fake(add_op_namespace_prefix("layer_norm_fp16_vec"))
154
  def _layer_norm_fp16_fake(x, weight, bias, eps: float, out) -> None:
155
  if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape or out.shape != x.shape:
156
  raise RuntimeError("expected x/out (rows,dim), weight/bias (dim,)")
157
 
158
 
159
  @torch.library.register_fake(add_op_namespace_prefix("layer_norm_quant_fp8_static_fp16"))
160
+ @torch.library.register_fake(add_op_namespace_prefix("layer_norm_fp8_static_fp16_vec"))
161
  def _layer_norm_quant_fp8_static_fp16_fake(x, weight, bias, scale, eps: float, out) -> None:
162
  if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape or out.shape != x.shape:
163
  raise RuntimeError("expected x/out (rows,dim), weight/bias (dim,)")
 
166
 
167
 
168
  @torch.library.register_fake(add_op_namespace_prefix("rope_rotate_half_fp16_"))
169
+ @torch.library.register_fake(add_op_namespace_prefix("rope_rotate_half_fp16_vec"))
170
  def _rope_rotate_half_fp16_fake(x, cos, sin) -> None:
171
  if x.dim() != 3 or cos.shape != (x.shape[0], x.shape[2]) or sin.shape != cos.shape:
172
  raise RuntimeError("expected x (sequence,heads,head_dim), cos/sin (sequence,head_dim)")
173
 
174
 
175
  @torch.library.register_fake(add_op_namespace_prefix("quantize_fp8_static_fp16"))
176
+ @torch.library.register_fake(add_op_namespace_prefix("quantize_fp8_static_fp16_vec"))
177
  def _quantize_fp8_static_fp16_fake(x, scale, out) -> None:
178
  if scale.numel() != 1 or out.shape != x.shape:
179
  raise RuntimeError("output must match x and scale must contain one value")
180
 
181
 
182
+ @torch.library.register_fake(add_op_namespace_prefix("quantize_fp8_static_bf16"))
183
+ def _quantize_fp8_static_bf16_fake(x, scale, out) -> None:
184
+ if scale.numel() != 1 or out.shape != x.shape:
185
+ raise RuntimeError("output must match x and scale must contain one value")
186
+
187
+
188
+ @torch.library.register_fake(add_op_namespace_prefix("layer_norm_quant_fp8_static_bf16"))
189
+ def _layer_norm_quant_fp8_static_bf16_fake(x, weight, bias, scale, eps: float, out) -> None:
190
+ if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape:
191
+ raise RuntimeError("expected x (rows,dim), weight/bias (dim,)")
192
+ if scale.numel() != 1 or out.shape != x.shape:
193
+ raise RuntimeError("output must match x and scale must contain one value")
194
+
195
+
196
+ @torch.library.register_fake(add_op_namespace_prefix("gate_geglu_merged_quant_fp8_static_bf16"))
197
+ def _gate_geglu_merged_quant_fp8_static_bf16_fake(merged, scale, out) -> None:
198
+ if merged.dim() != 2 or merged.shape[1] % 2:
199
+ raise RuntimeError("merged must have shape (rows, 2 * hidden)")
200
+ if scale.numel() != 1 or out.shape != (merged.shape[0], merged.shape[1] // 2):
201
+ raise RuntimeError("output must have shape (rows, hidden) and scale must be scalar")
202
+
203
+
204
  @torch.library.register_fake(add_op_namespace_prefix("residual_add_fp16_"))
205
+ @torch.library.register_fake(add_op_namespace_prefix("residual_add_fp16_vec"))
206
  def _residual_add_fp16_fake(residual, x) -> None:
207
  if residual.shape != x.shape:
208
  raise RuntimeError("residual and x must have the same shape")
209
 
210
 
211
  @torch.library.register_fake(add_op_namespace_prefix("repeat_interleave_heads_fp16"))
212
+ @torch.library.register_fake(add_op_namespace_prefix("gpu_repeat_interleave_heads_vec"))
213
  def _repeat_interleave_heads_fp16_fake(x, repeat: int, out) -> None:
214
  if x.dim() != 3 or out.shape != (x.shape[0], x.shape[1] * repeat, x.shape[2]):
215
  raise RuntimeError("output shape must be (sequence, heads * repeat, head_dim)")
 
351
  return out
352
 
353
 
354
+ def rms_norm_fp16_vec(x, weight, *, eps: float = 1e-6, out=None):
355
+ if out is None:
356
+ out = torch.empty_like(x)
357
+ ops.rms_norm_fp16_vec(x, weight, float(eps), out)
358
+ return out
359
+
360
+
361
  def layer_norm_fp16(x, weight, bias, *, eps: float = 1e-6, out=None):
362
  if out is None:
363
  out = torch.empty_like(x)
 
365
  return out
366
 
367
 
368
+ def layer_norm_fp16_vec(x, weight, bias, *, eps: float = 1e-6, out=None):
369
+ if out is None:
370
+ out = torch.empty_like(x)
371
+ ops.layer_norm_fp16_vec(x, weight, bias, float(eps), out)
372
+ return out
373
+
374
+
375
  def layer_norm_quant_fp8_static_fp16(
376
  x, weight, bias, scale, *, eps: float = 1e-6, out=None
377
  ):
 
383
  return out
384
 
385
 
386
+ def layer_norm_fp8_static_fp16_vec(
387
+ x, weight, bias, scale, *, eps: float = 1e-6, out=None
388
+ ):
389
+ if out is None:
390
+ out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
391
+ ops.layer_norm_fp8_static_fp16_vec(
392
+ x, weight, bias, scale, float(eps), out
393
+ )
394
+ return out
395
+
396
+
397
  def rope_rotate_half_fp16_(x, cos, sin):
398
  ops.rope_rotate_half_fp16_(x, cos, sin)
399
  return x
400
 
401
 
402
+ def rope_rotate_half_fp16_vec(x, cos, sin):
403
+ ops.rope_rotate_half_fp16_vec(x, cos, sin)
404
+ return x
405
+
406
+
407
  def quantize_fp8_static_fp16(x, scale, *, out=None):
408
  if out is None:
409
  out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
 
411
  return out
412
 
413
 
414
+ def quantize_fp8_static_fp16_vec(x, scale, *, out=None):
415
+ if out is None:
416
+ out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
417
+ ops.quantize_fp8_static_fp16_vec(x, scale, out)
418
+ return out
419
+
420
+
421
+ def quantize_fp8_static_bf16(x, scale, *, out=None):
422
+ """Quantize contiguous BF16 input with a static FP32 scale."""
423
+ if out is None:
424
+ out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
425
+ ops.quantize_fp8_static_bf16(x, scale, out)
426
+ return out
427
+
428
+
429
+ def layer_norm_quant_fp8_static_bf16(
430
+ x, weight, bias, scale, *, eps: float = 1e-6, out=None
431
+ ):
432
+ """LayerNorm BF16 input and emit static-scale FP8 without an intermediate."""
433
+ if out is None:
434
+ out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
435
+ ops.layer_norm_quant_fp8_static_bf16(
436
+ x, weight, bias, scale, float(eps), out
437
+ )
438
+ return out
439
+
440
+
441
+ def gate_geglu_merged_quant_fp8_static_bf16(merged, scale, *, out=None):
442
+ """Apply tanh-approximate GeGLU to merged BF16 gate/up and emit FP8."""
443
+ if out is None:
444
+ out = torch.empty(
445
+ (merged.shape[0], merged.shape[1] // 2),
446
+ device=merged.device,
447
+ dtype=torch.float8_e4m3fn,
448
+ )
449
+ ops.gate_geglu_merged_quant_fp8_static_bf16(merged, scale, out)
450
+ return out
451
+
452
+
453
  def residual_add_fp16_(residual, x):
454
  ops.residual_add_fp16_(residual, x)
455
  return residual
456
 
457
 
458
+ def residual_add_fp16_vec(residual, x):
459
+ ops.residual_add_fp16_vec(residual, x)
460
+ return residual
461
+
462
+
463
  def repeat_interleave_heads_fp16(x, repeat: int, *, out=None):
464
  if out is None:
465
  out = torch.empty(
 
471
  return out
472
 
473
 
474
+ def gpu_repeat_interleave_heads_vec(x, repeat: int, *, out=None):
475
+ if out is None:
476
+ out = torch.empty(
477
+ (x.shape[0], x.shape[1] * repeat, x.shape[2]),
478
+ device=x.device,
479
+ dtype=x.dtype,
480
+ )
481
+ ops.gpu_repeat_interleave_heads_vec(x, int(repeat), out)
482
+ return out
483
+
484
+
485
  __all__ = [
486
  "argmax_bf16",
487
  "embedding_lookup_bf16",
 
497
  "router_topk_bf16",
498
  "moe_weighted_sum_bf16_to_fp32",
499
  "layer_norm_fp16",
500
+ "layer_norm_fp16_vec",
501
+ "layer_norm_fp8_static_fp16_vec",
502
  "layer_norm_quant_fp8_static_fp16",
503
  "quantize_fp8_static_fp16",
504
+ "quantize_fp8_static_fp16_vec",
505
+ "quantize_fp8_static_bf16",
506
+ "layer_norm_quant_fp8_static_bf16",
507
+ "gate_geglu_merged_quant_fp8_static_bf16",
508
  "repeat_interleave_heads_fp16",
509
+ "gpu_repeat_interleave_heads_vec",
510
  "residual_add_fp16_",
511
+ "residual_add_fp16_vec",
512
  "rms_norm_fp16",
513
+ "rms_norm_fp16_vec",
514
  "rope_rotate_half_fp16_",
515
+ "rope_rotate_half_fp16_vec",
516
  ]
build/torch212-cxx11-cu130-x86_64-linux/_ops.py CHANGED
@@ -1,9 +1,9 @@
1
  import torch
2
- from . import _transformer_fused_ops_cuda_8a66d8b
3
- ops = torch.ops._transformer_fused_ops_cuda_8a66d8b
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
- return f"_transformer_fused_ops_cuda_8a66d8b::{op_name}"
 
1
  import torch
2
+ from . import _transformer_fused_ops_cuda_6ab0803
3
+ ops = torch.ops._transformer_fused_ops_cuda_6ab0803
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
+ return f"_transformer_fused_ops_cuda_6ab0803::{op_name}"
build/torch212-cxx11-cu130-x86_64-linux/{_transformer_fused_ops_cuda_8a66d8b.abi3.so → _transformer_fused_ops_cuda_6ab0803.abi3.so} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:27473682b7fde9f2461947ad0730f6edd256282e2ff54f23681051993fcafba3
3
- size 1463960
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ed5c176316d0ef39d90cc677292c6d7f6ac772b5b51f52bd5e4deb3dcf6fb98c
3
+ size 1544528
build/torch212-cxx11-cu130-x86_64-linux/metadata.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "transformer-fused-ops",
3
- "id": "_transformer_fused_ops_cuda_8a66d8b",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],
 
1
  {
2
  "name": "transformer-fused-ops",
3
+ "id": "_transformer_fused_ops_cuda_6ab0803",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],
build/torch212-cxx11-cu132-x86_64-linux/__init__.py CHANGED
@@ -143,18 +143,21 @@ def _relu2_quantize_fp8_static_fake(
143
 
144
 
145
  @torch.library.register_fake(add_op_namespace_prefix("rms_norm_fp16"))
 
146
  def _rms_norm_fp16_fake(x, weight, eps: float, out) -> None:
147
  if x.dim() != 2 or weight.shape != (x.shape[1],) or out.shape != x.shape:
148
  raise RuntimeError("expected x/out (rows,dim), weight (dim,)")
149
 
150
 
151
  @torch.library.register_fake(add_op_namespace_prefix("layer_norm_fp16"))
 
152
  def _layer_norm_fp16_fake(x, weight, bias, eps: float, out) -> None:
153
  if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape or out.shape != x.shape:
154
  raise RuntimeError("expected x/out (rows,dim), weight/bias (dim,)")
155
 
156
 
157
  @torch.library.register_fake(add_op_namespace_prefix("layer_norm_quant_fp8_static_fp16"))
 
158
  def _layer_norm_quant_fp8_static_fp16_fake(x, weight, bias, scale, eps: float, out) -> None:
159
  if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape or out.shape != x.shape:
160
  raise RuntimeError("expected x/out (rows,dim), weight/bias (dim,)")
@@ -163,24 +166,50 @@ def _layer_norm_quant_fp8_static_fp16_fake(x, weight, bias, scale, eps: float, o
163
 
164
 
165
  @torch.library.register_fake(add_op_namespace_prefix("rope_rotate_half_fp16_"))
 
166
  def _rope_rotate_half_fp16_fake(x, cos, sin) -> None:
167
  if x.dim() != 3 or cos.shape != (x.shape[0], x.shape[2]) or sin.shape != cos.shape:
168
  raise RuntimeError("expected x (sequence,heads,head_dim), cos/sin (sequence,head_dim)")
169
 
170
 
171
  @torch.library.register_fake(add_op_namespace_prefix("quantize_fp8_static_fp16"))
 
172
  def _quantize_fp8_static_fp16_fake(x, scale, out) -> None:
173
  if scale.numel() != 1 or out.shape != x.shape:
174
  raise RuntimeError("output must match x and scale must contain one value")
175
 
176
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  @torch.library.register_fake(add_op_namespace_prefix("residual_add_fp16_"))
 
178
  def _residual_add_fp16_fake(residual, x) -> None:
179
  if residual.shape != x.shape:
180
  raise RuntimeError("residual and x must have the same shape")
181
 
182
 
183
  @torch.library.register_fake(add_op_namespace_prefix("repeat_interleave_heads_fp16"))
 
184
  def _repeat_interleave_heads_fp16_fake(x, repeat: int, out) -> None:
185
  if x.dim() != 3 or out.shape != (x.shape[0], x.shape[1] * repeat, x.shape[2]):
186
  raise RuntimeError("output shape must be (sequence, heads * repeat, head_dim)")
@@ -322,6 +351,13 @@ def rms_norm_fp16(x, weight, *, eps: float = 1e-6, out=None):
322
  return out
323
 
324
 
 
 
 
 
 
 
 
325
  def layer_norm_fp16(x, weight, bias, *, eps: float = 1e-6, out=None):
326
  if out is None:
327
  out = torch.empty_like(x)
@@ -329,6 +365,13 @@ def layer_norm_fp16(x, weight, bias, *, eps: float = 1e-6, out=None):
329
  return out
330
 
331
 
 
 
 
 
 
 
 
332
  def layer_norm_quant_fp8_static_fp16(
333
  x, weight, bias, scale, *, eps: float = 1e-6, out=None
334
  ):
@@ -340,11 +383,27 @@ def layer_norm_quant_fp8_static_fp16(
340
  return out
341
 
342
 
 
 
 
 
 
 
 
 
 
 
 
343
  def rope_rotate_half_fp16_(x, cos, sin):
344
  ops.rope_rotate_half_fp16_(x, cos, sin)
345
  return x
346
 
347
 
 
 
 
 
 
348
  def quantize_fp8_static_fp16(x, scale, *, out=None):
349
  if out is None:
350
  out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
@@ -352,11 +411,55 @@ def quantize_fp8_static_fp16(x, scale, *, out=None):
352
  return out
353
 
354
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
355
  def residual_add_fp16_(residual, x):
356
  ops.residual_add_fp16_(residual, x)
357
  return residual
358
 
359
 
 
 
 
 
 
360
  def repeat_interleave_heads_fp16(x, repeat: int, *, out=None):
361
  if out is None:
362
  out = torch.empty(
@@ -368,6 +471,17 @@ def repeat_interleave_heads_fp16(x, repeat: int, *, out=None):
368
  return out
369
 
370
 
 
 
 
 
 
 
 
 
 
 
 
371
  __all__ = [
372
  "argmax_bf16",
373
  "embedding_lookup_bf16",
@@ -383,10 +497,20 @@ __all__ = [
383
  "router_topk_bf16",
384
  "moe_weighted_sum_bf16_to_fp32",
385
  "layer_norm_fp16",
 
 
386
  "layer_norm_quant_fp8_static_fp16",
387
  "quantize_fp8_static_fp16",
 
 
 
 
388
  "repeat_interleave_heads_fp16",
 
389
  "residual_add_fp16_",
 
390
  "rms_norm_fp16",
 
391
  "rope_rotate_half_fp16_",
 
392
  ]
 
143
 
144
 
145
  @torch.library.register_fake(add_op_namespace_prefix("rms_norm_fp16"))
146
+ @torch.library.register_fake(add_op_namespace_prefix("rms_norm_fp16_vec"))
147
  def _rms_norm_fp16_fake(x, weight, eps: float, out) -> None:
148
  if x.dim() != 2 or weight.shape != (x.shape[1],) or out.shape != x.shape:
149
  raise RuntimeError("expected x/out (rows,dim), weight (dim,)")
150
 
151
 
152
  @torch.library.register_fake(add_op_namespace_prefix("layer_norm_fp16"))
153
+ @torch.library.register_fake(add_op_namespace_prefix("layer_norm_fp16_vec"))
154
  def _layer_norm_fp16_fake(x, weight, bias, eps: float, out) -> None:
155
  if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape or out.shape != x.shape:
156
  raise RuntimeError("expected x/out (rows,dim), weight/bias (dim,)")
157
 
158
 
159
  @torch.library.register_fake(add_op_namespace_prefix("layer_norm_quant_fp8_static_fp16"))
160
+ @torch.library.register_fake(add_op_namespace_prefix("layer_norm_fp8_static_fp16_vec"))
161
  def _layer_norm_quant_fp8_static_fp16_fake(x, weight, bias, scale, eps: float, out) -> None:
162
  if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape or out.shape != x.shape:
163
  raise RuntimeError("expected x/out (rows,dim), weight/bias (dim,)")
 
166
 
167
 
168
  @torch.library.register_fake(add_op_namespace_prefix("rope_rotate_half_fp16_"))
169
+ @torch.library.register_fake(add_op_namespace_prefix("rope_rotate_half_fp16_vec"))
170
  def _rope_rotate_half_fp16_fake(x, cos, sin) -> None:
171
  if x.dim() != 3 or cos.shape != (x.shape[0], x.shape[2]) or sin.shape != cos.shape:
172
  raise RuntimeError("expected x (sequence,heads,head_dim), cos/sin (sequence,head_dim)")
173
 
174
 
175
  @torch.library.register_fake(add_op_namespace_prefix("quantize_fp8_static_fp16"))
176
+ @torch.library.register_fake(add_op_namespace_prefix("quantize_fp8_static_fp16_vec"))
177
  def _quantize_fp8_static_fp16_fake(x, scale, out) -> None:
178
  if scale.numel() != 1 or out.shape != x.shape:
179
  raise RuntimeError("output must match x and scale must contain one value")
180
 
181
 
182
+ @torch.library.register_fake(add_op_namespace_prefix("quantize_fp8_static_bf16"))
183
+ def _quantize_fp8_static_bf16_fake(x, scale, out) -> None:
184
+ if scale.numel() != 1 or out.shape != x.shape:
185
+ raise RuntimeError("output must match x and scale must contain one value")
186
+
187
+
188
+ @torch.library.register_fake(add_op_namespace_prefix("layer_norm_quant_fp8_static_bf16"))
189
+ def _layer_norm_quant_fp8_static_bf16_fake(x, weight, bias, scale, eps: float, out) -> None:
190
+ if x.dim() != 2 or weight.shape != (x.shape[1],) or bias.shape != weight.shape:
191
+ raise RuntimeError("expected x (rows,dim), weight/bias (dim,)")
192
+ if scale.numel() != 1 or out.shape != x.shape:
193
+ raise RuntimeError("output must match x and scale must contain one value")
194
+
195
+
196
+ @torch.library.register_fake(add_op_namespace_prefix("gate_geglu_merged_quant_fp8_static_bf16"))
197
+ def _gate_geglu_merged_quant_fp8_static_bf16_fake(merged, scale, out) -> None:
198
+ if merged.dim() != 2 or merged.shape[1] % 2:
199
+ raise RuntimeError("merged must have shape (rows, 2 * hidden)")
200
+ if scale.numel() != 1 or out.shape != (merged.shape[0], merged.shape[1] // 2):
201
+ raise RuntimeError("output must have shape (rows, hidden) and scale must be scalar")
202
+
203
+
204
  @torch.library.register_fake(add_op_namespace_prefix("residual_add_fp16_"))
205
+ @torch.library.register_fake(add_op_namespace_prefix("residual_add_fp16_vec"))
206
  def _residual_add_fp16_fake(residual, x) -> None:
207
  if residual.shape != x.shape:
208
  raise RuntimeError("residual and x must have the same shape")
209
 
210
 
211
  @torch.library.register_fake(add_op_namespace_prefix("repeat_interleave_heads_fp16"))
212
+ @torch.library.register_fake(add_op_namespace_prefix("gpu_repeat_interleave_heads_vec"))
213
  def _repeat_interleave_heads_fp16_fake(x, repeat: int, out) -> None:
214
  if x.dim() != 3 or out.shape != (x.shape[0], x.shape[1] * repeat, x.shape[2]):
215
  raise RuntimeError("output shape must be (sequence, heads * repeat, head_dim)")
 
351
  return out
352
 
353
 
354
+ def rms_norm_fp16_vec(x, weight, *, eps: float = 1e-6, out=None):
355
+ if out is None:
356
+ out = torch.empty_like(x)
357
+ ops.rms_norm_fp16_vec(x, weight, float(eps), out)
358
+ return out
359
+
360
+
361
  def layer_norm_fp16(x, weight, bias, *, eps: float = 1e-6, out=None):
362
  if out is None:
363
  out = torch.empty_like(x)
 
365
  return out
366
 
367
 
368
+ def layer_norm_fp16_vec(x, weight, bias, *, eps: float = 1e-6, out=None):
369
+ if out is None:
370
+ out = torch.empty_like(x)
371
+ ops.layer_norm_fp16_vec(x, weight, bias, float(eps), out)
372
+ return out
373
+
374
+
375
  def layer_norm_quant_fp8_static_fp16(
376
  x, weight, bias, scale, *, eps: float = 1e-6, out=None
377
  ):
 
383
  return out
384
 
385
 
386
+ def layer_norm_fp8_static_fp16_vec(
387
+ x, weight, bias, scale, *, eps: float = 1e-6, out=None
388
+ ):
389
+ if out is None:
390
+ out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
391
+ ops.layer_norm_fp8_static_fp16_vec(
392
+ x, weight, bias, scale, float(eps), out
393
+ )
394
+ return out
395
+
396
+
397
  def rope_rotate_half_fp16_(x, cos, sin):
398
  ops.rope_rotate_half_fp16_(x, cos, sin)
399
  return x
400
 
401
 
402
+ def rope_rotate_half_fp16_vec(x, cos, sin):
403
+ ops.rope_rotate_half_fp16_vec(x, cos, sin)
404
+ return x
405
+
406
+
407
  def quantize_fp8_static_fp16(x, scale, *, out=None):
408
  if out is None:
409
  out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
 
411
  return out
412
 
413
 
414
+ def quantize_fp8_static_fp16_vec(x, scale, *, out=None):
415
+ if out is None:
416
+ out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
417
+ ops.quantize_fp8_static_fp16_vec(x, scale, out)
418
+ return out
419
+
420
+
421
+ def quantize_fp8_static_bf16(x, scale, *, out=None):
422
+ """Quantize contiguous BF16 input with a static FP32 scale."""
423
+ if out is None:
424
+ out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
425
+ ops.quantize_fp8_static_bf16(x, scale, out)
426
+ return out
427
+
428
+
429
+ def layer_norm_quant_fp8_static_bf16(
430
+ x, weight, bias, scale, *, eps: float = 1e-6, out=None
431
+ ):
432
+ """LayerNorm BF16 input and emit static-scale FP8 without an intermediate."""
433
+ if out is None:
434
+ out = torch.empty_like(x, dtype=torch.float8_e4m3fn)
435
+ ops.layer_norm_quant_fp8_static_bf16(
436
+ x, weight, bias, scale, float(eps), out
437
+ )
438
+ return out
439
+
440
+
441
+ def gate_geglu_merged_quant_fp8_static_bf16(merged, scale, *, out=None):
442
+ """Apply tanh-approximate GeGLU to merged BF16 gate/up and emit FP8."""
443
+ if out is None:
444
+ out = torch.empty(
445
+ (merged.shape[0], merged.shape[1] // 2),
446
+ device=merged.device,
447
+ dtype=torch.float8_e4m3fn,
448
+ )
449
+ ops.gate_geglu_merged_quant_fp8_static_bf16(merged, scale, out)
450
+ return out
451
+
452
+
453
  def residual_add_fp16_(residual, x):
454
  ops.residual_add_fp16_(residual, x)
455
  return residual
456
 
457
 
458
+ def residual_add_fp16_vec(residual, x):
459
+ ops.residual_add_fp16_vec(residual, x)
460
+ return residual
461
+
462
+
463
  def repeat_interleave_heads_fp16(x, repeat: int, *, out=None):
464
  if out is None:
465
  out = torch.empty(
 
471
  return out
472
 
473
 
474
+ def gpu_repeat_interleave_heads_vec(x, repeat: int, *, out=None):
475
+ if out is None:
476
+ out = torch.empty(
477
+ (x.shape[0], x.shape[1] * repeat, x.shape[2]),
478
+ device=x.device,
479
+ dtype=x.dtype,
480
+ )
481
+ ops.gpu_repeat_interleave_heads_vec(x, int(repeat), out)
482
+ return out
483
+
484
+
485
  __all__ = [
486
  "argmax_bf16",
487
  "embedding_lookup_bf16",
 
497
  "router_topk_bf16",
498
  "moe_weighted_sum_bf16_to_fp32",
499
  "layer_norm_fp16",
500
+ "layer_norm_fp16_vec",
501
+ "layer_norm_fp8_static_fp16_vec",
502
  "layer_norm_quant_fp8_static_fp16",
503
  "quantize_fp8_static_fp16",
504
+ "quantize_fp8_static_fp16_vec",
505
+ "quantize_fp8_static_bf16",
506
+ "layer_norm_quant_fp8_static_bf16",
507
+ "gate_geglu_merged_quant_fp8_static_bf16",
508
  "repeat_interleave_heads_fp16",
509
+ "gpu_repeat_interleave_heads_vec",
510
  "residual_add_fp16_",
511
+ "residual_add_fp16_vec",
512
  "rms_norm_fp16",
513
+ "rms_norm_fp16_vec",
514
  "rope_rotate_half_fp16_",
515
+ "rope_rotate_half_fp16_vec",
516
  ]
build/torch212-cxx11-cu132-x86_64-linux/_ops.py CHANGED
@@ -1,9 +1,9 @@
1
  import torch
2
- from . import _transformer_fused_ops_cuda_8a66d8b
3
- ops = torch.ops._transformer_fused_ops_cuda_8a66d8b
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
- return f"_transformer_fused_ops_cuda_8a66d8b::{op_name}"
 
1
  import torch
2
+ from . import _transformer_fused_ops_cuda_6ab0803
3
+ ops = torch.ops._transformer_fused_ops_cuda_6ab0803
4
 
5
  def add_op_namespace_prefix(op_name: str):
6
  """
7
  Prefix op by namespace.
8
  """
9
+ return f"_transformer_fused_ops_cuda_6ab0803::{op_name}"
build/torch212-cxx11-cu132-x86_64-linux/{_transformer_fused_ops_cuda_8a66d8b.abi3.so → _transformer_fused_ops_cuda_6ab0803.abi3.so} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:0e61c0f0225f2d4a2698be8615950e0d1e328669b5575543a455307bf1b7a698
3
- size 1468056
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9a1c470ffbe525f3b95584f9be1045f690721cea885d41cb131ed8d50ad151eb
3
+ size 1552720
build/torch212-cxx11-cu132-x86_64-linux/metadata.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "transformer-fused-ops",
3
- "id": "_transformer_fused_ops_cuda_8a66d8b",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],
 
1
  {
2
  "name": "transformer-fused-ops",
3
+ "id": "_transformer_fused_ops_cuda_6ab0803",
4
  "version": 1,
5
  "license": "Apache-2.0",
6
  "python-depends": [],