Coverage for  / home / jenkins / .local / lib / python3.10 / site-packages / hyper_parallel / custom_ops / experimental / __init__.py: 100%

2 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-07-06 05:41 +0800

1# Copyright 2026 Huawei Technologies Co., Ltd 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"); 

4# you may not use this file except in compliance with the License. 

5# You may obtain a copy of the License at 

6# 

7# http://www.apache.org/licenses/LICENSE-2.0 

8# 

9# Unless required by applicable law or agreed to in writing, software 

10# distributed under the License is distributed on an "AS IS" BASIS, 

11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

12# See the License for the specific language governing permissions and 

13# limitations under the License. 

14# ============================================================================ 

15"""Experimental custom operators for HyperParallel. 

16 

17.. warning:: 

18 This is an experimental API that subject to change or deletion. 

19 

20These operators delegate to the platform-specific ``custom_ops`` interface. 

21On MindSpore they wrap Ascend NPU custom C++ kernels through the 

22``DFunction`` distributed dispatch framework. On PyTorch they raise 

23``NotImplementedError``. 

24 

25Usage:: 

26 

27 from hyper_parallel.custom_ops.experimental import npu_dense_lightning_indexer_softmax_lse 

28 softmax_max, softmax_sum = npu_dense_lightning_indexer_softmax_lse( 

29 query_index, key_index, weights, layout='BSND') 

30 

31When inputs are ``DTensor`` objects, the call is automatically routed 

32through the registered ``DistributedOp`` for layout inference and 

33re-distribution. 

34""" 

35__all__ = [ 

36 "npu_dense_lightning_indexer_grad_kl_loss", 

37 "npu_dense_lightning_indexer_softmax_lse", 

38 "npu_mhc_post", 

39 "npu_mhc_pre_clamp_sinkhorn", 

40 "npu_mhc_pre_sinkhorn", 

41 "npu_sparse_lightning_indexer_grad_kl_loss", 

42] 

43 

44from hyper_parallel.custom_ops.experimental.experimental_ops import ( 

45 npu_dense_lightning_indexer_grad_kl_loss, 

46 npu_dense_lightning_indexer_softmax_lse, 

47 npu_mhc_post, 

48 npu_mhc_pre_clamp_sinkhorn, 

49 npu_mhc_pre_sinkhorn, 

50 npu_sparse_lightning_indexer_grad_kl_loss, 

51)