Skip to content

spyx.experimental.litert: TFLite/LiteRT export of spiking step functions#46

Closed
kmheckel wants to merge 1 commit into
mainfrom
feat/litert-export
Closed

spyx.experimental.litert: TFLite/LiteRT export of spiking step functions#46
kmheckel wants to merge 1 commit into
mainfrom
feat/litert-export

Conversation

@kmheckel

@kmheckel kmheckel commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Adds a LiteRT export leg (the commodity-phone counterpart to spyx.nir's neuromorphic leg).

to_litert(model, input_shape, ...) exports a spiking model's single-timestep (x, state) -> (out, new_state) forward to a TFLite flatbuffer via jax2tftf.lite.TFLiteConverter. The recurrence stays in on-device app code (the phone runs the loop, threading state) — the exported model is a small feed-forward step, which is exactly what runs cheaply on phone CPU/DSP/NPU for always-on sensing.

  • Verified: the tf.lite.Interpreter output numerically matches the JAX single step for zero and nonzero state (atol 1e-4).
  • tensorflow/jax2tf imported lazilyimport spyx.experimental.litert needs no TF; conversion needs spyx[litert], phone inference only tflite-runtime/ai-edge-litert.
  • [litert] optional extra added; the CI ty job syncs explicit extras (quant+loaders) rather than --all-extras so it doesn't pull tensorflow.

Experimental / unstable API. Pairs with the ternary-LLM QAT PR as the two edge-efficiency LOEs.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

…nctions

Export a spiking model's single-timestep (x, state) -> (out, new_state) forward to
a TFLite flatbuffer via jax2tf -> tf.lite.TFLiteConverter, so a phone runs the
temporal loop on-device (the recurrence stays in app code; the model is a small
feed-forward step). tensorflow/jax2tf imported lazily — importing the module needs
no TF; conversion needs 'pip install tensorflow', phone inference only tflite-runtime.

- to_litert(model, input_shape, *, batch, dtype) -> bytes + a LiteRTStepSignature
  describing the flattened state I/O for on-device threading.
- Verified: the TFLite interpreter output matches the JAX single step (zero AND
  nonzero state, atol 1e-4).
- TensorFlow is NOT declared as a spyx extra on purpose: it's a heavyweight
  conversion-only tool, and pinning it drags the universal lock (e.g. h5py) to
  tf-compatible versions that break newer Python. Users install it themselves.

Experimental / unstable API.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kmheckel

kmheckel commented Jul 4, 2026

Copy link
Copy Markdown
Owner Author

Shelving for now — ONNX (#48) covers the universal deployment story (phones via ONNX Runtime Mobile + servers + edge, plus the native-Loop full-temporal export). LiteRT remains valuable specifically for best-in-class Android NPU performance (Google's forward path vs ONNX's deprecated-NNAPI route), so keeping the branch feat/litert-export intact to reopen if/when Android-optimized deployment becomes a priority.

@kmheckel kmheckel closed this Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant