From f5533e4814c76dbfc6d1dff838f72a5ab4546e52 Mon Sep 17 00:00:00 2001 From: Samanvya Tripathi Date: Wed, 25 Mar 2026 20:43:25 -0400 Subject: [PATCH] fix(runners): call ensure_chat_template in load() for all runners load() was missing the ensure_chat_template() call that _load_model() has. This caused the common notebook pattern of save-then-reload to produce a tokenizer without a chat template, breaking any subsequent apply_chat_template call. Fixes #25 --- src/alignrl/dpo.py | 1 + src/alignrl/grpo.py | 1 + src/alignrl/sft.py | 1 + 3 files changed, 3 insertions(+) diff --git a/src/alignrl/dpo.py b/src/alignrl/dpo.py index 779b631..79a6766 100644 --- a/src/alignrl/dpo.py +++ b/src/alignrl/dpo.py @@ -134,3 +134,4 @@ def load(self, path: Path) -> None: max_seq_length=self.config.max_seq_length, load_in_4bit=self.config.load_in_4bit, ) + ensure_chat_template(self._tokenizer) diff --git a/src/alignrl/grpo.py b/src/alignrl/grpo.py index 3eaf7da..738e110 100644 --- a/src/alignrl/grpo.py +++ b/src/alignrl/grpo.py @@ -173,3 +173,4 @@ def load(self, path: Path) -> None: max_seq_length=self.config.max_seq_length, load_in_4bit=self.config.load_in_4bit, ) + ensure_chat_template(self._tokenizer) diff --git a/src/alignrl/sft.py b/src/alignrl/sft.py index 8e1f003..045ef89 100644 --- a/src/alignrl/sft.py +++ b/src/alignrl/sft.py @@ -141,3 +141,4 @@ def load(self, path: Path) -> None: max_seq_length=self.config.max_seq_length, load_in_4bit=self.config.load_in_4bit, ) + ensure_chat_template(self._tokenizer)