Skip to content

Commit 78391e7

Browse files
committed
Config: Read and expose max_position_embeddings
1 parent 402ab56 commit 78391e7

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

exllamav3/architecture/gemma3.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ def __init__(
138138
self.vision_pp.size = read_dict(read_prep_config, dict, ["size"], no_default)
139139

140140

141+
def default_max_position_embeddings(self):
142+
# Fixed for Gemma3, usually not present in config.json
143+
return 131072
144+
145+
141146
class Gemma3TextConfig(Config):
142147
arch_string = "Gemma3ForCausalLM"
143148

@@ -218,6 +223,11 @@ def __init__(
218223
self.final_logit_softcapping = self.read_cfg(float, "final_logit_softcapping", 0.0)
219224

220225

226+
def default_max_position_embeddings(self):
227+
# Fixed for Gemma2, usually not present in config.json
228+
return 8192
229+
230+
221231
class Gemma3Model(Model):
222232
config_class = Gemma3Config
223233

exllamav3/model/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,16 @@ def __init__(
6969
self.num_q_heads = -1
7070
self.num_kv_heads = -1
7171
self.pos_encoding_mode = "NONE"
72+
self.max_position_embeddings = self.read_cfg(int, "max_position_embeddings", self.default_max_position_embeddings())
7273

7374
# Load parameters
7475
self.load_isq = False
7576

7677

78+
def default_max_position_embeddings(self):
79+
return 8192
80+
81+
7782
def read_cfg(self, *args):
7883
"""
7984
Read from config.json, see read()

0 commit comments

Comments
 (0)