Skip to content

Commit ebf5725

Browse files
authored
convert : yield Mamba2Model/GraniteMoeModel modify_tensors (ggml-org#19157)
* convert : yield Mamba2Model/GraniteMoeModel modify_tensors This commit updates the `GraniteHybridModel` class' modify_tensors function to properly delegate to `Mamba2Model.modify_tensors` and `GraniteMoeModel.modify_tensors` using 'yield from' instead of 'return'. The motivation for this is that modify_tensors is a generator function (it uses 'yield from'), but the two calls above use return statements but don't yield anything which means that the the caller of this function will not receive any yielded values from it. And this causes layer tensors to be silently dropped during conversion.
1 parent 0cd7032 commit ebf5725

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

convert_hf_to_gguf.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8912,13 +8912,16 @@ def modify_tensors(
89128912
name.endswith("block_sparse_moe.input_linear.weight")
89138913
or "shared_mlp" in name
89148914
):
8915-
return GraniteMoeModel.modify_tensors(self, data_torch, name, bid)
8915+
yield from GraniteMoeModel.modify_tensors(self, data_torch, name, bid)
8916+
return
89168917

89178918
# Determine whether this is a mamba layer or an attention layer
89188919
if bid in self._ssm_layers:
8919-
return Mamba2Model.modify_tensors(self, data_torch, name, bid)
8920+
yield from Mamba2Model.modify_tensors(self, data_torch, name, bid)
8921+
return
89208922
elif bid in self._attn_layers:
8921-
return GraniteMoeModel.modify_tensors(self, data_torch, name, bid)
8923+
yield from GraniteMoeModel.modify_tensors(self, data_torch, name, bid)
8924+
return
89228925
yield from ModelBase.modify_tensors(self, data_torch, name, bid)
89238926

89248927
def set_gguf_parameters(self):

0 commit comments

Comments
 (0)