Diff Coverage

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

Source File Diff Coverage (%) Missing Lines
hyper_parallel/components/modules/shared_compressed_dsa_attention.py 70.0% 461,509-510,540,594-595
hyper_parallel/components/modules/shared_compressed_dsa_attention.py
457
458
459
460
461
462
463
464
465
    key_positions = torch.arange(compressed_length, device=query.device).view(1, 1, -1)
    candidate_chunks = []
    for start in range(0, sequence_length, query_chunk_size):
        end = min(start + query_chunk_size, sequence_length)
        scores = torch.matmul(query[:, start:end].float(), key_fp32).relu()
        scores = (scores * merge_weight[:, start:end].float().unsqueeze(-1)).sum(dim=2)
        if reduce_sum is not None:
            scores = reduce_sum(scores)
        visible = (
505
506
507
508
509
510
511
512
513
514
            query, key, merge_weight, compress_ratio=compress_ratio,
            sparse_count=sparse_count, topk_blocks=topk_blocks,
            block_size=block_size, query_offset=query_offset,
            reduce_sum=reduce_sum, minimum_key_indices=minimum_key_indices)
        if selected is not None:
            return selected
    batch_size, sequence_length, _, head_dim = query.shape
    if key.ndim != 3 or key.shape[0] != batch_size or key.shape[2] != head_dim:
        raise ValueError(
            "compressed index key must have shape [batch, compressed_sequence, head_dim]"
536
537
538
539
540
541
542
543
544
    selected_chunks = []
    candidate_chunks = []
    for start in range(0, sequence_length, query_chunk_size):
        end = min(start + query_chunk_size, sequence_length)
        scores = torch.matmul(query[:, start:end].float(), key_fp32).relu()
        scores = (scores * merge_weight[:, start:end].float().unsqueeze(-1)).sum(dim=2)
        if reduce_sum is not None:
            scores = reduce_sum(scores)
        visible = (
590
591
592
593
594
595
596
597
598
599
            query, key, merge_weight, candidate_blocks,
            compress_ratio=compress_ratio, sparse_count=sparse_count,
            block_size=block_size, query_offset=query_offset,
            reduce_sum=reduce_sum, minimum_key_indices=minimum_key_indices)
        if selected is not None:
            return selected
    batch_size, sequence_length, _, head_dim = query.shape
    if key.ndim != 3 or key.shape[0] != batch_size or key.shape[2] != head_dim:
        raise ValueError(
            "compressed index key must have shape [batch, compressed_sequence, head_dim]"