From 6883221edcf67295c0f5b5d3fd60cbc498b4edbf Mon Sep 17 00:00:00 2001 From: Griffin Bassman Date: Fri, 17 Nov 2023 11:29:58 -0500 Subject: [PATCH 01/16] refactor: option to turn on sse2 optimization --- CMakeLists.txt | 1 + vowpalwabbit/core/src/reductions/gd.cc | 48 +++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea8c108eb68..c0b8308a065 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,6 +155,7 @@ option(vw_BUILD_NET_FRAMEWORK "Build .NET Framework targets" OFF) option(VW_USE_ASAN "Compile with AddressSanitizer" OFF) option(VW_USE_UBSAN "Compile with UndefinedBehaviorSanitizer" OFF) option(VW_BUILD_WASM "Add WASM target" OFF) +option(SSE2_OPT "Add SSE2 optimization" OFF) if(VW_USE_ASAN) add_compile_definitions(VW_USE_ASAN) diff --git a/vowpalwabbit/core/src/reductions/gd.cc b/vowpalwabbit/core/src/reductions/gd.cc index d98b994306a..ff1b3480ceb 100644 --- a/vowpalwabbit/core/src/reductions/gd.cc +++ b/vowpalwabbit/core/src/reductions/gd.cc @@ -136,6 +136,52 @@ void sync_weights(VW::workspace& all) all.sd->contraction = 1.; } +VW_WARNING_STATE_PUSH +VW_WARNING_DISABLE_UNUSED_FUNCTION +inline float quake_inv_sqrt(float x) +{ + // Carmack/Quake/SGI fast method: + float xhalf = 0.5f * x; + static_assert(sizeof(int) == sizeof(float), "Floats and ints are converted between, they must be the same size."); + int i = reinterpret_cast(x); // store floating-point bits in integer + i = 0x5f3759d5 - (i >> 1); // initial guess for Newton's method + x = reinterpret_cast(i); // convert new bits into float + x = x * (1.5f - xhalf * x * x); // One round of Newton's method + return x; +} +VW_WARNING_STATE_POP + +static inline float inv_sqrt(float x) +{ +#if !defined(SSE2_OPT) + return 1.f / std::sqrt(x); +#endif +#if !defined(VW_NO_INLINE_SIMD) +# if defined(__ARM_NEON__) + // Propagate into vector + float32x2_t v1 = vdup_n_f32(x); + // Estimate + float32x2_t e1 = vrsqrte_f32(v1); + // N-R iteration 1 + float32x2_t e2 = vmul_f32(e1, vrsqrts_f32(v1, vmul_f32(e1, e1))); + // N-R iteration 2 + float32x2_t e3 = vmul_f32(e2, vrsqrts_f32(v1, vmul_f32(e2, e2))); + // Extract result + return vget_lane_f32(e3, 0); +# elif defined(__SSE2__) + __m128 eta = _mm_load_ss(&x); + eta = _mm_rsqrt_ss(eta); + _mm_store_ss(&x, eta); +# else + x = quake_inv_sqrt(x); +# endif +#else + x = quake_inv_sqrt(x); +#endif + + return x; +} + VW_WARNING_STATE_PUSH VW_WARNING_DISABLE_COND_CONST_EXPR template @@ -580,7 +626,7 @@ inline float compute_rate_decay(power_data& s, float& fw) float rate_decay = 1.f; if (adaptive) { - if (sqrt_rate) { rate_decay = 1.0f / std::sqrt(w[adaptive]); } + if (sqrt_rate) { rate_decay = inv_sqrt(w[adaptive]); } else { rate_decay = powf(w[adaptive], s.minus_power_t); } } if VW_STD17_CONSTEXPR (normalized != 0) From d4ae1e60370246c9ff7c3be90c6b32b41502a10c Mon Sep 17 00:00:00 2001 From: Griffin Bassman Date: Mon, 3 Jun 2024 11:51:53 -0400 Subject: [PATCH 02/16] remove sse2 option --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 862acb5ee47..7b373508f90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,7 +178,6 @@ option(VW_BUILD_VW_C_WRAPPER "Enable building the c_wrapper project" ON) option(vw_BUILD_NET_CORE "Build .NET Core targets" OFF) option(vw_BUILD_NET_FRAMEWORK "Build .NET Framework targets" OFF) option(VW_BUILD_WASM "Add WASM target" OFF) -option(SSE2_OPT "Add SSE2 optimization" OFF) if(VW_INSTALL AND NOT VW_ZLIB_SYS_DEP) message(WARNING "Installing with a vendored version of zlib is not recommended. Use VW_ZLIB_SYS_DEP to use a system dependency or specify VW_INSTALL=OFF to silence this warning.") From c817e31e29a91250ce2f93f2dd0b34ff0a928ff9 Mon Sep 17 00:00:00 2001 From: Griffin Bassman Date: Mon, 3 Jun 2024 12:13:48 -0400 Subject: [PATCH 03/16] add opt for std sqrt --- vowpalwabbit/core/src/reductions/gd.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vowpalwabbit/core/src/reductions/gd.cc b/vowpalwabbit/core/src/reductions/gd.cc index ff1b3480ceb..493ed61c9f0 100644 --- a/vowpalwabbit/core/src/reductions/gd.cc +++ b/vowpalwabbit/core/src/reductions/gd.cc @@ -153,7 +153,7 @@ VW_WARNING_STATE_POP static inline float inv_sqrt(float x) { -#if !defined(SSE2_OPT) +#if defined (STD_INV_SQRT) return 1.f / std::sqrt(x); #endif #if !defined(VW_NO_INLINE_SIMD) From 362b98b8c87f077aae7c4046b1772257c9c02d2e Mon Sep 17 00:00:00 2001 From: Griffin Bassman Date: Mon, 3 Jun 2024 12:23:44 -0400 Subject: [PATCH 04/16] add opt to ci --- .github/workflows/vendor_build.yml | 1 + vowpalwabbit/core/src/reductions/gd.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/vendor_build.yml b/.github/workflows/vendor_build.yml index e15b5ae89ab..fe5a9167a55 100644 --- a/.github/workflows/vendor_build.yml +++ b/.github/workflows/vendor_build.yml @@ -49,6 +49,7 @@ jobs: -DWARNINGS=On -DWARNING_AS_ERROR=On -DVW_CXX_STANDARD=17 + -DSTD_INV_SQRT=ON - name: Build run: cmake --build build - name: Unit tests diff --git a/vowpalwabbit/core/src/reductions/gd.cc b/vowpalwabbit/core/src/reductions/gd.cc index 493ed61c9f0..852448606b7 100644 --- a/vowpalwabbit/core/src/reductions/gd.cc +++ b/vowpalwabbit/core/src/reductions/gd.cc @@ -153,7 +153,7 @@ VW_WARNING_STATE_POP static inline float inv_sqrt(float x) { -#if defined (STD_INV_SQRT) +#if defined(STD_INV_SQRT) return 1.f / std::sqrt(x); #endif #if !defined(VW_NO_INLINE_SIMD) From b778776532bd12041a1a8c6f584ff41fba041c4c Mon Sep 17 00:00:00 2001 From: Griffin Bassman Date: Mon, 3 Jun 2024 12:55:04 -0400 Subject: [PATCH 05/16] add to vw_core --- CMakeLists.txt | 1 + vowpalwabbit/core/CMakeLists.txt | 4 ++++ vowpalwabbit/core/src/reductions/gd.cc | 1 + 3 files changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b373508f90..2b367e7eb20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,6 +178,7 @@ option(VW_BUILD_VW_C_WRAPPER "Enable building the c_wrapper project" ON) option(vw_BUILD_NET_CORE "Build .NET Core targets" OFF) option(vw_BUILD_NET_FRAMEWORK "Build .NET Framework targets" OFF) option(VW_BUILD_WASM "Add WASM target" OFF) +option(STD_INV_SQRT "Use standard library inverse square root" OFF) if(VW_INSTALL AND NOT VW_ZLIB_SYS_DEP) message(WARNING "Installing with a vendored version of zlib is not recommended. Use VW_ZLIB_SYS_DEP to use a system dependency or specify VW_INSTALL=OFF to silence this warning.") diff --git a/vowpalwabbit/core/CMakeLists.txt b/vowpalwabbit/core/CMakeLists.txt index db03a2ed0b7..e6107a988fd 100644 --- a/vowpalwabbit/core/CMakeLists.txt +++ b/vowpalwabbit/core/CMakeLists.txt @@ -440,6 +440,10 @@ if (MSVC_IDE) target_sources(vw_core PRIVATE $ ) endif() +if(STD_INV_SQRT) + target_compile_definitions(vw_core PUBLIC STD_INV_SQRT) +endif() + # Clang-cl on Windows has issues with our usage of SIMD types. Turn it off explicitly for Windows + clang-cl to mitigate. # See issue # if(WIN32 AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") diff --git a/vowpalwabbit/core/src/reductions/gd.cc b/vowpalwabbit/core/src/reductions/gd.cc index 852448606b7..a97c6521984 100644 --- a/vowpalwabbit/core/src/reductions/gd.cc +++ b/vowpalwabbit/core/src/reductions/gd.cc @@ -153,6 +153,7 @@ VW_WARNING_STATE_POP static inline float inv_sqrt(float x) { + return 1.f / std::sqrt(x); #if defined(STD_INV_SQRT) return 1.f / std::sqrt(x); #endif From 37b7ba22cb0087cc881b0cb55d6c0cd053c6edc5 Mon Sep 17 00:00:00 2001 From: Griffin Bassman Date: Mon, 3 Jun 2024 13:19:06 -0400 Subject: [PATCH 06/16] more ci defs --- .github/workflows/wasm.yml | 2 +- .scripts/linux/build-static-java.sh | 2 +- .scripts/linux/build-with-coverage.sh | 2 +- .scripts/linux/build.sh | 2 +- vowpalwabbit/core/src/reductions/gd.cc | 1 - 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 6561733e607..b1dbd4f3ae8 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -26,7 +26,7 @@ jobs: with: node-version: 16 - name: Configure - run: emcmake cmake --preset wasm -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=$(pwd)/ext_libs/vcpkg/scripts/buildsystems/vcpkg.cmake + run: emcmake cmake --preset wasm -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel -DSTD_INV_SQRT=ON -DCMAKE_TOOLCHAIN_FILE=$(pwd)/ext_libs/vcpkg/scripts/buildsystems/vcpkg.cmake - name: Build run: cmake --build build --target vw-wasm - uses: actions/upload-artifact@v3 diff --git a/.scripts/linux/build-static-java.sh b/.scripts/linux/build-static-java.sh index 21d334cb8fe..826685fb8a5 100755 --- a/.scripts/linux/build-static-java.sh +++ b/.scripts/linux/build-static-java.sh @@ -12,6 +12,6 @@ cd build # /usr/local/bin/gcc + g++ is 9.2.0 version cmake -E env LDFLAGS="-Wl,--exclude-libs,ALL -static-libgcc -static-libstdc++" cmake .. -DCMAKE_BUILD_TYPE=Release -DWARNINGS=Off -DBUILD_JAVA=On -DBUILD_DOCS=Off -DVW_FEAT_FLATBUFFERS=On -DVW_FEAT_CSV=On -DVW_FEAT_CB_GRAPH_FEEDBACK=On\ -DBUILD_PYTHON=Off -DSTATIC_LINK_VW_JAVA=On -DCMAKE_C_COMPILER=/usr/local/bin/gcc -DCMAKE_CXX_COMPILER=/usr/local/bin/g++ \ - -DBUILD_TESTING=Off -DVW_ZLIB_SYS_DEP=Off -DBUILD_SHARED_LIBS=Off -DVW_BUILD_LAS_WITH_SIMD=Off + -DBUILD_TESTING=Off -DVW_ZLIB_SYS_DEP=Off -DBUILD_SHARED_LIBS=Off -DVW_BUILD_LAS_WITH_SIMD=Off -DSTD_INV_SQRT=ON NUM_PROCESSORS=$(nproc) make vw_jni -j ${NUM_PROCESSORS} diff --git a/.scripts/linux/build-with-coverage.sh b/.scripts/linux/build-with-coverage.sh index bac8db23bac..83b4acc49d1 100755 --- a/.scripts/linux/build-with-coverage.sh +++ b/.scripts/linux/build-with-coverage.sh @@ -6,5 +6,5 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" REPO_DIR=$SCRIPT_DIR/../../ cd $REPO_DIR -cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DVW_GCOV=ON -DWARNINGS=OFF -DBUILD_JAVA=Off -DBUILD_PYTHON=Off -DBUILD_TESTING=On -DVW_FEAT_FLATBUFFERS=On -DVW_FEAT_CSV=On -DVW_FEAT_CB_GRAPH_FEEDBACK=On +cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DVW_GCOV=ON -DWARNINGS=OFF -DBUILD_JAVA=Off -DBUILD_PYTHON=Off -DBUILD_TESTING=On -DVW_FEAT_FLATBUFFERS=On -DVW_FEAT_CSV=On -DVW_FEAT_CB_GRAPH_FEEDBACK=On -DSTD_INV_SQRT=ON cmake --build build diff --git a/.scripts/linux/build.sh b/.scripts/linux/build.sh index ab886b0a349..50a61fe5d7b 100755 --- a/.scripts/linux/build.sh +++ b/.scripts/linux/build.sh @@ -9,5 +9,5 @@ cd $REPO_DIR # If parameter 1 is not supplied, it defaults to Release BUILD_CONFIGURATION=${1:-Release} -cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=${BUILD_CONFIGURATION} -DWARNINGS=Off -DWARNING_AS_ERROR=On -DVW_BUILD_VW_C_WRAPPER=Off -DBUILD_JAVA=On -DBUILD_PYTHON=Off -DBUILD_TESTING=On -DBUILD_EXPERIMENTAL_BINDING=On -DVW_FEAT_FLATBUFFERS=On -DVW_FEAT_CSV=On -DVW_FEAT_CB_GRAPH_FEEDBACK=On +cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=${BUILD_CONFIGURATION} -DWARNINGS=Off -DWARNING_AS_ERROR=On -DVW_BUILD_VW_C_WRAPPER=Off -DBUILD_JAVA=On -DBUILD_PYTHON=Off -DBUILD_TESTING=On -DBUILD_EXPERIMENTAL_BINDING=On -DVW_FEAT_FLATBUFFERS=On -DVW_FEAT_CSV=On -DVW_FEAT_CB_GRAPH_FEEDBACK=On -DSTD_INV_SQRT=ON cmake --build build --target all diff --git a/vowpalwabbit/core/src/reductions/gd.cc b/vowpalwabbit/core/src/reductions/gd.cc index a97c6521984..852448606b7 100644 --- a/vowpalwabbit/core/src/reductions/gd.cc +++ b/vowpalwabbit/core/src/reductions/gd.cc @@ -153,7 +153,6 @@ VW_WARNING_STATE_POP static inline float inv_sqrt(float x) { - return 1.f / std::sqrt(x); #if defined(STD_INV_SQRT) return 1.f / std::sqrt(x); #endif From 57b7257e2015c9a1903b1573b9f60c403034844e Mon Sep 17 00:00:00 2001 From: Griffin Bassman Date: Mon, 3 Jun 2024 13:37:59 -0400 Subject: [PATCH 07/16] add to more CIs --- .github/workflows/asan.yml | 1 + .github/workflows/build_macos.yml | 2 +- .github/workflows/python_wheels.yml | 2 +- .github/workflows/vendor_build.yml | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/asan.yml b/.github/workflows/asan.yml index 2165e9f65fe..9fcd9283b58 100644 --- a/.github/workflows/asan.yml +++ b/.github/workflows/asan.yml @@ -54,6 +54,7 @@ jobs: - uses: lukka/run-cmake@v10 env: VCPKG_ROOT: ${{github.workspace}}/ext_libs/vcpkg + CMAKE_ARGS: "-DSTD_INV_SQRT=ON" with: cmakeListsTxtPath: "${{ github.workspace }}/CMakeLists.txt" configurePreset: "${{ matrix.preset }}" diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index 2670782379f..8a32cd59496 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -27,7 +27,7 @@ jobs: - name: Install dependencies run: brew install cmake boost flatbuffers ninja - name: Configure - run: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DWARNINGS=Off -DVW_BUILD_VW_C_WRAPPER=Off -DBUILD_TESTING=On -DBUILD_EXPERIMENTAL_BINDING=On -DVW_FEAT_CSV=On -DVW_FEAT_CB_GRAPH_FEEDBACK=On -DVW_INSTALL=Off + run: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DWARNINGS=Off -DVW_BUILD_VW_C_WRAPPER=Off -DBUILD_TESTING=On -DBUILD_EXPERIMENTAL_BINDING=On -DVW_FEAT_CSV=On -DVW_FEAT_CB_GRAPH_FEEDBACK=On -DVW_INSTALL=Off -DSTD_INV_SQRT=ON - name: Build run: cmake --build build --target all - name: Unit tests diff --git a/.github/workflows/python_wheels.yml b/.github/workflows/python_wheels.yml index 2302c48c0a6..c96d47fe7ef 100644 --- a/.github/workflows/python_wheels.yml +++ b/.github/workflows/python_wheels.yml @@ -43,7 +43,7 @@ jobs: - name: Build wheel shell: bash run: | - ${{ matrix.config.base_path }}bin/pip wheel . -w wheel_output/ --global-option --cmake-options="-DSTATIC_LINK_VW_JAVA=On;-DPython_INCLUDE_DIR='${{ matrix.config.base_path }}include/${{ matrix.config.include_dir_name }}'" --verbose + ${{ matrix.config.base_path }}bin/pip wheel . -w wheel_output/ --global-option --cmake-options="-DSTATIC_LINK_VW_JAVA=On -DSTD_INV_SQRT=ON;-DPython_INCLUDE_DIR='${{ matrix.config.base_path }}include/${{ matrix.config.include_dir_name }}'" --verbose auditwheel repair wheel_output/*whl -w audit_output/ - name: Upload built wheel uses: actions/upload-artifact@v1 diff --git a/.github/workflows/vendor_build.yml b/.github/workflows/vendor_build.yml index fe5a9167a55..918ec45e593 100644 --- a/.github/workflows/vendor_build.yml +++ b/.github/workflows/vendor_build.yml @@ -86,6 +86,7 @@ jobs: -DVW_ZLIB_SYS_DEP=Off -DVW_BOOST_MATH_SYS_DEP=Off -DVW_INSTALL=Off + -DSTD_INV_SQRT=ON - name: Build run: cmake --build "${{ env.CMAKE_BUILD_DIR }}" --config ${{ matrix.build_type }} - name: Test run_tests.py From 3d1f42e5bb2d21786923f67d5b164c7a38153d46 Mon Sep 17 00:00:00 2001 From: Griffin Bassman Date: Mon, 3 Jun 2024 14:35:54 -0400 Subject: [PATCH 08/16] ; --- .github/workflows/python_wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python_wheels.yml b/.github/workflows/python_wheels.yml index c96d47fe7ef..a9dbbd26ba4 100644 --- a/.github/workflows/python_wheels.yml +++ b/.github/workflows/python_wheels.yml @@ -43,7 +43,7 @@ jobs: - name: Build wheel shell: bash run: | - ${{ matrix.config.base_path }}bin/pip wheel . -w wheel_output/ --global-option --cmake-options="-DSTATIC_LINK_VW_JAVA=On -DSTD_INV_SQRT=ON;-DPython_INCLUDE_DIR='${{ matrix.config.base_path }}include/${{ matrix.config.include_dir_name }}'" --verbose + ${{ matrix.config.base_path }}bin/pip wheel . -w wheel_output/ --global-option --cmake-options="-DSTATIC_LINK_VW_JAVA=On;-DSTD_INV_SQRT=ON;-DPython_INCLUDE_DIR='${{ matrix.config.base_path }}include/${{ matrix.config.include_dir_name }}'" --verbose auditwheel repair wheel_output/*whl -w audit_output/ - name: Upload built wheel uses: actions/upload-artifact@v1 From b4891e1aaab6576d520345674164f384b5511794 Mon Sep 17 00:00:00 2001 From: Griffin Bassman Date: Mon, 3 Jun 2024 14:44:51 -0400 Subject: [PATCH 09/16] asan preset --- .github/workflows/asan.yml | 1 - CMakePresets.json | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/asan.yml b/.github/workflows/asan.yml index 9fcd9283b58..2165e9f65fe 100644 --- a/.github/workflows/asan.yml +++ b/.github/workflows/asan.yml @@ -54,7 +54,6 @@ jobs: - uses: lukka/run-cmake@v10 env: VCPKG_ROOT: ${{github.workspace}}/ext_libs/vcpkg - CMAKE_ARGS: "-DSTD_INV_SQRT=ON" with: cmakeListsTxtPath: "${{ github.workspace }}/CMakeLists.txt" configurePreset: "${{ matrix.preset }}" diff --git a/CMakePresets.json b/CMakePresets.json index 2c9110de54c..dd25509df1b 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -100,6 +100,10 @@ "VW_FEAT_CB_GRAPH_FEEDBACK": { "type": "BOOL", "value": "On" + }, + "STD_INV_SQRT": { + "type": "BOOL", + "value": "On" } } }, From 19e0802c887867a00a40c3fcbbaac7aab2e5c0fa Mon Sep 17 00:00:00 2001 From: Griffin Bassman Date: Mon, 3 Jun 2024 15:40:56 -0400 Subject: [PATCH 10/16] add to valgrind + setup.py --- .github/workflows/valgrind.yml | 2 +- setup.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index c7c35bda6bc..f24630265cb 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -21,7 +21,7 @@ jobs: submodules: recursive - name: Build C++ VW binary run: | - cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_EXPERIMENTAL_BINDING=On -DVW_FEAT_FLATBUFFERS=On -DVW_FEAT_CSV=On -DVW_FEAT_CB_GRAPH_FEEDBACK=On + cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_EXPERIMENTAL_BINDING=On -DVW_FEAT_FLATBUFFERS=On -DVW_FEAT_CSV=On -DVW_FEAT_CB_GRAPH_FEEDBACK=On -DSTD_INV_SQRT=ON cmake --build build - name: Upload vw binary uses: actions/upload-artifact@v2 diff --git a/setup.py b/setup.py index 5cf49116393..d7cd252db36 100644 --- a/setup.py +++ b/setup.py @@ -82,6 +82,7 @@ def build_cmake(self, ext): "-DBUILD_TESTING=Off", "-DWARNINGS=Off", "-DVW_FEAT_CB_GRAPH_FEEDBACK=On", + "-DSTD_INV_SQRT=On", ] # This doesn't work as expected for Python3.6 and 3.7 on Windows. From 4d92a069506fe680320b2ca244ac0c2cf8503573 Mon Sep 17 00:00:00 2001 From: Griffin Bassman Date: Mon, 3 Jun 2024 17:05:26 -0400 Subject: [PATCH 11/16] macOS --- .github/workflows/vendor_build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/vendor_build.yml b/.github/workflows/vendor_build.yml index 918ec45e593..0d17809b8fe 100644 --- a/.github/workflows/vendor_build.yml +++ b/.github/workflows/vendor_build.yml @@ -120,6 +120,7 @@ jobs: -DVW_ZLIB_SYS_DEP=Off -DVW_BOOST_MATH_SYS_DEP=Off -DVW_INSTALL=Off + -DSTD_INV_SQRT=ON - name: Build run: cmake --build build - name: Unit tests From 8cc48fcd934751680e6ae2863d200d6df5f63fa1 Mon Sep 17 00:00:00 2001 From: Griffin Bassman Date: Mon, 3 Jun 2024 17:08:14 -0400 Subject: [PATCH 12/16] fix wasm --- .github/workflows/wasm.yml | 2 +- CMakePresets.json | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index b1dbd4f3ae8..6561733e607 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -26,7 +26,7 @@ jobs: with: node-version: 16 - name: Configure - run: emcmake cmake --preset wasm -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel -DSTD_INV_SQRT=ON -DCMAKE_TOOLCHAIN_FILE=$(pwd)/ext_libs/vcpkg/scripts/buildsystems/vcpkg.cmake + run: emcmake cmake --preset wasm -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=$(pwd)/ext_libs/vcpkg/scripts/buildsystems/vcpkg.cmake - name: Build run: cmake --build build --target vw-wasm - uses: actions/upload-artifact@v3 diff --git a/CMakePresets.json b/CMakePresets.json index dd25509df1b..693b834a4a1 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -212,6 +212,10 @@ "VCPKG_TARGET_TRIPLET": { "type": "STRING", "value": "wasm32-emscripten" + }, + "STD_INV_SQRT": { + "type": "BOOL", + "value": "On" } } } From d12b4b8b88d9fea5e2d5c5c025a6b951bc1bf734 Mon Sep 17 00:00:00 2001 From: Griffin Bassman Date: Tue, 4 Jun 2024 15:41:34 -0400 Subject: [PATCH 13/16] remove std from wheels --- .github/workflows/python_wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python_wheels.yml b/.github/workflows/python_wheels.yml index a9dbbd26ba4..2302c48c0a6 100644 --- a/.github/workflows/python_wheels.yml +++ b/.github/workflows/python_wheels.yml @@ -43,7 +43,7 @@ jobs: - name: Build wheel shell: bash run: | - ${{ matrix.config.base_path }}bin/pip wheel . -w wheel_output/ --global-option --cmake-options="-DSTATIC_LINK_VW_JAVA=On;-DSTD_INV_SQRT=ON;-DPython_INCLUDE_DIR='${{ matrix.config.base_path }}include/${{ matrix.config.include_dir_name }}'" --verbose + ${{ matrix.config.base_path }}bin/pip wheel . -w wheel_output/ --global-option --cmake-options="-DSTATIC_LINK_VW_JAVA=On;-DPython_INCLUDE_DIR='${{ matrix.config.base_path }}include/${{ matrix.config.include_dir_name }}'" --verbose auditwheel repair wheel_output/*whl -w audit_output/ - name: Upload built wheel uses: actions/upload-artifact@v1 From fc5b29834c7f71b37647f731638549aef72fc9c9 Mon Sep 17 00:00:00 2001 From: Griffin Bassman Date: Thu, 6 Jun 2024 14:17:23 -0400 Subject: [PATCH 14/16] comment --- vowpalwabbit/core/src/reductions/gd.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/vowpalwabbit/core/src/reductions/gd.cc b/vowpalwabbit/core/src/reductions/gd.cc index 852448606b7..8e84e061cf0 100644 --- a/vowpalwabbit/core/src/reductions/gd.cc +++ b/vowpalwabbit/core/src/reductions/gd.cc @@ -153,6 +153,7 @@ VW_WARNING_STATE_POP static inline float inv_sqrt(float x) { +// Standard library used in CI because SSE2 path has floating point differences in github machines #if defined(STD_INV_SQRT) return 1.f / std::sqrt(x); #endif From 0cad4ddf0e53d867fc1bdcd5a7b6b26667e94b62 Mon Sep 17 00:00:00 2001 From: Griffin Bassman Date: Wed, 19 Jun 2024 13:07:29 -0400 Subject: [PATCH 15/16] macos version --- .github/workflows/python_wheels.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python_wheels.yml b/.github/workflows/python_wheels.yml index 2302c48c0a6..7af8dbb5653 100644 --- a/.github/workflows/python_wheels.yml +++ b/.github/workflows/python_wheels.yml @@ -222,7 +222,7 @@ jobs: deactivate' macos-python-build: name: macos.amd64.py${{ matrix.config.version }}.build - runs-on: macos-11 + runs-on: macos-13 strategy: matrix: config: @@ -254,7 +254,7 @@ jobs: macos-python-test: name: macos.amd64.py${{ matrix.version }}.test needs: macos-python-build - runs-on: macos-11 + runs-on: macos-13 strategy: matrix: version: [3.6, 3.7, 3.8, 3.9, "3.10"] From 2a9ec822a9c1a8e06f7e4e1b5fc5257325e1a7e5 Mon Sep 17 00:00:00 2001 From: Griffin Bassman Date: Thu, 20 Jun 2024 10:40:45 -0400 Subject: [PATCH 16/16] revert --- .github/workflows/python_wheels.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python_wheels.yml b/.github/workflows/python_wheels.yml index 7af8dbb5653..2302c48c0a6 100644 --- a/.github/workflows/python_wheels.yml +++ b/.github/workflows/python_wheels.yml @@ -222,7 +222,7 @@ jobs: deactivate' macos-python-build: name: macos.amd64.py${{ matrix.config.version }}.build - runs-on: macos-13 + runs-on: macos-11 strategy: matrix: config: @@ -254,7 +254,7 @@ jobs: macos-python-test: name: macos.amd64.py${{ matrix.version }}.test needs: macos-python-build - runs-on: macos-13 + runs-on: macos-11 strategy: matrix: version: [3.6, 3.7, 3.8, 3.9, "3.10"]