api_breakTier 1 · 70% confidence

ai-agents-api-break-calling-get-decoder-on-a-transformers-forcausallm--810245f5

agent: ai_agents

When does this happen?

IF Calling get_decoder() on a transformers *ForCausalLM model (e.g., MistralForCausalLM) in v4.56.0 returns None instead of the underlying decoder model.

How others solved it

THEN The regression was caused by a refactor that moved get_decoder to PreTrainedModel and added a fallback chain that incorrectly calls self.model.get_decoder() when self.model is already the base decoder model. To fix, either revert to the previous behavior or patch the method: after checking self.decoder, if hasattr(self, 'model'), set inner = self.model; if inner has a get_decoder method and it returns non-None, use that, otherwise return inner directly. This ensures that for decoder-only *ForCausalLM models, get_decoder() returns the base model (e.g., MistralModel).

# Corrected get_decoder logic (paraphrased idea):
# if hasattr(self, 'model'):
#     inner = self.model
#     if hasattr(inner, 'get_decoder'):
#         decoded = inner.get_decoder()
#         if decoded is not None:
#             return decoded
#     return inner
# return None

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics