wrhhh/Maple728-TimeMoE-50M-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Maple728/TimeMoE-50M-NPU

#NPU

模型简介

  • 模型名称: Maple728/TimeMoE-50M
  • 权重URL: https://huggingface.co/Maple728/TimeMoE-50M
  • Revision: 446753ee48ff3726d0606a81d0092d54acee995e (main)
  • 类型: 时间序列预测 (Time Series Forecasting) / 表格数据适配
  • 架构: TimeMoeForPrediction (Decoder-only MoE Transformer, 12层, hidden 384, 12 heads, MoE 8 experts top2)
  • 参数量: 50M (safetensors 217MB)
  • 配置: input_size 1, intermediate 1536, max_position 4096, horizon_lengths [1,8,32,64]
  • 任务: 单变量时序点预测,支持可变 context/horizon
  • 许可: apache-2.0
  • 论文: https://huggingface.co/papers/2409.16040

本仓库为昇腾 910 (Ascend910_9362) 单卡 NPU 适配,基于 transformers + trust_remote_code 推理管线,真实权重在 npu:0 完成验证。

数据契约

  • 数据来源: 合成可追溯序列 (seed=0, 正弦时序, 长度 512)
  • 频率: synthetic steps, 时区 UTC, 排序 时间递增
  • 轴顺序: [batch, time, channel] 例如 [1,512,1]
  • 归一化: z-score per series, 推理后逆归一化
  • 上下文/预测: context 512 horizon 32 (可选 1/8/32/64)
  • 验证: 合成 512→32 直接预测与自回归双路径

环境

  • NPU: Ascend910 (910_9362), 2 cards, tested on npu:0, 64GB HBM
  • CANN: 8.5.1, torch_npu 2.9.0.post1, torch 2.9.0+cpu, transformers 4.57.6
  • Python: 3.11.14, OS: Linux aarch64
  • 驱动验证: npu-smi info & torch.npu.is_available()==True

安装

pip install -r requirements.txt

NPU 推理

python inference.py

真实结果

  • 输入 (512) 归一化样本 [-0.0126,0.0498,0.1122,0.1744,0.2363]
  • CPU 直接预测 (32) norm 前5: [0.0496,0.1145,0.2019,0.2328,0.2907]
  • NPU 直接预测 (32) norm 前5: [0.04969,0.11451,0.20199,0.23283,0.29076]
  • 耗时: NPU 直接 61.5ms / 平均 64.9ms, CPU 1181ms, 加速 ~18x
  • 吞吐: 15.4 windows/s

一致性

  • 工具: scripts/compare_outputs.py --task regression --atol 1e-4 --rtol 1e-3
  • 直接预测: max_abs=8.34e-06 mean_abs=2.45e-06 shape [1,32] PASSED
  • 自回归: max_abs=8.34e-06 PASSED
  • 阈值解释: FP32 严格阈值, 实测远低于阈值

性能

  • 预热 3 次, 测试 10 次, 每轮 torch.npu.synchronize() 同步
  • NPU: avg 64.95ms min 61.79ms max 66.41ms p50 65.32ms p90 66.07ms p95 66.24ms
  • CPU: avg 1261ms
  • 显存峰值: 217MB + 激活 <1GB

证据图

图片由 xterm.js 根据本次真实日志生成 (raw style), 非手工绘制

agent workflow npu device call model result

限制

  • 已验证 horizon 32 於 context 512
  • 输入仅支持 float32 单通道
  • 合成数据验证,真实业务建议替换为目标领域时序