Skip to content

Commit a4c78d4

Browse files
authored
Merge branch 'dev' into upgrade-github-actions-node24
2 parents b66aa11 + baa69df commit a4c78d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+4106
-1821
lines changed

BUILD.bazel

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ cc_library(
6666
srcs = ["util/topology.cc"],
6767
hdrs = ["util/topology.h"],
6868
deps = [
69+
"@highway//:bit_set",
6970
"@highway//:hwy",
7071
"@highway//:topology",
7172
],
@@ -111,6 +112,7 @@ cc_library(
111112
":threading",
112113
":topology",
113114
":zones",
115+
"//io",
114116
"@highway//:hwy",
115117
"@highway//:hwy_test_util",
116118
"@highway//:profiler",
@@ -139,7 +141,7 @@ cc_test(
139141
":kv_cache",
140142
":mat",
141143
":matmul",
142-
":ops",
144+
":test_util",
143145
":threading_context",
144146
":weights",
145147
"@googletest//:gtest_main", # buildcleaner: keep
@@ -172,8 +174,11 @@ cc_library(
172174
name = "test_util",
173175
hdrs = ["util/test_util.h"],
174176
deps = [
177+
":basics",
178+
":mat",
175179
"@highway//:hwy",
176180
"@highway//:hwy_test_util",
181+
"@highway//:nanobenchmark",
177182
"@highway//:stats",
178183
],
179184
)
@@ -440,9 +445,9 @@ cc_test(
440445
":gemma_lib",
441446
":mat",
442447
":ops",
448+
":query",
443449
":test_util",
444450
":threading_context",
445-
":zones",
446451
"@googletest//:gtest_main", # buildcleaner: keep
447452
"//compression:test_util",
448453
"//compression:types",
@@ -519,32 +524,70 @@ cc_library(
519524
],
520525
)
521526

527+
cc_test(
528+
name = "kv_cache_test",
529+
srcs = ["gemma/kv_cache_test.cc"],
530+
deps = [
531+
":configs",
532+
":gemma_args",
533+
":kv_cache",
534+
":threading_context",
535+
"//testing/base/public:gunit_main",
536+
"@highway//:hwy",
537+
],
538+
)
539+
540+
cc_library(
541+
name = "query",
542+
hdrs = ["gemma/query.h"],
543+
deps = [
544+
":basics",
545+
":gemma_args",
546+
":kv_cache",
547+
"@highway//:hwy",
548+
],
549+
)
550+
522551
cc_library(
523552
name = "gemma_args",
524553
hdrs = ["gemma/gemma_args.h"],
525554
deps = [
526555
":args",
527556
":basics",
557+
":configs",
528558
":mat",
559+
":threading_context",
529560
"//io",
530561
"@highway//:hwy",
531562
"@highway//:profiler",
532563
],
533564
)
534565

566+
cc_test(
567+
name = "gemma_args_test",
568+
srcs = ["gemma/gemma_args_test.cc"],
569+
deps = [
570+
":gemma_args",
571+
"@googletest//:gtest_main", # buildcleaner: keep
572+
],
573+
)
574+
535575
cc_library(
536576
name = "gemma_lib",
537577
srcs = [
538578
"gemma/attention.cc",
539579
"gemma/flash_attention.cc",
540580
"gemma/gemma.cc",
581+
"gemma/tensor_stats.cc",
541582
"gemma/vit.cc",
542583
],
543584
hdrs = [
544585
"gemma/activations.h",
545586
"gemma/attention.h",
546587
"gemma/flash_attention.h",
588+
"gemma/flash_structs.h",
547589
"gemma/gemma.h",
590+
"gemma/tensor_stats.h",
548591
"gemma/vit.h",
549592
],
550593
exec_properties = {
@@ -555,6 +598,7 @@ cc_library(
555598
"gemma/gemma-inl.h",
556599
],
557600
deps = [
601+
":allocator",
558602
":basics",
559603
":configs",
560604
":gemma_args",
@@ -564,6 +608,7 @@ cc_library(
564608
":matmul_env",
565609
":model_store",
566610
":ops",
611+
":query",
567612
":threading",
568613
":threading_context",
569614
":weights",
@@ -577,8 +622,34 @@ cc_library(
577622
"@highway//:hwy",
578623
"@highway//:nanobenchmark", # timer
579624
"@highway//:profiler",
625+
"@highway//:stats",
580626
"@highway//:thread_pool",
581627
"@highway//hwy/contrib/sort:vqsort",
628+
] +
629+
[
630+
],
631+
)
632+
633+
cc_test(
634+
name = "gemma_lib_test",
635+
srcs = ["gemma/attention_test.cc"],
636+
# MatMulEnvs are up to 20GB large.
637+
tags = ["requires-mem:28g"],
638+
deps = [
639+
":configs",
640+
":gemma_args",
641+
":gemma_lib",
642+
":kv_cache",
643+
":mat",
644+
":matmul_env",
645+
":test_util",
646+
":threading_context",
647+
":weights",
648+
"@googletest//:gtest_main", # buildcleaner: keep
649+
"//compression:compress",
650+
"//compression:types",
651+
"@highway//:hwy",
652+
"@highway//:hwy_test_util",
582653
],
583654
)
584655

@@ -604,7 +675,6 @@ cc_library(
604675
":gemma_args",
605676
":gemma_lib",
606677
":matmul_env",
607-
":ops",
608678
":threading_context",
609679
":tokenizer",
610680
"@google_benchmark//:benchmark",

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ set(CMAKE_CXX_STANDARD 17)
2222
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2323
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
2424

25-
FetchContent_Declare(highway GIT_REPOSITORY https://github.com/google/highway.git GIT_TAG 2a16a50ff61071bb25ddef0ce35d92b0e2b9c579 EXCLUDE_FROM_ALL)
25+
FetchContent_Declare(highway GIT_REPOSITORY https://github.com/google/highway.git GIT_TAG 3b680cde3a556bead9cc23c8f595d07a44d5a0d5 EXCLUDE_FROM_ALL)
2626
FetchContent_MakeAvailable(highway)
2727

2828
## Note: absl needs to be installed by sentencepiece. This will only happen if
@@ -82,6 +82,7 @@ set(SOURCES
8282
gemma/configs.h
8383
gemma/flash_attention.cc
8484
gemma/flash_attention.h
85+
gemma/flash_structs.h
8586
gemma/gemma_args.h
8687
gemma/gemma-inl.h
8788
gemma/gemma.cc
@@ -221,6 +222,7 @@ set(GEMMA_TEST_FILES
221222
compression/nuq_test.cc
222223
compression/sfp_test.cc
223224
evals/gemma_test.cc
225+
gemma/gemma_args_test.cc
224226
gemma/flash_attention_test.cc
225227
gemma/tensor_info_test.cc
226228
io/blob_store_test.cc

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ bazel_dep(name = "google_benchmark", version = "1.8.5")
1818
# Require a more recent version.
1919
git_override(
2020
module_name = "highway",
21-
commit = "2a16a50ff61071bb25ddef0ce35d92b0e2b9c579",
21+
commit = "3b680cde3a556bead9cc23c8f595d07a44d5a0d5",
2222
remote = "https://github.com/google/highway",
2323
)
2424

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ Guidelines](https://opensource.google.com/conduct/).
5555

5656
- CPU-only inference for: Gemma 2-3, PaliGemma 2.
5757
- Sampling with TopK and temperature.
58-
- Backward pass (VJP) and Adam optimizer for Gemma research.
5958

6059
- Optimizations
6160

@@ -452,7 +451,7 @@ FetchContent_MakeAvailable(sentencepiece)
452451
FetchContent_Declare(gemma GIT_REPOSITORY https://github.com/google/gemma.cpp GIT_TAG origin/main)
453452
FetchContent_MakeAvailable(gemma)
454453
455-
FetchContent_Declare(highway GIT_REPOSITORY https://github.com/google/highway.git GIT_TAG 2a16a50ff61071bb25ddef0ce35d92b0e2b9c579)
454+
FetchContent_Declare(highway GIT_REPOSITORY https://github.com/google/highway.git GIT_TAG 3b680cde3a556bead9cc23c8f595d07a44d5a0d5)
456455
FetchContent_MakeAvailable(highway)
457456
```
458457
@@ -520,13 +519,19 @@ Mikhaylov, Eugene Kliuchnikov, Jan Wassenberg, Jyrki Alakuijala, Lode
520519
Vandevenne, Luca Versari, Martin Bruse, Phil Culliton, Sami Boukortt, Thomas
521520
Fischbacher and Zoltan Szabadka. It was removed in 2025-09.
522521
523-
Gemma-2 support was implemented in June/July 2024 with the help of several
524-
people.
522+
Gemma 2 support was implemented in June/July 2024 with the help of several
523+
people including Daniel Keysers and Phil Culliton.
525524
526525
PaliGemma support was implemented in September 2024 with contributions from
527526
Daniel Keysers.
528527
528+
Gemma 3 support was implemented in January-March 2025 with contributions from
529+
Daniel Keysers and Phil Culliton.
530+
529531
[Jan Wassenberg](mailto:janwas@google.com) has continued to contribute many
530532
improvements, including major gains in efficiency, since the initial release.
531533
534+
[Phil Culliton](mailto:philculliton@google.com) has worked on model releases,
535+
eval and validation, GTM, and quantization, since the initial release.
536+
532537
This is not an officially supported Google product.

compression/BUILD.bazel

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Weight compression and analysis.
1+
# Compressed tensor types.
22

33
load("@rules_cc//cc:cc_library.bzl", "cc_library")
44
load("@rules_cc//cc:cc_test.bzl", "cc_test")
@@ -101,13 +101,11 @@ cc_test(
101101
# for test_suite.
102102
tags = ["hwy_ops_test"],
103103
deps = [
104-
":distortion",
105104
":int",
106105
"@googletest//:gtest_main", # buildcleaner: keep
107106
"//:test_util",
108107
"@highway//:hwy",
109108
"@highway//:hwy_test_util",
110-
"@highway//:nanobenchmark",
111109
],
112110
)
113111

@@ -135,8 +133,8 @@ cc_test(
135133
# for test_suite.
136134
tags = ["hwy_ops_test"],
137135
deps = [
136+
":compress",
138137
":distortion",
139-
":sfp",
140138
"@googletest//:gtest_main", # buildcleaner: keep
141139
"//:test_util",
142140
"@highway//:hwy",
@@ -182,7 +180,6 @@ cc_library(
182180
"//:mat",
183181
"//:threading_context",
184182
"@highway//:hwy",
185-
"@highway//:nanobenchmark",
186183
"@highway//:profiler",
187184
"@highway//:stats",
188185
"@highway//:thread_pool",
@@ -209,19 +206,3 @@ cc_test(
209206
"@highway//:hwy_test_util",
210207
],
211208
)
212-
213-
# For internal experimentation
214-
cc_library(
215-
name = "analyze",
216-
textual_hdrs = ["analyze.h"],
217-
deps = [
218-
":int",
219-
":nuq",
220-
":sfp",
221-
":types",
222-
"@highway//:hwy",
223-
"@highway//:stats",
224-
"@highway//:thread_pool",
225-
"@highway//hwy/contrib/sort:vqsort",
226-
],
227-
)

0 commit comments

Comments
 (0)