Updating a model on 5,000 devices behind NAT, on cellular links, is a different discipline from updating a web service. You cannot roll back by redeploying. You cannot read the logs. Some devices are offline for days. And a bad update can make every device confidently wrong at once.
This post describes the pipeline that makes that survivable: shadow mode, cohort canaries, guardrail metrics, and a manifest that keeps version skew visible.
The artifact and its manifest
A model is not one file. Ship a signed bundle with everything inference needs, described by a manifest that the device can verify before it stops running the current model:
{
"model_id": "vib-anomaly",
"version": "3.2.0",
"created_at": "2026-11-20T04:12:00Z",
"framework": "tflite-micro",
"files": {
"model.tflite": { "sha256": "9f2c...", "bytes": 98304 },
"normalizer.json": { "sha256": "41ab...", "bytes": 512 }
},
"input": { "shape": [1, 512, 3], "dtype": "int8", "scaler": "rolling_zscore_v2" },
"feature_set_hash": "7d19c0e2",
"min_firmware": "1.8.0",
"target": { "ram_kb_max": 160, "latency_ms_p99_max": 25 },
"metrics": { "alarm_rate_expected": 0.0041, "alarm_rate_tolerance": 0.5 },
"signature": "MEUCIQ..."
}
Four fields carry disproportionate weight:
-
feature_set_hash— binds the model to the exact feature definitions it was trained on. If a device computes features with a different version, inference must refuse rather than produce plausible garbage. -
min_firmware— prevents a model from landing on a device whose runtime cannot execute it. Version skew between firmware and model is the most common cause of "works in staging, crashes in the field". -
alarm_rate_expected— the number the rollback logic compares against. Without an expected value, a 10× alarm-rate increase looks like an improvement in recall. -
signature— verify on-device against a pinned public key. An unsigned OTA path into a fleet is a remote code execution vulnerability.
Shadow mode: run it, do not act on it
Shadow mode is the highest-value step in the whole pipeline and the one teams skip most often. The new model runs on live data alongside the old one; only the old one's decisions are acted upon.
class ShadowRunner:
"""Run a candidate model beside production; log divergence, act on nothing."""
def __init__(self, prod_model, shadow_model, sink, warn_ratio=1.5):
self.prod, self.shadow, self.sink = prod_model, shadow_model, sink
self.warn_ratio = warn_ratio
self.n = self.disagree = self.shadow_only = self.prod_only = 0
def step(self, window, context):
p = self.prod.score(window)
s = self.shadow.score(window)
p_alarm, s_alarm = p > self.prod.threshold, s > self.shadow.threshold
self.n += 1
self.disagree += int(p_alarm != s_alarm)
self.shadow_only += int(s_alarm and not p_alarm)
self.prod_only += int(p_alarm and not s_alarm)
# sample aggressively on disagreement, sparsely otherwise
if p_alarm != s_alarm or self.n % 500 == 0:
self.sink.write({
"ts": context["ts"],
"device": context["device_id"],
"prod_score": round(float(p), 4),
"shadow_score": round(float(s), 4),
"corroboration": context.get("corroboration"),
"window_ref": context.get("ring_buffer_ref"),
})
return p_alarm
def report(self) -> dict:
return {
"n": self.n,
"disagreement_rate": self.disagree / max(self.n, 1),
"shadow_only": self.shadow_only,
"prod_only": self.prod_only,
}
Two details make shadow mode actually usable:
Log the corroborating signals, not just scores. When the shadow model disagrees, you need to know whether it did so with or without a second independent signal (temperature rising, current anomaly). Divergence with corroboration is a potential catch; divergence without is probably a false positive.
Sample the raw window reference. A ring-buffer reference lets you pull the actual waveform for a sample of disagreements, which is the difference between "the new model is worse" and "the new model is better and we can prove it".
What shadow mode can and cannot tell you
It can tell you: disagreement rate, which direction the disagreement goes, whether the new model fires on windows with corroborating evidence, and whether latency and memory fit in the real duty cycle.
It cannot tell you: whether the new model is right. Shadow mode has no labels. It reduces the risk of shipping a catastrophically wrong model; it does not validate accuracy. For that you need the labelled incidents from a later post in this series.
Canary by cohort, not by percentage
Randomly selecting 1% of devices is a bad idea when your fleet is heterogeneous. Select a cohort that is representative and low-stakes:
cohort A: 12 devices, one site, mixed models, monitored by an engaged technician
cohort B: 60 devices, three sites, all machine types
cohort C: remainder
Promotion gates, checked after a fixed observation period (not a fixed event count):
| Gate | Threshold | Action on breach |
|---|---|---|
| Alarm rate vs. expected | within ±50% | auto-rollback |
| p99 latency | ≤ manifest budget | auto-rollback |
| Crash / watchdog resets | ≤ baseline + 0 | auto-rollback |
| Shadow disagreement on cohort | ≤ 20% | hold, investigate |
| Operator disposition (spot check) | ≥ 70% actionable | hold |
The alarm-rate gate is the one that catches the most real failures, because a broken model usually fails loudly — it fires constantly. Note that the tolerance is relative to alarm_rate_expected from the manifest, which is why that field must be computed from the validation set at training time, not guessed.
Rollback must be boring
Design rollback as "switch a pointer back", not "download and reinstall":
- Keep the previous two model versions resident on the device (flash permitting).
- The active version is a single field in NVS, written only after signature and hash verification pass.
- Rollback does not require a network round trip: a device that fails its own self-test reverts on the next boot.
def activate(bundle_path: str, expected_sha: str, pubkey: str, slot: str) -> None:
verify_signature(bundle_path, pubkey)
assert sha256_file(bundle_path) == expected_sha
self_test(bundle_path) # run one inference with a fixture, check output
nvs_write("active_model_slot", slot) # single atomic-ish write
reboot()
If self_test() fails at boot, the bootloader falls back to the other slot. This is the same A/B slot pattern used by firmware update systems, and there is no reason models should be less careful than firmware.
Handling the devices that are not listening
Real fleets are never uniformly up to date. A model rollout will stall at 85% and the rest will be a long tail of devices that are offline, behind a broken gateway, or have an old firmware.
Make skew visible and bounded:
def fleet_skew(inventory):
from collections import Counter
c = Counter(d["active_model_version"] for d in inventory)
total = sum(c.values())
return {v: {"count": n, "share": round(n / total, 3)} for v, n in c.most_common()}
# alert when an old version persists beyond its support window
def stale_versions(skew, supported: set[str], max_unsupported_share=0.02):
unsupported = sum(v["count"] for ver, v in skew.items() if ver not in supported)
return unsupported / sum(v["count"] for v in skew.values()) > max_unsupported_share
Two policies that keep this from becoming permanent debt:
- A version support window. Old models are supported for N releases; after that the fleet report flags them and the devices are scheduled for attention.
- Server-side compatibility. The cloud must accept telemetry from any supported model version, because the model version is embedded in the payload. Never gate ingestion on the newest model — you will silently drop data from the tail.
The release checklist
- [ ] Model artifact signed; hash and signature verified on-device before activation
- [ ]
feature_set_hashmatches the deployed feature code - [ ]
min_firmwareset and enforced - [ ]
alarm_rate_expectedderived from a held-out validation period - [ ] Shadow run on ≥ 2,000 real windows; disagreement rate reviewed
- [ ] Canary cohort chosen for heterogeneity, not convenience
- [ ] Guardrail metrics wired to automatic rollback, not to a dashboard nobody watches
- [ ] Previous two versions retained on-device; boot-time self-test with fixture
- [ ] Fleet skew report and support window documented
- [ ] Rollback rehearsed on one device that is physically accessible
That last item matters more than it looks. A rollback path that has never been executed is a hypothesis, and the worst time to discover it does not work is during a bad rollout at 2 a.m.
Next: LLM-Assisted Triage for IoT Alerts — Turning 10,000 Alarms into 10 Tickets.
Top comments (0)