模型名称: Maple728/TimeMoE-50M
模型链接: HuggingFace
AtomGit 镜像: AtomGit
模型描述: TimeMoE-50M 是一个基于 Mixture-of-Experts (MoE) 架构的时间序列预测模型。模型采用 Transformer Decoder 架构,通过稀疏专家混合机制实现高效的时间序列多步预测。
模型架构: MoE Transformer Decoder
输入规格:
[batch_size, seq_len, input_size],其中 input_size=1输出规格:
[batch_size, horizon, 1]horizon_lengths = [1, 8, 32, 64]| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| transformers | >= 4.40.0 | 模型配置加载(需兼容补丁) |
| huggingface_hub | >= 0.20.0 | 权重下载 |
| safetensors | >= 0.4.0 | 安全张量格式加载 |
| numpy | >= 1.24.0 | 数值计算 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install torch torch-npu transformers huggingface_hub safetensors numpy注意事项:
modeling_time_moe.py、configuration_time_moe.py),inference.py 脚本通过 importlib 动态加载,无需安装额外包。transformers >= 4.50 移除了 DynamicCache.get_usable_length() 方法,inference.py 已内置运行时兼容补丁(monkey-patch),无需降级 transformers。# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"方式一:HuggingFace(推荐)
huggingface-cli download Maple728/TimeMoE-50M --local-dir ./weights方式二:AtomGit 镜像(HuggingFace 下载慢时使用)
huggingface-cli download --repo-type model https://ai.gitcode.com/hf_mirrors/Maple728/TimeMoE-50M --local-dir ./weightspython3 inference.py --model-path ./weights| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --seq-len | int | 96 | 输入序列长度 |
| --device | int | 0 | NPU 设备编号 |
[模型] Maple728/TimeMoE-50M
[设备] Ascend910_9362 (npu:0)
[输入] 正弦波序列, seq_len=96, horizon=8
[输出] shape=(8, 1), 前8个预测值: [0.1206, 0.2734, 0.4141, 0.5469, 0.6680, 0.7656, 0.8594, 0.9375]
[耗时] 248.26ms (首次推理,含 KV Cache 初始化)
[状态] SUCCESS[基准测试] 100次推理统计:
平均: 64.53ms
最小: 60.44ms
最大: 69.31ms
标准差: 2.03ms
P50: 64.52ms
P99: 69.16ms运行命令:
python3 inference.py --model-path ./weights --seq-len 96输出:
[输入] 正弦波序列 (seq_len=96)
前5个值: [0.0, 0.1319, 0.2615, 0.3865, 0.5048]
[输出] 预测 shape: (8, 1)
预测前8个值 (horizon=1): [0.1206, 0.2734, 0.4141, 0.5469, 0.6680, 0.7656, 0.8594, 0.9375]
[耗时] 248.26ms
[状态] SUCCESS输出:
[输入] 3条序列, 每条 seq_len=96
[输出] 批量预测 shape: (3, 8, 1)
序列0 前4个预测值: [0.1240, 0.2793, 0.4141, 0.5547]
序列1 前4个预测值: [0.9844, 0.9570, 0.9336, 0.8789]
序列2 前4个预测值: [0.1084, 0.1582, 0.2334, 0.2988]
[耗时] 84.48ms
[状态] SUCCESS输出:
[基准测试] 100次推理统计:
平均: 64.53ms
最小: 60.44ms
最大: 69.31ms
标准差: 2.03ms
P50: 64.52ms
P99: 69.16ms


测试数据: 合成正弦波序列 (seq_len=96, horizon=8),模拟典型时间序列预测场景
评测指标:
| 指标 | 结果 | 说明 |
|---|---|---|
| 参数量 | 113.4M | MoE 架构,仅激活部分专家 |
| 首次推理延迟 | 248.26ms | 含 KV Cache 初始化开销 |
| 稳态推理延迟 (P50) | 64.52ms | 100次推理统计 |
| 推理延迟 (P99) | 69.16ms | 100次推理统计 |
| 硬件 | Ascend910_9362 | 单卡 NPU,bfloat16 精度 |
评测命令:
python3 inference.py --model-path ./weights实际输出:
[基准测试] 100次推理统计:
平均: 64.53ms
最小: 60.44ms
最大: 69.31ms
标准差: 2.03ms
P50: 64.52ms
P99: 69.16mstransformers >= 4.50 移除了 DynamicCache.get_usable_length() 方法,inference.py 已通过 monkey-patch 修复,不影响使用。transformers==4.40.1,运行环境使用 transformers==4.57.6,通过运行时兼容补丁确保功能一致。