Skip to content

Add optimizer exercises (Adam, AdamW, Muon) - #28

Open
ezhoureal wants to merge 3 commits into
Exorust:mainfrom
ezhoureal:add-optimizers-exercise
Open

Add optimizer exercises (Adam, AdamW, Muon)#28
ezhoureal wants to merge 3 commits into
Exorust:mainfrom
ezhoureal:add-optimizers-exercise

Conversation

@ezhoureal

@ezhoureal ezhoureal commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Three new Hard problems under torch/hard/optimizers/, one per optimizer, each in the repo's template Q + _SOLN notebook format and fully auto-graded. Replaces the earlier single combined "Optimizers" exercise.

What's included

Problem ID Notebooks Grading
Implement Adam from Scratch v1-36 torch/hard/optimizers/adam/ 3 checks (MyAdam)
Implement AdamW from Scratch v1-37 torch/hard/optimizers/adamw/ 2 checks (MyAdamW)
Implement Muon from Scratch v1-38 torch/hard/optimizers/muon/ 6 checks (newton_schulz, MyMuon)

Each problem has its own problem.toml (difficulty hard, companies Meta + Google), question notebook with Colab badge + check("…", ...) line, and solution notebook with blanked-out answers.

Validation

  • Adam: compared step-for-step against torch.optim.Adam on a quadratic bowl; bias correction pinned by a hand-derived first step (-lr·sign(grad) from zero state).
  • AdamW: compared step-for-step against torch.optim.AdamW; decoupled decay pinned by a zero-gradient parameter that must still shrink by (1 - lr·weight_decay) — fails Adam + L2.
  • Muon: newton_schulz checked as geometry (orthonormal rows/columns, scale invariance, orthogonal matrices as fixed points); Muon checked for orthogonal update directions, the AdamW fallback for 1-D parameters, and loss convergence on a small linear model.

Grader specs in python/torchleet/problems/{adam,adamw,muon}.py (11 checks total) wired into the autograder with generated hints, and registered as v1-36/37/38 in mcp-server/src/data/questions.ts, problems.json, space/problems.json, and the generated website/MCP data. README and PROBLEMS.md updated → 68 problems total, 62 auto-graded.

The superseded .py exercise files under torch/ were removed (notebook format is canonical).

Checks

  • scripts/generate.py check — 0 problems; coverage — 62/68 auto-graded
  • python/test_grader.py — 8/8 pass
  • scripts/validate_specs.py adam adamw muon — all 3 solutions pass their own checks

@ezhoureal
ezhoureal requested a review from Exorust as a code owner August 26, 2026 10:42
@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

@ezhoureal is attempting to deploy a commit to the exorust's projects Team on Vercel.

A member of the Team first needs to authorize it.

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

ezhoureal added a commit to ezhoureal/TorchLeet that referenced this pull request Aug 26, 2026
…/ Muon)

Replaces the single combined optimizer exercise (v1-36) with three
registered problems, each with its own question + solution notebook pair
and grader spec:

- torch/hard/optimizers/adam/  (v1-36)  — MyAdam, 3 checks
- torch/hard/optimizers/adamw/ (v1-37)  — MyAdamW, 2 checks
- torch/hard/optimizers/muon/  (v1-38)  — newton_schulz + MyMuon, 6 checks

Generated catalogue files (problems.json, space/, website data, PROBLEMS.md,
README counts) regenerated to 68 problems / 62 auto-graded.

Co-Authored-By: Claude <noreply@anthropic.com>
@ezhoureal ezhoureal changed the title Add Optimizers (Adam / AdamW / Muon) from scratch exercise Add optimizer exercises (Adam, AdamW, Muon) — three notebook problems Aug 26, 2026
@ezhoureal ezhoureal changed the title Add optimizer exercises (Adam, AdamW, Muon) — three notebook problems Add optimizer exercises (Adam, AdamW, Muon) Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant