Skip to content

Commit

Permalink
Fix : Nemotron Processor in GGUF conversion (#35708)
Browse files Browse the repository at this point in the history
* fixing nemotron processor

* make style
  • Loading branch information
MekkCyber authored Jan 15, 2025
1 parent 387663e commit 12dfd99
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/transformers/modeling_gguf_pytorch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,17 @@ def process(self, weights, name, **kwargs):
return GGUFTensor(weights, name, {})


class NemotronTensorProcessor(TensorProcessor):
def __init__(self, config=None):
super().__init__(config=config)

# ref : https://github.com/ggerganov/llama.cpp/blob/master/convert_hf_to_gguf.py#L4666
def process(self, weights, name, **kwargs):
if "norm.weight" in name:
weights = weights - 1
return GGUFTensor(weights, name, {})


class Gemma2TensorProcessor(TensorProcessor):
def __init__(self, config=None):
super().__init__(config=config)
Expand All @@ -241,6 +252,7 @@ def process(self, weights, name, **kwargs):
"t5encoder": T5TensorProcessor,
"gpt2": GPT2TensorProcessor,
"mamba": MambaTensorProcessor,
"nemotron": NemotronTensorProcessor,
"gemma2": Gemma2TensorProcessor,
}

Expand Down

0 comments on commit 12dfd99

Please sign in to comment.