liaogx_/toto-2.0-4m
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Toto-2.0-4m on Ascend NPU

Datadog Toto-2.0-4m is the 4M-parameter member of the Toto 2.0 family of time-series foundation models for multivariate forecasting (technical report: arXiv:2605.20119, TIME benchmark: arXiv:2602.12147). It is a u-μP-scaled decoder-only patched transformer with alternating time-axis (causal) and variate-axis (full) attention, a quantile output head (9 knots 0.1…0.9 trained with pinball loss), contiguous patch masking (CPM) for single-pass parallel decoding, a robust arcsinh input scaler and a residual MLP patch projection.

This adaptation deploys the model for service-based probabilistic forecasting on an Ascend 910 NPU via torch_npu. vLLM-Ascend 0.18 does not support this custom time-series architecture, so the standalone Toto2Model (from DataDog/toto, vendored) is used as-is on torch_npu — zero source modification to the model; only the GluonTS wrapper was stripped from the vendored package.

Model

AttributeValue
Parameters4M (fp32 safetensors 15.8 MB)
Architecturedecoder-only transformer, d_model=256, num_layers=4, num_heads=4, num_groups=4, qk_dim/v_dim=64, d_ff=688, patch_size=32, xPos RoPE, SwiGLU MLP, τ-rule residual, MuP (per-dim scale)
Attentiontime/variate alternating groups (layer_group_size=4, last layer = variate)
Output9 quantiles [0.1 … 0.9], shape [9, batch, n_variate, horizon]
Taskzero-shot multivariate time-series forecasting (observability / GIFT-Eval / TIME)

Environment

  • Ascend 910 ×2 (64 GB HBM/card), CANN 8.5.1
  • Python 3.11, torch 2.9.0 + torch-npu 2.9.0.post1
  • unit-scaling==0.3.5 (PyPI) + vendored dd_unit_scaling + vendored toto2 (GluonTS-stripped)
  • fastapi / uvicorn / pydantic

Quick start

# 1. download weights (ModelScope, sha256-verified)
python3 download_model.py

# 2. generate a demo test series
python3 make_test_data.py

# 3. run a one-shot forecast on NPU
python3 inference.py --device npu:1 --num-variates 3 --time-steps 1024 --prediction-length 96

# 4. start the HTTP service (default port 8041, device npu:1)
./start_serve.sh 8041 npu:1

Service API

POST /v1/forecast

{
  "series": [[1.0, 2.0, ...], [...], ...],   // [variate, time_steps]; 1D also ok
  "prediction_length": 96,
  "decode_block_size": 768,
  "has_missing_values": true
}

Response:

{
  "quantiles": {"0.1": [[...], ...], ..., "0.9": [[...], ...]},
  "median": [[...], ...],
  "shape": [n_variate, horizon],
  "prediction_length": 96,
  "latency_ms": 23.4
}

Performance (Ascend 910, npu:1)

Configp50 latency
3v / ctx 1024 / pred 9623.4 ms
1v / ctx 512 / pred 9622.8 ms
7v / ctx 4096 / pred 33623.9 ms
3v / ctx 1024 / pred 102448.2 ms
3v / ctx 512 / pred 9623.8 ms
  • Process HBM: 237 MB (model weights only 15.8 MB)
  • Numerical agreement (NPU vs CPU): max_abs_diff ≤ 5.5e-05, cosine ≥ 0.9999999, corr = 1.0

Repository structure

├── assets/                    # Screenshot materials (user uploads actual screenshots)
│   ├── adaptation-workflow.txt
│   ├── adaptation-result.txt
│   └── npu-smi.txt
├── toto2/                     # Vendored Toto2Model (GluonTS-stripped)
├── dd_unit_scaling/           # Vendored dd_unit_scaling
├── patches/
│   └── toto2_ascend_npu.patch
├── inference.py               # Inference engine (torch_npu)
├── server.py                  # FastAPI HTTP service
├── download_model.py          # ModelScope download + sha256 verification
├── make_test_data.py          # Synthetic test data generator
├── verify_npu_vs_cpu.py       # Numerical correctness verification
├── test_server.py             # HTTP service test
├── start_serve.sh             # One-click service launcher
├── readme.md                  # This file
├── requirements.txt
├── .gitignore
└── .gitattributes

Files

  • inference.py: Loads Toto2Model from local checkpoint, builds forecast inputs, runs 9-quantile probabilistic forecast
  • server.py: FastAPI /v1/forecast endpoint with CPM block decoding and KV cache
  • download_model.py: Fetches weights from ModelScope with sha256 verification
  • verify_npu_vs_cpu.py: Compares NPU and CPU forecasts (all quantiles) for numerical agreement