← TinyGPT · docs · devlog · roadmap · speedup
source: docs/prds/B15-layerwise-lr-decay-sft.md · view on GitHub ↗

PRD — Layer-wise LR decay (--llrd γ) for tinygpt sft

Goal

Add --llrd γ to tinygpt sft (and the DPO family for symmetry). For γ < 1, each transformer block’s LR is multiplied by γ^(depth_from_top), so the embedding + lower blocks see exponentially smaller updates than the LM head + upper blocks. The standard “freeze the foundation, finetune the head” trick from ULMFiT (Howard & Ruder 2018) turned into a continuous knob.

Default γ = 0.95 (mild decay) when the flag is omitted with a value; γ = 1.0 (today’s behavior) when the flag isn’t passed at all so existing recipes don’t drift.

Why now

Scope — in

Scope — out

Files to touch

FileChange
Sources/TinyGPTModel/Optimizers.swiftfactor groupedLRs(γ, layers) helper (likely already exists for pretrain — re-use, don’t duplicate)
Sources/TinyGPT/SFT.swiftparse --llrd, pass to optimizer construction, log resolved per-group LRs in banner
Sources/TinyGPT/DPO.swiftsame flag, same plumbing
Tests/TinyGPTModelTests/LLRDTests.swiftnew — assert per-block LR matches γ^k closed-form

Acceptance criteria

Reference patterns

Open questions