Coverage for  / home / jenkins / .local / lib / python3.10 / site-packages / hyper_parallel / tools / dryrun / __main__.py: 94%

18 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-12-05 05:12 +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"""CLI entry point for running FakeTensor memory dry-run under ``torchrun``.""" 

16 

17import logging 

18 

19from hyper_parallel.tools.dryrun import HyperModelsDryRunRunner 

20from hyper_parallel.tools.dryrun.config import resolve_dryrun_config 

21from hyper_parallel.tools.dryrun.runtime import DryRunRuntime 

22from hyper_parallel.trainer.config.parser import parse_training_args 

23 

24logger = logging.getLogger(__name__) 

25 

26 

27def main() -> None: 

28 """Run dry-run from a resolved training YAML and optional CLI overrides.""" 

29 config = parse_training_args() 

30 dry_run = resolve_dryrun_config(config.dry_run) 

31 config.dry_run = dry_run 

32 runtime = DryRunRuntime.from_torchrun_env() 

33 dry_run.validate(world_size=runtime.world_size) 

34 if runtime.rank not in dry_run.ranks: 

35 logger.info("Skipping dry-run rank %s; dry_run.ranks=%s", runtime.rank, dry_run.ranks) 

36 return 

37 HyperModelsDryRunRunner(config, runtime).run() 

38 

39 

40if __name__ == "__main__": 

41 main()