From a44cbdadc234b8776e30893d189d1df741f9df0c Mon Sep 17 00:00:00 2001 From: Jan Wassenberg Date: Fri, 31 May 2024 12:27:42 -0700 Subject: [PATCH] Update to Highway 1.2 for topology/VQSelect Also fix unused-warning in compress-inl. PiperOrigin-RevId: 639116915 --- CMakeLists.txt | 2 +- MODULE.bazel | 5 ++--- compression/compress-inl.h | 4 ---- compression/distortion.h | 6 +----- compression/sfp-inl.h | 6 +----- gemma/run.cc | 5 ++++- 6 files changed, 9 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c09b330..4a07305 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -FetchContent_Declare(highway GIT_REPOSITORY https://github.com/google/highway.git GIT_TAG da250571a45826b21eebbddc1e50d0c1137dee5f EXCLUDE_FROM_ALL) +FetchContent_Declare(highway GIT_REPOSITORY https://github.com/google/highway.git GIT_TAG 457c891775a7397bdb0376bb1031e6e027af1c48 EXCLUDE_FROM_ALL) FetchContent_MakeAvailable(highway) ## Note: absl needs to be installed by sentencepiece. This will only happen if diff --git a/MODULE.bazel b/MODULE.bazel index 72d1d42..7c6336c 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -15,9 +15,8 @@ http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "ht http_archive( name = "hwy", - urls = ["https://github.com/google/highway/archive/refs/tags/1.1.0.zip"], - integrity = "sha256-zkJX2SwL4wQ0nHMsURW7MDLEf43vFSnqhSUsUM6eQmY=", - strip_prefix = "highway-1.1.0", + urls = ["https://github.com/google/highway/archive/refs/tags/1.2.0.zip"], + integrity = "sha256-fbtKAGj5hhhBr5Bggtsrj4aIodC2OHb1njB8LGfom8A=", strip_prefix = "highway-1.2.0", ) http_archive( diff --git a/compression/compress-inl.h b/compression/compress-inl.h index dce62cd..1f18765 100644 --- a/compression/compress-inl.h +++ b/compression/compress-inl.h @@ -244,10 +244,6 @@ struct CompressTraits { VF32 sum2 = Zero(df32); VF32 sum3 = Zero(df32); - const hn::RebindToUnsigned du32; - using VU32 = hn::VFromD; - const VU32 odd = Set(du32, 0xFFFF0000u); - for (size_t i = 0; i < num; /* i += 2 * N */) { const auto interleaved0 = hn::LoadU(dbf16, in + in_ofs + i); const VF32 ae0 = Load(df32, vec_aligned + i); diff --git a/compression/distortion.h b/compression/distortion.h index 67736dd..93f460a 100644 --- a/compression/distortion.h +++ b/compression/distortion.h @@ -161,12 +161,8 @@ class DistortionStats { std::vector weights(l1_); // copy so we can modify const float median = [&weights]() { const size_t mid = weights.size() / 2; - // We just want the median; partial sort is faster if available (v1.2). -#if HWY_MAJOR > 1 || HWY_MINOR >= 2 + // We just want the median; partial sort is faster. hwy::VQSelect(weights.data(), weights.size(), mid, hwy::SortAscending()); -#else - hwy::VQSort(weights.data(), weights.size(), hwy::SortAscending()); -#endif return weights[mid]; }(); weights = l1_; // restore original order diff --git a/compression/sfp-inl.h b/compression/sfp-inl.h index 4e3350e..b48447a 100644 --- a/compression/sfp-inl.h +++ b/compression/sfp-inl.h @@ -637,13 +637,9 @@ class SfpCodec { const hn::Repartition d8; V8 lo, hi; DecBytes(d8, packed, lo, hi); -#if HWY_MAJOR > 1 || HWY_MINOR >= 2 + // (Supported since Highway 1.2) even = hn::BitCast(dbf, hn::InterleaveEven(d8, lo, hi)); odd = hn::BitCast(dbf, hn::InterleaveOdd(d8, lo, hi)); -#else - even = hn::BitCast(dbf, hn::OddEven(hn::DupEven(hi), lo)); - odd = hn::BitCast(dbf, hn::OddEven(hi, hn::DupOdd(lo))); -#endif } template