m
mengsihan/ibm-research-test-patchtsmixer-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

ibm-research/test-patchtsmixer - NPU

#NPU Ascend910 PatchTSMixer Time-Series Forecasting on Ascend 910

Model Introduction

  • Model Name: ibm-research/test-patchtsmixer (config _name_or_path: ibm/patchtsmixer-etth1-pretrain)
  • HuggingFace URL: https://huggingface.co/ibm-research/test-patchtsmixer
  • Revision: 929deb5554d0dc787505243f5372463b241f0c68 (snapshot_download)
  • Architecture: PatchTSMixerForPrediction (transformers 4.57.6, model_type patchtsmixer)
  • Task: Time-series forecasting (point prediction), pipeline_tag: time-series-forecasting
  • Config: context_length=512, prediction_length=96, num_input_channels=7, num_patches=32, patch_length=16, patch_stride=16, d_model=48, num_layers=2, mode=common_channel, scaling=true, distribution_output=student_t (but loss mse, point forecast)
  • Weights: model.safetensors 789,328 bytes (~0.75 MB), 771K on disk, param_count 196,144, dtype float32
  • License: apache-2.0
  • Reference Official Model: https://huggingface.co/ibm-granite/granite-timeseries-patchtsmixer

Test checkpoint for PatchTSMixer ETTh1 pretrain. Small footprint, suitable for single-card NPU validation.

Data Contract

FieldValue
Input formatpast_values: FloatTensor [batch, seq_length, num_input_channels] [B,T,C]
Input shape[2, 512, 7] (batch 2 tested, dynamic batch supported)
Channel semanticsmultivariate 7 channels (ETTh-like)
Context length512
Prediction length96
Horizon96 steps ahead, 7 channels forecasted
dtypefloat32
Scalingmodel internal scaling=true (reversible instance norm via loc/scale)
Observed masktorch.ones_like(past_values) internal, no missing values in this test
Seed42 (deterministic torch.manual_seed)
Outputprediction_outputs: [2, 96, 7], plus loc [2,1,7], scale [2,1,7], last_hidden_state [2,7,32,48]
Preprocessingnone beyond Tensor creation; values sampled from N(0,1) for synthetic validation; real ETTh data would be normalized via same pipeline

No CSV/Parquet dataset required for this synthetic validation; model accepts raw Tensor. For real data, maintain column order and channel count =7.

Environment

  • NPU: Ascend910 (910_9362), 2 devices on pod, target npu:0, npu-smi info verified
  • CANN: /usr/local/Ascend/cann-8.5.1
  • Python: 3.11.14
  • Torch: 2.9.0+cpu
  • torch_npu: 2.9.0.post1+gitee7ba04
  • Transformers: 4.57.6
  • tsfm_public: 0.1.dev1+g9739fa59b (not required for this model but installed)
  • NPU check: torch.npu.is_available()==True, device_count=2, torch.npu.get_device_name(0)==Ascend910_9362

Installation

pip install torch==2.9.0 torch-npu==2.9.0.post1 transformers==4.57.6 numpy==1.26.4 huggingface_hub safetensors
# or
pip install -r requirements.txt

Model is downloaded on first run via snapshot_download if models/test-patchtsmixer not present; subsequent runs use local files only. Cache path models/test-patchtsmixer is excluded from GitCode submission.

NPU Inference

python inference.py

Default behavior (no args) does:

  1. Resolve model directory (./models/test-patchtsmixer or HF download)
  2. Set torch.npu.set_device(0) and move model + Tensor to npu:0
  3. Create deterministic input [2,512,7] with seed 42
  4. Warmup 3 iterations (graph compilation), then timed inference with torch.npu.synchronize() before/after
  5. Benchmark 10 stable runs, report avg/min/max/p50/p90/p95, throughput, peak memory
  6. Print input/output summaries and device verification

Explicit NPU device trace in output:

target_device: npu:0
model device: npu:0
input device: npu:0
output device: npu:0

No CPU fallback; warnings about allow_internal_format=False are harmless and indicate NPU execution.

Real Results (from npu:0 in this pod)

First run (post-warmup): 1.57 ms for batch 2 Stable benchmark (10 runs): avg 1.63 ms | min 1.57 ms | max 1.73 ms | p50 1.62 ms | p90 1.69 ms | p95 1.71 ms Throughput: 1225 windows/s (batch 2), series/s equivalent Peak NPU memory: 1.9 MB

Output shape torch.Size([2, 96, 7]) dtype float32 device npu:0 Sample forecast [0, :3, :3]:

tensor([[ 0.7755, -0.0929, -0.7411],
        [ 0.7456, -0.0931, -0.4562],
        [ 0.8253, -0.1361, -0.3123]])

Forecast stats: mean -0.036455, std 0.234339, min -0.893713, max 0.825281 Input sample [0,0,:3]: [1.9269, 1.4872, 0.9007], mean 0.0083, std 1.0021

Logs captured in evidence images below; these numbers are from real NPU execution, not simulation.

Consistency (CPU vs NPU)

Using identical weights, input, seed, dtype, eval mode:

python .claude/skills/npu-adapt-skills/scripts/compare_outputs.py --cpu working/cpu_output.npy --npu working/npu_output.npy --task regression --atol 1e-4 --rtol 1e-3

Result:

{
  "task": "regression",
  "cpu_shape": [2, 96, 7],
  "npu_shape": [2, 96, 7],
  "max_abs_error": 6.62e-05,
  "mean_abs_error": 1.73e-05,
  "passed": true
}

Threshold atol=1e-4, rtol=1e-3 for float32 point forecast. Single-window smoke consistency (not full ETTh benchmark). Classification metrics not applicable; forecast tensors compared directly.

Performance

  • Compile/first: ~1.57 ms after 3 warmup iterations (first run after warmup in inference.py)
  • Stable: 1.63 ms avg (see benchmark above)
  • Batch: 2, Context 512, Horizon 96, Channels 7, dtype float32
  • Device: npu:0 with torch.npu.synchronize() around each measurement
  • Memory: weight 0.75 MB, peak allocated 1.9 MB (tiny model)
  • Note: Preprocessing (random generation) not timed; pure model forward timed. Throughput counts windows, not CSV rows.

Evidence (xterm.js from real logs)

Images below are rendered from real terminal logs via xterm.js (scripts/render_xterm_evidence.mjs --style raw), not manually drawn. Fixed prompt atomgit@pod-a94f8701860f4700b161b00e290de466:~$ is display-only.

Agent Workflow

agent workflow

NPU Device Call

npu device

Model Result

model result

Manifest evidence.json SHA256 of logs recorded in PNG footer.

Limitations

  • Single NPU npu:0 only; multi-NPU not tested.
  • Synthetic input; real ETTh/ETT datasets require channel 7 and length 512, otherwise shape mismatch.
  • FP32 only validated; FP16/BF16 not tested (model config float32).
  • num_targets=3 in config but forward returns 7 channels (all); filtering to prediction_channel_indices not exercised.
  • No training/fine-tuning on NPU, only inference.
  • Small model (<1 MB) hides scaling issues of larger TTM/MOMENT variants.

Submission Validation

python .claude/skills/npu-adapt-skills/scripts/validate_submission.py submission
# [PASS] required files and strict whitelist
# [PASS] three valid xterm evidence PNG files

Submission contains only inference.py, readme.md, requirements.txt, assets/*.png; no weights, caches, logs, or credentials.