# microsoft/mira architecture

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

- Interactive diagram: https://gitdiagram.com/microsoft/mira
- Repository: https://github.com/microsoft/mira

## Overview

MIRA is a medical time-series foundation model whose main workflow loads clinical sequences and timestamps, trains a time-aware model, and uses autoregressive or continuous-time forecasting for zero-shot evaluation. The repository also supports several dataset encodings and windowed/time-aware datasets. The graph preserves the documented CT-RoPE, frequency-specialized MoE, and neural ODE capabilities. Some dataset and evaluation modules were not excerpted, so their internal calls are not inferred.

Main entry points: [`MIRA/models/modeling_mira.py`](https://github.com/microsoft/mira/blob/main/MIRA/models/modeling_mira.py) (MIRA model), [`MIRA/datasets/mira_dataset.py`](https://github.com/microsoft/mira/blob/main/MIRA/datasets/mira_dataset.py) (Dataset aggregator), [`MIRA/datasets/general_dataset.py`](https://github.com/microsoft/mira/blob/main/MIRA/datasets/general_dataset.py) (File datasets), [`MIRA/datasets/binary_dataset.py`](https://github.com/microsoft/mira/blob/main/MIRA/datasets/binary_dataset.py) (Binary dataset)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Clinical data"]
  node_dataset["Dataset aggregator<br/>[mira_dataset.py]"]
  node_general["File datasets<br/>[general_dataset.py]"]
  node_binary["Binary dataset<br/>[binary_dataset.py]"]
  node_timeseries["Dataset interface<br/>[ts_dataset.py]"]
  node_timeaware["Time-aware data"]
  node_windows["Window datasets"]
  node_benchmark["Benchmark data"]
  node_timeutils["Time utilities<br/>[time_utils.py]"]
end

subgraph group_training["Training"]
  node_main["Training CLI<br/>[main.py]"]
  node_runner["Training runner<br/>[runner.py]"]
  node_trainer["HF trainer<br/>[hf_trainer.py]"]
end

subgraph group_model["Forecast model"]
  node_config["Model configuration"]
  node_model["MIRA model<br/>[modeling_mira.py]"]
  node_generation["Generation mixin"]
  node_normalization["Time normalization"]
end

subgraph group_evaluation["Inference and evaluation"]
  node_inference["Autoregressive inference<br/>[mira_inference.py]"]
  node_eval["Evaluation CLI<br/>[model_eval.py]"]
  node_evalrun["Evaluation runner<br/>[run_eval.py]"]
end

node_user(("Researcher"))

node_user -->|"starts training"| node_main
node_main -->|"configures"| node_runner
node_runner -->|"loads time-aware data"| node_timeaware
node_dataset -->|"selects"| node_binary
node_dataset -->|"selects"| node_general
node_dataset -->|"loads JSONL"| node_timeaware
node_binary -->|"implements"| node_timeseries
node_general -->|"implements"| node_timeseries
node_config -->|"configures"| node_model
node_model -->|"uses"| node_generation
node_model -->|"uses"| node_normalization
node_user -->|"runs forecasts"| node_inference
node_inference -->|"calls"| node_model
node_user -->|"runs evaluation"| node_eval

click node_main "https://github.com/microsoft/mira/blob/main/main.py"
click node_runner "https://github.com/microsoft/mira/blob/main/MIRA/runner.py"
click node_dataset "https://github.com/microsoft/mira/blob/main/MIRA/datasets/mira_dataset.py"
click node_general "https://github.com/microsoft/mira/blob/main/MIRA/datasets/general_dataset.py"
click node_binary "https://github.com/microsoft/mira/blob/main/MIRA/datasets/binary_dataset.py"
click node_timeseries "https://github.com/microsoft/mira/blob/main/MIRA/datasets/ts_dataset.py"
click node_timeaware "https://github.com/microsoft/mira/blob/main/MIRA/datasets/timeawared_dataset.py"
click node_windows "https://github.com/microsoft/mira/blob/main/MIRA/datasets/mira_window_dataset.py"
click node_benchmark "https://github.com/microsoft/mira/blob/main/MIRA/datasets/benchmark_dataset.py"
click node_timeutils "https://github.com/microsoft/mira/blob/main/MIRA/datasets/time_utils.py"
click node_config "https://github.com/microsoft/mira/blob/main/MIRA/models/configuration_mira.py"
click node_model "https://github.com/microsoft/mira/blob/main/MIRA/models/modeling_mira.py"
click node_generation "https://github.com/microsoft/mira/blob/main/MIRA/models/ts_generation_mixin.py"
click node_normalization "https://github.com/microsoft/mira/blob/main/MIRA/models/utils_time_normalization.py"
click node_trainer "https://github.com/microsoft/mira/blob/main/MIRA/trainer/hf_trainer.py"
click node_inference "https://github.com/microsoft/mira/blob/main/MIRA/models/mira_inference.py"
click node_eval "https://github.com/microsoft/mira/blob/main/model_eval.py"
click node_evalrun "https://github.com/microsoft/mira/blob/main/run_eval.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_dataset,node_general,node_binary,node_timeseries,node_timeaware,node_windows,node_benchmark,node_timeutils toneBlue
class node_main,node_runner,node_trainer toneAmber
class node_config,node_model,node_generation,node_normalization toneMint
class node_inference,node_eval,node_evalrun toneRose
class node_user toneIndigo
```

## Components

### Clinical data

- [Dataset aggregator](https://github.com/microsoft/mira/blob/main/MIRA/datasets/mira_dataset.py): `MIRA/datasets/mira_dataset.py`
- [File datasets](https://github.com/microsoft/mira/blob/main/MIRA/datasets/general_dataset.py): `MIRA/datasets/general_dataset.py`
- [Binary dataset](https://github.com/microsoft/mira/blob/main/MIRA/datasets/binary_dataset.py): `MIRA/datasets/binary_dataset.py`
- [Dataset interface](https://github.com/microsoft/mira/blob/main/MIRA/datasets/ts_dataset.py): `MIRA/datasets/ts_dataset.py`
- [Time-aware data](https://github.com/microsoft/mira/blob/main/MIRA/datasets/timeawared_dataset.py): `MIRA/datasets/timeawared_dataset.py`
- [Window datasets](https://github.com/microsoft/mira/blob/main/MIRA/datasets/mira_window_dataset.py): `MIRA/datasets/mira_window_dataset.py`
- [Benchmark data](https://github.com/microsoft/mira/blob/main/MIRA/datasets/benchmark_dataset.py): `MIRA/datasets/benchmark_dataset.py`
- [Time utilities](https://github.com/microsoft/mira/blob/main/MIRA/datasets/time_utils.py): `MIRA/datasets/time_utils.py`

### Training

- [Training CLI](https://github.com/microsoft/mira/blob/main/main.py): `main.py`
- [Training runner](https://github.com/microsoft/mira/blob/main/MIRA/runner.py): `MIRA/runner.py`
- [HF trainer](https://github.com/microsoft/mira/blob/main/MIRA/trainer/hf_trainer.py): `MIRA/trainer/hf_trainer.py`

### Forecast model

- [Model configuration](https://github.com/microsoft/mira/blob/main/MIRA/models/configuration_mira.py): `MIRA/models/configuration_mira.py`
- [MIRA model](https://github.com/microsoft/mira/blob/main/MIRA/models/modeling_mira.py): `MIRA/models/modeling_mira.py`
- [Generation mixin](https://github.com/microsoft/mira/blob/main/MIRA/models/ts_generation_mixin.py): `MIRA/models/ts_generation_mixin.py`
- [Time normalization](https://github.com/microsoft/mira/blob/main/MIRA/models/utils_time_normalization.py): `MIRA/models/utils_time_normalization.py`

### Inference and evaluation

- [Autoregressive inference](https://github.com/microsoft/mira/blob/main/MIRA/models/mira_inference.py): `MIRA/models/mira_inference.py`
- [Evaluation CLI](https://github.com/microsoft/mira/blob/main/model_eval.py): `model_eval.py`
- [Evaluation runner](https://github.com/microsoft/mira/blob/main/run_eval.py): `run_eval.py`

### Other components

- **Researcher**

## Connections

- Researcher → Training CLI: starts training (evidence: `README.md`)
- Training CLI → Training runner: configures (evidence: `main.py`)
- Training runner → Time-aware data: loads time-aware data (evidence: `MIRA/runner.py`)
- Dataset aggregator → Binary dataset: selects (evidence: `MIRA/datasets/mira_dataset.py`)
- Dataset aggregator → File datasets: selects (evidence: `MIRA/datasets/mira_dataset.py`)
- Dataset aggregator → Time-aware data: loads JSONL (evidence: `MIRA/datasets/mira_dataset.py`)
- Binary dataset → Dataset interface: implements (evidence: `MIRA/datasets/binary_dataset.py`)
- File datasets → Dataset interface: implements (evidence: `MIRA/datasets/general_dataset.py`)
- Model configuration → MIRA model: configures (evidence: `MIRA/models/modeling_mira.py`)
- MIRA model → Generation mixin: uses (evidence: `MIRA/models/modeling_mira.py`)
- MIRA model → Time normalization: uses (evidence: `MIRA/models/modeling_mira.py`)
- Researcher → Autoregressive inference: runs forecasts (evidence: `README.md`)
- Autoregressive inference → MIRA model: calls (evidence: `MIRA/models/mira_inference.py`)
- Researcher → Evaluation CLI: runs evaluation (evidence: `README.md`)
