From ee215189a6fbf2257bf8e0a3d61709e8b8610041 Mon Sep 17 00:00:00 2001 From: MekkCyber Date: Wed, 15 Jan 2025 10:06:18 +0000 Subject: [PATCH 1/2] fixing nemotron processor --- src/transformers/modeling_gguf_pytorch_utils.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/transformers/modeling_gguf_pytorch_utils.py b/src/transformers/modeling_gguf_pytorch_utils.py index 9b20c1b61226..621258ff2a76 100644 --- a/src/transformers/modeling_gguf_pytorch_utils.py +++ b/src/transformers/modeling_gguf_pytorch_utils.py @@ -220,6 +220,15 @@ def process(self, weights, name, **kwargs): weights = np.log(-weights) 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): @@ -241,7 +250,8 @@ def process(self, weights, name, **kwargs): "t5encoder": T5TensorProcessor, "gpt2": GPT2TensorProcessor, "mamba": MambaTensorProcessor, - "gemma2": Gemma2TensorProcessor, + "nemotron": NemotronTensorProcessor, + "gemma2": Gemma2TensorProcessor } From adda2e1625aafb5be6ef2985c2a6b881f1701897 Mon Sep 17 00:00:00 2001 From: MekkCyber Date: Wed, 15 Jan 2025 10:13:52 +0000 Subject: [PATCH 2/2] make style --- src/transformers/modeling_gguf_pytorch_utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/transformers/modeling_gguf_pytorch_utils.py b/src/transformers/modeling_gguf_pytorch_utils.py index 621258ff2a76..0da06a1f582a 100644 --- a/src/transformers/modeling_gguf_pytorch_utils.py +++ b/src/transformers/modeling_gguf_pytorch_utils.py @@ -220,16 +220,18 @@ def process(self, weights, name, **kwargs): weights = np.log(-weights) 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 + # 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) @@ -251,7 +253,7 @@ def process(self, weights, name, **kwargs): "gpt2": GPT2TensorProcessor, "mamba": MambaTensorProcessor, "nemotron": NemotronTensorProcessor, - "gemma2": Gemma2TensorProcessor + "gemma2": Gemma2TensorProcessor, }