Skip to content

Speed up A2-Full processing at 32/64 sample blocks - #330

Open
honkkis wants to merge 3 commits into
sdatkinson:mainfrom
honkkis:perf/a2-small-block-prepack
Open

honkkis wants to merge 3 commits into
sdatkinson:mainfrom
honkkis:perf/a2-small-block-prepack

Conversation

@honkkis

@honkkis honkkis commented Sep 10, 2026

Copy link
Copy Markdown

This reduces the CPU cost of A2-Full at small host buffer sizes by caching Eigen's packed 8x8 weight panels and reusing them for 32- and 64-sample blocks.

The changing input side is still packed per callback, and the calculation uses Eigen's existing gebp kernel so the accumulation order stays the same. Other block sizes continue through the existing Eigen path. A2-Lite is unchanged, and builds using external BLAS keep the original dispatch.

On an Apple M1 Release build, three runs against the current main baseline measured:

  • 32/32: 12.8-13.2% lower A2-Full CPU
  • 64/64: 7.8-8.4% lower A2-Full CPU
  • A2-Lite control cases stayed around measurement noise

Validation against an untouched checkout of the current main:

  • 330 streams / 10,814,430 samples compared bit-for-bit with zero differences
  • 180 impulse cases with zero added audio latency

The packed weights add roughly 45 KiB per A2-Full instance and are prepared when the model weights are loaded; there are no extra process-time heap allocations or audio buffers.

I also keep a version of the same optimization adapted to the older Core revision used by the current NAM plugin (9c7b185) here:

https://github.com/honkkis/NeuralAmpModelerCore/tree/perf/a2-small-block-prepack-9c7b185

That branch is only for testing/integration against the older plugin-pinned Core. This PR targets current main.

dfernandes83 added a commit to dfernandes83/NeuralAmpModelerCore that referenced this pull request Sep 15, 2026
dfernandes83 added a commit to dfernandes83/NeuralAmpModelerCore that referenced this pull request Sep 18, 2026
sdatkinson#313)

Merges upstream PR sdatkinson#313 on top of our sdatkinson#330 panel-caching commit: a2_fast's
create() now tries the planar kernel first (NAM_A2_PLANAR, gated to
__aarch64__ or __arm__+NEON+FMA at compile time) and falls back to the
existing Eigen-panel-cached reference model everywhere else, including
Windows/x86 where a2_planar.cpp compiles to an empty translation unit.

Claimed bit-identical to a2_fast (2.0-2.47x on Apple M2, 1.4-2.9x on
Cortex-A17/A76), contingent on the compiler contracting a*b+c into an FMA
in the scalar reference -- true under GCC/Clang, not under MSVC/fp:precise,
and on ARMv7 additionally contingent on FPSCR.FZ being set by the host.
Not yet verified on our own hardware; C.2 of the tone3000 NAM evolution
plan needs this run through nam-inference-cpu-benchmark on real Apple
Silicon before/after before it's trusted.
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