You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Train with DecisionTrainer on ~40k decision rows (lr 1e-4, head lr 3e-4, batch 4 x accum 4, 1 epoch)
Expected behavior: loss decreases and accuracy rises, as it does for Qwen3.5-0.8B, LFM2-700M, LFM2.5-350M and MiniCPM5-1B with the identical script.
Actual behavior: loss stays flat for the whole epoch and accuracy is at chance (BANKING77 1.4%, CLINC150 0.4–0.6%).
Model and operation involved:google/gemma-3-270m and google/gemma-3-270m-it, FastDecisionModel + Clef decision head, LoRA training.
Details
Training a decision model on google/gemma-3-270m (and -it) with FastDecisionModel + decision_head="clef" gives a flat loss and chance-level accuracy. The same script trains Qwen3.5-0.8B, LFM2-700M, LFM2.5-350M and MiniCPM5-1B normally. The same Clef head and data on plain transformers + PEFT (no Unsloth import) trains Gemma fine, so the issue looks specific to the Unsloth Gemma3 training path. Gemma3 is forced to float32 ("Using float16 precision for gemma3 won't work! Using float32.").
Base and -it produce near-identical loss curves (to 3 decimals), i.e. the head's output barely depends on the backbone. Grad norm is finite and decays (0.57 → 0.03); no NaN/inf.
Ruled out (400 steps each, all still flat, BANKING77 1–3%)
Prepending BOS to every Clef record (encode_record builds inputs without <bos>)
Widening the sliding window to full attention
Rescaling the final norm to remove outlier dims (rms max/median 19.5 → 1.0)
use_gradient_checkpointing=False + batch size 1 (no padding)
Head-only training on a frozen Gemma backbone does learn a little (BANKING77 4.6%, CLINC150 18.8% at 300 steps), so the hidden states are usable; it's the LoRA/backbone training through the patched path that fails.
A note on settings, to rule out user error. I checked the decision-model docs: they benchmark Qwen3.5, Llama 3.2 and Gemma 4 E4B, not Gemma 3, so Gemma 3 may simply be untested here.
My recipe differs slightly from the docs defaults (LoRA lr 1e-4 vs 2e-4, head lr 3e-4 vs the 1e-4 default, r=64 as in the docs benchmark, max_seq_length 4096). The identical recipe trains Qwen3.5-0.8B, LFM2-700M, LFM2.5-350M and MiniCPM5-1B normally. I left fp16/bf16 at False so _clef_mixed_precision picks the precision, which for Gemma 3 is the forced-float32 path with no autocast.
Happy to run any variant you'd like (e.g. docs-default lr/rank, Gemma 4 E2B as a comparison) and report back.
Thanks for the thorough bakeoff and the plain-PEFT control — that pins this to the Unsloth Gemma3 training path.
What we think is going on
On T4, Gemma3 hits FORCE_FLOAT32 (“Using float16 precision for gemma3 won't work! Using float32.”). Clef then disabled all autocast for every forced-float32 backbone, copying the Qwen3.5 rule (GDN overflows in fp16). Gemma3’s Unsloth patches still use fp16 activations; GRPO already turns fp16 autocast back on for Gemma3/gpt-oss under that stamp, but Clef did not. Same script + Qwen works because Qwen’s forced path keeps fp32 activations. Plain transformers+PEFT fp32 works because it never takes those patches.
BOS/encode_record alone doesn’t explain the flat LoRA run (you already ruled that out under Unsloth).
PR
#14485 — Clef now enables fp16 autocast for Gemma/gpt-oss* under FORCE_FLOAT32, and keeps no autocast for Qwen/GLM**.
@danielhanchen — please take a look and tell us if this is enough, or if we also need a zoo Gemma3 prepare/activation change. Happy to iterate.
Fixed! On a T4, Gemma 3 runs the decision model in float16 without autocast, and nothing scaled the loss, so its gradients underflowed and the head never learned. #14482 adds loss scaling on that path, and #14670 keeps Gemma 3's flex attention off GPUs whose shared memory cannot fit its backward kernel.
To update: uv pip install --upgrade unsloth unsloth_zoo --force-reinstall --no-cache-dir (if it's not in the current release yet it'll be in the next one). Reopen if it still happens.
Activity
Manitchahar commentedon Oct 21, 2026
A note on settings, to rule out user error. I checked the decision-model docs: they benchmark Qwen3.5, Llama 3.2 and Gemma 4 E4B, not Gemma 3, so Gemma 3 may simply be untested here.
My recipe differs slightly from the docs defaults (LoRA lr 1e-4 vs 2e-4, head lr 3e-4 vs the 1e-4 default, r=64 as in the docs benchmark, max_seq_length 4096). The identical recipe trains Qwen3.5-0.8B, LFM2-700M, LFM2.5-350M and MiniCPM5-1B normally. I left
fp16/bf16at False so_clef_mixed_precisionpicks the precision, which for Gemma 3 is the forced-float32 path with no autocast.Happy to run any variant you'd like (e.g. docs-default lr/rank, Gemma 4 E2B as a comparison) and report back.
indrajeetapache commentedon Oct 21, 2026
Thanks for the thorough bakeoff and the plain-PEFT control — that pins this to the Unsloth Gemma3 training path.
What we think is going on
On T4, Gemma3 hits
FORCE_FLOAT32(“Using float16 precision for gemma3 won't work! Using float32.”). Clef then disabled all autocast for every forced-float32 backbone, copying the Qwen3.5 rule (GDN overflows in fp16). Gemma3’s Unsloth patches still use fp16 activations; GRPO already turns fp16 autocast back on for Gemma3/gpt-oss under that stamp, but Clef did not. Same script + Qwen works because Qwen’s forced path keeps fp32 activations. Plain transformers+PEFT fp32 works because it never takes those patches.BOS/
encode_recordalone doesn’t explain the flat LoRA run (you already ruled that out under Unsloth).PR
#14485 — Clef now enables fp16 autocast for Gemma/gpt-oss* under FORCE_FLOAT32, and keeps no autocast for Qwen/GLM**.
@danielhanchen — please take a look and tell us if this is enough, or if we also need a zoo Gemma3
prepare/activation change. Happy to iterate.indrajeetapache commentedon Oct 21, 2026
Correction: the PR link is #14482 (not 14485).
Gemma 3: keep flex attention only where its head_dim 256 template fit…
danielhanchen commentedon Oct 25, 2026
Fixed! On a T4, Gemma 3 runs the decision model in float16 without autocast, and nothing scaled the loss, so its gradients underflowed and the head never learned. #14482 adds loss scaling on that path, and #14670 keeps Gemma 3's flex attention off GPUs whose shared memory cannot fit its backward kernel.
To update:
uv pip install --upgrade unsloth unsloth_zoo --force-reinstall --no-cache-dir(if it's not in the current release yet it'll be in the next one). Reopen if it still happens.Clef: keep fp16 loss scaling on the float32 path (fixes Gemma 3 not t…