# mindspore-ai/hyper-parallel architecture

> Architecture diagram of the GitHub repository mindspore-ai/hyper-parallel, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mindspore-ai/hyper-parallel
- Repository: https://github.com/mindspore-ai/hyper-parallel

## Overview

HyperParallel is a distributed training and execution framework for Ascend supernodes. Its main user workflow is to configure a Hugging Face model and training run, apply model-specific parallelization and graph transformations, execute training using composed distributed and memory-management capabilities, and persist or restore distributed state. Separate subsystems support automatic parallel planning, pipeline balancing, checkpoint conversion, inference, and reinforcement-learning rollout. The README documents the major capabilities; sampled source and the SOURCE INDEX substantiate several internal calls, but do not expose the complete training runtime wiring.

Main entry points: [`hyper_parallel/trainer/base.py`](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/trainer/base.py) (Training runtime), [`hyper_parallel/auto_parallel/sapp_ppb/sapp/sapp_pipeline.py`](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/auto_parallel/sapp_ppb/sapp/sapp_pipeline.py) (Pipeline balancing), [`hyper_parallel/core/distributed_checkpoint/filesystem_storage.py`](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/core/distributed_checkpoint/filesystem_storage.py) (Distributed checkpoint), [`hyper_parallel/trainer/config/parser.py`](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/trainer/config/parser.py) (Trainer config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Model training"]
  node_trainer_config["Trainer config<br/>[parser.py]"]
  node_codegen["Model codegen<br/>[manager.py]"]
  node_inline["Inline patching<br/>[pipeline.py]"]
  node_compiler["Graph compiler<br/>[pipeline.py]"]
  node_trainer["Training runtime<br/>[base.py]"]
end

subgraph group_parallel["Parallel execution"]
  node_dtensor["DeviceMesh and DTensor<br/>[placement_types.py]"]
  node_fully_shard["FSDP / HSDP<br/>[api.py]"]
  node_context_parallel["Context parallel"]
  node_expert_parallel["Expert parallel<br/>[expert_parallel.py]"]
  node_pipeline_parallel["Pipeline parallel<br/>[pipeline_swap.py]"]
  node_multicore["Multicore MoE<br/>[module.py]"]
  node_activation_memory["Activation memory<br/>[api.py]"]
end

subgraph group_planning["Automatic planning"]
  node_auto_parallel["ND auto parallel<br/>[parallelize.py]"]
  node_memory_estimation["Memory estimation<br/>[_context.py]"]
  node_pipeline_balancer["Pipeline balancing<br/>[sapp_pipeline.py]"]
  node_pipeline_solver["Balance solver<br/>[sapp_solver.py]"]
  node_pipeline_simulator["Pipeline simulator<br/>[sim_block.py]"]
end

subgraph group_state["State and integration"]
  node_checkpoint[("Distributed checkpoint")]
  node_checkpoint_components["Checkpoint conversion"]
  node_optimizer["Optimizer components<br/>[builders.py]"]
end

subgraph group_runtime["Model runtime"]
  node_inference["Generation and KV cache<br/>[generation.py]"]
  node_rl_rollout["RL rollout worker<br/>[worker.py]"]
  node_weight_sync["Rollout weight sync<br/>[vllm_worker.py]"]
end

node_user(("Training user"))
node_vllm(("vLLM service"))

node_user -->|"configures"| node_trainer_config
node_trainer_config -.->|"starts training"| node_trainer
node_trainer -.->|"prepares model"| node_codegen
node_codegen -->|"renders patches"| node_inline
node_trainer -.->|"transforms graph"| node_compiler
node_trainer -->|"uses optimizer"| node_optimizer
node_trainer -->|"saves state"| node_checkpoint
node_trainer -->|"distributes tensors"| node_dtensor
node_dtensor -->|"defines layouts"| node_fully_shard
node_trainer -->|"applies parallelism"| node_context_parallel
node_trainer -->|"applies parallelism"| node_expert_parallel
node_trainer -->|"schedules stages"| node_pipeline_parallel
node_trainer -->|"dispatches MoE"| node_multicore
node_trainer -->|"manages activations"| node_activation_memory
node_user -->|"requests planning"| node_auto_parallel
node_auto_parallel -.->|"estimates memory"| node_memory_estimation
node_user -->|"requests balancing"| node_pipeline_balancer
node_pipeline_balancer -->|"solves balance"| node_pipeline_solver
node_pipeline_balancer -->|"simulates schedule"| node_pipeline_simulator
node_pipeline_balancer -.->|"persists state"| node_checkpoint
node_user -.->|"requests generation"| node_inference
node_user -.->|"starts rollout"| node_rl_rollout
node_rl_rollout -.->|"synchronizes weights"| node_weight_sync
node_weight_sync -.->|"updates parameters"| node_vllm
node_checkpoint -.->|"converts weights"| node_checkpoint_components

click node_trainer_config "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/trainer/config/parser.py"
click node_codegen "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/codegen/manager.py"
click node_inline "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/codegen/inline/pipeline.py"
click node_compiler "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/compile/passes/pipeline.py"
click node_trainer "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/trainer/base.py"
click node_dtensor "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/core/dtensor/placement_types.py"
click node_fully_shard "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/core/fully_shard/api.py"
click node_context_parallel "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/core/context_parallel/context_parallel.py"
click node_expert_parallel "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/core/expert_parallel/expert_parallel.py"
click node_pipeline_parallel "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/core/pipeline_parallel/pipeline_swap.py"
click node_multicore "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/core/multicore/modules/mega_moe/module.py"
click node_activation_memory "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/core/activation_memory/api.py"
click node_auto_parallel "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/auto_parallel/sapp_nd/nd/parallelize.py"
click node_memory_estimation "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/auto_parallel/sapp_nd/memory_estimation/_context.py"
click node_pipeline_balancer "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/auto_parallel/sapp_ppb/sapp/sapp_pipeline.py"
click node_pipeline_solver "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/auto_parallel/sapp_ppb/sapp/sapp_solver.py"
click node_pipeline_simulator "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/auto_parallel/sapp_ppb/simulator/sim_block.py"
click node_checkpoint "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/core/distributed_checkpoint/filesystem_storage.py"
click node_checkpoint_components "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/components/checkpoint/weight_conversion.py"
click node_optimizer "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/components/optim/builders.py"
click node_inference "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/infer/generation.py"
click node_rl_rollout "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/rl/rl/roles/rollout/worker.py"
click node_weight_sync "https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/rl/rl/weight_sync/vllm_worker.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_trainer_config,node_codegen,node_inline,node_compiler,node_trainer,node_user toneBlue
class node_dtensor,node_fully_shard,node_context_parallel,node_expert_parallel,node_pipeline_parallel,node_multicore,node_activation_memory toneAmber
class node_auto_parallel,node_memory_estimation,node_pipeline_balancer,node_pipeline_solver,node_pipeline_simulator toneMint
class node_checkpoint,node_checkpoint_components,node_optimizer toneRose
class node_inference,node_rl_rollout,node_weight_sync,node_vllm toneIndigo
```

## Components

### Model training

- [Trainer config](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/trainer/config/parser.py): `hyper_parallel/trainer/config/parser.py`
- [Model codegen](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/codegen/manager.py): `hyper_parallel/codegen/manager.py`
- [Inline patching](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/codegen/inline/pipeline.py): `hyper_parallel/codegen/inline/pipeline.py`
- [Graph compiler](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/compile/passes/pipeline.py): `hyper_parallel/compile/passes/pipeline.py`
- [Training runtime](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/trainer/base.py): `hyper_parallel/trainer/base.py`

### Parallel execution

- [DeviceMesh and DTensor](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/core/dtensor/placement_types.py): `hyper_parallel/core/dtensor/placement_types.py`
- [FSDP / HSDP](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/core/fully_shard/api.py): `hyper_parallel/core/fully_shard/api.py`
- [Context parallel](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/core/context_parallel/context_parallel.py): `hyper_parallel/core/context_parallel/context_parallel.py`
- [Expert parallel](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/core/expert_parallel/expert_parallel.py): `hyper_parallel/core/expert_parallel/expert_parallel.py`
- [Pipeline parallel](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/core/pipeline_parallel/pipeline_swap.py): `hyper_parallel/core/pipeline_parallel/pipeline_swap.py`
- [Multicore MoE](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/core/multicore/modules/mega_moe/module.py): `hyper_parallel/core/multicore/modules/mega_moe/module.py`
- [Activation memory](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/core/activation_memory/api.py): `hyper_parallel/core/activation_memory/api.py`

### Automatic planning

- [ND auto parallel](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/auto_parallel/sapp_nd/nd/parallelize.py): `hyper_parallel/auto_parallel/sapp_nd/nd/parallelize.py`
- [Memory estimation](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/auto_parallel/sapp_nd/memory_estimation/_context.py): `hyper_parallel/auto_parallel/sapp_nd/memory_estimation/_context.py`
- [Pipeline balancing](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/auto_parallel/sapp_ppb/sapp/sapp_pipeline.py): `hyper_parallel/auto_parallel/sapp_ppb/sapp/sapp_pipeline.py`
- [Balance solver](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/auto_parallel/sapp_ppb/sapp/sapp_solver.py): `hyper_parallel/auto_parallel/sapp_ppb/sapp/sapp_solver.py`
- [Pipeline simulator](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/auto_parallel/sapp_ppb/simulator/sim_block.py): `hyper_parallel/auto_parallel/sapp_ppb/simulator/sim_block.py`

### State and integration

- [Distributed checkpoint](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/core/distributed_checkpoint/filesystem_storage.py): `hyper_parallel/core/distributed_checkpoint/filesystem_storage.py`
- [Checkpoint conversion](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/components/checkpoint/weight_conversion.py): `hyper_parallel/components/checkpoint/weight_conversion.py`
- [Optimizer components](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/components/optim/builders.py): `hyper_parallel/components/optim/builders.py`

### Model runtime

- [Generation and KV cache](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/infer/generation.py): `hyper_parallel/infer/generation.py`
- [RL rollout worker](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/rl/rl/roles/rollout/worker.py): `hyper_parallel/rl/rl/roles/rollout/worker.py`
- [Rollout weight sync](https://github.com/mindspore-ai/hyper-parallel/blob/master/hyper_parallel/rl/rl/weight_sync/vllm_worker.py): `hyper_parallel/rl/rl/weight_sync/vllm_worker.py`

### Other components

- **Training user**
- **vLLM service**

## Connections

- Training user → Trainer config: configures (evidence: `README.md`)
- Trainer config → Training runtime: starts training
- Training runtime → Model codegen: prepares model
- Model codegen → Inline patching: renders patches (evidence: `hyper_parallel/codegen/manager.py`)
- Training runtime → Graph compiler: transforms graph
- Training runtime → Optimizer components: uses optimizer (evidence: `README.md`)
- Training runtime → Distributed checkpoint: saves state (evidence: `README.md`)
- Training runtime → DeviceMesh and DTensor: distributes tensors (evidence: `README.md`)
- DeviceMesh and DTensor → FSDP / HSDP: defines layouts (evidence: `README.md`)
- Training runtime → Context parallel: applies parallelism (evidence: `README.md`)
- Training runtime → Expert parallel: applies parallelism (evidence: `README.md`)
- Training runtime → Pipeline parallel: schedules stages (evidence: `README.md`)
- Training runtime → Multicore MoE: dispatches MoE (evidence: `README.md`)
- Training runtime → Activation memory: manages activations (evidence: `README.md`)
- Training user → ND auto parallel: requests planning (evidence: `README.md`)
- ND auto parallel → Memory estimation: estimates memory
- Training user → Pipeline balancing: requests balancing
- Pipeline balancing → Balance solver: solves balance (evidence: `hyper_parallel/auto_parallel/sapp_ppb/sapp/sapp_pipeline.py`)
- Pipeline balancing → Pipeline simulator: simulates schedule (evidence: `hyper_parallel/auto_parallel/sapp_ppb/sapp/sapp_pipeline.py`)
- Pipeline balancing → Distributed checkpoint: persists state
- Training user → Generation and KV cache: requests generation
- Training user → RL rollout worker: starts rollout
- RL rollout worker → Rollout weight sync: synchronizes weights
- Rollout weight sync → vLLM service: updates parameters
- Distributed checkpoint → Checkpoint conversion: converts weights
