Skip to content

Commit 8fb44ed

Browse files
Merge pull request #97 from ufownl:feature/topk_flag
PiperOrigin-RevId: 615772458
2 parents a2ef389 + 83ec429 commit 8fb44ed

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

configs.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,17 @@
2323
#define GEMMA_MAX_SEQLEN 4096
2424
#endif // !GEMMA_MAX_SEQLEN
2525

26+
// Allow changing k parameter of `SampleTopK` as a compiler flag
27+
#ifndef GEMMA_TOPK
28+
#define GEMMA_TOPK 1
29+
#endif // !GEMMA_TOPK
30+
2631
#include <stddef.h>
2732

2833
namespace gcpp {
2934

3035
static constexpr size_t kSeqLen = GEMMA_MAX_SEQLEN;
36+
static constexpr size_t kTopK = GEMMA_TOPK;
3137

3238
struct ConfigGemma7B {
3339
static constexpr int kSeqLen = gcpp::kSeqLen;
@@ -38,7 +44,7 @@ struct ConfigGemma7B {
3844
static constexpr int kHeads = 16;
3945
static constexpr int kKVHeads = 16; // standard MHA
4046
static constexpr int kQKVDim = 256; // query size == key size == value size
41-
static constexpr int kTopK = 1;
47+
static constexpr int kTopK = gcpp::kTopK;
4248
};
4349

4450
struct ConfigGemma2B {
@@ -50,7 +56,7 @@ struct ConfigGemma2B {
5056
static constexpr int kHeads = 8;
5157
static constexpr int kKVHeads = 8; // TODO(austinvhuang): add MQA support
5258
static constexpr int kQKVDim = 256; // query size == key size == value size
53-
static constexpr int kTopK = 1;
59+
static constexpr int kTopK = gcpp::kTopK;
5460
};
5561

5662
} // namespace gcpp

0 commit comments

Comments
 (0)