#NPU Ascend 910B Time-Series Forecasting Adaptation
Model adapted from Maple728/TimeMoE-200M (200M MoE) weights model.safetensors 906M.
Maple728/TimeMoE-200M (time_moe, 12 layers, hidden 768, 12 heads, 8 experts top-2, horizon_lengths [1,8,32,64])time-series-forecasting univariate point forecasting. Route: 点预测 (forecast tensor, no quantiles)npu:0 Ascend910_9362 (2 devices, CANN 8.5.1, torch_npu 2.9.0.post1, torch 2.9.0+cpu, transformers 4.40.1)/tmp/TimeMoE-200M (config.json + model.safetensors, 865M after download)Synthetic univariate series mirroring ETTh/Electricity trend+seasonality, seed=42, 600 timesteps, traceable via SHA256.
numpy.random.RandomState(42); SHA256(inp_norm prefix) = 3d0869b35ae00ea80.5*sin(2πt/24)+0.3*sin(2πt/96)+0.01*t+ N(0,0.1)(x-mean)/(std+1e-5) where mean/std computed on context window (512); inverse transform forecast*std+mean for denorm outputcontext=512 (input), pred_len=32 (forecast), max_length=544; same slice used for CPU and NPU (last 512 before horizon)[batch=1, seq_len=512] (model unsqueezes to [B,T,1] internally)[batch=1, seq_len=544] full including input copy + [32] forecast horizonpython 3.11.14
torch 2.9.0+cpu
torch_npu 2.9.0.post1+gitee7ba04
transformers 4.40.1
numpy 1.26.4, pandas 3.0.2
Ascend CANN 8.5.1, Ascend910_9362 x2, HBM 3105/65536 MB (npu:0), 2873/65536 MB (npu:1)
npu-smi driver 25.5.5Collect via python scripts/collect_env.py --output working/env.json and python scripts/check_npu.py (see assets/npu_device_call.png).
pip install -r requirements.txt
# Ensure Ascend CANN 8.5.1 and torch_npu installed (Ascend910B)
# Model weights downloaded once to /tmp/TimeMoE-200M via:
# huggingface-cli download Maple728/TimeMoE-200M --local-dir /tmp/TimeMoE-200M --local-dir-use-symlinks Falserequirements.txt pins torch, torch_npu, transformers, numpy, safetensors, huggingface_hub. No internet download at inference beyond first snapshot (cached).
Default command (uses NPU if available, otherwise CPU):
python inference.py
python inference.py --device npu:0 --context 512 --pred-len 32
python inference.py --device cpu --context 512 --pred-len 32Key logs prove NPU call:
npu-smi info shows 2x Ascend910scripts/check_npu.py => {"torch_npu_available": true, "npu_available": true, "device_count": 2, "device_name": "Ascend910_9362"}inference.py prints Model param device: npu:0, dtype: torch.float32 and params on npu: 463/463, No CPU fallback, inputs/outputs on npu:0, and synchronizes via torch.npu.synchronize() before/after timingmodel.to(device) and seq.to(device), assert out.device.type=='npu'Captured from python inference.py --device npu:0 (2026-08-20, float32, seed 42):
[INFO] Model: Maple728/TimeMoE-200M
[INFO] NPU device name: Ascend910_9362, count: 2
[DATA] inp mean 3.100524 std 1.538619 sha256 prefix 3d0869b35ae00ea8
[DATA] inp_norm mean 0.000000 std 0.999993
[LOAD] Model param device after move: npu:0, dtype torch.float32
[CHECK] params on npu: 463/463
[OUTPUT] output shape torch.Size([1, 544]), device npu:0
[OUTPUT] forecast normalized full: [1.1353217363357544, 1.129515528678894, 1.129783034324646, 1.0987622737884521, 1.115885853767395, 1.17235267162323, 1.2253246307373047, 1.3212476968765259, 1.4092044830322266, 1.4990017414093018, 1.5927329063415527, 1.6473511457443237, 1.6993191242218018, 1.7142565250396729, 1.7313669919967651, 1.718336582183838, 1.6956920623779297, 1.6466922760009766, 1.5589796304702759, 1.4523346424102783, 1.3398641347885132, 1.2228366136550903, 1.1338753700256348, 1.068324327468872, 0.9837856292724609, 0.9675366282463074, 0.9717206358909607, 0.95228111743927, 0.9697256684303284, 1.0113574266433716, 1.0698736906051636, 1.1581742763519287]
[OUTPUT] forecast denorm full: [4.847352027893066, 4.838418483734131, 4.83882999420166, 4.791100978851318, 4.817447662353516, 4.904328346252441, 4.985832214355469, 5.133420944213867, 5.2687530517578125, 5.406917095184326, 5.551133632659912, 5.6351704597473145, 5.715129375457764, 5.738112449645996, 5.764438629150391, 5.74439001083374, 5.7095489501953125, 5.634156703948975, 5.499200344085693, 5.335114479064941, 5.162064552307129, 4.982004165649414, 4.845126628875732, 4.744268417358398, 4.614195823669434, 4.589194297790527, 4.595632076263428, 4.5657219886779785, 4.592562675476074, 4.656618118286133, 4.746652603149414, 4.882513523101807]
[OUTPUT] forecast normalized stats mean 1.298213 std 0.267647 min 0.952281 max 1.731367
[TIMING] synchronized elapsed 0.3205s (device npu:0)
[TIMING] second stable run 0.0630s, throughput 15.86 windows/s
[STATUS] SUCCESSFull forecast head: [1.1353, 1.1295, 1.1297, 1.0987, 1.1158] tail [0.9522, 0.9697, 1.0113, 1.0698, 1.1581] (normalized).
CPU same forecast tail [0.9522808790206909, 0.9697253704071045, 1.0113576650619507, 1.0698736906051636, 1.1581764221191406] - difference max 4.6e-06.
Saved CPU/NPU arrays and compared via scripts/compare_outputs.py:
python scripts/compare_outputs.py --cpu working/timemoe/cpu_forecast.npy --npu working/timemoe/npu_forecast.npy --task forecasting --atol 1e-4 --rtol 1e-3Result:
{
"task": "forecasting",
"cpu_shape": [32],
"npu_shape": [32],
"finite": true,
"atol": 0.0001,
"rtol": 0.001,
"max_abs_error": 4.649162292480469e-06,
"mean_abs_error": 1.1622905731201172e-06,
"passed": true
}Additional full output (544 length) max_abs 4.65e-06, mean 6.8e-08. Threshold chosen for FP32 MoE (router top-k, one_hot). Strict pass.
Same weight, input, preprocessing, dtype (float32), seed (42), eval mode. No CPU fallback - output device verified npu:0 and param count 463/463 on NPU.
Single-sample smoke consistency (not full benchmark). No sampling variance.
Measured with torch.npu.synchronize() around each model.generate.
Warmup 3, test 10, as required. Preprocessing not timed.
Three PNGs generated by xterm.js from real logs via scripts/render_xterm_evidence.mjs --style raw (dark background, white mono, prompt atomgit@pod-a94f8701860f4700b161b00e290de466:~$):
assets/agent_workflow.png - workflow: inspect, env, download, comparison, benchmark, inference, validateassets/npu_device_call.png - npu-smi + check_npu + model param device/dtype + input/output deviceassets/model_result.png - default python inference.py full outputREADME references assets/agent_workflow.png, assets/npu_device_call.png, assets/model_result.png. Images only via xterm.js, not Pillow/matplotlib.
input_size=1) forecasting; multivariate not supported (model config fixed)max_position_embeddings), tested 512 (typical ETTh)Cannot create tensor with interal format is benign (one_hot internal format) - does not indicate fallback