You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 14b5e1d
Browse filesBrowse the repository at this point in the historyBrowse files
Make Neuron adapter selection version-aware (#24160) (#24160)
Summary:
## Problem
A delegated NeuroPilot program did not identify the Neuron adapter ABI
used to compile it. Runtime loading therefore relied on legacy soname
order and could select an incompatible adapter. A failed
compiled-network load could then surface as a usable-looking null
delegate instead of an initialization error.
## Solution
- Add an optional `neuron-adapter-major` compile spec and preserve it in
the serialized ExecuTorch program.
- Validate the spec during export as one raw ASCII decimal value from 1
through 255.
- Select a versioned adapter first, verify every fallback alias with
`Neuron_getVersion`, and reject a different or unknown major.
- Pin the first successful adapter ABI process-wide because shim entry
points cache resolved function pointers.
- Keep adapter selection synchronization alive for the process lifetime
so static module teardown cannot lock a destroyed mutex.
- Preserve legacy lookup for programs without the new label.
- Fail initialization on malformed labels, incompatible adapters, null
handles, and compiled-network load failures.
- Map Neuron load statuses to specific ExecuTorch errors and stop
combining non-bitmask status values.
- Keep the optional buffer allocator lazy and absent-safe. This does not
claim allocator ABI compatibility across adapter generations; the
allocator is loaded only by paths that request persistent imports or
shared weights.
## Compatibility
Existing programs without `neuron-adapter-major` keep their previous
lookup behavior. Existing exporters without `mlir-export-spec` keep the
previous converter call. Explicitly labeled programs may use an
unversioned alias only when that library reports the requested major.
This change is backend infrastructure only. It does not contain an
application, model, asset, SDK pin, SoC allowlist, or rollout policy.
## Authorship
This diff was authored with Codex.
Test Plan:
- NeuropilotPreprocessTest: 5 tests passed, including malformed and
duplicate label rejection plus a serialized-program round trip proving
the label reaches delegate compile specs.
- NeuronAdapterLibrarySelectorTest: 18 tests passed, including a
shutdown-order regression proving the adapter mutex outlives a static
module.
- NeuronErrorTest and NeuronBackendInitTest: 6 tests passed. The
init-path guardrails cover malformed labels before adapter
configuration, runtime-major mismatch, compiled-network load error
mapping, and delegate cleanup on load failure.
- The Android MediaTek backend built successfully.
- Device-runner validation: a program labeled with the matching adapter
major loaded and ran; an intentionally mismatched label failed cleanly
during initialization.
- Fast lint passed; comprehensive lint completed without errors, with
only host-platform skips for Android-only compilation units.
Differential Revision: D124210809
Pulled By: alirezamonfared
Co-authored-by: Ali Monfared <2058201+alirezamonfared@users.noreply.github.com>
0 commit comments