Skip to content

About

Quilt edge ML — out-of-core learning, ring buffer, first/last mile filters, TFLite/EI/ONNX substrates

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

quilt-edge-ml

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              │
│                                                                       │
└─────────────────────────────────────────────────────────────────────┘

What this solves

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

Files

  • src/ring_buffer.py — JSONL FIFO ring buffer on disk
  • src/out_of_core.py — streaming dataset iterator + sklearn-style partial_fit loop
  • src/first_last_mile.py — anomaly filter + parameter-update reducer
  • src/ei_substrate.py — Edge Impulse .eim runner as a substrate
  • src/tflite_substrate.py — TFLite + ONNX runtime wrappers
  • tests/test_ring_buffer.py — rotation + total cap tests
  • examples/vessel_demo.py — vessel-observability canonical demo
  • DESIGN.md — architecture & rationale

Quick start

cd /opt/quilt-edge-ml   # on the UNO Q, after install
python3 examples/vessel_demo.py

This runs a 5000-record synthesized vessel telemetry stream through:

  1. The ring buffer (1 file, 1 MB)
  2. The first-mile anomaly filter
  3. The out-of-core training loop
  4. The last-mile parameter reducer

Wire into a cell

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")

Doctrines demonstrated

  1. Out-of-core learning. Stream batches from disk; never load the full dataset.
  2. Bounded disk. A ring buffer keeps fresh data and evicts old. The disk never fills up.
  3. First/last mile. The node filters what goes up (egress) and what it accepts from above (ingress). It is not a dumb pipe.
  4. 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.
  5. ML is one substrate. LLM, TFLite, ONNX, sklearn — they're all tiles in the cell's tiling. None of them is the spine.

Why these specific patterns

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.

Edge Impulse integration

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))
"

Performance expectations on UNO Q 4GB

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

About

Quilt edge ML — out-of-core learning, ring buffer, first/last mile filters, TFLite/EI/ONNX substrates

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages