Zenaique

Pick the three first things to check when LoRA training loss sits flat from step 0

Multi-select·Medium·4.0 · 0·~1 min·Asked atCrewaiOpenAIUnity·Relevant atCoreweaveDatabricksFireworks AiLambda Labs
Attempt it
TL;DR

Flat loss from step 0 is a structural break, not a tuning problem. Check the LR schedule, the target_modules wiring, and whether assistant tokens survive label masking.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine trying to drive a car that will not move. Three things to check first: is there fuel reaching the engine (the labels you are training on), is the engine connected to the wheels (the adapter actually wrapping a layer), and is the gas pedal pressed (the step-size knob the trainer uses not stuck at zero)? Only after confirming all three are working do you start asking whether the engine is too small or the wheels are the wrong size. People who jump straight to swapping engines waste hours when the real fix is plugging in a cable or pressing the pedal. Flat loss is the same: check the structural breaks before changing capacity or precision.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Debugging flat loss is one of the cleanest signals fine-tuning produces. The symptom is unambiguous (loss does not move from step 0), the failure modes are structural, and the diagnostic order is well-defined. Senior engineers should be able to walk the checks in under five minutes; junior engineers often waste hours bumping rank or switching base models because they reach for the levers they know rather than the diagnostics the symptom calls for.

The specific failure mode in this question is the easiest to debug and the easiest to misdiagnose. Flat from step 0 specifically excludes the categories of mid-run failures (NaN spikes, plateaus, oscillation, overfitting) and points squarely at structural breaks in the optimization path. The three first checks (learning rate after warmup, target_modules wiring, assistant tokens after label masking) cover the failure modes that actually fire in production fine-tuning stacks, and each one has a one-line diagnostic that takes seconds to run.

The rest of this section walks each failure mode in detail with its diagnostic and fix, explains why the distractors (bump rank, switch model, disable mixed precision) cannot help, and ends with the general diagnostic path order that should govern any fine-tuning debugging session.

Learning rate after warmup

The first check is the optimizer's learning rate. A zero LR multiplies every gradient by zero in the update rule, so the parameters never move regardless of how large the gradient actually is. The cleanest way this happens in production is a schedule misconfig.

The canonical bug: total_steps is set incorrectly. With a cosine decay schedule, LR drops from the peak value at the end of warmup down to zero at total_steps. If total_steps is much smaller than the actual training duration (because of a mis-counted batch size, gradient accumulation, or epoch count), the cosine decay zeros out within the first few hundred steps and stays there. Loss never moves.

Another variant: warmup_steps is set larger than total_steps. The LR is still ramping up when the schedule nominally ends, so the actual training LR stays at zero or near-zero throughout.

The diagnostic is to log the actual LR at step 100 or 200, after warmup should be complete. Hugging Face Trainer includes learning_rate in the metrics dict at each logging step. If you see 0.0 or 1e-10, the schedule is broken. The fix is to recalculate total_steps as len(train_dataloader) * num_epochs // gradient_accumulation_steps and reset warmup_steps to a small fraction (typically 0.03 to 0.10 of total_steps).

A related failure mode: the optimizer itself is wrong. AdamW with weight_decay set to something massive (like 1.0 instead of 0.01) can produce updates that effectively cancel each other on the small adapter parameters. Less common but worth checking if the LR diagnostic comes back clean.

target_modules wiring and the silent zero-wrap failure
Assistant tokens after label masking
Why the distractors cannot help and the general diagnostic order
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
SymptomLikely causeFirst check
Flat loss from step 0 (this case)Structural break in optimization pathLR, wrapping, label masking
Loss drops then spikes to NaNNumerical overflow or schedule discontinuityMixed precision, gradient clipping, beta
Loss drops then plateausModel is converged or undercapacityEval loss trend; capacity if eval flat
Loss drops then eval risesOverfittingEarly stopping; reduce capacity next run
Loss oscillates wildlyLR too high or batch size too smallLower LR, larger batch, more warmup

Real products, models, and research that use this idea.

  • Hugging Face PEFT issues GitHub history is full of target_modules name mismatches between Llama-3 and Mistral, and the standard fix is print_trainable_parameters before training starts.
  • TRL SFTTrainer in 2026 logs a warning when more than a configurable fraction of labels are -100, exactly because the all-masked failure mode is common.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow do you verify the actual post-warmup learning rate is nonzero in Hugging Face Trainer?
A

Trainer logs include the learning_rate field at each logging step. Check the metric dictionary at step 100 or 200, after warmup is complete. If the value is zero or near-zero, the schedule is broken; common cause is total_steps mis-set or warmup_steps larger than total_steps.

3 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Bumping rank or switching models when loss is flat from step 0. Capacity changes do not help when no gradient is flowing; the fix is upstream in the data, the wiring, or the optimizer.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Why flat loss from step 0 is always a structural break, not a tuning issue

  • The three first checks: LR, target_modules wiring, label masking

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
What is RLHF, and why is it used after pretraining?
MCQ·Easy