An IR for efficiently simulating distributed ML computation.
Перейти к файлу
Keshav Santhanam 7cfa1b0c1e
Revert update to live memory initialization in simulator (#41)
2022-01-05 10:01:07 -08:00
.github/workflows Add support for fp16 execution and memory tracking (#40) 2021-12-16 14:19:34 -08:00
.vscode Slight tweak to VS Code settings 2021-02-02 18:25:44 +00:00
dist_ir Revert update to live memory initialization in simulator (#41) 2022-01-05 10:01:07 -08:00
docs Refactor: immutable core classes using dataclasses (#15) 2021-01-12 22:16:32 +00:00
examples Add support for fp16 execution and memory tracking (#40) 2021-12-16 14:19:34 -08:00
notebooks MLP training, simulator parameter calibration, and grid search infrastructure (#30) 2021-09-16 13:01:34 -07:00
test Add support for fp16 execution and memory tracking (#40) 2021-12-16 14:19:34 -08:00
.gitignore Added README.md, .gitignore (Python) files 2020-10-19 17:47:02 +00:00
CODE_OF_CONDUCT.md Prepare for open source release (#35) 2021-10-19 13:33:50 +01:00
LICENSE Prepare for open source release (#35) 2021-10-19 13:33:50 +01:00
README.md Prepare for open source release (#35) 2021-10-19 13:33:50 +01:00
SECURITY.md Prepare for open source release (#35) 2021-10-19 13:33:50 +01:00
azure-pipelines.yml Fix Azure pipeline and set to run manually 2021-09-15 16:18:12 +01:00
mlsys_experiments.yaml Add support for fp16 execution and memory tracking (#40) 2021-12-16 14:19:34 -08:00
requirements.txt Add support for fp16 execution and memory tracking (#40) 2021-12-16 14:19:34 -08:00
setup.py Prepare for open source release (#35) 2021-10-19 13:33:50 +01:00

README.md

DistIR

An IR to represent distributed computations. Our main goal is an IR capable of representing the complex distributed strategies used in large-scale distributed training, while at the same time enabling fast cost models/simulations.

Distributed strategies we want to support:

  • Data parallelism
  • Horizontal parallelism
  • Pipeline parallelism
  • Megatron
  • ZeRO partitioning
  • PyTorch lightning's Zero
  • Stashing & recomputation
  • Overlapping computation and communication
  • Local layer parallelism

Requirements/Installation

See the build file and PIP packages list.

Directory structure

  • dist_ir: Python source for DistIR
    • ir: IR definitions
    • importer: create DistIR from ONNX/MLIR
    • executor: ways to "execute" or simulate DistIR
  • docs: documentation and notes
  • notebooks: small experiments and worked examples
  • test: unit tests, small/toy example models

Running tests

Run the following from the root of this repository:

python -m pytest

Components

  • Executors:
    • SequentialExecutor: a reference implementation that runs a DistIR function on a single device. Can be used to check correctness of transforms.
    • DistributedSimulator: an executor that uses profile data or flop counts to simulate the execution of a given DistIR function on a given hardware configuration (including communication bandwidths and processor speed). Returns estimated execution time and live memory profile. This can be split into three subcomponents:
      • Shape Inference: a pass that uses the shapes of inputs to calculate the shapes of all intermediate values.
      • Cost Inference: a pass that uses either shape information to compute (or profiles the function and measures) the runtime and temporary memory requirement of each op in the function. This output can be cached.
      • Simulator: takes a function and a mapping from op to time/memory consumption and does a simulation to obtain a concurrent trace (from which total runtime and memory usage plots can be derived).
  • Importers:
    • ONNX Importer: convert a .onnx file to a DistIR function. Can be given an intermediate graph from ORT (for example, after AD).
    • MLIR Importer: import a DistIR function written in MLIR text format to an in-memory DistIR function object. TODO
  • Exporter/Prettyprinter: converts a DistIR function to an MLIR text format string.
  • Transforms: a module containing DistIR->DistIR transforms. Ideally, these transforms should be composable and should run on subfunctions so that we can have nested parallelism (data parallel where a subset of the layers are horizontal parallel, or pipeline parallel where each stage is data parallel with a different degree).
    • DataParallelTransform: converts a given DistIR function to a data-parallel version that runs on a given number of devices.
    • HorizontalParallelTransform: converts a given DistIR function to a horizontal-parallel version (if possible) that runs on a given number of devices.
    • PipelineParallelTransform: converts a given DistIR function to a pipeline-parallel version that runs on a given number of devices.
  • Search: an algorithm to find the best distributed version of a given sequential DistIR function. Initially, this can be something that searches the DHP space (i.e. find the optimal parameters to give the D/H/P transforms).

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Trademarks: This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.