Warmup and cosine learning-rate decay
Implement a resumable linear-warmup and cosine-decay schedule.
What’s going wrong
Original LLM Architecture lab. Implement the missing behavior in solve(data) and keep the supplied JSON interface. Use Python’s standard library.
Input steps contains nonnegative integer update indices. Use base_lr × step/warmup when step < warmup. From warmup through total, interpolate from base_lr to min_lr by cosine with fraction (step−warmup)/(total−warmup). At and beyond total return min_lr. Require 0 ≤ warmup < total and 0 ≤ min_lr ≤ base_lr. Return rates in input order.
Small, well-formed JSON inputs and standard-library Python arithmetic. Keep full precision during computation. The supplied output wrapper rounds results to six decimal places.
Expected behavior
Implement a resumable linear-warmup and cosine-decay schedule.
Reproduction
{"steps":[0,1,2,3,5,8],"warmup":2,"total":6,"base_lr":1,"min_lr":0.1}[0,0.5,1,0.868198,0.231802,0.1]
{"steps":[4,5],"warmup":0,"total":4,"base_lr":0.01,"min_lr":0.001}[0.001,0.001]
{"steps":[0,1,2],"warmup":0,"total":2,"base_lr":1,"min_lr":0}[1,0.5,0]
Before you begin
- Python functions, lists and dictionaries
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
Read the report, then sign in to start your investigation.