Diff Coverage

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

Source File Diff Coverage (%) Missing Lines
hyper_parallel/components/functional/attention_rescale.py 100%  
hyper_parallel/components/functional/dsa_sparse_attention_rescale.py 100%  
hyper_parallel/distributed/_builder/planner.py 100%  
hyper_parallel/distributed/context_parallel/attention.py 100%  
hyper_parallel/distributed/expert_parallel/experts.py 81.0% 364,368,377,381
hyper_parallel/distributed/expert_parallel/experts.py
360
361
362
363
364
365
366
367
368
369
370
371
372
    tokens: torch.Tensor,
    indices: torch.Tensor,
) -> tuple[torch.Tensor, torch.Tensor]:
    """Load the optional NPU fused permutation only when requested."""
    from hyper_parallel.components.functional.moe_token_permute import (  # pylint: disable=C0415
        moe_token_permute,
    )

    return moe_token_permute(tokens, indices)


def _npu_moe_token_unpermute(
    permuted_tokens: torch.Tensor,
373
374
375
376
377
378
379
380
381
382
383
384
385
    sorted_indices: torch.Tensor,
    probabilities: torch.Tensor,
) -> torch.Tensor:
    """Load the optional NPU fused unpermutation only when requested."""
    from hyper_parallel.components.functional.moe_token_unpermute import (  # pylint: disable=C0415
        moe_token_unpermute,
    )

    return moe_token_unpermute(permuted_tokens, sorted_indices, probabilities)


def _npu_token_dispatch_enabled(hidden_states: torch.Tensor, enabled: bool) -> bool:
    """Use NPU routing kernels only for NPU tensors when enabled."""