z
zhangyuge147/Datadog-Toto-2.0-313m-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Datadog/Toto-2.0-313m NPU

#NPU

Model: Datadog/Toto-2.0-313m | Revision: a7bab288f5e95f8606f8306f86659357e1c001ef | Type: model | Hardware: Ascend 910 (NPU) | Task: Time-Series Forecasting (Probabilistic Quantiles)

Toto 2.0 is a family of time-series foundation models for multivariate forecasting developed by Datadog. The 313M checkpoint is a decoder-only patched transformer with u-μP scaling, alternating time/variate attention, contiguous patch masking (CPM) and a quantile output head (9 quantiles: 0.1..0.9, pinball loss). This port runs the original 313M weights directly on single npu:0 with synchronized timing and validated CPU–NPU numerical consistency.

Model & Task Contract

ItemValue
ArchitectureToto2 transformer, d_model=1024, num_layers=24, num_heads=16, patch_size=32, d_ff=2736, residual_mult=0.75, use_xpos=true
Params312.7M, dtype float32, weights model.safetensors (1.2 GB)
TaskProbabilistic forecasting, pipeline_tag: time-series-forecasting
Input[batch, variates, time] — e.g. [1,2,512] (example below); target_mask bool, series_ids long
OutputQuantiles tensor [Q=9, batch, variates, horizon] — levels [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]
Context / HorizonContext 512, Horizon 96 (configurable), Patch 32, decode_block_size 768 (3*256)
Frequency / ScalingFrequency-agnostic; internal PatchedCausalStdScaler (patch-aware causal mean/std, patch_size=32)
PreprocessingNo column reorder; missing values masked via target_mask; arcsinh not applied in inference scaler

Data contract for this validation: synthetic observability-like series (sine+trend+noise) sampled at 512 steps, seed 42, same preprocessing on CPU and NPU. See inference.py for exact generation.

Environment

  • NPU: Ascend910_9362, 2 devices, tested on npu:0 (torch.npu.is_available()==True)
  • Software: Python 3.11.14, torch 2.9.0+cpu, torch_npu 2.9.0.post1, transformers 4.57.6, gluonts 0.17.0, einops 0.8.2, dd-unit-scaling 0.1.0, CANN 8.5.1
  • Weights: model.safetensors + config.json from Datadog/Toto-2.0-313m (local load, no implicit download at inference)
npu-smi info
| NPU 3 Ascend910 | OK | 169W 45C | chip 0, phy 6 | 0% | 3108/65536 MB |
| NPU 3 Ascend910 | OK | -   43C | chip 1, phy 7 | 0% | 2870/65536 MB |

Installation

pip install -r requirements.txt
# If toto2 source not installed, clone and install (requires python>=3.12 upstream, use --ignore-requires-python on 3.11):
# git clone https://github.com/DataDog/toto.git && pip install --no-build-isolation --ignore-requires-python -e toto/dd_unit_scaling -e toto/toto2
pip install --no-build-isolation --ignore-requires-python -e /tmp/toto-main/dd_unit_scaling -e /tmp/toto-main/toto2  # as done on this pod

Weights must be present locally at /opt/atomgit/adapt-npu-agent/workspace_npu/models/Datadog-Toto-2.0-313m or Datadog/Toto-2.0-313m via HF cache. inference.py checks these paths in order and falls back to HF Hub id if needed.

NPU Inference

Default command (real NPU path, synchronized):

python inference.py

Expected output (truncated):

[INFO] Model: Datadog/Toto-2.0-313m
[INFO] torch_npu available: True
[INFO] NPU device: Ascend910_9362, count: 2
[INFO] Selected device: npu:0
[INFO] Model loaded: d_model=1024, layers=24, patch=32
[INFO] Params: 312.7M
[INFO] First param device: npu:0
[INFO] Input: shape [1, 2, 512] [batch, variates, time], context=512, horizon=96
[RESULT] Output shape: [9, 1, 2, 96] [quantiles, batch, variates, horizon]
[RESULT] Elapsed: ~114 ms (synchronized, stable)
[RESULT] Quantiles variate0 t0: [9.78, 10.02, 10.19, 10.31, 10.42, 10.56, 10.69, 10.85, 11.05]
[RESULT] Median variate0 first5: [10.42, 10.94, 11.45, 11.94, 12.39]
[DONE] NPU inference succeeded

The script explicitly moves model and all tensors to npu:0, calls torch.npu.synchronize() before/after timing, and exits non-zero on error.

Real Results (This Pod)

Inputs: batch=1, variates=2, time=512, horizon=96, seed 42, synthetic sine+trend series.

DeviceShapeFirst-run (compile)StableFiniteMonotonicSample q50 v0 t0Mean
CPU[9,1,2,96]~1502 ms~1500 ms✓✓10.4296565.637
NPU npu:0[9,1,2,96]346.8 ms113.7 ms avg✓✓10.4296515.637

NPU stable timings (10 runs, synchronized): avg 113.7 ms, min 112.7, max 114.5, p50 113.7, p90 114.4, p95 114.4 — 8.8 windows/s, batch=1.

Consistency — CPU vs NPU

Same weights (a7bab288), same input, same float32, same decode_block_size=768, seed 42:

python scripts/compare_outputs.py --cpu cpu_final.npy --npu npu_final.npy --task forecasting --atol 1e-4 --rtol 1e-3
{
  "task": "forecasting",
  "cpu_shape": [9,1,2,96], "npu_shape": [9,1,2,96],
  "finite": true,
  "max_abs_error": 5.34e-05,
  "mean_abs_error": 7.95e-06,
  "passed": true
}

Individual checks: quantiles sorted along dim 0 (diff >= -1e-6), correlation of median forecast = 1.0000, all values finite. Threshold atol=1e-4, rtol=1e-3 (float32). Smoke consistency on single synthetic window; not a full benchmark ranking.

Performance (NPU npu:0, Synchronized)

MetricValue
First run (incl. compile)346.8 ms
Stable avg (10 runs)113.7 ms
min / max / p50 / p90 / p95112.7 / 114.5 / 113.7 / 114.4 / 114.4 ms
Throughput8.8 windows/s (batch=1, horizon=96, context=512)
Peak Memory (NPU)allocated 1330.7 MB, max 1363.2 MB
Batch / Shapebatch=1, variates=2, context=512, horizon=96, dtype float32
Preprocessing incl.No (pure model forward)

Timing measured with torch.npu.synchronize() before/after each run; 3 warmup + 10 measured.

Evidence

Three xterm.js-rendered PNGs exported from real pod logs (prompt atomgit@pod-a94f8701860f4700b161b00e290de466:~$ is display-only):

  • assets/agent_workflow.png — full workflow (env check → model inspection → CPU baseline → NPU run → comparison)
  • assets/npu_device_call.png — NPU device proof (torch.npu.is_available, device_name, npu:0 move, first param device)
  • assets/model_result.png — default python inference.py stdout on NPU with real quantiles

agent workflow npu device call model result

Limitations

  • Single-window smoke consistency; not BOOM/GIFT-Eval/ TIME full benchmark.
  • decode_block_size must be divisible by patch_size=32 (asserted in model).
  • Horizon truncation: when horizon not divisible by patch_size, tail is sliced correctly.
  • float64 scaler on CPU falls back to float32 on NPU ( Device do not support double warning) — negligible error (~5e-05) on realistic series; synthetic low-variance random input may show larger drift.
  • Model is inference-only; no training/fine-tuning on NPU demonstrated.
  • Single NPU npu:0 only; multi-NPU sharding not evaluated.

License

Model weights: Apache-2.0 (Datadog). Code: Apache-2.0.