cd /news/machine-learning/chronos-2-in-96-mb-of-webassembly Β· home β€Ί topics β€Ί machine-learning β€Ί article
[ARTICLE Β· art-182079] src=github.com β†— pub= topic=machine-learning verified=true sentiment=↑ positive

Chronos-2 in 96 MB of WebAssembly

A developer compiled Amazon's full 120M-parameter Chronos-2 time-series forecasting model into a 119 KiB Rust/WebAssembly SIMD engine that runs resident inside a single Cloudflare Worker, using 95.9 MB of peak WASM memory versus 959.8 MB RSS for PyTorch FP32 on CPU β€” roughly 10Γ— less RAM β€” with an 88.7 MB weight file against 478.0 MB. Across 224 public benchmarks and 9 deciles the engine stayed within Β±0.12% of FP32 on SQL, WQL and MASE, ran 1.16Γ— faster than single-core PyTorch on 512/64 forecasts (96.6 ms vs 112.0 ms) and 1.11Γ— faster across 3,800 benchmark forecasts, and served 261 ms p50 latency at the edge. The engine avoids 4-bit quantization and calibration data by assigning precision by structural sensitivity: FP32 for I/O boundary heads and norms (3.1 MB), IEEE FP16 for large I/O MLPs (9.4 MB), Q8_G64 for the 17 most sensitive encoder projections (15.3 MB) and split-plane 6-bit Q6_G64 for the remaining 67 encoder projections (60.8 MB).

recommendation

Pack weights by structural sensitivity instead of uniform 4-bit quantization β€” keep norms and I/O heads in FP32 and use 6-bit split-plane for less sensitive projections β€” to cut Chronos-2 memory roughly 10Γ— with Β±0.12% accuracy loss.

more in playbook: Inference and self-hosting
read5 min views6 publishedDec 4, 2026
Chronos-2 in 96 MB of WebAssembly
Image: Michielbdejong (auto-discovered)

Full 120M-parameter Amazon Chronos-2 time-series forecasting compiled into a 119 KiB Rust/WASM SIMD engine β€” ~10Γ— less RAM than PyTorch, faster on single-core CPU for typical forecasts, within Β±0.12% of FP32 across 224 public benchmarks, and running resident inside a single Cloudflare Worker.

No GPUs. No containers. No external inference APIs. No calibration data or retraining.

PyTorch FP32 (CPU) This Engine (WASM SIMD) Delta
Weight file 478.0 MB 88.7 MB 5.4Γ— smaller
Peak memory (8,192 / 1,024) 959.8 MB RSS 95.9 MB WASM (fits 128 MiB Worker) ~10Γ— less RAM
Runtime binary Python + PyTorch + OpenBLAS 119 KiB.wasm (37.5 KiB gz) Zero runtime deps
Single-core CPU (512 / 64 p50) 112.0 ms 96.6 ms 1.16Γ— faster
3,800 benchmark forecasts (512 ctx) 403.9 s 363.1 s 1.11Γ— faster (1.42Γ— on Chronos-II)
Accuracy (224 tasks, 9 deciles) baseline Β±0.12% SQL / WQL / MASE Indistinguishable from FP32
Live Cloudflare Workers edge Cannot run (OOM) 261 ms p50 (512/64 ) Β·1.03 s R2 cold 0 warm R2 reads

Supports the full univariate amazon/chronos-2 contract: 1–8,192 context length (including null missing values), 1–1,024 forecast horizon, and all 9 native deciles (0.1 through 0.9).

Five engineering choices make the full 120M model fit in 95.9 MB and outperform PyTorch CPU without losing accuracy:

A bespoke 119 KiB WASM engine specialized to one model. Instead of shipping a general-purpose ML runtime,engine/src/c2edge30.rs hardcodes everyamazon/chronos-2 dimension (12 layers, D=768, FF=3072, patch=16, 9 deciles ) and computes every tensor's byte offset at compile time (const usize ). There is no header parser, no dynamic shape dispatch, and no per-layer heap allocation. Activations run through a32-token micro-batched scratch arena with L2-tiled 4-query head-major attention, keeping total working RAM flat at6.5 MB even at8,192 context /1,024 horizon. 2. Why WebAssembly beats PyTorch CPU on typical forecasts. For1–512 step histories, transformer inference is memory-bandwidth bound, not FLOP bound. Streaming88.7 MB of packed weights moves5.4Γ— fewer bytes than FP32 (478 MB ), eliminates Python/PyTorch dispatch overhead, and drops 12 matrix multiplies via exactO @ V fusion. Custom 16-token WASM SIMD128 micro-kernels (i32x4_dot_i16x8 ) run1.11×–1.42Γ— faster than single-core PyTorch OpenBLAS FP32 across 3,800 public benchmark forecasts.(At 8,192 / 1,024, quadratic attention FLOPs dominate and PyTorch OpenBLAS is slightly faster: 1.38 s vs 1.67 s.) 3. Zero 4-bit quantization, zero calibration data. Standard 4-bit quantization degrades Chronos-2 on spiky and high-dynamic-range series, while switching to Amazon's smaller 28Mchronos-2-small drops accuracy by+4% to+14% . Instead,model/pack.py assigns precision purely by structural sensitivity with zero calibration data:

  • Tiny I/O boundary heads & all norms/biases stay in FP32 (3.1 MB ).
  • Large I/O MLPs use IEEE FP16 (9.4 MB ), decoded branchlessly on the fly in SIMD with zero RAM expansion.
  • The 17 most sensitive encoder projections (all 12 V matrices,L0/L1/L11 FFNwi , andL11`` ov /wo ) use**Q8_G64** ( 15.3 MB ).
  • The remaining 67 encoder projections use split-plane 6-bit (Q6_G64: low4 + high2) ( 60.8 MB ), fitted with 3-iteration closed-form alternating least-squares per 64 weights and unpacked with zero byte shuffles in WASM SIMD128.
  1. Tiny I/O boundary heads & all norms/biases stay in

Two exact weight-space transforms (zero accuracy loss in FP32).

  • Diagonal-split exact O @ V fusion: For univariate series, Chronos-2's group-attention softmax has a single active key, so attention weights are identically1.0 . The exporter multipliesM = O @ V exactly in FP64 (eliminating 12 matrices), pulls out the 768-element diagonal intoFP32 (36 KB total β€” capturing ~25% of matrix energy), and quantizes only the smooth off-diagonalM βˆ’ diag(M) .
  • Free FFN neuron sorting: BecauseW_o Β· ReLU(W_i Β· x) is invariant to permuting hidden neurons, sorting the 3,072 neurons by ascendingmax(|W_o[:, j]|) clusters outlier columns into shared 64-element quantization blocks β€” cuttingW_o quantization error by up to19% at0 bytes and0 runtime cycles.

Zero-copy BYOB streaming from Cloudflare R2. Buffering an88.7 MB model in JS heap before copying to WASM blows past Cloudflare Workers' 128 MiB isolate ceiling. On cold start,worker/handler.mjs streams the single R2 object through a reused128 KiB BYOB buffer straight intoWebAssembly.Memory while verifyingSHA-256 incrementally (1.03 s cold on live edge,0 R2 reads on every warm request after).

Requires Linux x86-64 (or macOS/ARM64 for local builds), Node.js 22+, Python 3.12, and Rust via rustup with wasm32-unknown-unknown.

./scripts/bootstrap.sh   # downloads pinned amazon/chronos-2, packs 88.7 MB weights, builds 119 KiB WASM
npm test                 # runs Worker, ABI, and 8,192/1,024 memory tests
npm run serve            # starts local workerd on http://127.0.0.1:8787

Run a forecast:

curl -sS http://127.0.0.1:8787/forecast \
  -H 'Content-Type: application/json' \
  -d '{"history":[10,12,11,13,15,14,10,12,11,13,15,14,10,12,11,13,15],"horizon":7}'
  • GET /health β€” liveness check ({"status":"ok"} ); does not load model weights (1 ms startup).
  • POST /forecast β€” accepts{"history": [...], "horizon": N} (application/json ,≀ 256 KiB ):
    • history :1–8,192 finite float32 values (null supported for missing observations; at least one observed value required).
    • horizon : integer in1–1,024 .
    • Returns {"quantiles": [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9], "values": [[...], ...]} (raw native model outputs; no post-processing).

Requires a Cloudflare Workers Paid plan ([limits] cpu_ms = 30000 for 8,192-context requests) and R2 enabled on your account.

key=$(node -p 'require("./worker/generated/artifact.json").key')
cf r2 buckets create-by-name chronos-2-artifacts
cf r2 buckets objects upload "$key" \
  --bucket-name chronos-2-artifacts \
  --content-type application/octet-stream \
  --file ".cache/artifacts/$key"

npx wrangler deploy

See docs/deployment.md for Wrangler R2 upload commands and production notes.

npm run evaluate

.cache/venv/bin/python campaigns/rfc5/run_official.py --context 512  --series-limit 16 --window-limit 1 --cpu 8 --output .cache/c2edge30/official-512
.cache/venv/bin/python campaigns/rfc5/run_official.py --context 8192 --series-limit 1  --window-limit 1 --cpu 8 --output .cache/c2edge30/official-8192

python3 scripts/generate-charts.py

Apache-2.0 β€” see LICENSE. Model weights are not redistributed; model/fetch.py downloads the pinned Apache-2.0 amazon/chronos-2 checkpoint directly from Hugging Face and verifies its SHA-256 digests against model/lock.json.

── more in #machine-learning 4 stories Β· sorted by recency
── more on @amazon 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/chronos-2-in-96-mb-o…] indexed:0 read:5min 2026-12-04 Β· β€”