本仓库适配 Hugging Face 官方时间序列模型 ibm-granite/granite-timeseries-patchtsmixer(固定 revision 90dc5a88d45f032b7dceefb5d814ca2af54f2ff9)到华为昇腾(Ascend)NPU,并完成真实 NPU 上的固定官方 ETTh1 样本前向推理。运行时按固定 MODEL_ID + revision 下载 config 与权重、按固定官方 ETDataset commit 下载 ETTh1.csv,缓存置于仓库外,禁止更换 checkpoint/数据源。模型为 PatchTSMixerForPrediction(PatchTSMixer 预测头):context_length=512、prediction_length=96、num_input_channels=7、patch 16×stride 16(32 patches)、d_model=48、2 层、distribution_output=student_t、loss=mse。这是 7 个传感器通道(ETTh1:HUFL/HULL/MUFL/MULL/LUFL/LULL/OT)的多元时间序列预测模型。
| 资产 | 运行时下载源 | 固定值 | SHA256 |
|---|---|---|---|
config.json | HF 官方 ibm-granite/granite-timeseries-patchtsmixer 固定 revision;失败回退比赛镜像 ai.gitcode.com/hf_mirrors/… 同 revision | 1182 bytes | 1574679e…b1525d |
model.safetensors | 同上 | 789328 bytes | 9b474a93…602a4f |
ETTh1.csv | 官方 ETDataset 固定 commit 1d16c8f4f943005d613b5bc962e9eeb06058cf07(raw.githubusercontent.com/zhouhaoyi/ETDataset/…/ETT-small/ETTh1.csv) | 2589657 bytes | f18de3ad…5ee066 |
90dc5a88d45f032b7dceefb5d814ca2af54f2ff9date + 7 数值列),每小时一个观测。tempfile.gettempdir() 下,按 model/revision 分目录),脚本复用已校验缓存,不写入仓库。模型输入为多元时间序列张量,本仓使用 ETTh1 固定窗口:
past_values:[batch, context_length, num_input_channels] = [1, 512, 7],来自 ETTh1 行 [11008, 11520),用 train 行 [0, 8640) 的 mean/std 标准化。future_values:[batch, prediction_length, num_input_channels] = [1, 96, 7],来自 ETTh1 行 [11520, 11616),同一套统计标准化,作为真标签参与 MSE。observed_mask:[1, 512, 7],全 1(真实观测)。float32,显式搬上 npu:0。输出 prediction_outputs 形状 [1, 96, 7]。推理在真实昇腾 NPU 上完成,而非 CPU 回退。运行环境由平台提供(本机实测):
Ascend910(npu-smi 显示 2 张健康芯片,Phy-ID 6/7,CANN 8.5.1)torch 2.9.0+cpu + torch_npu 2.9.0.post1 + transformers 4.57.6 + numpy 1.26.4requirements.txt 中列出;如需自行部署,请按昇腾官方安装 CANN Toolkit + torch_npu 配套版本。requirements.txt:transformers==4.57.6、numpy>=1.24.0。pip install -r requirements.txt
flock -x -w 1800 /tmp/ascend-model-agent-npu-v1.lock bash -c 'python3 inference.py'脚本按固定 MODEL_ID/revision 运行时下载 config 与权重(官方 HF 优先、失败回退比赛镜像),按固定 ETDataset commit 下载 ETTh1.csv;缓存优先复用(仓库外目录),下载后严格校验 bytes/SHA256。随后在 npu:0 上执行完整流程,打印每步证据(资产 SHA256、tensor 设备/形状、推理结果、最终 GO/NO_GO 判定)。退出码 0 表示通过全部断言(GO),非 0 表示 NO_GO。
outputs/inference_results.json 中的本次真实运行结果(MODEL_ID=ibm-granite/granite-timeseries-patchtsmixer,revision 90dc5a88…,data_commit 1d16c8f4…,设备 npu:0):
{
"model_id": "ibm-granite/granite-timeseries-patchtsmixer",
"revision": "90dc5a88d45f032b7dceefb5d814ca2af54f2ff9",
"data_commit": "1d16c8f4f943005d613b5bc962e9eeb06058cf07",
"device": "npu:0",
"outputs": {
"prediction_outputs": [1, 96, 7],
"prediction_outputs_device": "npu:0",
"prediction_outputs_dtype": "torch.float32",
"loss": 0.28261271119117737,
"all_finite": true,
"fixed_sample_mse_npu": 0.28261271119117737
},
"latency": {"timed_forward_seconds": 0.001597}
}past_values/future_values/observed_mask、prediction_outputs、loss 均验证为 npu:0;输出 [1,96,7]、float32、全部 finite。0.28261,与模型 return_loss=True 返回的 loss 一致。[0.247046, 0.503542, 0.359562, 0.540095, -0.098541, 0.342299, -0.843927],首个标签 [0.351338, 0.699467, 0.463907, 0.553277, -0.396441, 0.246813, -0.862362]。[1,512,7]→[1,96,7]、设备 npu:0 均为固定断言,任一不符即 NO_GO。NO_GO,不伪造。flock -x -w 1800 /tmp/ascend-model-agent-npu-v1.lock 串行执行。ibm-granite/granite-timeseries-patchtsmixer,遵循其模型卡/上游许可证。本仓库已归档三张由真实适配与 NPU 运行页面截取的原始证据图:
| 文件 | 内容 |
|---|---|
assets/agent_workflow.png | 模型 ID、固定 revision、资产校验、推理脚本和交付状态 |
assets/npu_device_call.png | 昇腾 NPU、参数、输入、输出与 loss 的 device/dtype/shape 证据 |
assets/model_result.png | 最终运行命令、真实输入窗口、真实输出、MSE 与耗时 |
机器可读的同次真实结果保存在 outputs/inference_results.json。截图均保持用户确认的原始像素,未裁剪、未编辑、未生成。