maderix / maderix/ANE

Runtime training on ANE — no baked weights, no recompile

Open
#47 2 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Objective-C
Stars
7.3k
Forks
960
PR merge metrics
No merged PRs in 30d

Description

Hey wanted to share some findings that might be useful here. I've been digging around the concept and found a pattern that avoids the baked-weight limitation.

The key insight: ANE accepts runtime IOSurface inputs for both operands of matmul. So instead of baking weights as BLOBFILE constants, you pass them as a second input tensor — compile once at startup, update weights in-place via IOSurface writes, and never recompile.

This enables a full Adam optimizer loop:
- Forward: W @ x with W and x both runtime IOSurfaces
- Backward: W^T @ dy and dy @ x^T as separate kernels
- Adam m/v/w update as 3 more kernels
- All compiled once, weights updated each step via memcpy to IOSurface

Running a 28-block ConvNeXt UNet (96→384ch, 256×256) with full forward+backward+Adam at ~3 it/s on M1 this way.

Some gotchas discovered along the way (all from direct probing, no docs): IOSurface slot sizes must be strictly ascending for inputs / descending for outputs — violations produce silent zeros with no error. Matmul inner dim (Ci) must be a
multiple of 32 — non-multiples also silently produce zeros. conv with runtime weights fails for grouped/depthwise (InvalidMILProgram) so depthwise stays on CPU NEON. reshape, transpose, concat, pad, reduce_* all fail at runtime — ANE is purely feed-forward matmul/elementwise.

Full cheatsheet and working implementation (LN, GELU, Adam, attention, ConvNeXt blocks) here if useful: https://github.com/imperatormk/ane-train

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue describes runtime training on the Apple Neural Engine and links a working implementation at github.com/imperatormk/ane-train, but names no repository files, tests, or entry points. Start by determining whether this repository is expected to adopt that approach; a concrete change and acceptance criteria are not specified.

Written by the indexing model from the issue text.

Assessment

Tech stack
objective-c
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.