feat: fine-tuning wizard — 5-step end-to-end flow#33
Conversation
Implements the core TuneOS fine-tuning experience as a dedicated /finetune wizard: model selection, dataset upload+validation, hyperparameter config, live training progress, and a results page with download, HF Hub push, perplexity eval, and inline model chat. Closes #8 — LoRA fine-tuning configuration workspace Closes #9 — QLoRA and advanced PEFT presets Closes #18 — evaluate_model() returns placeholder None values Trainer: - trainer/evaluate.py: implement perplexity on 20% held-out sample - trainer/finetune.py: return (output_path, model, tokenizer) for eval Worker: - workers/train_task.py: run eval post-training, publish to Redis job:{id}:eval so results are available without re-loading the model API (app/api.py): - GET /api/jobs/{id}/download — stream adapter weights as zip - POST /api/jobs/{id}/push_hub — push adapter to HF Hub - GET /api/jobs/{id}/eval — read perplexity from Redis - POST /api/jobs/{id}/infer — local inference with lazy model cache State (app/state/finetune_state.py): - New FinetuneState owning all wizard fields, events, computed vars - Isolated from existing ModelState to avoid breaking /configure flow UI (app/pages/finetune.py): - Step 1: model cards + technique selector (QLoRA/LoRA active, Full fine-tune/DPO as "Coming soon" stubs) - Step 2: upload dropzone + reuse existing datasets + preview table with column validation - Step 3: LoRA sliders + training params grid with beginner tooltips - Step 4: live loss chart (reuses loss_chart component) + log stream + stop button + auto-advance on completion - Step 5: 2×2 results grid (download / push / eval / test chat) Navigation: - app/app.py: /finetune route registered - sidebar.py: "Fine-tune" nav item wired in expanded + collapsed states Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR delivers a complete LoRA fine-tuning workspace. It implements real model evaluation, adds post-training REST endpoints for adapter download and Hugging Face Hub integration, introduces a five-step UI wizard for job configuration and monitoring, and provides state management for the entire workflow. ChangesFine-tuning Workflow Implementation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
This PR implements the core TuneOS fine-tuning experience as a dedicated
/finetunepage — a guided 5-step wizard that takes a non-technical user from picking a model all the way to a testable, downloadable, shareable fine-tuned adapter.What's included
Trainer backend
trainer/evaluate.py— Real perplexity calculation (replacesNonestub). Runs on a 20% held-out sample of the training data, no extra data required from the user.trainer/finetune.py— Returns(output_path, model, tokenizer)so the worker can pass directly to eval without reloading.Worker
workers/train_task.py— Runs eval automatically after training, publishes result to Redisjob:{id}:eval. Eval failure is caught and does not fail the job.Four new REST endpoints (
app/api.py)GET /api/jobs/{id}/download.zipPOST /api/jobs/{id}/push_hubGET /api/jobs/{id}/evalPOST /api/jobs/{id}/inferWizard UI (
app/pages/finetune.py+app/state/finetune_state.py)Navigation
/finetuneroute registered inapp/app.pyDesign decisions
FinetuneState— isolated from existingModelStateto avoid breaking the/configure→/trainingflowCloses
Test plan
/finetune, verify 5 step dots render and progress bar advances.jsonlwithinstruction/outputcolumns, verify preview table; upload a bad file, verify error callout/finetunecurl GET /api/jobs/{id}/download— unzip, confirmadapter_config.jsonpresentcurl GET /api/jobs/{id}/eval— confirm{"status":"done","perplexity":...}🤖 Generated with Claude Code
Summary by CodeRabbit
New Features