Views
No views yet
flashrt/transformer-layout-primitivesfill_neginf_bf16(dst) -> dstadd_bias_bf16_(data, bias) -> datarepeat_interleave_heads_bf16(src, repeat) -> bf16text_gather_bf16(src, batch, seq) -> bf16text_scatter_bf16(dst, src, batch, seq) -> dstrope_rotate_half_bf16_(x, cos, sin) -> xqk_rmsnorm_rope_bf16_(qk, weight, cos, sin, eps=1e-6) -> qkqk_pair_rmsnorm_rope_bf16(q, k, q_weight, k_weight, cos, sin, eps=1e-6) -> (q, k)gather_rows_bf16(src, row_indices, out=None) -> bf16scatter_rows_bf16(src, row_indices, rows, out=None) -> bf161from kernels import get_kernel
2import torch
3
4ops = get_kernel("flashrt/transformer-layout-primitives", version=1)
5
6q = torch.randn((128, 32, 128), device="cuda", dtype=torch.bfloat16)
7weight = torch.ones((128,), device="cuda", dtype=torch.bfloat16)
8cos = torch.randn((128, 128), device="cuda", dtype=torch.bfloat16)
9sin = torch.randn((128, 128), device="cuda", dtype=torch.bfloat16)
10ops.qk_rmsnorm_rope_bf16_(q, weight, cos, sin)
11
12k = torch.randn((128, 8, 128), device="cuda", dtype=torch.bfloat16)
13q, k = ops.qk_pair_rmsnorm_rope_bf16(
14 q, k, weight, weight, cos, sin
15)repeat_interleave_heads_bf16: src is (seq, heads, head_dim).text_gather_bf16: src is flattened (batch * seq, dim) and returns
first and last token rows as (2 * batch, dim).text_scatter_bf16: writes (2 * batch, dim) rows back to first and last
positions in (batch * seq, dim).cos/sin shaped (seq, head_dim)
or (rows, head_dim).qk_pair_rmsnorm_rope_bf16 accepts Q (rows, q_heads, head_dim) and K
(rows, kv_heads, head_dim). head_dim must be even and in [8, 256].
Q and K may have different head counts.gather_rows_bf16 and scatter_rows_bf16 use contiguous CUDA int64 row
indices. Scatter indices must be unique.128 -> 60 rows with hidden size 2048, including exact CUDA Graph replay.benchmarks/RESULTS.md for current local RTX 5090 source benchmark data.