Skip to content

H14 linked: later slices of a multi-task layer reuse the L2 input - #14

Merged
RyanTheTide merged 1 commit into
feature/h14-formula-linkedfrom
feature/h14-linked-input-reuse
Nov 1, 2026
Merged

RyanTheTide merged 1 commit into
feature/h14-formula-linkedfrom
feature/h14-linked-input-reuse

Conversation

@RyanTheTide

Copy link
Copy Markdown

Stacked on #11. Fixes the wrong MobileNet output on the M2 from layer 9 on.

Layer 9 is the first layer split into two tasks that read their input from scratch DRAM. On the M2 the second task computed on zeros: its 128 output channels equalled relu(bias) while the first task's channels were correct (p9 slice rel. L2 5e-4 and 1.00). The same two tasks are correct when they read the program input.

Apple's compiler never emits a second slice that reloads the input. To check that for the case at hand, research/mint_h14_s2_chains.py compiles six new chains compile-only (h14_s2link_*, decoded with this repository's parser like the rest of the h14-mobile corpus), including a six-slice stride-2 layer that reads scratch DRAM. In every decoded multi-task H14 layer only the first task loads the input. Later slices carry no source TileDMA and no 0x504/0x514/0x518 words, set the 0x38 repeat fields to the NE class, drop 0x500030 from ResultCfg 0x530, and every task of the layer except the program's last keeps LiveOuts 0x1fffffff. The linker now emits that form.

M2, 7.3.0-aurora-tt3, real weights

  • p9 (first 9 layers): rel. L2 5.5e-4, both slices, cold and warm.
  • MobileNetV1 224 as one linked program: top-1 16/16 against the CPU, top-5 overlap 5.0, worst logit rel. L2 1.28e-3, repeated output stable.
  • 1000 passes: p50 1.128 to 1.212 ms over three runs, p99 1.60 ms, about 764 inf/s (before: 1.370 ms p50 with top-1 0/16).
  • The compiler-built package and a binary-patched copy of the old package have identical task streams and give identical results.
  • Not run: the 28-program per-layer cold comparison. The tt3 driver keeps every firmware process until reboot and the firmware allows about eight, so it cannot load 28 programs in one boot (ANE: H14 program lifetime linux#737 tracks the driver side).

Host

  • make test-h14-parity pieces: 722 H14 oracle parity cases, fixture programs, conv CLI corpus (610 records, 6 linked chains), encoding test, new test_h14_linked_reuse_oracles.py (12 decoded chain programs, 19 reuse slices). test_h14_mobilenet_package.py passes on a fresh package.

Not changed: Apple also uses an 8-channel interleaved scratch layout and clears the low bits of header word 4 on middle tasks. Ours stay planar and unchanged, and the device results above do not need either.

🤖 Generated with Claude Code

On the M2, MobileNetV1 as one H14 program went wrong at layer 9, the
first layer split into two tasks that read their input from scratch
DRAM (prefix p8 rel. L2 4.8e-4, p9 0.67), while the same two tasks are
correct when they read the program input.

Apple's compiler never emits a second slice that reloads the input. In
every decoded multi-task H14 layer the first task loads the input (from
scratch with DependencyMode 1, from the program input, or from L2) and the
later slices reuse what it staged in L2. Those slices carry no source
TileDMA records and no 0x504/0x514/0x518 words, their NE repeat fields
(0x38 bits 15:8) equal the NE class, ResultCfg (0x530) drops the
DMA-source bits 0x500030, and every task of the layer except the
program's last keeps LiveOuts 0x1fffffff.

The linker now emits that form. On the M2 (7.3.0-aurora-tt3) the
second slice of layer 9 had computed on zeros (its 128 channels equalled
relu(bias)); with input reuse both slices match the CPU (rel. L2 5.5e-4,
cold and warm). The whole linked MobileNetV1 224 with real weights now
agrees with the CPU on top-1 for 16/16 images (top-5 overlap 5.0, worst
logit rel. L2 1.28e-3, repeated output stable) at 1.128 to 1.212 ms p50,
1.60 ms p99 over 1000 passes (was 1.370 ms p50 with wrong output). The new compile-only probes
(research/mint_h14_s2_chains.py, six h14_s2link records) add stride-2
consumers, including h14_s2link_pw1024_pws2_2048, a six-slice stride-2
layer that reads scratch DRAM. test_h14_linked_reuse_oracles.py checks
the rule on all twelve decoded chain programs (19 reuse slices).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RyanTheTide
RyanTheTide merged commit 1dcdb9a into feature/h14-formula-linked Nov 1, 2026
@RyanTheTide
RyanTheTide deleted the feature/h14-linked-input-reuse branch November 6, 2026 03:26
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