Add ANE quantization probe and expand project scope to GPT-2 - #16
Closed
m0at wants to merge 7 commits into
Closed
Conversation
Forked the project and updated the README to reflect changes.
Updated README to clarify implementation details and added NEON CPU decode.
…ttribution Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Probe whether Apple Neural Engine executes quantized ops natively
(faster int8-int8 compute path) or just dequantizes to fp16 at load time.
Tests 5 approaches at transformer-representative dimensions:
1. FP16 baseline conv (baked weights)
2. INT8 via constexpr_affine_dequantize (per-channel scale+zp)
3. UINT4 via constexpr_affine_dequantize (per-channel)
4. UINT4 via constexpr_blockwise_shift_scale (block_size=32)
5. 4-bit palettized via constexpr_lut_to_dense (16-entry LUT)
Each test compiles MIL → ANE kernel, benchmarks 100 evals, reports
TFLOPS. If int8 shows ~2x fp16 TFLOPS, ANE has native int8 compute.
If same TFLOPS, it's dequant-only (still useful for memory savings).
Build: xcrun clang -O2 -fobjc-arc -o quant_probe quant_probe.m \
-framework Foundation -framework IOSurface -ldl
https://claude.ai/code/session_01U5HLjsm4iUzL9iDaHbxeRB
ebowwa
pushed a commit
to ebowwa/ANE
that referenced
this pull request
Aug 4, 2026
…uristics ane_mil.parse() extracts funcs (signature inputs/outputs) and statements (op, args, attrs, output dtype/shape) via balanced bracket matching; ane_mil.validate() checks the Orion catalog precisely — banned ops (concat/gelu) by op-name, conv bias=, matmul transpose-const (maderix#12), 32K-channel conv (maderix#16), output liveness (maderix#14), multi-output uniform (#2) + alphabetical binding (maderix#3), multi-input alphabetical (maderix#19). ane_lint.lint_mil uses the parser as primary and falls back to the regex checks when a program won't parse; size checks (maderix#4 min / maderix#18 input-uniform) and perf advisories always run. End-to-end via /raw/lint (func-wrapped gelu -> ANE010, relu -> ok). 71 tests (9 new parser tests). Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a comprehensive quantization probe for Apple Neural Engine (
quant_probe.m) and significantly expands the project README to document GPT-2 inference, M5 hardware investigation, and fused kernel benchmarking work.Key Changes
New Files
quant_probe.m(551 lines) — Systematic probe to determine if ANE executes int8/int4 quantized operations natively or only dequantizes to fp16:Documentation Updates
Implementation Details
Quantization Probe Architecture:
constexpr_affine_dequantizefor per-channel quantization andconstexpr_blockwise_shift_scalefor block-wise int4constexpr_lut_to_densefor palettized weights with shared 16-entry lookup tableWeight Blob Format:
The probe enables empirical determination of ANE quantization capabilities without relying on undocumented compiler behavior or reverse-engineering binary outputs.
https://claude.ai/code/session_01U5HLjsm4iUzL9iDaHbxeRB