模型名称: mldi-lab/Kairos_23m 模型链接: HuggingFace 模型描述: Kairos-23M 是一个 2300 万参数的时间序列基础模型,专为零样本跨域预测设计。采用动态分块分词器、混合尺寸编码器和动态旋转位置嵌入(DRoPE),可处理具有不同信息密度的异构时间序列数据。 模型架构: Transformer (Encoder-Decoder) + Mixture-of-Experts (MoE) 参数规模: 23M (23,000,576) 上下文长度: 2048 预测长度: 64(可配置) 量化预测: 9 个分位数 (0.1 ~ 0.9)
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch / torch_npu | 2.1.0+ | 昇腾 NPU 后端 |
| transformers | >= 4.45.0 | HuggingFace 库 |
| jaxtyping | >= 0.3.0 | 模型代码类型标注依赖 |
| 昇腾驱动 | CANN 8.0.RC2+ | 推荐最新版 |
安装命令:
pip install torch torch_npu transformers jaxtyping# 检查 NPU 设备
npu-smi info
# 确认 torch_npu 可用
python3 -c "import torch_npu; print(torch.npu.is_available())"# 单次推理(默认:上下文2048,预测64)
python inference.py
# 自定义参数
python inference.py --context_length 2048 --prediction_length 64 --num_runs 10
# 指定设备
python inference.py --device npu:0| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model_path | str | /data/models/mldi-lab__Kairos_23m | 模型路径 |
| --context_length | int | 2048 | 输入时间序列长度 |
| --prediction_length | int | 64 | 预测时间步数 |
| --batch_size | int | 1 | 批大小 |
| --device | str | npu:0 | 推理设备 |
| --num_runs | int | 10 | Benchmark 运行轮数 |
输入: 随机标准正态分布时间序列,长度 2048
python inference.py --context_length 2048 --prediction_length 64 --num_runs 5输出:
[INFO] 设备类型: npu, 设备名称: Ascend910_9362
[INFO] 模型参数量: 23,000,576
[结果] 预测输出形状: [1, 9, 64]
[结果] 平均延迟: 267.1ms (min: 266.1ms, max: 268.5ms)
[结果] 量化预测分位数: ['0.1', '0.5', '0.9']
[模型] mldi-lab/Kairos_23m
[设备] Ascend910_9362 (npu:0)
[输入] Context=2048, Batch=1, Device=npu
[输出] Shape=[1, 9, 64] (9 quantile forecasts, pred_len=64)
[耗时] 267.1ms
[状态] SUCCESS输入: 上下文长度 2048,预测长度 96
python inference.py --context_length 2048 --prediction_length 96 --num_runs 3输出:
[INFO] 设备类型: npu, 设备名称: Ascend910_9362
[INFO] 模型参数量: 23,000,576
[结果] 预测输出形状: [1, 9, 96]
[结果] 平均延迟: 285.3ms
[模型] mldi-lab/Kairos_23m
[设备] Ascend910_9362 (npu:0)
[输入] Context=2048, Batch=1, Device=npu
[输出] Shape=[1, 9, 96] (9 quantile forecasts, pred_len=96)
[耗时] 285.3ms
[状态] SUCCESS


测试数据: 随机标准正态分布时间序列(零样本推理) 评测指标: 输出形状验证、推理延迟
| 指标 | 结果 |
|---|---|
| 预测输出形状 | [1, 9, 64] (batch, quantiles, prediction_length) |
| NPU 平均延迟 | ~267ms (上下文2048, 预测64) |
| 参数量 | 23,000,576 |
tsfm/model/kairos/),已包含在仓库中torch.abs 不支持复数张量,已做兼容处理