onnxruntime
6dd9ba94 - Add AVX2 LayerNorm/RMSNorm kernel for x86-64 (MLAS) (#31973)

Commit
51 days ago
Add AVX2 LayerNorm/RMSNorm kernel for x86-64 (MLAS) (#31973) ## Summary Adds an AVX2/FMA MLAS kernel for LayerNorm and RMSNorm on x86. LayerNorm uses a centered two-pass algorithm with an fp64 mean accumulator, improving accuracy over the existing scalar fp32 Welford path for poorly conditioned inputs. Short rows retain the scalar fallback, and existing non-x86 kernels are unchanged. ## Performance On an AMD EPYC 9V74, the corrected microbenchmark (whose scalar baseline mirrors production's per-output division) measured approximately these median speedups: | NormSize | LayerNorm | RMSNorm | |---:|---:|---:| | 128 | 9x | 3x | | 256 | 9x | 5x | | 768–4096 | 10–14x | 4.3–6.3x | These are per-row microbenchmarks; the committed benchmark verifies that the AVX2 kernel is dispatched. ## Validation - MLAS tests: 41 passed, 2 disabled; 43/43 with disabled tests enabled - fp64 parity sweep: 180 cases, 0 failures; worst normalized max error 0.022318 - Adversarial case relative error: 0.032976 for AVX2 vs. 0.93573 for the scalar path (28.4x better) - Windows builds compile the kernel translation unit with `/arch:AVX2` ```bash ./onnxruntime_mlas_test --gtest_filter="*Fp64ParitySweep*" --gtest_also_run_disabled_tests ./onnxruntime_mlas_test --gtest_filter="*Benchmark*" --gtest_also_run_disabled_tests ``` --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Author
Parents
Loading