Add torch213-cxx11-cu130-aarch64-linux artifact
Browse files
build/torch213-cxx11-cu130-aarch64-linux/__init__.py
CHANGED
|
@@ -206,6 +206,57 @@ def _qkv_split_rope_kvcache_bf16_fake(
|
|
| 206 |
return None
|
| 207 |
|
| 208 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
@torch.library.register_fake(add_op_namespace_prefix("qkv_split_bf16"))
|
| 210 |
def _qkv_split_bf16_fake(
|
| 211 |
packed_qkv: torch.Tensor,
|
|
@@ -500,6 +551,83 @@ def qkv_split_rope_kvcache_bf16(
|
|
| 500 |
return q_out, k_cache, v_cache
|
| 501 |
|
| 502 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 503 |
def qkv_split_per_head_norm_rope_bf16(
|
| 504 |
packed_qkv: torch.Tensor,
|
| 505 |
q_norm_weight: torch.Tensor,
|
|
@@ -867,6 +995,8 @@ __all__ = [
|
|
| 867 |
"qkv_split_bias_rope_fp16",
|
| 868 |
"qkv_split_bf16",
|
| 869 |
"qkv_split_rope_kvcache_bf16",
|
|
|
|
|
|
|
| 870 |
"qkv_split_norm_rope_bf16",
|
| 871 |
"qkv_split_bias_norm_rope_v_bf16",
|
| 872 |
"qkv_split_bias_norm_rope_v_cat_bf16",
|
|
|
|
| 206 |
return None
|
| 207 |
|
| 208 |
|
| 209 |
+
@torch.library.register_fake(add_op_namespace_prefix("qkv_split_rope_kvcache_fp16"))
|
| 210 |
+
def _qkv_split_rope_kvcache_fp16_fake(
|
| 211 |
+
packed_qkv: torch.Tensor,
|
| 212 |
+
rope: torch.Tensor,
|
| 213 |
+
q_heads: int,
|
| 214 |
+
kv_heads: int,
|
| 215 |
+
head_dim: int,
|
| 216 |
+
cache_offset: int,
|
| 217 |
+
device_position: torch.Tensor | None,
|
| 218 |
+
q_out: torch.Tensor,
|
| 219 |
+
k_cache: torch.Tensor,
|
| 220 |
+
v_cache: torch.Tensor,
|
| 221 |
+
) -> None:
|
| 222 |
+
_check_packed_gqa_qkv(packed_qkv, q_heads, kv_heads, head_dim)
|
| 223 |
+
batch, seq_len, _ = packed_qkv.shape
|
| 224 |
+
if packed_qkv.dtype != torch.float16 or rope.dtype != torch.float16:
|
| 225 |
+
raise RuntimeError("packed_qkv and rope must have dtype torch.float16")
|
| 226 |
+
if rope.dim() != 2 or rope.shape[0] < seq_len or rope.shape[1] != head_dim:
|
| 227 |
+
raise RuntimeError("rope must have shape (>= seq_len, head_dim)")
|
| 228 |
+
if q_out.shape != (batch, seq_len, q_heads, head_dim):
|
| 229 |
+
raise RuntimeError("q_out has an invalid shape")
|
| 230 |
+
if k_cache.dim() != 4 or k_cache.shape[0] != batch or k_cache.shape[2:] != (kv_heads, head_dim):
|
| 231 |
+
raise RuntimeError("k_cache must have shape (batch, max_seq_len, kv_heads, head_dim)")
|
| 232 |
+
if v_cache.shape != k_cache.shape:
|
| 233 |
+
raise RuntimeError("v_cache must have the same shape as k_cache")
|
| 234 |
+
if cache_offset < 0:
|
| 235 |
+
raise RuntimeError("cache_offset must be non-negative")
|
| 236 |
+
if device_position is not None and (device_position.dtype != torch.int32 or device_position.numel() != 1):
|
| 237 |
+
raise RuntimeError("device_position must contain one int32 element")
|
| 238 |
+
return None
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
@torch.library.register_fake(add_op_namespace_prefix("qk_norm_rope_strided_bf16"))
|
| 242 |
+
def _qk_norm_rope_strided_bf16_fake(
|
| 243 |
+
q_in, k_in, q_weight, k_weight, cos, sin,
|
| 244 |
+
q_heads: int, k_heads: int, eps: float, q_out, k_out,
|
| 245 |
+
) -> None:
|
| 246 |
+
rows = q_in.shape[0]
|
| 247 |
+
if q_in.dim() != 2 or k_in.dim() != 2 or k_in.shape[0] != rows:
|
| 248 |
+
raise RuntimeError("q_in and k_in must be rank-2 with the same row count")
|
| 249 |
+
if q_in.shape[1] < q_heads * 128 or k_in.shape[1] < k_heads * 128:
|
| 250 |
+
raise RuntimeError("input row widths must cover heads * 128")
|
| 251 |
+
if q_weight.shape != (128,) or k_weight.shape != (128,):
|
| 252 |
+
raise RuntimeError("Q/K weights must have shape (128,)")
|
| 253 |
+
if cos.shape != (rows, 128) or sin.shape != cos.shape:
|
| 254 |
+
raise RuntimeError("cos and sin must have shape (rows, 128)")
|
| 255 |
+
if q_out.shape != (rows, q_heads, 128) or k_out.shape != (rows, k_heads, 128):
|
| 256 |
+
raise RuntimeError("output shapes must be (rows, heads, 128)")
|
| 257 |
+
return None
|
| 258 |
+
|
| 259 |
+
|
| 260 |
@torch.library.register_fake(add_op_namespace_prefix("qkv_split_bf16"))
|
| 261 |
def _qkv_split_bf16_fake(
|
| 262 |
packed_qkv: torch.Tensor,
|
|
|
|
| 551 |
return q_out, k_cache, v_cache
|
| 552 |
|
| 553 |
|
| 554 |
+
def qkv_split_rope_kvcache_fp16(
|
| 555 |
+
packed_qkv: torch.Tensor,
|
| 556 |
+
rope: torch.Tensor,
|
| 557 |
+
q_heads: int,
|
| 558 |
+
kv_heads: int,
|
| 559 |
+
head_dim: int,
|
| 560 |
+
cache_offset: int = 0,
|
| 561 |
+
device_position: torch.Tensor | None = None,
|
| 562 |
+
q_out: torch.Tensor | None = None,
|
| 563 |
+
k_cache: torch.Tensor | None = None,
|
| 564 |
+
v_cache: torch.Tensor | None = None,
|
| 565 |
+
max_seq_len: int | None = None,
|
| 566 |
+
) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
| 567 |
+
"""Split FP16 GQA QKV, apply interleaved RoPE, and update K/V caches.
|
| 568 |
+
|
| 569 |
+
``device_position`` is an optional CUDA int32 scalar used by CUDA Graph
|
| 570 |
+
decode loops. When provided, cache rows start at
|
| 571 |
+
``cache_offset + device_position[0]`` without a host synchronization.
|
| 572 |
+
"""
|
| 573 |
+
batch, seq_len, _ = packed_qkv.shape
|
| 574 |
+
if q_out is None:
|
| 575 |
+
q_out = torch.empty(
|
| 576 |
+
(batch, seq_len, q_heads, head_dim),
|
| 577 |
+
device=packed_qkv.device,
|
| 578 |
+
dtype=torch.float16,
|
| 579 |
+
)
|
| 580 |
+
if k_cache is None or v_cache is None:
|
| 581 |
+
if max_seq_len is None:
|
| 582 |
+
if device_position is not None:
|
| 583 |
+
raise ValueError("max_seq_len is required when device_position is used")
|
| 584 |
+
max_seq_len = cache_offset + seq_len
|
| 585 |
+
cache_shape = (batch, int(max_seq_len), kv_heads, head_dim)
|
| 586 |
+
if k_cache is None:
|
| 587 |
+
k_cache = torch.empty(cache_shape, device=packed_qkv.device, dtype=torch.float16)
|
| 588 |
+
if v_cache is None:
|
| 589 |
+
v_cache = torch.empty(cache_shape, device=packed_qkv.device, dtype=torch.float16)
|
| 590 |
+
ops.qkv_split_rope_kvcache_fp16(
|
| 591 |
+
packed_qkv,
|
| 592 |
+
rope,
|
| 593 |
+
int(q_heads),
|
| 594 |
+
int(kv_heads),
|
| 595 |
+
int(head_dim),
|
| 596 |
+
int(cache_offset),
|
| 597 |
+
device_position,
|
| 598 |
+
q_out,
|
| 599 |
+
k_cache,
|
| 600 |
+
v_cache,
|
| 601 |
+
)
|
| 602 |
+
return q_out, k_cache, v_cache
|
| 603 |
+
|
| 604 |
+
|
| 605 |
+
def qk_norm_rope_strided_bf16(
|
| 606 |
+
q_in: torch.Tensor,
|
| 607 |
+
k_in: torch.Tensor,
|
| 608 |
+
q_weight: torch.Tensor,
|
| 609 |
+
k_weight: torch.Tensor,
|
| 610 |
+
cos: torch.Tensor,
|
| 611 |
+
sin: torch.Tensor,
|
| 612 |
+
q_heads: int,
|
| 613 |
+
k_heads: int,
|
| 614 |
+
eps: float = 1e-6,
|
| 615 |
+
q_out: torch.Tensor | None = None,
|
| 616 |
+
k_out: torch.Tensor | None = None,
|
| 617 |
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
| 618 |
+
"""Per-head RMSNorm and rotate-half RoPE from padded Q/K row strides."""
|
| 619 |
+
rows = q_in.shape[0]
|
| 620 |
+
if q_out is None:
|
| 621 |
+
q_out = torch.empty((rows, q_heads, 128), device=q_in.device, dtype=torch.bfloat16)
|
| 622 |
+
if k_out is None:
|
| 623 |
+
k_out = torch.empty((rows, k_heads, 128), device=k_in.device, dtype=torch.bfloat16)
|
| 624 |
+
ops.qk_norm_rope_strided_bf16(
|
| 625 |
+
q_in, k_in, q_weight, k_weight, cos, sin,
|
| 626 |
+
int(q_heads), int(k_heads), float(eps), q_out, k_out,
|
| 627 |
+
)
|
| 628 |
+
return q_out, k_out
|
| 629 |
+
|
| 630 |
+
|
| 631 |
def qkv_split_per_head_norm_rope_bf16(
|
| 632 |
packed_qkv: torch.Tensor,
|
| 633 |
q_norm_weight: torch.Tensor,
|
|
|
|
| 995 |
"qkv_split_bias_rope_fp16",
|
| 996 |
"qkv_split_bf16",
|
| 997 |
"qkv_split_rope_kvcache_bf16",
|
| 998 |
+
"qkv_split_rope_kvcache_fp16",
|
| 999 |
+
"qk_norm_rope_strided_bf16",
|
| 1000 |
"qkv_split_norm_rope_bf16",
|
| 1001 |
"qkv_split_bias_norm_rope_v_bf16",
|
| 1002 |
"qkv_split_bias_norm_rope_v_cat_bf16",
|
build/torch213-cxx11-cu130-aarch64-linux/flashrt_qkv_cache_rope_test.abi3.so
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d54aecf1ef0f6217e3f2c820aa3752270cc51d0d1c77c4e53c0dd65dc6ad2eab
|
| 3 |
+
size 698616
|
build/torch213-cxx11-cu130-aarch64-linux/metadata.json
CHANGED
|
@@ -13,15 +13,15 @@
|
|
| 13 |
"digest": {
|
| 14 |
"algorithm": "sha256",
|
| 15 |
"files": {
|
| 16 |
-
"__init__.py": "
|
| 17 |
-
"flashrt_qkv_cache_rope_test.abi3.so": "
|
| 18 |
"_ops.py": "ZSIUGrzgBBffx37jx/znR0nnvtuaR3+G3FSvPKa9UHQ=",
|
| 19 |
"flashrt_qkv_cache_rope/__init__.py": "v6p5XMfQzddhi1fLSAw4HX9CyS0rQsidvu9VsT01xi4="
|
| 20 |
}
|
| 21 |
},
|
| 22 |
"provenance": {
|
| 23 |
"kernel": {
|
| 24 |
-
"sha": "
|
| 25 |
"dirty": false
|
| 26 |
},
|
| 27 |
"validation": {
|
|
|
|
| 13 |
"digest": {
|
| 14 |
"algorithm": "sha256",
|
| 15 |
"files": {
|
| 16 |
+
"__init__.py": "Izk+vnt9b4h2bryy/G+JK29rnXtvBhAbTLxsiNQGCSk=",
|
| 17 |
+
"flashrt_qkv_cache_rope_test.abi3.so": "1Urs8e8PYhfj8sggqjdSJwzFHQ0cd8TlPA3WXcatLqs=",
|
| 18 |
"_ops.py": "ZSIUGrzgBBffx37jx/znR0nnvtuaR3+G3FSvPKa9UHQ=",
|
| 19 |
"flashrt_qkv_cache_rope/__init__.py": "v6p5XMfQzddhi1fLSAw4HX9CyS0rQsidvu9VsT01xi4="
|
| 20 |
}
|
| 21 |
},
|
| 22 |
"provenance": {
|
| 23 |
"kernel": {
|
| 24 |
+
"sha": "fed80c9",
|
| 25 |
"dirty": false
|
| 26 |
},
|
| 27 |
"validation": {
|