Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Keep audio feature extractors right padded when loading processors (#6157)

Daniel Hand0ffe2638321
diff --git a/unsloth/models/vision.py b/unsloth/models/vision.py
index 34336aa80f9..58814699b3c 100644
--- a/unsloth/models/vision.py
+++ b/unsloth/models/vision.py
@@ -1280,6 +1280,15 @@ class FastBaseModel:
tokenizer.padding_side = "left" # Force inference
if hasattr(tokenizer, "tokenizer"):
tokenizer.tokenizer.padding_side = "left" # Force inference
+ # Audio feature extractors must stay right padded: left (a text setting,
+ # forwarded by from_pretrained) shifts Whisper mels and desyncs Gemma 4
+ # audio token counts (crash on transformers < 5.10).
+ feature_extractor = getattr(tokenizer, "feature_extractor", None)
+ if (
+ feature_extractor is not None
+ and getattr(feature_extractor, "padding_side", None) == "left"
+ ):
+ feature_extractor.padding_side = "right"
m = model
while hasattr(m, "model"):
m.max_seq_length = max_seq_length