Bump Eigen submodule to 5.0.0 (closes #67)#264
Open
rhaist wants to merge 1 commit intosdatkinson:mainfrom
Open
Bump Eigen submodule to 5.0.0 (closes #67)#264rhaist wants to merge 1 commit intosdatkinson:mainfrom
rhaist wants to merge 1 commit intosdatkinson:mainfrom
Conversation
Updates Dependencies/eigen from a pre-3.5 dev snapshot (87300c93c, 2023-04-17) to the released 5.0.0 tag (549bf8c75, 2025-09-28). Why this closes sdatkinson#67 ------------------- Issue sdatkinson#67 asks that we follow Eigen's struct-having-Eigen-members guidance to ensure correct alignment of Eigen members. The Eigen 5.0 release notes resolve this at the library level: > Eigen now uses the c++11 alignas keyword for static alignment. > Users targeting C++17 only and recent compilers (e.g., GCC>=7, > clang>=5, MSVC>=19.12) will thus be able to completely forget about > all issues related to static alignment, including > EIGEN_MAKE_ALIGNED_OPERATOR_NEW. NAM already requires C++20 (see CMakeLists.txt). With Eigen 5.0, the README "Sharp edges" workarounds (EIGEN_MAX_ALIGN_BYTES=0, EIGEN_DONT_VECTORIZE) are no longer needed. A follow-up commit can remove that section. Refs sdatkinson#67.
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
Bumps
Dependencies/eigento the released Eigen 5.0.0 tag.87300c93c(pre-3.5 dev snapshot, 2023-04-17) →549bf8c75(5.0.0, 2025-09-28).Why this closes #67
Issue #67 asks the project to follow Eigen's struct-having-Eigen-members guidance so consumers don't hit alignment crashes under aggressive vectorization, and so the README "Sharp edges" workarounds (
EIGEN_MAX_ALIGN_BYTES=0,EIGEN_DONT_VECTORIZE) become unnecessary.The Eigen 5.0 release notes resolve this at the library level. From
CHANGELOG.md:NAM already requires C++20 (
CMakeLists.txt). With Eigen 5.0, no per-class macros, noaligned_allocatoraudit, and noEIGEN_MAX_ALIGN_BYTESoverrides are needed for correct alignment of either fixed-size or dynamic-size Eigen members. The README "Sharp edges" section can be retired in a follow-up.I also briefly explored an alternative PR adding
EIGEN_MAKE_ALIGNED_OPERATOR_NEWto every class with Eigen members. Decided against it: today every member is dynamic-size (MatrixXf/VectorXf), so the macro is a runtime no-op, and Eigen 5.0 obsoletes it anyway. The submodule bump fixes the underlying problem rather than working around it.What I tested locally
Platform: macOS (Darwin 25.4.0, AppleClang 21.0.0), C++20, Apple Silicon.
Reproduced the same matrix CI runs on Ubuntu (
build.yml):run_testsbenchmodel wavenet.nambenchmodel lstm.namrenderDebug, default GEMMDebug,-DNAM_USE_INLINE_GEMMThe only warnings emitted in the new build are the three pre-existing
-Wsign-comparewarnings inDependencies/AudioDSPTools/dsp/wav.cpp(unrelated, present onmain).Render bit-exactness check
I rendered
example_models/wavenet.namoverexample_audio/input.wav(96000 samples) on Eigen 3.4.90 (currentmain) and Eigen 5.0, with both GEMM paths, and compared SHA-256 hashes:1d920928a7588f0455f8df088df3758d4f14e8afb4a3f09d5f9afdd477c533d9465e0cb0c8be01f21aa570dce41fb754c0016abcf17dbfeac247fc195a9e84d1be598b753d127d9c90e5cee8bb59235f16f3e5fd294c2cc2c6110968a6fc4470465e0cb0c8be01f21aa570dce41fb754c0016abcf17dbfeac247fc195a9e84d1✅ identicalInline GEMM is bit-exact across the bump (expected — that path bypasses Eigen's matrix product). Default Eigen GEMM is not bit-exact — Eigen 5.0 changes product evaluation/vectorization, producing different LSB rounding.
run_testsstill passes on both Eigen versions because the unit-test tolerances are wider than the rounding noise. Heads-up for the integration-tests workflow (Atkinson-Advanced-Modeling/NamIntegrationTests): if it pins golden audio bit-exactly against the current Eigen output, those goldens will need refreshing.What I did NOT verify locally
I'm on macOS, so I could not exercise the Linux side of the existing CI matrix. Specifically not run locally:
build-ubuntu(libstdc++) — both default andNAM_USE_INLINE_GEMMbuild-ubuntu-libcxx(libc++ via-DNAM_USE_LIBCXX_LINUX=ON) — both default andNAM_USE_INLINE_GEMM. This job exists specifically to cover the_LIBCPP_VERSIONbranch inwavenet/slimmable.h(atomic shared_ptr free-functions vsstd::atomic<std::shared_ptr<…>>).These will run on the existing
.github/workflows/build.ymlmatrix when CI fires, which is the right place to catch any platform-specific Eigen 5 incompatibility.Other Eigen 5.0 changes worth noting
From the changelog, the changes most relevant to NAM:
Eigen::aligned_allocatorno longer inherits fromstd::allocator(C++ standard change). NAM does not usealigned_allocatordirectly — no impact.EIGEN_ALIGNOF(X)macro available if needed.alignas-based static alignment as quoted above.Suggested follow-ups (separate PRs, not in this one)
Dependencies/AudioDSPTools/Dependencies/eigen(still pinned at a 3.4.90 dev snapshot from 2023-09-14, but unused by NAM core — onlywav.cppis compiled and it doesn't include Eigen) should be bumped inAudioDSPToolsfor consistency.Test plan
build-ubuntu(libstdc++, default GEMM) — greenbuild-ubuntu(libstdc++, inline GEMM) — greenbuild-ubuntu-libcxx(libc++, default GEMM) — greenbuild-ubuntu-libcxx(libc++, inline GEMM) — greenrun_tests+benchmodel+render— all passNAM_USE_INLINE_GEMM:run_tests+benchmodel+render— all pass