SensorForge Optimizer

v0.1.0
io.github.sidupreti/sensorforge-mcp Checked 23 hours ago Published 8 days ago

Shrink trained models to fit edge devices with the hosted SensorForge Optimizer.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_chips List chips

List the chips (edge devices) the optimizer targets, with each one's SRAM and flash budget for the model. Use a chip's name as `chip` in check_fit, lossless and optimize. Chips without budgets take yours (ram_kb, flash_kb in optimize).

check_fit Check fit on a chip

Check whether a model runs on one or more chips and how much SRAM and flash it needs there, measured. Takes seconds; no data needed. Returns a per-chip verdict with SRAM and flash against each chip's budget, and the SRAM lossless would reach. Use it first, before lossless or optimize.

ParameterTypeDescription
model_path *stringThe model: a .tflite or .onnx file, or a .zip of a firmware export. Relative to the working directory, or starting with ~.
chipsChip names from list_chips (a list, or comma separated). Each chip is one run. Default: cortex-m-cmsis, a generic Arm Cortex-M.

check_data Check data locally

Check, locally, that a data file is what optimize needs for this model, before uploading anything. For an .npz: X present, float32, each sample in the model's input shape; y one class index per sample within the model's outputs; X_test / y_test if given. For an image zip: class folders (or train/ and test/). Explains each problem and how to fix it. Nothing is uploaded and no run is used.

ParameterTypeDescription
data_path *stringThe data: an .npz (X, y) or a .zip of image folders, one per class.
model_path *stringThe model the data is for (.tflite, .onnx, or a firmware .zip).
outputstring'classes' when the model outputs class scores; 'values' for detectors, autoencoders and regression.

lossless Lossless shrink

Make the model smaller in SRAM and flash with outputs bit-identical to the original: no data, no retraining. Usually under a minute. Waits for the result, downloads it, and unpacks the model for TensorFlow Lite Micro and its C sources into the project. Returns the before -> after figures and the files. If it is still running after about four minutes it returns the run id: then call wait_for_run and download.

ParameterTypeDescription
chip *stringA chip name from list_chips.
model_path *stringThe model: .tflite or .onnx, or a .zip of a firmware export.
folderWhere to unpack the result. Default: <the model's folder>/sensorforge/<run id>/.
overwritebooleanReplace files already in the folder.

optimize Optimize within an accuracy limit

Find the smallest model for the chip within your accuracy limit, retrained on your data. Runs on the service for 5-60 minutes, so this returns right away with the run id and its place in the queue: then call wait_for_run(run_id) (again while it says still running), and download(run_id) when it passes.

ParameterTypeDescription
chip *stringA chip name from list_chips.
data_path *stringThe data: an .npz (X, y) or a .zip of image folders, one per class. Run check_data first.
model_path *stringThe trained model: .tflite or .onnx, or a .zip of a firmware export.
accuracy_limitnumberHow many points of accuracy the result may lose against your model, on the test part of the data.
check_firstbooleanRun the local data check first and stop on problems.
effortstring'quick' (about 15 minutes) or 'thorough' (up to an hour; not on the trial).
flash_kbFlash budget in KB (default: the chip's).
image_scalingstringImage zips only: how the model expects pixels. 'auto' = as the model says (int8 .tflite files carry it).
minimizestringWhat to shrink: SRAM ('ram'), flash, or both.
outputstring'classes' for class scores; 'values' for detectors, autoencoders and regression (y not needed).
ram_kbSRAM budget in KB (default: the chip's).

run_status Run status

The state of a run right now, without waiting: queued (with its place in line), running (with its latest progress), or finished with the verdict and the before -> after SRAM, flash and accuracy.

ParameterTypeDescription
run_id *stringThe run id from check_fit, lossless, optimize or list_runs.

wait_for_run Wait for a run

Wait for a run to finish, checking about every 10 seconds and reporting progress. Returns the final result (verdict and before -> after figures), or 'still running, call again' when max_wait_s is up: then call wait_for_run again. Optimize runs take 5-60 minutes, so expect several calls.

ParameterTypeDescription
run_id *stringThe run id.
max_wait_sintegerHow long to wait in this call, in seconds (at most 600).

get_report Get a run's report

The run's full report as markdown: the measured figures, what was changed and why, and what to do next. Available on every plan, including the trial.

ParameterTypeDescription
run_id *stringThe run id.

download Download a run's result

Download a finished run's result and unpack it into the project: the model for TensorFlow Lite Micro, its C sources (c/: the model as a C array, the operator list, integration notes) and the report. Refuses to write into a folder that is not empty unless overwrite=True. Returns each file and what it is for.

ParameterTypeDescription
run_id *stringThe run id of a lossless or optimize run that passed.
folderWhere to unpack. Default: <the model's folder>/sensorforge/<run id>/ (the working directory's when the model is unknown).
overwritebooleanReplace files already in the folder.

list_runs List runs

The account's recent runs, newest first: id, when, kind, model, status and verdict.

ParameterTypeDescription
limitintegerHow many runs, newest first.

stop_run Stop a run

Stop a queued or running run, for example one sent with the wrong chip or data. A stopped run gives no result; submit it again to rerun.

ParameterTypeDescription
run_id *stringThe run id.

account Account and usage

The account's plan, this month's usage, and how many runs are left today (with when the next one is free when a daily cap is reached).