Skip to content

accel/ane: pipeline bounded H16/H17 EXECUTEs by request key - #1234

Merged
RyanTheTide merged 1 commit into
integration/aurorafrom
ane2/ane-pipelined
Nov 8, 2026
Merged

RyanTheTide merged 1 commit into
integration/aurorafrom
ane2/ane-pipelined

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

What

The ANE driver now lets up to execute_depth EXECUTEs from different file descriptors be in flight together. execute_depth is a read-only module parameter of ane_h16_program; it defaults to 2 and accepts 1-4.

  • Before: one session mutex serialized every request. On H16 (M4) a second process could not even load a program: H16_LOAD returned -EBUSY while another program was loaded.
  • Now: publication, acknowledgment and completion dispatch stay under the session mutex. Only the pause between terminal-report polls runs unlocked.
  • Mailbox and faults: on H16, draining the ASC mailbox, stepping RTKit and checking faults move into a new optional .service transport op, which runs under the lock before the pause.
  • Reports and timing are dispatched to the pending key of the request they belong to.
  • Ownership: each fd keeps one program, and a file mutex protects that program's lifetime.
  • Program switching on H16 uses the queued BAR-context setup that H17 already uses.
  • Quarantine fails every pending request. A request that already completed keeps its own status.
  • Arena: a sustained pipeline that fills the command arena gets backpressure. Successful batches are reclaimed only after the last running request ends.

KUnit covers out-of-order completion on H16 and H17, same-program exclusion, the depth bound, arena pressure, surface ownership, timeout, quarantine, and sleep with concurrent callers.

Benchmark

Method: MobileNetV1 running as 1, 2 or 4 concurrent processes, each doing 1000 EXECUTEs (ane-run.py), two rounds.

  • Throughput is the aggregate rate: processes × 1000 / wall-clock time. The wall clock includes each process's Python start and LOAD.
  • Each arm is one boot of the same fleet36 kernel (integration 6cf0ab0). The stock arm uses the installed modules. The test arms use this patch's modules from a /lib/modules/<rel>/updates override with execute_depth set by modprobe.d.
  • After each test the stock modules and initramfs were restored, byte-identical.
  • Every arm produced the same output (identical md5). There were 0 DART faults, quarantines or timeouts, and MobileNet top-1 was 16/16 on every J616s arm.

J616s (M4 Pro, H16), 26-resident L2 MobileNet, EXECUTE/s (round 1 / round 2):

Arm 1 process 2 processes 4 processes
stock 1748 / 1897 extra processes fail with -EBUSY extra processes fail with -EBUSY
depth 1 1930 / 2013 1436 / 1443 1419 / 1427
depth 2 (default) 2043 / 2019 2622 / 2934 2520 / 2512
depth 4 2019 / 2115 2749 / 3344 4219 / 3523

Neo (J700, H17), EXECUTE/s (round 1 / round 2):

Arm 1 process 2 processes 4 processes
stock 640 / 694 632 / 655 633 / 633
depth 1 641 / 651 629 / 640 641 / 657
depth 2 (default) 642 / 788 861 / 873 880 / 884
depth 2, final commit (after the review fix) 785 / 662 857 / 854 891 / 880

What the numbers show:

  • Single-process latency does not change. The J616s h16-mobilenet.py host p50 was 0.264-0.273 ms in every arm, against 0.271 ms on stock.
  • With 2 or more callers, throughput rises 35-39% on the Neo. On the J616s, 2 or 4 processes now work at all, and they reach 1.4-2.2x the single-process rate.
  • Depth 1 keeps today's serialization. On H16 that costs a program switch per request when processes interleave, which is why depth 1 is slower there with 2+ processes.

Review fix

An independent review of the first version found that it released the session lock around the whole H16 relax(). That relax() also drains the mailbox: two readqs pop one entry. Two waiters doing this concurrently could tear an RTKit message. In this version only the pause runs unlocked.

Tests

  • checkpatch --strict: clean.
  • ANE KUnit, boot and transport configurations: 223/223 each.
  • Hardware: the tables above. The J616s rows were measured on the pre-review commit.
  • J616s re-check of this final commit, depth 2, EXECUTE/s (round 1 / round 2):
    • 1 process: 1848 / 1979
    • 2 processes: 2620 / 2673
    • 4 processes: 2510 / 2477
    • top-1 16/16, the same output as every other arm, 0 faults.

🤖 Generated with Claude Code

Keep publication, acknowledgment and completion dispatch under the session
mutex, but release it while waiting between terminal-report polls. Reserve
a bounded session slot and each program's surfaces through copy-out so
other fds can overlap preparation and submission with engine execution.
Default to two slots; a read-only execute_depth parameter permits 1-4.

Dispatch reports and timing to their own pending keys. Fail every pending
request on quarantine, retain the command arena on uncertain outcomes,
and drain owners before lifecycle traffic and sleep. Reclaim successful
batches only after the last running request ends, with backpressure when
a sustained pipeline fills the arena. Hold the gate and performance vote
while any request runs, preserving the existing idle gate hold.

Allow H16 program switching through the queued BAR-context setup already
used on H17. Queue overlapping requests and invalidate speculative direct
context after an overlapping batch, whose completion order can differ.
Keep one program per fd with a file mutex protecting its lifetime.

Exercise out-of-order completion on H16/H17, same-program exclusion, the
default bound, arena pressure, surface ownership, timeout, quarantine and
sleep with concurrent KUnit callers.

Only the poll pause runs without the session lock. On H16 the
backend relax also drains the ASC mailbox (two reads pop one entry),
steps RTKit and checks faults; two waiters doing that at once could
tear a message. A new optional service op does that part under the
lock before the pause. A request that already completed keeps its own
status even if the session is quarantined before its owner re-takes
the lock.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
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