#NPU Ascend910 TinyTimeMixer Time-Series Forecasting
ibm-granite/granite-timeseries-ttm-r1 revision f04bebdd4c13475b006ce72672e74c9dc28871dc (3.1 MB safetensors, 805280 params)TinyTimeMixerForPrediction (tinytimemixer, d_model 192, num_layers 2, decoder d_model 128, adaptive_patching_levels 3, patch_length 64, num_patches 8)TinyTimeMixerForPrediction.from_pretrained + 外部 std 归一化后 past_values 前向past_values Tensor 形状 [B, T, C],本仓默认 [1, 512, 1] 单变量正弦合成序列;多变量时自动走 common_channel 无需转置[batch, time, channel],禁止转置;num_input_channels=1 但模型自动支持 C>1(x - mean)/ (std+1e-5) 按每通道独立计算(遵循官方 TimeSeriesPreprocessor 要求),预测后 pred*std+mean 逆归一化context_length=512 prediction_length=96(config 固定),prediction_channel_indices=null 全通道预测prediction_outputs Tensor [B, pred_len, C],保存为 numpy [1,96,1] 去归一化后均值 ~0.30sin(t*0.1)+0.5*sin(t*0.25)+N(0,0.05) seed 0,T=608,past=vals[:512],SHA-256 可复现,已校验有限值npu:0http://127.0.0.1:7890/tmp/ttm-r1 与 HF Hub 缓存 /opt/atomgit/.cache/huggingface/hub/models--ibm-granite--granite-timeseries-ttm-r2/snapshots/f04bebd... 再 from_pretrained 加载,无二次联网pip install -r requirements.txt
# 需预装 CANN Toolkit 8.5.1 并使 torch_npu 可用默认命令 (已在 npu:0 验证, 自动检测设备):
python inference.py
# 显式指定
python inference.py --device npu:0 --context-length 512 --prediction-length 96
python inference.py --device cpu --context-length 512 --prediction-length 96 # CPU 对比脚本自动: 检测 NPU、从本地或 HF Hub 加载模型、打印设备/dtype/输入输出摘要、同步计时、报告吞吐与 HBM.
[1,512,1] 均值 0.0121 std 0.7914 归一化后均值 0.0000 std 1.0000[1,96,1] 归一化均值 0.3662 std 0.2725 去归一化均值 0.3019t+1: 1.0527
t+2: 0.9762
t+3: 0.9016
t+4: 0.8147
t+5: 0.7483torch.npu.synchronize() 前后计时)/tmp/ttm-r1、同一输入 (seed 0 合成序列 512)、同一预处理 (x-mean)/std、dtype float32、eval mode、无采样cpu.npy / npu.npy forecast [1,96,1] 原始归一化输出python scripts/compare_outputs.py --cpu working/cpu.npy --npu working/npu.npy --task forecasting --atol 1e-3 --rtol 1e-3max_abs_error 0.001551 mean_abs_error 0.000529 passed true 通过阈值max_abs ~0.00123 mean ~0.00042 — 在全量程 ~1.5 内相对误差 <0.1%torch.npu.synchronize()三图由 xterm.js 根据本次真实日志渲染 (--style raw), 非手工绘图:
assets/agent_workflow.png - 侦察/下载/加载/一致性/性能全流程assets/npu_device_call.png - npu-smi + check_npu + 参数 device Proofassets/model_result.png - 默认 python inference.py 完整输出

图片由 xterm.js 根据真实日志生成, 提示符为 atomgit@pod-a94f8701860f4700b161b00e290de466:~$ 展示标签, 非桌面截图.
context_length=512 prediction_length=96,超长需截断或滚动预测 (rolling beyond 2*forecast_length 不推荐)C>1 时需保证每通道独立 std 归一化npu:0 验证, 未测试多卡/分布式submission/
├── inference.py
├── readme.md
├── requirements.txt
└── assets/
├── agent_workflow.png
├── npu_device_call.png
└── model_result.png