From b486c17b3e8bee4340b4095075cefc8415d92068 Mon Sep 17 00:00:00 2001 From: Dowon Date: Thu, 19 Mar 2026 19:41:11 +0900 Subject: [PATCH] convert : support is_causal hyperparameter (#20746) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * convert : support is_causal hyperparameter Check for the `is_causal` attribute in the Hugging Face model configuration and include it in the GGUF metadata. * Update convert_hf_to_gguf.py Co-authored-by: Sigbjørn Skjæret * style: fix F541 f-string is missing placeholders --------- Co-authored-by: Sigbjørn Skjæret --- convert_hf_to_gguf.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/convert_hf_to_gguf.py b/convert_hf_to_gguf.py index 46469c8620..8cfd0bf2f5 100755 --- a/convert_hf_to_gguf.py +++ b/convert_hf_to_gguf.py @@ -1062,6 +1062,10 @@ class TextModel(ModelBase): self.gguf_writer.add_head_count_kv(n_head_kv) logger.info(f"gguf: key-value head count = {n_head_kv}") + if self.hparams.get("is_causal") is False: + self.gguf_writer.add_causal_attention(False) + logger.info("gguf: causal attention = False") + # TODO: Handle "sliding_attention" similarly when models start implementing it rope_params = self.rope_parameters.get("full_attention", self.rope_parameters) if (rope_type := rope_params.get("rope_type")) is not None: