Toto-Open-Base-1.0 是 Datadog 发布的时间序列基础模型 Toto(Time Series Optimized Transformer for Observability,HF),论文 This Time is Different: An Observability Perspective on Time Series Foundation Models (NeurIPS)。模型采用 decoder-only Transformer 与 Proportional Factorized Space-Time Attention,在超过 2 万亿时间点(Datadog 可观测性指标 + 公开数据集)上预训练,可对多变量时间序列做零样本概率预测(Student-T 混合分布输出),在 GIFT-Eval 与 BOOM 榜单上达到 SOTA。
| 项 | 值 |
|---|---|
| 参数量 | ~151M |
| 架构 | Toto decoder-only Transformer(patch_size=64, 12 层, 12 头, embed_dim=768) |
| 上下文长度 | 最长 4096 |
| 输出 | 概率预测(Mixture of Student-T),取中位数作为点预测 |
| 输入 | 多变量时间序列 (variates, context),float32 |
| 任务类型 | 时间序列零样本预测(表格数据) |
| 依赖 | 版本 | 说明 |
|---|---|---|
| Python | 3.10+ | 推荐 3.11 |
| torch | >=2.0 | CPU/NPU 均可 |
| torch_npu | 与 CANN 配套 | 昇腾NPU支持 |
| toto-ts | ==0.2.0 | Toto 官方推理包 |
| gluonts / einops / safetensors | - | toto-ts 依赖 |
| numpy / matplotlib | - | 数据处理与绘图 |
依赖安装到独立目录(不污染共享环境):
pip install --target /mnt/workspace/Toto-Open-Base-1.0/libs \
-i https://pypi.tuna.tsinghua.edu.cn/simple \
toto-ts numpy matplotlib注:libs 中随 toto-ts 安装的 torch 已移除,统一使用共享环境的 torch + torch_npu,避免版本不匹配。
模型权重:/home/developer/models/Toto-Open-Base-1.0
确认权重与依赖就位后,脚本会自动将 /mnt/workspace/Toto-Open-Base-1.0/libs 与仓库目录加入 PYTHONPATH,无需手动设置。可用 npu-smi info 检查 NPU 设备状态。
python3 inference.py --model_path /home/developer/models/Toto-Open-Base-1.0脚本内置合成多变量时间序列示例输入(趋势+周期+噪声,7 变量 × 4096 步),只传 --model_path 即可跑通;设备自动选择(优先 NPU,不可用回退 CUDA/CPU),执行零样本概率预测并打印耗时(耗时/elapsed 字段),结果图保存至 assets/model_result.png。
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--model_path | str | /home/developer/models/Toto-Open-Base-1.0 | 模型权重目录 |
--context_length | int | 4096 | 输入历史长度(不超过模型上限 4096) |
--prediction_length | int | 336 | 预测步数 |
--num_samples | int | 64 | 概率采样条数 |
--samples_per_batch | int | 64 | 每批采样数(控制显存占用) |
--device | str | 自动 (npu > cuda > cpu) | 指定推理设备 |
--output | str | assets/model_result.png | 结果图保存路径 |
输入为内置合成的 7 变量、4096 步时间序列,零样本预测未来 336 步。NPU 实测输出示例:
[INFO] device = npu
[INFO] model_path = /home/developer/models/Toto-Open-Base-1.0
[INFO] 模型加载完成 load_time=x.xxs
[INFO] 推理完成 耗时/elapsed: x.xx s (context=4096, variates=7, prediction_length=336, num_samples=64, device=npu)
[INFO] 输入形状: (7, 4096), 预测输出形状: (1, 336, 7)
[RESULT] status=ok device=npu 耗时/elapsed: x.xx s结果截图见 assets/model_result.png。
见 assets/agent_workflow.png。
见 assets/npu_device_call.png。
见 assets/model_result.png。
use_memory_efficient_attention 自动置 False),勿启用 flash_attention_2;Toto.from_pretrained(本地目录) 加载 config.json + model.safetensors;pip install --target 隔离安装到 /mnt/workspace/Toto-Open-Base-1.0/libs,勿直接装入共享环境。