The ML substrate zoo for the Arduino UNO Q Quilt node. Out-of-core learning, FIFO ring buffer, first/last mile filtering, TFLite/ONNX/EI runners.
The cell architecture from quilt-cell-harness is substrate-agnostic.
This repo provides the ML substrates that turn the UNO Q into a
productive edge node at the capacity of its 4 GB RAM and 32 GB eMMC.
┌─────────────────────────────────────────────────────────────────────┐
│ Quilt cell (from quilt-edge-node) │
│ │
│ engine.substrates: │
│ ───────────── │
│ ring_buffer_substrate → FIFO JSONL on eMMC │
│ out_of_core_substrate → streaming dataset iterator │
│ first_mile_substrate → anomaly filter at the edge │
│ last_mile_substrate → parameter-update reducer │
│ ei_object_detect → Edge Impulse `.eim` runner │
│ tflite_classify → TFLite runtime wrapper │
│ onnx_inference → ONNX runtime wrapper │
│ │
└─────────────────────────────────────────────────────────────────────┘
The UNO Q has constraints that don't show up on a workstation:
- 4 GB RAM, 32 GB eMMC — but the OS already eats ~0.5 GB at idle.
- Bandwidth is expensive (sat, cellular, marina Wi-Fi).
- Power is finite (solar, battery).
- A naive
pd.read_csv('multi_GB.csv')would swap to death.
This repo provides the patterns that keep the node productive inside those constraints:
| Pattern | What it does |
|---|---|
| Out-of-core learning | Stream batches from disk (no full load) |
| FIFO ring buffer | Bounded disk usage (oldest data dropped) |
| First-mile filter | Forward only anomalies to the cloud |
| Last-mile reducer | Apply only meaningful global updates |
| EI/TFLite/ONNX substrates | Run models without rewriting the cell |
src/ring_buffer.py— JSONL FIFO ring buffer on disksrc/out_of_core.py— streaming dataset iterator + sklearn-stylepartial_fitloopsrc/first_last_mile.py— anomaly filter + parameter-update reducersrc/ei_substrate.py— Edge Impulse.eimrunner as a substratesrc/tflite_substrate.py— TFLite + ONNX runtime wrapperstests/test_ring_buffer.py— rotation + total cap testsexamples/vessel_demo.py— vessel-observability canonical demoDESIGN.md— architecture & rationale
cd /opt/quilt-edge-ml # on the UNO Q, after install
python3 examples/vessel_demo.pyThis runs a 5000-record synthesized vessel telemetry stream through:
- The ring buffer (1 file, 1 MB)
- The first-mile anomaly filter
- The out-of-core training loop
- The last-mile parameter reducer
from ring_buffer import RingBuffer
from out_of_core import RingBufferDataset, partial_fit_loop
from first_last_mile import FirstMileFilter, LastMileReducer
from ei_substrate import make_substrate as make_ei_substrate
from tflite_substrate import make_tflite_substrate
rb = RingBuffer("/home/arduino/.quilt/buffer",
max_file_bytes=10_000_000,
max_total_bytes=2_000_000_000)
fmf = FirstMileFilter(window=200, z_threshold=2.5)
lmr = LastMileReducer(min_relative_change=0.05)
cell.engine.substrates["ring_buffer"] = lambda r: rb.write(r)
cell.engine.substrates["first_mile"] = lambda r: fmf.score(r)
cell.engine.substrates["last_mile"] = lambda u: lmr.reduce(current_params, u)
cell.engine.substrates["ei_detect"] = make_ei_substrate("object_detection.eim")
cell.engine.substrates["tflite_cls"] = make_tflite_substrate("/opt/models/cls.tflite")- Out-of-core learning. Stream batches from disk; never load the full dataset.
- Bounded disk. A ring buffer keeps fresh data and evicts old. The disk never fills up.
- First/last mile. The node filters what goes up (egress) and what it accepts from above (ingress). It is not a dumb pipe.
- Substrate agnosticism. Edge Impulse models, TFLite models, ONNX models, ring buffers, anomaly filters, parameter reducers — all substrates. The cell doesn't care which one is which.
- ML is one substrate. LLM, TFLite, ONNX, sklearn — they're all tiles in the cell's tiling. None of them is the spine.
The UNO Q is a small computer. The patterns above are the ones that keep it useful at scale:
- A boat generates megabytes of telemetry a minute. Without a ring buffer the disk fills in days. With one, it stays bounded forever.
- Anomalies are rare (<0.1% of events). Without first-mile filtering the network carries 99.9% noise. With it, only the rare events go up.
- Global model updates drift slowly. Without last-mile reduction, every global update wastes bandwidth and CPU. With it, only the meaningful deltas are applied.
The Arduino App Lab deploys EI models as .eim files to
/home/arduino/.arduino-bricks/ei-models/. This repo wraps
edge-impulse-linux-runner so the model becomes a substrate callable:
# On the UNO Q:
sudo apt update
sudo npm install edge-impulse-linux -g --unsafe-perm
# Deploy a model via Arduino App Lab, then:
python3 -c "
from ei_substrate import make_substrate
import sys, json
ei = make_substrate('object_detection.eim')
out = ei(b'\\x00' * (640 * 480 * 3))
print(json.dumps(out, indent=2))
"| Pattern | Throughput | Notes |
|---|---|---|
| Ring buffer writes | ~50k rec/s | JSONL, fsync per record |
| First-mile filter | ~5k events/s | Single-thread Python |
| Out-of-core batch (sklearn) | dataset-bound | No I/O bottleneck |
| TFLite MobileNetV2 (224x224) | ~30ms/frame | Adreno GPU delegate |
| TFLite YOLO-nano (640) | ~80ms/frame | NPU/GPU delegate |
Edge Impulse (.eim) |
model-bound | depends on the project |