Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,10 @@ cc_library(
cc_library(
name = "weights",
srcs = ["gemma/weights.cc"],
hdrs = ["gemma/weights.h"],
hdrs = [
"gemma/weights.h",
"gemma/weights_internal.h",
],
deps = [
":configs",
":gemma_args",
Expand Down Expand Up @@ -379,6 +382,23 @@ cc_test(
],
)

cc_test(
name = "weights_test",
srcs = ["gemma/weights_test.cc"],
deps = [
":gemma_args",
":mat",
":threading_context",
":weights",
"//compression:compress",
"//compression:types",
"//io",
"//io:blob_store",
"@googletest//:gtest_main", # buildcleaner: keep
"@highway//:hwy",
],
)

# For building all tests in one command, so we can test several.
test_suite(
name = "ops_tests",
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ set(SOURCES
gemma/vit.h
gemma/weights.cc
gemma/weights.h
gemma/weights_internal.h
io/blob_store.cc
io/blob_store.h
io/fields.cc
Expand Down Expand Up @@ -383,6 +384,7 @@ set(GEMMA_TEST_FILES
deepseek/deepseek_test.cc
gemma/gemma_args_test.cc
gemma/tensor_info_test.cc
gemma/weights_test.cc
io/blob_store_test.cc
io/fields_test.cc
ops/bench_matmul.cc
Expand Down
8 changes: 8 additions & 0 deletions gemma/gemma_args.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct LoaderArgs : public ArgsBase<LoaderArgs> {
Path weights; // weights file location
Tristate map;
Tristate to_bf16;
Tristate sfp_embedding;
Tristate wrapping;

template <class Visitor>
Expand All @@ -65,6 +66,13 @@ struct LoaderArgs : public ArgsBase<LoaderArgs> {
"Enable memory-mapping? -1 = auto, 0 = no, 1 = yes.");
visitor(to_bf16, "to_bf16", Tristate::kDefault,
"Convert weights to bf16? -1 = auto, 0 = no, 1 = yes.");
visitor(sfp_embedding, "sfp_embedding", Tristate::kDefault,
"Compress the embedding table to SFP while loading? This halves\n"
" its footprint and, for models with tied input/output\n"
" embeddings, the bandwidth of the per-token logits MatMul,\n"
" in exchange for 8-bit precision on that tensor. Enabling this\n"
" disables automatic mapping; explicit --map=1 still wins.\n"
" -1 = auto (currently off), 0 = no, 1 = yes.");
visitor(wrapping, "wrapping", Tristate::kDefault,
"Enable prompt wrapping? Specify 0 for pre-2025 format PT models.");
}
Expand Down
Loading
Loading