Skip to main content

Check if an AI model fits on a microcontroller — before you flash it.

Project description

mcufit

Check if an AI model fits on a microcontroller — before you flash it.

🌐 Try it in your browser  ·  📦 pip install mcufit

You trained a model. You have a board. Will it run, or will it crash with a cryptic allocation failure after an hour of toolchain setup? Today the official answer from the TensorFlow Lite Micro docs is that arena size "may need to be determined by experimentation." mcufit replaces the experimentation with an answer in one second:

$ mcufit check wake_word.tflite --board esp32-s3

  Model:  wake_word.tflite  (int8, 14 layers, 340 KB)
  Board:  ESP32-S3 DevKit  (362 KB usable SRAM · 8 MB flash)

  ✅ FITS

  RAM   ████████████░░░░░░░░  ~289 KB arena / 362 KB   (80%)
  Flash ██░░░░░░░░░░░░░░░░░░  490 KB total  / 8 MB     (6%)

  Peak memory moment: layer 9 (DEPTHWISE_CONV_2D) — 118 KB live tensors

   • Leaves ~73 KB RAM for your application, sensor buffers, and network stack.

No hardware required. No vendor lock-in. Works with any .tflite model and any board in the database (ESP32, RP2040, STM32, Teensy, Arduino, ...).

Install

pip install mcufit

Commands

Command What it does
mcufit check model.tflite -b esp32-s3 Fit verdict for one board (exit code 1 if it doesn't fit — CI-friendly)
mcufit check model.tflite -b rp2040 --json Same, as JSON for scripts and CI
mcufit compare model.tflite Verdict matrix across every board in the database
mcufit inspect model.tflite Layer-by-layer memory profile — see where the peak is
mcufit boards List all known boards

How it works

The RAM bottleneck on microcontrollers is the tensor arena: every intermediate activation tensor that is alive at the same moment must fit in SRAM simultaneously. mcufit:

  1. Parses the .tflite flatbuffer directly — layers, tensor shapes, dtypes, and which tensors are baked-in weights (flash) vs. runtime activations (RAM).
  2. Computes tensor lifetimes across the execution schedule and finds the peak of simultaneously-live activation memory — the same quantity TFLite Micro's memory planner must pack into the arena.
  3. Adds honest overhead for interpreter structures and a safety margin for per-op scratch buffers that static analysis cannot see, and labels the result as an estimate.
  4. Compares against a curated board database that accounts for the RAM your RTOS/Wi-Fi stack already eats before your app gets any.

A measurement mode — running your model through the real TFLM interpreter compiled for your host machine, for exact-to-the-byte arena numbers with zero hardware — is the next milestone on the roadmap.

Supported boards

ESP32, ESP32-S3, ESP32-C3, Raspberry Pi Pico (RP2040), Pico 2 (RP2350), STM32F411 BlackPill, STM32F746 Discovery, STM32H743 Nucleo, Arduino Nano 33 BLE Sense, Teensy 4.1, Seeed XIAO ESP32S3 Sense, and the Arduino Uno (so the tool can politely tell you no).

Adding a board is a 10-line PR to boards.yaml — contributions very welcome.

Roadmap

  • Measurement mode: exact arena numbers via host-compiled TFLM
  • ONNX model support
  • Latency estimation per board
  • GitHub Action (mcufit-action) to guard model size in CI
  • Web UI: mcufit in the browser — same package, running via Pyodide

Why this exists

Pre-deployment arena estimation has been requested in the TensorFlow repos since 2019 (and again in 2024) and never shipped. Vendor tools (STM32Cube.AI, eIQ, ...) answer it only for their own silicon. mcufit is the neutral, open version.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcufit-0.1.1.tar.gz (490.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcufit-0.1.1-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file mcufit-0.1.1.tar.gz.

File metadata

  • Download URL: mcufit-0.1.1.tar.gz
  • Upload date:
  • Size: 490.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.5

File hashes

Hashes for mcufit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 26edc01b1a9b3ab36d58f7b32eb13b1f2dc6d740076ba19401b80473c330dd20
MD5 a2c25eea9e2fdebef03ad4479544d7c3
BLAKE2b-256 3a3519a51a6e9103607addd930c2eb1c468ce29220840d2af56f490cbc20cda4

See more details on using hashes here.

File details

Details for the file mcufit-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mcufit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.5

File hashes

Hashes for mcufit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 af9a73d130d684c2035a4db7944bb401f5fc2a5e74e44f6b4964b30a78b95414
MD5 4122e241d863746d07bfc12f6068d2f2
BLAKE2b-256 98a76f5e02f69077e2ce06319b134ef5b471cd33dfd042f1bae8549cc4a0055c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page