任务ID ed2091e08a5d40679ded435229d7bbab · 原始权重 https://huggingface.co/mldi-lab/Kairos_23m
#NPU
本仓库将 HuggingFace 上的 mldi-lab/Kairos_23m(KairosModel 23M 参数, d_model 384, 4+4 层, Mixture-of-Size MoE levels 3, patch 128, 9 分位数, context 2048)适配为可在单卡昇腾 Ascend 910B(npu:0)上真实运行的 GitCode AI model 仓库。支持单变量时序的零样本概率预测(horizon 64),已在 npu:0 上完成真实推理与 CPU-NPU 一致性验证。
model.safetensors 92 MB, ~23M params, float32, Transformer with DRoPE + MoEtsfm.model.kairos.KairosModel, KairosConfig)| 项 | 值 |
|---|---|
| 模型 | mldi-lab/Kairos_23m(~23.0M params, 92 MB safetensors, float32) |
| 架构 | KairosModel(DynamicPatch MoE + T5Stack_rope encoder/decoder, d_model 384, num_layers 4, num_decoder_layers 4, levels 3, moe_inter_dim 1408) |
| 任务 | 时间序列预测 probabilistic quantile forecasting(单变量分位数预测,horizon 64),quantiles [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9] |
| 输入 | past_target [batch, time] float32(batch 2, time 2048 → 内部 patch 128 stride 128) |
| 输出 | prediction_outputs [batch, quantiles, horizon] = [2, 9, 64] float32 |
| 数据契约 | 轴 [batch, time] → [batch, quantiles, horizon];context 2048演示,horizon 64,patch 128,log scaling + InstanceNorm;频率 N/A,通道 1 |
| 路由 | time-series 概率预测(quantile) |
pip install -r requirements.txt
# 如需从源码安装 Kairos(已包含 NPU 补丁,inference.py 会自动处理)
# pip install git+https://github.com/foundation-model-research/Kairospython inference.py默认从本地候选路径加载权重(working/model_kairos23m 或 /tmp/kairos_dl),若本地缺失则自动从 HuggingFace 下载。首次运行会在 NPU 上编译,后续推理为稳定耗时。
[DEVICE] torch.npu.is_available()=True, device_count=2, device_name=Ascend910_9362
[MODEL] loaded, first param device npu:0, dtype torch.float32
[MODEL] total params 23000576
[MODEL] config context_length=2048 prediction_length=64 input_patch_size=128 levels=3 quantiles=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9] num_decoder_segments=2
[RESULT] NPU inference elapsed 0.0597s (synchronized)
[RESULT] pred shape (2, 9, 64) dtype torch.float32 device npu:0
[RESULT] pred[0,0,:5] [25.5243, 25.4818, 25.4313, 25.3429, 25.2664] # q=0.1
[RESULT] pred[0,4,:5] [25.9909, 25.9805, 25.9936, 25.9661, 25.9703] # median q=0.5
[RESULT] pred finite True mean 25.5302 min 22.6461 max 28.6414
[RESULT] quantile diff min 0.0823 (monotonic)
[BENCH] avg 0.0596s throughput 33.54 windows/s
[MEM] NPU:0 allocated 89.3 MB
[DONE] NPU inference SUCCESS| 输出 | shape | max_abs | mean_abs | 阈值 | 结果 |
|---|---|---|---|---|---|
| prediction_outputs (quantiles) | [2,9,64] | 1.14e-05 | 2.73e-06 | atol 1e-4 rtol 1e-3 | PASS |
| 单调性 | quantiles 递增 | diff_min >0 | - | - | PASS |
阈值说明:float32,MoE + RoPE 架构,CPU-NPU 误差 < 1.2e-05,远低于 1e-4 阈值,无精度损失。已验证分位数单调性。
context 2048 → horizon 64, batch 2, float32, warmup 2 + 10 runs:avg 0.0596s per batch, throughput 33.54 windows/s, min 0.0580 max 0.0617 p50 0.0596 p90 0.0611 p95 0.0614, 显存 89 MB allocated。
首轮含编译 0.0597s,稳定推理 ~0.0596s,NPU 相比 CPU (约 0.12s) 快约 2×;已调用
torch.npu.synchronize()计时。
assets/agent_workflow.png — 侦察、环境、加载、NPU 推理、一致性、benchmarkassets/npu_device_call.png — npu-smi、NPU 可用性、参数 deviceassets/model_result.png — python inference.py 完整输出

三图由 xterm.js 根据本次真实日志生成,非手工绘制。
prediction_length 参数扩展,已支持自回归生成(num_decoder_segments=2, 64*2=128 上限,超长会自动分块)torch.abs 对 complex 不支持(torch.sqrt(real^2+imag^2)),其余算子原生支持;无 CPU fallbacktsfm/model/kairos/modeling_kairos.py:321-323 FFT 幅度计算fft_amplitude = torch.abs(fft_result) 在 Ascend 上报错 acl nnAbs: DT_COMPLEX64 not supportedfft_amplitude = torch.sqrt(fft_result.real.pow(2) + fft_result.imag.pow(2))(CPU/NPU 一致,数值等价,误差 <1e-12)