From 389f7b1f2ec365ffe62e6d5956517d799a921c41 Mon Sep 17 00:00:00 2001 From: AmitMY Date: Mon, 27 Jul 2026 13:19:09 +0200 Subject: [PATCH] refactor(char-causal-lm): drop redundant gradient checkpointing overrides Both overrides only forwarded to self.model, which is what PreTrainedModel already does: its own implementation walks submodules and reaches the wrapped model on its own. Verified against the four tests added in #10 rather than assumed. With the overrides deleted, enable/disable/kwargs and the backward pass all still pass on transformers 4.57.6 and 5.14.1: 245 passed on both. Co-Authored-By: Claude Opus 5 (1M context) --- utf8_tokenizer/char_causal_lm.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/utf8_tokenizer/char_causal_lm.py b/utf8_tokenizer/char_causal_lm.py index 20ac92b..6465739 100644 --- a/utf8_tokenizer/char_causal_lm.py +++ b/utf8_tokenizer/char_causal_lm.py @@ -94,14 +94,6 @@ def __init__( # We resize so that we can access logits self.model.resize_token_embeddings(hidden_size) - def gradient_checkpointing_enable(self, gradient_checkpointing_kwargs=None): - """Enable gradient checkpointing on the underlying model.""" - self.model.gradient_checkpointing_enable(gradient_checkpointing_kwargs=gradient_checkpointing_kwargs) - - def gradient_checkpointing_disable(self): - """Disable gradient checkpointing on the underlying model.""" - self.model.gradient_checkpointing_disable() - def get_input_embeddings(self): """Return the input embedding layer.""" return self.char_embedding