模型名称: Maple728/TimeMoE-200M
模型链接: HuggingFace
模型描述: TimeMoE 是一个基于 Mixture of Experts (MoE) 架构的时间序列基础模型,用于多变量时间序列预测。该模型采用 LLaMA 风格的 Transformer 解码器架构,结合稀疏 MoE 层实现高效的长程时序建模。
模型架构: TimeMoe (LLaMA-style Transformer Decoder + Sparse MoE)
参数规模: ~453M (453,196,800)
输入规格:
[batch_size, seq_len, input_size],input_size=1(单变量时序)输出规格:
[batch_size, seq_len, input_size * horizon_length]| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| transformers | >= 4.50.0 | HuggingFace Transformers |
| numpy | >= 1.24.0 | 数值计算 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
NPU 硬件: Ascend910_9362
安装命令:
pip install torch torch_npu transformers numpy# 检查 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-200M --local-dir ./TimeMoE-200M
# 或使用 AtomGit 镜像(国内推荐)
export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download Maple728/TimeMoE-200M --local-dir ./TimeMoE-200Mpython3 inference.py --model-path ./TimeMoE-200M --seq-len 128 --batch-size 1| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --seq-len | int | 128 | 历史序列长度 |
| --batch-size | int | 1 | 批次大小 |
| --horizon | int | 1 | 预测步长 (1/8/32/64) |
| --npu-device | int | 0 | NPU 设备 ID |
[模型] Maple728/TimeMoE-200M
[设备] Ascend910_9362 (npu:0)
[框架] torch_npu 2.9.0.post1+gitee7ba04, transformers 4.57.6
[输入] shape=torch.Size([1, 128, 1]), range=[-0.5938, 0.8984]
[输出] shape=torch.Size([1, 128, 1]), range=[-0.546875, 0.742188]
[耗时] 255.7ms
[状态] SUCCESS[基准测试] 10次推理统计:
平均: 61.2ms
最小: 58.1ms
最大: 67.6ms
标准差: 2.8ms
P50: 60.8ms
P99: 67.3ms运行命令:
python3 inference.py --model-path ./weights --seq-len 128 --batch-size 1输出:
[模型] Maple728/TimeMoE-200M
[设备] Ascend910_9362 (npu:0)
[输入] shape=torch.Size([1, 128, 1]), range=[-0.5938, 0.8984]
[输出] shape=torch.Size([1, 128, 1]), range=[-0.546875, 0.742188]
[耗时] 255.7ms
[状态] SUCCESS运行命令:
python3 inference.py --model-path ./weights --seq-len 128 --batch-size 2输出:
[基准测试] 10次推理统计:
平均: 61.2ms
最小: 58.1ms
最大: 67.6ms
标准差: 2.8ms
P50: 60.8ms
P99: 67.3ms输出:
seq_len= 32 -> output=torch.Size([1, 32, 1]), 62.8ms
seq_len= 64 -> output=torch.Size([1, 64, 1]), 62.4ms
seq_len=128 -> output=torch.Size([1, 128, 1]), 58.4ms
seq_len=256 -> output=torch.Size([1, 256, 1]), 68.6ms
seq_len=512 -> output=torch.Size([1, 512, 1]), 73.4ms


测试数据: 合成时序数据(正弦波 + 噪声 + 趋势),seq_len=128
评测指标:
| 指标 | 结果 | 说明 |
|---|---|---|
| 单条推理耗时 | 255.7ms | seq_len=128, batch=1, 首次推理含编译开销 |
| 批量推理平均 | 61.2ms | seq_len=128, batch=1, 10次均值 |
| P99 延迟 | 67.3ms | 稳态推理 |
| 输出数值范围 | [-0.55, 0.74] | 与输入量级匹配 |
| 输出 shape | [B, S, 1] | 与 horizon_lengths[0]=1 一致 |
评测命令:
python3 inference.py --model-path ./weights --seq-len 128 --batch-size 1use_cache=True 时 DynamicCache.get_usable_length() 在 transformers 4.57.6 中不可用,建议使用 use_cache=False。one_hot 操作会触发内部格式警告,不影响推理正确性。