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

10 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-08-21 04:29 +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# pylint: disable=undefined-all-variable 

16"""SAPP-PPB: Symbolic Automatic Parallel Planner - Pipeline Parallelism Balancing. 

17 

18Offline ILP planner for automatically generating layer distribution and 

19recomputation policies across pipeline parallel stages. 

20""" 

21 

22from importlib import import_module as _import_module # pylint: disable=invalid-name 

23 

24__all__ = [ 

25 "SappPipeline", 

26 "choose_interleave", 

27 "flatten", 

28 "SappSolver", 

29 "PipelineMemoryConstraint", 

30 "Layer", 

31 "generate_layers_list", 

32 "compute_memories", 

33 "initialize_layer_json", 

34 "build_arg_parser", 

35 "run", 

36 "main", 

37 "LayerBuilder", 

38 "SAPP_PPB_AVAILABLE", 

39 "PPSimulator", 

40 "PPBalancer", 

41] 

42 

43_EXPORTS = { 

44 "SappPipeline": ".sapp.sapp_pipeline", 

45 "choose_interleave": ".sapp.sapp_pipeline", 

46 "flatten": ".sapp.sapp_pipeline", 

47 "SappSolver": ".sapp.sapp_solver", 

48 "PipelineMemoryConstraint": ".sapp.sapp_solver", 

49 "Layer": ".utils.layer", 

50 "generate_layers_list": ".utils.layer", 

51 "compute_memories": ".utils.compute_memory", 

52 "initialize_layer_json": ".utils.config", 

53 "build_arg_parser": ".run_pipeline_balance", 

54 "run": ".run_pipeline_balance", 

55 "main": ".run_pipeline_balance", 

56 "LayerBuilder": ".pp_config_builder.layer_loader", 

57 "SAPP_PPB_AVAILABLE": ".pp_config_builder.layer_loader", 

58 "PPSimulator": ".pp_sim_adapter", 

59 "PPBalancer": ".pp_modeling.pp_balancer", 

60} 

61 

62 

63def __getattr__(name): # pylint: disable=invalid-name 

64 """Lazily import public SAPP-PPB interfaces.""" 

65 if name not in _EXPORTS: 

66 raise AttributeError(f"module {__name__!r} has no attribute {name!r}") 

67 

68 module = _import_module(_EXPORTS[name], __name__) 

69 value = getattr(module, name) 

70 globals()[name] = value 

71 return value