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

Datadog/Toto-2.0-1B NPU

#NPU

Model: Datadog/Toto-2.0-1B | Revision: 1604e1a5242884fb9848f88c4ced14f4dc62d9d3 | 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 1B 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 1B weights directly on single npu:0 with synchronized timing and validated CPU–NPU numerical consistency.

Model & Task Contract

ItemValue
ArchitectureToto2 transformer, d_model=1536, num_layers=36, num_heads=24, d_ff=4096, patch_size=32, v_dim=64, qk_dim=64, use_xpos=true
Params1041.0M, dtype float32, weights model.safetensors (3.9 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
Frequency / ScalingFrequency-agnostic; internal CausalPatchStdMeanScaler (patch-aware causal mean/std, patch_size=32)
PreprocessingNo column reorder; missing values masked via target_mask

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, gluonts 0.17.0, einops 0.8.2, dd-unit-scaling 0.1.0, unit_scaling 0.3.5, CANN 8.5.1
  • Weights: model.safetensors + config.json from Datadog/Toto-2.0-1B (local load, no implicit download at inference)
npu-smi info
| NPU 0 Ascend910 | OK | 167W 46C | chip 0, phy 0 | 0% | 3111/65536 MB |
| NPU 1 Ascend910 | OK | -   45C | chip 1, phy 1 | 0% | 2871/65536 MB |

Installation

pip install -r requirements.txt
# Install Toto2 source (requires python>=3.12 upstream, use --ignore-requires-python on 3.11):
# curl -L https://github.com/DataDog/toto/archive/main.zip -o /tmp/toto.zip && unzip -q /tmp/toto.zip -d /tmp
pip install --no-build-isolation --ignore-requires-python -e /tmp/toto-src/dd_unit_scaling -e /tmp/toto-src/toto2
pip install unit_scaling

Weights must be present locally at /opt/atomgit/adapt-npu-agent/working/Datadog-Toto-2.0-1B or Datadog/Toto-2.0-1B 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-1B
[INFO] torch_npu available: True
[INFO] NPU device: Ascend910_9362, count: 2
[INFO] Selected device: npu:0
[INFO] Model loaded: d_model=1536, layers=36, patch=32
[INFO] Params: 1041.0M
[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: ~170 ms (synchronized, stable)
[RESULT] Quantiles variate0 t0: [9.77970027923584, 9.998741149902344, 10.160859107971191, 10.305907249450684, 10.446053504943848, 10.578828811645508, 10.713598251342773, 10.879066467285156, 11.1056547164917]
[RESULT] Median variate0 first5: [10.446053504943848, 10.968950271606445, 11.46769905090332, 11.970688819885254, 12.437016487121582]
[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]5776.1 ms5776 ms✓✓10.4460415.873535
NPU npu:0[9,1,2,96]401.7 ms166.4 ms avg✓✓10.4460545.873533

NPU stable timings (10 runs, synchronized): avg 166.4 ms, min 160.6, max 168.8, p50 167.0, p90 168.4, p95 168.6 — 6.0 windows/s, batch=1.

Consistency — CPU vs NPU

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

python scripts/compare_outputs.py --cpu cpu_toto1b.npy --npu npu_toto1b.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": 6.10e-05,
  "mean_abs_error": 8.08e-06,
  "passed": true
}

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

Performance (NPU npu:0, Synchronized)

MetricValue
First run (incl. compile)401.7 ms
Stable avg (10 runs)166.4 ms
min / max / p50 / p90 / p95160.6 / 168.8 / 167.0 / 168.4 / 168.6 ms
Throughput6.0 windows/s (batch=1, horizon=96, context=512)
Peak Memory (NPU)allocated 4288.8 MB, max ~4400 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.
  • 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 (~6e-05) on realistic series.
  • 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.