Skip to content

Commit

Permalink
convert : renamed expert_weights_func to expert_gating_func
Browse files Browse the repository at this point in the history
  • Loading branch information
sszymczy committed Jan 2, 2025
1 parent a43d495 commit 93aca64
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions convert_hf_to_gguf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3859,9 +3859,9 @@ def set_gguf_parameters(self):
self.gguf_writer.add_expert_weights_norm(hparams["norm_topk_prob"])

if hparams["scoring_func"] == "sigmoid":
self.gguf_writer.add_expert_weights_func(gguf.ExpertWeightsFuncType.SIGMOID)
self.gguf_writer.add_expert_gating_func(gguf.ExpertGatingFuncType.SIGMOID)
elif hparams["scoring_func"] == "softmax":
self.gguf_writer.add_expert_weights_func(gguf.ExpertWeightsFuncType.SOFTMAX)
self.gguf_writer.add_expert_gating_func(gguf.ExpertGatingFuncType.SOFTMAX)
else:
raise ValueError(f"Unsupported scoring_func value: {hparams['scoring_func']}")

Expand Down
4 changes: 2 additions & 2 deletions gguf-py/gguf/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class LLM:
EXPERT_SHARED_COUNT = "{arch}.expert_shared_count"
EXPERT_WEIGHTS_SCALE = "{arch}.expert_weights_scale"
EXPERT_WEIGHTS_NORM = "{arch}.expert_weights_norm"
EXPERT_WEIGHTS_FUNC = "{arch}.expert_weights_func"
EXPERT_GATING_FUNC = "{arch}.expert_gating_func"
POOLING_TYPE = "{arch}.pooling_type"
LOGIT_SCALE = "{arch}.logit_scale"
DECODER_START_TOKEN_ID = "{arch}.decoder_start_token_id"
Expand Down Expand Up @@ -1581,7 +1581,7 @@ class GGMLQuantizationType(IntEnum):
TQ2_0 = 35


class ExpertWeightsFuncType(IntEnum):
class ExpertGatingFuncType(IntEnum):
SOFTMAX = 1
SIGMOID = 2

Expand Down
6 changes: 3 additions & 3 deletions gguf-py/gguf/gguf_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
RopeScalingType,
PoolingType,
TokenType,
ExpertWeightsFuncType,
ExpertGatingFuncType,
)

from .quants import quant_shape_from_byte_shape
Expand Down Expand Up @@ -719,8 +719,8 @@ def add_expert_weights_scale(self, value: float) -> None:
def add_expert_weights_norm(self, value: bool) -> None:
self.add_bool(Keys.LLM.EXPERT_WEIGHTS_NORM.format(arch=self.arch), value)

def add_expert_weights_func(self, value: ExpertWeightsFuncType) -> None:
self.add_uint32(Keys.LLM.EXPERT_WEIGHTS_FUNC.format(arch=self.arch), value.value)
def add_expert_gating_func(self, value: ExpertGatingFuncType) -> None:
self.add_uint32(Keys.LLM.EXPERT_GATING_FUNC.format(arch=self.arch), value.value)

def add_swin_norm(self, value: bool) -> None:
self.add_bool(Keys.LLM.SWIN_NORM.format(arch=self.arch), value)
Expand Down

0 comments on commit 93aca64

Please sign in to comment.