Fine-tuning: interview drills
- Production
- 45 min
- Lesson 7 of 7 in Fine-tuning
- Last verified
Select text in the lesson first to keep it with your note. With the keyboard, move focus here and press the button: the note goes with the section you are reading.
In this module
On this page
Before you start
- Completed:Evaluation, deployment and special cases
You will be able to
- Give a 90-second answer to whether a team should fine-tune, covering the failure kind, the baseline a tune must beat, the break-even against a cheaper alternative, and the upkeep.
- Work the memory derivations: model states of full fine-tuning at 16 bytes per parameter, the trainable parameters of a stated LoRA setup, QLoRA states, and ZeRO per-GPU states, and say what each estimate leaves out.
- Work a training-time estimate from 6ND with LoRA at about two thirds, and the DPO loss for given log-ratios, and say what a larger beta does.
- Structure a 40-minute answer to design a fine-tuning program, from clarifying questions and a baseline through data, method, evaluation gate, rollout and upkeep.
- Diagnose a described symptom, such as a clean loss with broken output, a fall in general ability or a score that jumped after a data refresh, by naming the likely causes in order and the first thing to check.
The review panel meets in the small room at the end of the day. Aarav reads a case aloud, evenly, and waits to be told whether it was right.
Kavya has the training data in tidy folders. Ananya says only that the panel would like to hear your case.
They ask you to defend whether to retrain Aarav at all. Where do you begin?
Concept
This lesson is the rehearsal for the panel’s question in the story, for fine-tuning interviews, which tend to combine a decision question, a sizing exercise and a design prompt. This lesson turns the module into practice. Everything below can be built from lessons 1 to 6, and it should be said aloud, in an order a listener can follow, against a clock. Try each prompt before you open its key. A drill you only read teaches little. The reading estimate covers the opener, the derivations, the drills and the quiz. The timed design drill (40 minutes) and the mock plan (45 minutes) are practice sessions you run separately, outside the 45.
All questions are Common industry pattern or Generated practice, and none is verified as asked by a named company. A sample answer is one good answer, not the only one. Library names and defaults are those of the docs read on 2026-10-21; if your interview uses a newer version, say which version you last read. Every derivation was recomputed with a script. All input figures are invented for the exercise and marked as illustrative.
Why It Matters
Knowing that full fine-tuning needs 16 bytes per parameter is not the same as using it to say, in thirty seconds, which GPU you need. Interviewers for tuning roles tend to probe a few things: whether you ask what failed before proposing a method, whether you can size a run with stated assumptions, whether you put a baseline and a gate in front of any tune, and whether you will say when not to tune at all.
Mental Model
The board’s question is the whole exercise. A strong answer goes in a fixed order, so you stay calm and the listener can follow: name the failure, name the cheapest thing that could fix it, price the tune against that, then say how you will know it worked and what it costs to keep. The order matters more than any single formula.
The 90-second opener
Rehearse this until it fits in about ninety seconds:
“First I sort the failure. Missing or changing knowledge goes to retrieval. Wrong behaviour goes to a better prompt and examples, and to tuning only if those fall short at volume. Cost or latency goes to caching or a smaller model first. A tune has to beat the best prompt-plus-retrieval baseline, on the newest base model, on a held-out set. Then I write the break-even: one-off cost over the daily saving after hosting and maintenance, and I test it against the cheapest alternative, such as prefix caching, because that can erase the saving. If it holds, I start with a small LoRA run, size the memory and time from 16 bytes per parameter and 6ND with assumptions stated, and gate the result on the task metric with an interval and slices, plus regression, safety and format suites compared with the base. I ship it with a canary and a rollback, and I plan to re-run the decision when the base model changes.”
Then add the sentence that shows judgement: “If the failure is stale facts, I would not tune at all.”
Whiteboard derivations
Try each before reading the key. Every input is illustrative. Sizes are decimal GB, and every memory figure is a floor that leaves out activations, logits and framework overhead.
- B1. Full fine-tuning states. An 8B-parameter model and a 34B-parameter model, Adam, mixed precision. How many GB of model states?
- B2. LoRA parameters. A made-up decoder: hidden size 3,072, 28 layers, gated MLP with intermediate size 8,192, full multi-head attention (query, key, value and output projections each ). Rank 16 on all linear layers. How many trainable parameters, as a share of the base linear parameters, and how many GB of training states for the adapter at 16 bytes per parameter?
- B3. QLoRA states. The 34B model with a 4-bit base and an adapter of 0.5 percent of the base. Include the quantisation constants after double quantisation. Does it fit a 24 GB card?
- B4. Time. An 8B model, 50 million tokens per epoch, 2 epochs, one GPU sustaining 300 TFLOP/s. Full fine-tuning time, and LoRA time.
- B5. ZeRO. The 34B model on 16 GPUs of 80 GB each. States per GPU under plain data parallelism and ZeRO stages 1, 2 and 3.
- B6. DPO loss. Beta 0.25. The preferred answer’s log-ratio is +0.6 and the rejected answer’s is -1.4. Compute the loss. Then raise beta to 1.0 with the same log-ratios.
Key.
- B1: GB for the 8B model; GB for the 34B model (2 bytes for 16-bit parameters, 2 for gradients, 12 for the Adam terms). Neither figure fits one 80 GB card, and activations come on top.
- B2: Attention per layer: . MLP per layer: . Per layer 933,888; over 28 layers 26,148,864 trainable parameters. The base linear parameters are , so the adapter is about 0.82 percent. The adapter’s training states at 16 bytes per parameter are about 0.42 GB. What it leaves out: embeddings and norm layers were ignored, the frozen base still has to be stored, and activations are extra.
- B3: The 4-bit base costs GB. The adapter is 0.5 percent of 34B, or 0.17B parameters, at 16 bytes: 2.72 GB. Double quantisation leaves 0.127 bits per parameter of constants: . The floor is about 20.3 GB. A 24 GB card is left with under 4 GB for everything else, and lesson 1’s example of a single logits tensor, 8.4 GB for 16,384 tokens at a 128,000 vocabulary, shows how fast that goes. So: not at a normal batch size; a 48 GB card is the more realistic home.
- B4: FLOPs . Time , about 4.4 hours. LoRA is about two thirds of that, roughly 3.0 hours. The 300 TFLOP/s is an assumption, and 128 GB of states means this run needs more than one GPU in practice, so state that the figure ignores the lost efficiency.
- B5: Plain data parallelism: 544 GB per GPU, which cannot fit. ZeRO-1: . ZeRO-2: . ZeRO-3: . Only stage 3 fits an 80 GB card, and it leaves about 46 GB for activations and gathered layers. It pays 1.5 times the communication of data parallelism (3 units against 2 in the ZeRO paper).
- B6: Margin . , so loss . With beta 1.0 the margin is 2.0, and the loss is about 0.127. The same movement is treated as nearly solved, so training stops pushing sooner and the model stays closer to the reference. The loss depends only on the difference of the two log-ratios, so log-ratios of -0.5 and -2.5 give the same 0.474 even though the preferred answer became less likely.
Design drill: a fine-tuning program (40 minutes)
Prompt. A support platform handles 3 million tickets a day with a large API model and a 1,200-token prompt that extracts a JSON triage record (category, priority, product, sentiment, suggested action). Cost is high and the tone is inconsistent. Propose whether and how to fine-tune. You have 60,000 labelled historical tickets with noisy labels, strict personal-data rules, and one platform team. All figures are invented for the exercise.
A framework to say aloud.
- Clarify. Success metrics (field accuracy, schema-valid rate, latency, cost per call), constraints (personal data, residency), what regression is acceptable, the timeline, and who will maintain it.
- Baseline first. The best prompt with examples, with prompt caching on. The prefix alone is billion input tokens a day. At an assumed $1 per million that is $3,600 a day, but if cached input is billed at 10 percent (an assumption; check your provider), it is about $360. A tune that only removes the prefix can save at most that, so the case for tuning must rest on the price gap between the large model and a small hosted one, as well as on tone.
- Data. Sample the labels with a second reviewer to measure noise. Strip personal data. Deduplicate, then decontaminate against the evaluation sets. Split by group (the ticket thread or customer) and by time if the product changes. Keep a hand-verified golden set with slices (language, rare categories, long tickets). Render with the serving template, include the end token, mask to the assistant tokens, and decode a batch.
- Method. LoRA SFT on a small open model first, and full fine-tuning only if a held-out gap justifies it. Preference methods only if you have chosen and rejected pairs on near-policy outputs.
- Training plan. Estimate memory and time with stated assumptions (B1 to B5), run a learning curve to see whether more data helps, and overfit a tiny batch as a pipeline check.
- Gate. Written before training: a baseline ladder, field accuracy with an interval and slices, schema-valid rate, a regression suite and a safety suite compared with the base, and pass rules.
- Serving and rollout. Adapter or merged weights, shadow traffic, a canary, and rollback by pointing to the previous adapter.
- Upkeep. Re-tune triggers (a new base model, a schema change, drift), a re-run of the baseline on the new base, consent and personal-data handling for logs, and a cost model with its assumptions.
- Alternatives and fallback. Prefix caching alone, a smaller classifier for some fields, or a router that sends low-confidence tickets to the large model. Say what each costs.
Markers of a strong answer. A baseline with caching before any tuning; label noise handled; a group split and a golden set with slices; a stated memory and time estimate with its omissions; a gate with a regression and a safety suite; a canary and rollback; upkeep when the base changes; and a fallback route. Expect a change of constraint (“the data may not leave our network”, “volume doubles”). Re-cost aloud and name the risk you accept.
Variant to try cold. The same program for a legal-document summariser with very long inputs and strict citation requirements. The knowledge and citation need points to retrieval first; a tune would be only for style and structure.
Debugging drills
Say the likely causes aloud, in order, before reading the right-hand column.
| Symptom | Causes to walk through, and the first check |
|---|---|
| Training loss is clean but production JSON is broken | Template mismatch between training and serving; end token missing; long examples truncated before the answer. First: decode one batch, then compare the training and serving prompts character by character |
| Task score up, general benchmark down | Forgetting from a high learning rate, many epochs, narrow data or full tuning. First: run the regression suite on base and tuned and read the difference |
| The model never stops generating | End token absent from the targets or mismatched with the template. First: look at the labels at the end of a decoded sequence |
| After DPO the answers are longer and less accurate | Length rewarded by the judge or the preference data; beta too small; pairs not from near the policy. First: a length check on the win rate and the absolute likelihoods of the chosen answers |
| The score jumped 15 points after a data refresh | Related rows split across train and test; duplicates; evaluation items inside the training data. First: check overlap between train and evaluation, and re-split by group |
| A QLoRA run runs out of memory at step 200 | A batch of long sequences spiking activations and logits; no checkpointing. First: the length of the longest batch, then cap length, enable gradient checkpointing, or lower the per-pass batch and accumulate |
| The adapter passed the gate but the merged model is worse | A merge is a new model; merging into a quantised base re-quantises it. First: re-run the whole gate on the merged artefact |
Rapid-fire
Answer each in about twenty seconds.
- How many bytes per parameter for full fine-tuning with Adam in mixed precision?
- Why does LoRA start with B at zero and A random?
- Name QLoRA’s three memory tricks. Which part stays in 16-bit?
- Does gradient checkpointing shrink model states?
- Per-GPU states under ZeRO-3, and what does it cost?
- What does the KL penalty protect against?
- Which models does DPO keep in memory?
- How is a GRPO advantage computed?
- Why split by group?
- Why is LoRA about two thirds of full compute?
- Merge or swap for 200 tenants?
- What does an embedding tune force downstream?
Key. 1. : 2 for parameters, 2 for gradients, 12 for the Adam terms. 2. B zero means the model starts as the base; A random means B still gets a non-zero gradient. 3. NF4, double quantisation, paged optimisers; the matrix multiply and the adapters stay in 16-bit. 4. No, it saves activations and costs recompute. 5. ; about 1.5 times the communication of data parallelism. 6. Over-optimising a reward model that is only accurate near the SFT model. 7. The policy and a frozen reference; the reference log-probabilities can be computed once and reused. 8. , with no critic. 9. Related rows in both sets make the evaluation look better than it is. 10. Frozen layers still need input gradients; only the weight gradients are skipped. 11. Swap: one base in memory, many small adapters, rollback by pointer. 12. Re-embedding and re-indexing the whole corpus, and re-checking similarity thresholds.
Mock plan (45 minutes)
| Minutes | Part | Prompt |
|---|---|---|
| 0 to 5 | Warm-up | “Fine-tune or use RAG for our internal docs assistant?” Follow-up: “They insist on tuning. What would you tune, and how do you prove value?” |
| 5 to 15 | Depth | “Explain LoRA and derive the trainable parameters for a config I give you.” Follow-up: “QLoRA: where does the memory go?” |
| 15 to 22 | Debug | “Your tuned model regressed on general tasks.” Follow-up: “How would you have caught it before shipping?” |
| 22 to 28 | Alignment | “DPO, RLHF or GRPO for a maths tutor?” Follow-up: “Give an example of reward hacking and a defence.” |
| 28 to 43 | Design | The design drill, with the interviewer probing data, gate, rollback and cost |
| 43 to 45 | Close | “What are the three biggest risks, and what do you measure first?” |
The interviewer does not teach during the mock. Afterwards, note the two places you lost the thread and repeat those drills on a nearby variant a few days later.
Real-World Application
Run the mock with a friend. A 35-minute version: the opener, two derivations and the design drill. A 45-minute version: the full plan, where the interviewer changes a constraint twice. A good habit is to record yourself answering the design drill cold, then count how many of the nine parts you reached before time ran out.
Interview Perspective
Expect all of the above in any order. Signals interviewers tend to look for: you ask what failed before naming a method; you put a baseline and a gate in front of any tune; you give formulas with stated assumptions and say what they omit; you separate task gains from regression and safety; and you say when not to tune.
Common failures are quoting 16 bytes per parameter and forgetting activations, claiming LoRA is a hundredfold saving in compute, and describing a design without a rollback. Another is to quote a library default from memory when the version may have changed.
Provenance: Common industry pattern and Generated practice. None of these drills is verified as asked by a named company.
Practice Questions
- Basic: Give the 90-second answer to “Should we fine-tune?”
- Intermediate: Redo B2 for hidden size 2,560, 32 layers, intermediate size 6,912, rank 8, all linear layers.
- Advanced: Run the design drill with the constraint “the data may not leave our network”. What changes?
- Product-Company: A manager wants a tune “because it will pay for itself in a month”. What do you ask for?
Activity
Time yourself on the opener and one derivation. If either takes more than twice its budget, mark the lesson it comes from and re-read that section, then try a nearby variant instead of the same prompt.
Homework
Record yourself on the design drill in 40 minutes. Play it back and list what the key covers that you missed. Rewrite your first sixty seconds so that it names the failure, the baseline, and the order you will cover things.
Quick Revision
- Opener: sort the failure, beat the baseline, test the break-even against caching, LoRA first, gate, canary, re-run on a new base.
- Memory: full fine-tuning ; LoRA plus ; QLoRA plus ; ZeRO , , , . All are floors.
- Adapter parameters: per matrix, summed.
- Time: over the sustained rate; LoRA about two thirds.
- DPO loss: ; larger beta saturates sooner.
- Design in nine parts, and diagnose by naming causes in order, then the first check.
Check yourself
- Walk-through: Design the ticket-triage program in forty minutes, covering all nine parts.
- Variation: Redo it for a legal-document summariser with strict citations.
- Common misconception: “A bigger tune is a better answer.” Each step should trace to a failure and a baseline.
Related
Resources & Further Reading
Checked sources to go deeper. The essential ones come first in each group.
Official documentation
Zero Redundancy Optimizer (DeepSpeed tutorial) (opens in a new tab)
The DeepSpeed tutorial for configuring the ZeRO stages whose per-GPU memory is worked out in the deck.
Hands-on
Performing gradient accumulation with Accelerate (opens in a new tab)
A worked guide to gradient accumulation, the usual way to fit a larger effective batch when memory is tight.
More for this module: Fine-tuning resources
Practice
Test what you just read. Quizzes and cards are grouped by module: Fine-tuning.
Check yourself19 questions on what this lesson set out to teach
Checking answers needs JavaScript. You can still read every question and option below.
Keyboard: arrow keys move between options. Space or Enter selects the focused option.