MindStudio-Modeling:基于 PyTorch 的神经网络推理性能模拟分析框架

MindStudio-Modeling(msmodeling)是MindStudio建模寻优工具,评估模型及服务化等场景下的理论性能,并在此基础上寻找性能较优的部署策略等参数。

Branch6Tags68

MindStudio Modeling

MindStudio-Modeling is a performance simulation and analysis framework for neural network inference workloads, consisting of two core components for predicting and optimizing model performance on target hardware:

  1. TensorCast

    • Core Purpose: A PyTorch program performance simulator, functioning as a "virtual machine."
    • Main Function: Intercepts a model's PyTorch computational graph and simulates its execution on a user-defined hardware profile (DeviceProfile) without requiring physical hardware.
    • Supported Tasks:
      • Text Generation: Simulates Large Language Model (LLM) inference (e.g., Qwen) via cli.inference.text_generate.
      • Video Generation: Simulates the forward pass of diffusion transformer models (e.g., Stable Video Diffusion-like architectures) via cli.inference.video_generate.
    • Output: Provides operator-level performance breakdown, memory footprint analysis, FLOPs analysis, and can generate Chrome Trace files for visualization.
  2. ServingCast

    • Core Purpose: A suite of tools for system-level inference serving simulation and throughput optimization.
    • Main Function:
      • Service Simulation: Driven by main.py, it simulates end-to-end serving scenarios with multiple instances and requests based on YAML configuration files, outputting system-level metrics like throughput, latency (TTFT, TPOT).
      • Throughput Optimization: Via cli.inference.throughput_optimizer.py, it automatically searches for the optimal model configuration (parallelism strategy, batch size) to maximize token throughput under specified Service Level Objective (SLO) constraints (e.g., limits on TTFT, TPOT). Supports benchmarking multiple --device profiles with cross-hardware comparison tables and terminal ASCII sweep curves for single-device analysis.

Core Value: It enables developers to predict model performance, identify bottlenecks, and optimize configurations for target hardware without needing access to the physical devices.

Installation

Supported Python versions: 3.10+

Warning

If you are using Windows, note that PyTorch 2.10 may not run properly on your system. For a solution, please refer to this issue. If you have not yet installed PyTorch, for optimal compatibility, we strongly recommend using version 2.8 or earlier to ensure the program functions correctly.

git clone https://gitcode.com/Ascend/msmodeling.git -b develop
cd msmodeling

pip install uv
uv venv --python 3.13 .venv

# Linux or macOS
source .venv/bin/activate
# Windows
# .venv\Scripts\activate

uv sync
# optional: uv sync --group lint / uv sync --group ci

Use uv run … or an activated venv to run commands. Scripts under scripts/ auto-detect uv when pyproject.toml is present.

Alternative: pip + requirements.txt

git clone https://gitcode.com/Ascend/msmodeling.git -b develop
cd msmodeling

python -m venv .venv
source .venv/bin/activate   # adjust for Windows

pip install "torch>=2.7,<=2.10" --index-url https://download.pytorch.org/whl/cpu
pip install -r requirements.txt

See comments at the top of requirements.txt for the CPU PyTorch step.

Environment Setup

If you are not using the tools within the msmodeling directory, please set the PYTHONPATH before running:

export PYTHONPATH=/path/to/msmodeling:$PYTHONPATH

Warning

When the tool is running, it will read the model configuration file from Hugging Face. Please ensure that your device can access Hugging Face. Or you can set: export HF_ENDPOINT="https://hf-mirror.com"

Getting Started

For detailed usage, please refer to the two documentation files:

Contributions

Coding style

Use pre-commit to make sure the coding style aligns:

uv sync --group lint
uv run pre-commit install   # run once

Later commits will be checked by pre-commit automatically.

Unit tests

cd /path/to/msmodeling
uv sync

Make sure unit tests pass by running: bash ./tests/run_ut.sh tensor_cast or bash ./tests/run_ut.sh serving_cast. Please ensure that the ut coverage rate of the newly added code is greater than 80%

Suggestions & Community

We welcome everyone to contribute to the community. If you have any questions or suggestions, please submit an Issue and we will respond as soon as possible. Thank you for your support.

Technical Chat Groups Official Account More Ways to Connect

Scan to join the technical chat

Scan to follow for the latest updates
Scan the codes to join our technical chat and follow our official account—the fastest way for MindStudio users and developers to connect:
Quick Q&A: Discuss technical issues instantly with community members
Stay Updated: Be the first to receive notifications on version releases and feature updates
Knowledge Sharing: Exchange best practices with fellow developers
🛠️ Other Channels:
Ascend Assistant:WeChat
Ascend Forum:Website

Weekly Meeting

About the MindStudio Team

The Huawei MindStudio end-to-end development toolchain team is dedicated to providing comprehensive Ascend AI application development solutions, empowering developers to efficiently complete training development, inference development, and operator development.

License

msmodeling has a MulanPSL2-style license, as found in the LICENSE file.

Introduction

MindStudio-Modeling(msmodeling)是MindStudio建模寻优工具,评估模型及服务化等场景下的理论性能,并在此基础上寻找性能较优的部署策略等参数。

Customize your domain