Diff Coverage

Diff: origin/master...HEAD, staged and unstaged changes

Source File Diff Coverage (%) Missing Lines
hyper_parallel/components/functional/gated_delta_net_triton.py 0.0% 23,1132-1133,1135,1184-1185,1300-1301
hyper_parallel/components/modules/attention/grouped_query_attention/grouped_query_attention_family.py 100%  
hyper_parallel/components/functional/gated_delta_net_triton.py
19
20
21
22
23
24
25
26
27
# pylint: disable=non-google-docstring,disallowed-name,unused-argument,invalid-name
# pylint: disable=missing-module-docstring,missing-function-docstring
# pylint: disable=abstract-method,arguments-differ

from functools import lru_cache
import warnings
from typing import Any, Optional

import torch
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
    )
    return output, final_state


@lru_cache
def _state_summary_tile_size(device: torch.device) -> int:
    """Use a narrower output tile to fit the Ascend 910B unified buffer."""
    return 64 if "910B" in torch.npu.get_device_name(device) else 128


def _validate_fixed_summary_shape(
    key_dim: int,
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
        raise ValueError("GDN state summary expects key/w/u [B,T,H,D] and g [B,T,H].")
    batch, seq_len, heads, key_dim = key.shape
    value_dim = u.shape[-1]
    _validate_fixed_summary_shape(key_dim, value_dim, chunk_size)
    if block_size is None:
        block_size = _state_summary_tile_size(key.device)
    if block_size not in (64, 128):
        raise ValueError(f"GDN state-summary block_size must be 64 or 128, got {block_size}.")
    if seq_len <= 0:
        raise ValueError("State summary requires a nonempty sample fragment.")
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
        value_dim,
        device=query.device,
        dtype=torch.float32,
    )
    block_size = _state_summary_tile_size(key.device)
    gdn_state_grad_ext_kernel[(triton.cdiv(value_dim, block_size), batch * heads)](
        query,
        key,
        w,
        g,