mlboydaisuke/TimesFM-2.5-200M-CoreAI
Core AI is Apple's on-device ML runtime in iOS 27 / macOS 27 and the successor to Core ML: PyTorch models are exported with Apple's coreai-torch (LLMs: coreai.llm.export) into .aimodel bundles that run on the GPU or the Neural Engine, e.g. Qwen3-8B 4-bit decodes at 94 tok/s on an M4 Max GPU, MLX 90 under the same protocol (apple-silicon-llm-bench, macOS 27 beta 26A5353q, 2026-06-11).
<!-- gen-cards:devicemark begin (managed by scripts/gen-cards + tools/devicemark_row.py — edit cards.json, not this block) --> This model has no row on DeviceMark, the on-device LLM leaderboard. <!-- gen-cards:devicemark end -->
TimesFM 2.5 200M — Core AI
`google/timesfm-2.5-200m-transformers` (Apache-2.0, 200M) converted to Apple Core AI .aimodel — the zoo's first time-series forecasting foundation model. A decoder-only patched transformer: feed it any univariate series, get a 128-step point + 10-quantile forecast, entirely on device.
TimesFM is a *decoder-only transformer over time-series patches* (32 points/patch), with the familiar LLM stack — RoPE, RMSNorm sandwich-norm, QK-norm, a learnable per-dim attention scale — but numeric patches in and quantile forecasts out. The zoo port runs it as one stateless Core AI graph
- a host DSP wrapper** (RevIN normalization, flip-invariance, continuous-quantile head): no LLM runtime, just CoreAIKit's
GraphModel.
Contents
timesfm_2p5_200m_ctx2048_fp16.aimodel— the transformer graph (fp16, ~463 MB). Fixed context 2048 (64 patches); shorter series are front-padded + masked by the host, so one bundle covers every context length ≤ 2048. Inputstok_in[1,64,64],cos/sin[1,64,80],attn_bias[1,1,64,64]→ outputsproj_point[1,64,1280],proj_q[1,64,10240].ios/timesfm_2p5_200m_ctx2048_fp16.aimodel— the same JIT graph, byte for byte; every iPhone generation specializes it on its first load.ios-h18p/timesfm_2p5_200m_ctx2048_fp16.h18p.aimodelc— the graph compiled ahead of time for the iPhone 17 Pro (h18p), that phone only; moved fromios/in revision2a0801a1(2026-09-26).host/— the Python host-DSP reference (timesfm_core.py,host_forecast.py): patching, two-level RevIN (global + per-patch causal Welford), flip-invariance (2 graph calls on ±input), continuous-quantile head, denormalization, positivity clamp. This is the exact spec the SwiftForecasterfollows.
Gates (vs the HF TimesFm2_5ModelForPrediction fp32 oracle)
- Re-authored graph vs HF projections: cos 1.0000000 (MAE ~1e-6).
- Independent host DSP + graph vs HF final forecast: cos 1.0000000 (rel ~1e-8).
- Core AI fp16 graph, Mac GPU: cos ≥ 0.99998; end-to-end forecast cos 0.9999999, values match HF to 2–3 decimals — including a front-padded short-context case.
- iPhone 17 Pro, in-app (`KitForecaster`, AOT h18p): device forecast == Mac to 3 decimals (Δ ≤ 0.001, fp16 GPU rounding).
- Mac GPU ~7 ms/graph → ~14 ms per 128-step forecast (flip = 2 calls); iPhone 17 Pro ~25 ms warm (54 ms cold). The iPhone numbers come from the h18p AOT bundle, now in
ios-h18p/.
Measured 2026-09-26 on an iPhone 18 Pro (iPhone19,2, iOS 27.0 build 24A437, h19p) with the zoo's DecideGate app in its load-only mode, without the increased-memory entitlement. Each first load was the graph's first in an app container that held no specialization of it; the app had run other graphs before. The call is one run on all-zero inputs. Each first load wrote a specialization of about the bundle's size into the app container, and the load after a relaunch reused it. One measurement per graph (knowledge/jit-distribution.md). The same phone refuses an h18p bundle with incompatibleCompiledAssetArchitecture.
Use (Python, Core AI runtime)
import numpy as np, torch, coreai.runtime as rt, asyncio
from host_forecast import forecast # host/host_forecast.py
from timesfm_core import EngineCore # thin engine adapter (see host/)
CFG = dict(patch=32, horizon=128, hidden=1280, layers=20, heads=16,
head_dim=80, inter=1280, q=9, oql=1024, eps=1e-6)
model = asyncio.run(rt.AIModel.load("timesfm_2p5_200m_ctx2048_fp16.aimodel",
rt.SpecializationOptions.from_preferred_compute_unit_kind(
rt.ComputeUnitKind.gpu())))
core = EngineCore(model.load_function("main"), torch.float16)
series = torch.tensor(my_1d_series, dtype=torch.float32) # any length ≤ 2048
mean_pred, full_pred = forecast(core, series, ctx_len=2048, cfg=CFG) # (128,), (128,10)Use (CoreAIKit, Swift)
let forecaster = try await KitForecaster(catalog: "timesfm-2.5-200m")
let out = try await forecaster.forecast(series) // [Float] → point + quantiles
// out.mean (128-step), out.quantiles (128 × 10)Base model: TimesFM 2.5 (Google Research). Core AI export: coreai-model-zoo. Apache-2.0.
<!-- funnel:v1 -->
More models in this format: Core AI Model Zoo — 75 models, each with the recipe that produced it.
Want a different model on-device? Open a request — free, open weights only; the export and its measured numbers get published publicly.
<!-- /funnel:v1 -->
