Repository navigation
accel/ane: h16, h17: load programs with int8 and uint8 surfaces - #2748
Conversation
|
The change is small and the bound that keeps a program inside its buffers,
Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Reviewed 046f9839d76b against pre-pr-checklist.md.
0 code/policy/attribution/CI blockers.
- §1–§3 (Correctness, bounds, alignment, safety):
hwx_element_size()safely reads+0x24,+0x68, and+0x6c(afterlength >= 0xd48is checked), rejects any non-zero upper 32 bits of the u64 element size, and admits strictly(5, 2)(fp16),(2, 1)(int8), and(3, 1)(uint8).- Checked overflow/bounds invariants in
hwx_tensor()and all downstream consumers (ane_h16_load.c,ane_h16_program.c,ane_h16_accel.c): lowering the row floor fromwidth * 2towidth * elementkeepsrow <= plane <= batch <= n * batch == b->span <= b->section.size <= b->allocation, and no downstream path assumes 2 bytes/element or allows DMA/mmap access past the validated section/allocation. hwx_element_format_testthoroughly exercises all 3 accepted pairs, 14 rejected pairs (including mixed sizes and non-zero upper u32), mixed int8-in/uint8-out, and the exact 256-byte row width boundary.- Non-blocking nit:
drivers/accel/ane/ane_h16_hwx.c:370-371says 8-bit surfaces keep the 64-byte row alignment of fp16 ones, thoughhwx_tensor()does not actually enforceIS_ALIGNED(row, 64)for either format—worth phrasing as what observed objects do (or enforcing it explicitly) if you respin.
- §4 & §6 (Clean-room, attribution, naming): Human author/committer and
Signed-off-by:only on046f9839d76b, PR disclosure present, clean-room and naming clean. - CI:
host-testsgreen on046f9839d76b.
Holding only for §5 hardware verification on 046f9839d76b:
- H16 hardware row (e.g., M4 J713 or J616s) at
046f9839d76b: 8-bit (int8/uint8) program load/execute plus fp16 regression (add/mhc), since the commit and validator cover both H16 and H17 (§1 requires proving across affected generations or requesting a test run). - Live-head regression row (on H17/J700 and H16) reporting the §5 baseline checks: 0 SELinux denials, 0 failed systemd units, 0 new kernel errors (
dmesg -l err..emerg) on046f9839d76b(the existing J700 row is from an earlier 2026-11-19 commit and omits the regression checks).
Assisted-by: LLM (Gemini 4 Neon)
The HWX validator refused every tensor descriptor whose format code (+0x24) was not 5 or whose element size (+0x68) was not 2, so any program with an 8-bit input or output failed H16_LOAD with ENOEXEC: quantized networks, quantize/dequantize at the edges, uint8 image inputs. Apple's H16 and H17 objects carry three (format, element bytes) pairs on surfaces that this driver can size: fp16 (5, 2), int8 (2, 1) and uint8 (3, 1). The rest of the descriptor is the same as for fp16: rows keep the 64-byte alignment (a 224-wide uint8 image has 256-byte rows, the fp16 one 512), plane = height * row, batch = channels * plane, and the span is still n * batch, so the buffer sizes need no change. Only the row minimum assumed two bytes per element; it is now width * element bytes, which an 8-bit surface needs whenever its row is shorter than 2 * width (797 of the 2057 8-bit surfaces in the qweights sweep). Accept exactly those three pairs. Other pairs seen in Apple's objects (fp32 (6, 4), int16 (4, 2), uint16 indices (15, 2)) and anything else stay refused until they are tested on hardware. Checked in userspace against Apple's H17 objects in Lean's Linux container (anec --wrap): all 2823 qweights programs and 15 8-bit op-survey programs validate (1315 of them were refused before), and the 1523 that validated before give the same surfaces and spans. Signed-off-by: Bartosz Nitka <niteria@gmail.com>
046f983 to
f03100f
Compare
|
Addressed both review points and force-pushed
Updated the PR description with these results. Assisted-by: LLM (Gemini) |
|
Re-review of f03100f. Both points are covered. The comment now describes what the observed objects do and says Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Re-reviewed f03100f28f2e against pre-pr-checklist.md (§1–§6). Every point from the prior review on 046f9839d76b is resolved:
- §1–§3 (Code, bounds, safety, no model gating):
- The only code delta from
046f9839d76btof03100f28f2erewords the comment indrivers/accel/ane/ane_h16_hwx.c:369-376to accurately describe observed 64-byte row alignment while stating explicitly thathwx_tensor()enforces only thewidth * elementfloor. hwx_element_size()rejects non-zero upper 32 bits of+0x68and admits strictly(5, 2)(fp16),(2, 1)(int8), and(3, 1)(uint8). All overflow/span invariants (row <= plane <= batch <= n * batch == b->span <= b->section.size <= b->allocation) remain intact across H16 and H17 with zero chip/board/firmware gating.hwx_element_format_testcovers all 3 accepted pairs, 14 rejected pairs (including fp32/int16/uint16 and non-zero upper u32), mixed int8-in/uint8-out, and exact 256-byte row width boundaries.
- The only code delta from
- §4 & §6 (Clean-room, attribution, naming): Commit
f03100f28f2ecarries human author/committer and humanSigned-off-by:only (zero AI trailers in commit); PR disclosure is present; clean-room and naming are clean. - §5 (Hardware evidence & regression baseline):
- H16G (J713 / T8132,
dc771820+f03100f28f2e): negative control confirms-ENOEXECbefore the patch onrow=64 < 2*width; patched run passes 67/67 wrapped Apple H16qweightscases across all 9 I/O combos (0LOADFAIL,0hangs/recoveries, maxrelL26.26e-3vs0.02), fp16add12810/10 exact (0 ulp),0failed systemd units,0newdmesg -l err..emergentries (NixOS, no SELinux). - H17 (J700 / T8140,
b8c5bb03+ identicalane_h16_hwx.c): fp16add102410/10 exact (0 ulp), 73 stagedqweightscases (0LOADFAIL,0hangs/recoveries),0failed systemd units,0newdmesg -l err..emergentries (NixOS, no SELinux). - Arm64 QEMU KUnit (
268/268, KASAN+UBSAN),checkpatch.pl --strict, andW=1clean.
- H16G (J713 / T8132,
- CI:
Host tests / host-testsgreen onf03100f28f2e.
LGTM — ready to merge.
Assisted-by: LLM (Gemini 4 Neon)
Problem
hwx_tensor()indrivers/accel/ane/ane_h16_hwx.crefuses every tensor descriptor whose format code (+0x24) is not5or whose element size (+0x68) is not2, and enforces a minimum row stride ofwidth * 2. As a result, any H16/H17 program with an 8-bit input or output (quantized networks, quantize/dequantize edges, uint8 image inputs, bool outputs) failsH16_LOADwith-ENOEXEC.Change
Accept the three
(format, element bytes)pairs seen on H16 and H17 surfaces that the driver already sizes cleanly:(5, 2)— fp16(2, 1)— int8(3, 1)— uint8and check the row minimum against
width * elementinstead ofwidth * 2(while also requiring the upper 32 bits of the u64 element size at+0x68to be zero).The rest of the layout is unchanged: observed 8-bit objects align rows to 64 bytes like fp16 ones (for example, a 224-wide uint8 image has 256-byte rows against 512 bytes for fp16),
plane = height * row,batch = channels * plane, andspan = n * batch.797of the20578-bit surfaces in the qweights sweep haverow < 2 * width, so updating the row minimum alongside the format table is required to admit them (hwx_tensor()checks only thewidth * elementfloor, not row alignment, for all accepted formats).Other pairs seen in Apple's objects (
fp32 (6, 4),int16 (4, 2),uint16 (15, 2)) and any unknown pairs stay refused until tested on hardware.KUnit (
hwx_element_format_testinane_h16_hwx_test.c) covers all three accepted pairs on input and output (including mixed int8-in / uint8-out), 14 refused pairs (mismatched sizes, unknown codes, fp32/int16/uint16, non-zero upper 32 bits), and the 256-byte row width boundary (256 int8 accepted, 257 int8 refused, 256 fp16 refused, 128 fp16 accepted).Testing
scripts/checkpatch.pl --strict(f03100f28f2e)drivers/accel/ane/,W=1, J700 config with ANE built in (f03100f28f2e)ane.kunitconfig, KASAN + UBSAN,f03100f28f2e)ane-h16-hwx: 18/18 includinghwx_element_format_test)tools/asahi/run-host-tests.py(ANE host tests)ane-tm-transient-fault-testspassed (2/2; commit only touchesane_h16_hwx.candane_h16_hwx_test.c)ane_h16_hwx.c, ASan/UBSan) against wrapped H17 objectsdc771820+f03100f28f2e,ane_h16_hwx.ko) — negative controlqweights.conv/held1/k3_c33_o79_34x45_b0_none__f16__us(uint8 -> int8,w=34,row=64 < 2*width) failsH16_LOADwith-ENOEXEC(Exec format error)qweights(67 wrapped Apple H16 cases) &add1280LOADFAIL,0hangs/recoveries,3.37 swall;qweights.conv42/42,qweights.linear11/11,qweights.multi14/14). Covers all 9 I/O combos (508-bit I/O,17withrow < 2*width,17fp16; maxrelL26.26e-38-bit /1.90e-3fp16 vstol=0.02). fp16add12810/10 runs16384/16384 exact, 0 ulp(0.6 msload, p50109.7 us). Baseline: 0 failed systemd units, 0 newdmesg -l err..emergentries, 0 ANE/DART/PMGR errors (NixOS, no SELinux)b8c5bb03+ identicalane_h16_hwx.ccode + H17 carries) — live-headqweights+add1024add102410/10 runs1024/1024 exact, 0 ulp(p50120.3 us);qweights73 staged cases (146 Apple + Lean programs; 1 case refused at emit by Lean's D10 gate):0LOADFAIL,0hangs/recoveries (7 sdevice time), 70/73 passC(remaining 3l4-v2/l4-v4match Apple bit-for-bit,bitdiff 0). Baseline: 0 failed systemd units, 0 newdmesg -l err..emergentries during the run (NixOS, no SELinux). Earlier 2026-11-19 run also verifiedmhc 960x540×2 exact (md5 34ff134b) and standalone uint8-actdw_c3_o3_35x65_b1_relu__au8-t-z0__fs(relL2 1.57e-3)Overlap
Checked against open PRs on
aurora-silicon/linux: PR #2647 (accel/ane: run Apple's camera programs, serve the ISP's MLVNR endpoint) also editshwx_tensor()inane_h16_hwx.c(procedure name"net"vs"main"), orthogonal to format/element-size admission.Still to run
None — tested on both H16G (J713 / T8132) and H17 (J700 / T8140).
Assisted-by: LLM (Claude, Gemini)