#NPU
ibm-research/ttm-r3 (TinyTimeMixer R3, decompose: trend + residual)aca5d4956c59726b320c1562a6eaebb7fd7ec9b9TinyTimeMixerForDecomposedPrediction (trend_forecaster + residual_forecaster), context 512 / prediction 30, d_model 128 / trend_d_model 8, 10+10 layers, 1.415M 参数npu-adapt-tabular (ibmr TTM R3 通过 tsfm_public / granite-tsfm 加载)working/sample_data_ttm.csv (合成示例, 可追溯) 与 submission fallback 合成56bcb114bf9d6e4a61f70cdcae62de619cc03127bb960572aa0a7edf06ceb97a (sample_data_ttm.csv, 1200 rows)timestamps: datetime64[ns] (5min freq, 2024-01-01 起), channel_0: float64, channel_1: float64, channel_2: float64; 推理使用 channel_0, channel_1 (2 channels)channel_0, channel_1past_values: [B, T=512, C=2] float32 (common_channel 模式, batch 1)prediction_outputs: [B, 30, 2] float32 (点预测), trend_prediction_outputs: [B,30,2], residual_prediction_outputs: [B,30,2][B,T,C] 验证context_length=512, prediction_length=30, patch_length=9/64, frequency_token_vocab_size=5Ascend910_9362 ×2 (910B), 已验证 torch.npu.is_available()==True, device_count=2, 目标设备 npu:0pip install -r requirements.txt (含 granite-tsfm 源码 tsfm_public 位于 /tmp/gtsfm2, 需 datasets mock)model.safetensors SHA256 74dcec10fa75f334f6e6ddb8f6df19452de1c70a1ad43b87e5064c4e30f930cc), 单卡显存预估 < 1GB (含激活)pip install -r requirements.txt
# 若环境无 granite-tsfm, 从本地源码安装:
pip install -e /tmp/gtsfm2 --no-deps --no-build-isolationhttps://huggingface.co/ibm-research/ttm-r3 (config.json + model.safetensors)working/model_ttm_r3/ (已通过 huggingface-cli download ibm-research/ttm-r3 --local-dir working/model_ttm_r3)snapshot_download (需联网)默认命令 (无需参数, 自动选数据与设备):
python inference.py行为:
torch.npu.is_available(), npu-smi info, 设定 torch.npu.set_device(0)TinyTimeMixerForDecomposedPrediction.from_pretrained(local_dir).to(npu:0) 并打印首参数 device/dtypeworking/sample_data_ttm.csv 或合成 512+30 窗口past_values [1,512,2] 并显式迁移到 npu:0, 执行 torch.npu.synchronize() 计时来自本次 npu:0 真实推理 (python inference.py 完整日志见 assets/model_result.png):
[INPUT] past tensor shape torch.Size([1, 512, 2]) device npu:0 dtype torch.float32
[INFER] Completed in 0.2136s (sync timed)
[RESULT] Forecast tensor shape (1, 30, 2), finite True
[RESULT] Trend tensor shape (1, 30, 2)
[RESULT] pred head:
timestamps channel_0 channel_1
2024-01-02 18:40:00 50.824959 35.490074
2024-01-02 18:45:00 50.823193 35.503796
2024-01-02 18:50:00 50.811890 35.508495
2024-01-02 18:55:00 50.791489 35.506134
2024-01-02 19:00:00 50.769341 35.517082
[RESULT] channel means ['channel_0:50.5372', 'channel_1:35.4849']
[VERIFY] Model param device after inference: npu:0
[STATUS] NPU inference SUCCESS on npu:0, elapsed 0.2136s
[PERF] second run 0.0187sCPU 对照 (相同权重/输入/seed, TinyTimeMixerForDecomposedPrediction):
prediction_outputs mean 43.0106, head [50.824707, 35.490063] (首点)working/cpu_output.npy 与 working/npu_output.npy 用于一致性校验同一权重、输入、预处理、dtype=float32、seed=42、eval mode:
python .opencode/skills/npu-adapt-skills/scripts/compare_outputs.py --cpu working/cpu_output.npy --npu working/npu_output.npy --task forecasting --atol 1e-4 --rtol 1e-3结果:
{
"task": "forecasting",
"cpu_shape": [1, 30, 2],
"npu_shape": [1, 30, 2],
"finite": true,
"atol": 0.0001,
"rtol": 0.001,
"max_abs_error": 0.001041412353515625,
"mean_abs_error": 0.0004620234171549479,
"passed": true
}
trend 校验: max_abs 0.000282 mean_abs 0.000124 passed true
阈值解释: FP32 点预测, 输出尺度 ~50, 1e-4/1e-3 严格阈值下仍通过; 误差来源为 NPU/CPU 浮点累积差异, 无 fallback。
单样本 smoke consistency, 非全量 benchmark。NPU npu:0 同步计时 (torch.npu.synchronize() 前后), batch 1, shape [1,512,2] -> [1,30,2], float32:
详见 working/perf.json 与 assets/model_result.png。
三图由 scripts/render_xterm_evidence.mjs --style raw 根据本次真实日志生成 (深灰背景、白色等宽、提示符 atomgit@pod-a94f8701860f4700b161b00e290de466:~$):
assets/agent_workflow.png — 侦察、数据检查、下载、加载、NPU 推理、一致性、benchmark 与提交校验assets/npu_device_call.png — npu-smi info、NPU 可用性、设备名、模型参数 device/dtype、输入输出 Tensor deviceassets/model_result.png — 默认 python inference.py 完整 stdout/stderr、UTC 时间与退出码README 仅引用图片, 渲染工具见技能文档。

torch_npu 与 Ascend 910B 环境, 默认 npu:0, 不支持 CPU fallback (检测到 fallback 即失败)prediction_length 固定 30, 改变需重载或插值working/model_ttm_r3 或联网下载estimate_errors / multi_quantile_head 的额外不确定性头, 仅主预测