Repository navigation
app: run gradient censuses and training runs with live charts - #58
Conversation
There was a problem hiding this comment.
This change adds the Fine-tune tab: a form to launch a gradient census (one epoch at lr 0) or a full train/merge/export run, with live progress, loss and grad-norm charts, cancel, and a census verdict. The job manager (desktop/jobs.rs) lives in App state, allows one job at a time, survives tab switches, and reattaches a reloaded webview. It also fixes RunProgress::Failed to a struct variant so the internally-tagged enum actually serializes (with a test over every variant), bundles mlx.metallib into release builds via the build scripts, and opts dependencies into opt-level = 3 for tauri dev. The pieces fit together well; the main things to look at are the useJob hook's handling of datasetRows and the sync Tauri command that does file I/O on the UI thread.
Automated review by siGit Code Review · commit b67a64b · see the review dashboard
b67a64b to
7aca59c
Compare
|
siGit Code Review couldn't finish this review: the model service was unavailable. Mention @sigit-code-review to try again. Automated review by siGit Code Review · commit 7aca59c · see the review dashboard |
The Fine-tune tab. Pick a project, then either run a gradient census (one
epoch at a learning rate of 0, which trains nothing and shows whether the
backward pass is sane) or a training run that ends in a GGUF.
While a job runs the tab shows the stage (train, merge, export), the backend
(a CPU fallback is called out with the reason), a progress bar, the time
left, live loss and gradient-norm charts, skipped steps, and a Cancel
button. A census ends with a verdict: norms of 10 to 100 are healthy, 1e6 or
more means a broken backward pass, and skipped steps are a warning. Rows the
trainer left out because they are longer than the max sequence length are
reported, since the trainer only logs that. The job lives in App, so it
survives switching tabs, the sidebar shows a dot while it runs, and a
webview that reloads picks the job back up.
One job runs at a time. The Mac is kept awake for the length of a run with an
activity assertion, which pmset lists while it is held. Cancel stops after
the current step and leaves no adapter.
Fixes a bug in the pipeline's progress events: RunProgress::Failed held a
bare string inside an internally tagged enum, which serde cannot serialize,
so every failure message would have been lost on its way to the app. It now
carries { message }, and a test serializes every variant.
The release scripts now bundle mlx.metallib next to the app binary and fail
the build if it is missing. Without it MLX falls back to the CPU quietly.
find-mlx-metallib.sh takes a profile and honours CARGO_TARGET_DIR.
tauri dev now builds dependencies with optimizations. A debug trainer took
about seven minutes to fine-tune and export a 1.7B model on 12 rows, and the
optimized one takes 47 seconds. The first build is slower, about 12 minutes.
Checked in the running app: a census (MLX, 4 steps, verdict "healthy"), a
full run to a 1.19 GB GGUF whose run.json, adapter and charts match, and
Cancel mid-run (status cancelled, no adapter). Not checked: the bundled
metallib in a signed release build, a CPU fallback run, or a reload in the
middle of a job.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: siGit Code v1.7.10 <noreply@sigit.si>
Co-Authored-By: OndeCode v1.1.2 <noreply@ondeinference.com>
…esponsive A webview that reloaded mid-run reattached to the job but had lost what the events it missed had carried. The backend now remembers the latest stage and backend of the running job and returns them when the screen attaches, so a merge is not shown as training and the CPU fallback is not forgotten. The training position is rebuilt from the steps the run has recorded (the first epoch's length is only known once it is over), which brings back the time left estimate and the rows-left-out warning, and the dataset row count is read from the project again. A finished run fills in the epoch losses the screen missed. start_job read and parsed the whole dataset on the main thread, which can freeze the window on a large one. It is async now. The header showed an ellipsis until the backend named the run. The webview works out the default name itself, and a test on each side pins the two to the same strings, including Rust's exponent format. Checked in the running app: with a run in its export stage, forcing a full page reload left the sidebar showing it was running, and the Fine-tune tab showed the run name, MLX, the Export stage, the warning, both charts and Cancel, then the final result with the GGUF. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: siGit Code v1.7.10 <noreply@sigit.si> Co-Authored-By: OndeCode v1.1.2 <noreply@ondeinference.com>
7aca59c to
8c409fe
Compare
There was a problem hiding this comment.
The Fine-tune tab lands its second slice: starting a gradient census or a full train→merge→export run, and watching it live. On the Rust side, desktop/jobs.rs (not shown here) owns the single job, commands/jobs.rs exposes start_job/attach_job/cancel_job over a Tauri channel of RunProgress events, and desktop/power.rs holds a macOS activity assertion for the run's duration. RunProgress::Failed becomes a struct variant so the internally tagged enum actually serializes — a real bug from #50, now pinned by a test that round-trips every variant. On the TS side, useJob keeps the job state in App (survives tab switches and webview reloads via attach_job), job.ts holds the pure fold/derive logic with node tests, census.ts grades gradient norms, and RunForm/JobPanel render the form and the live progress, charts, verdict and rows-left-out warning. Packaging builds the MLX kernels for aarch64, bundles mlx.metallib via the files config, and fails the build if it is missing; find-mlx-metallib.sh gains a profile argument and honours CARGO_TARGET_DIR; [profile.dev.package."*"] opt-level = 3 makes tauri dev usable. The four earlier findings (defaulted rows param, sync start_job, reattach losing timing/stage/backend, and the "…" run-name placeholder) are all addressed in 7aca59c. Worth a first look: the reattach path in useJob.ts (finding below) and the census verdict's handling of non-finite norms.
Automated review by siGit Code Review · commit 8c409fe · see the review dashboard
…nsus wording Reattaching to a running job fetched the recorded steps and then overwrote the steps that had arrived on the live channel in the meantime, leaving a gap in the chart. The two are now merged, deduped on epoch and step, and a position set by a live event is no longer replaced by the older one from the file. The progress panel no longer announces every step to screen readers. Only the census verdict and the finished and stopped messages are live regions. A census where steps ran but no norm was finite said all steps were skipped. It now says that no step reported a finite norm, and keeps the "all skipped" wording for when that is true. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: siGit Code v1.7.10 <noreply@sigit.si> Co-Authored-By: OndeCode v1.1.2 <noreply@ondeinference.com>
There was a problem hiding this comment.
Three small fixes for previously raised threads. JobPanel.tsx removes the panel-wide aria-live="polite" and adds role="status" only to the verdict, finished, and cancelled messages so screen readers announce outcomes without narrating every progress update. census.ts splits the "no usable gradients" verdict into "all skipped" vs "ran but no finite norm," with two new tests in census.test.ts pinning both branches. useJob.ts fixes the reattach race: steps that arrived live during the runSteps/projectDetail fetches are merged with the recorded steps (deduped on epoch:step), and an existing live position is preserved instead of being overwritten by the older file-derived one.
Automated review by siGit Code Review · commit 9e996cc · changes since 8c409fe · see the review dashboard
| // Steps that arrived on the live channel while those fetches ran are in | ||
| // steps.current already. Keep them, and drop any the file also has. | ||
| const seen = new Set(recorded.map((r) => `${r.epoch}:${r.step}`)); | ||
| const merged = [...recorded, ...steps.current.filter((r) => !seen.has(`${r.epoch}:${r.step}`))]; |
There was a problem hiding this comment.
warning — The merge dedups recorded steps against live steps, but if a step exists in both recorded and steps.current with different field values (e.g. a step that was still in-flight when recorded and later completed live with updated loss/grad_norm), the recorded (stale) version wins because it comes first in the spread and the live version is filtered out by the seen set. Reversing the priority — live steps first, then recorded steps not already seen — would keep the freshest data in the chart.
There was a problem hiding this comment.
No change. A step is written to steps.jsonl and sent live only once it has finished, and it is never updated afterwards, so the recorded copy and the live copy of the same epoch and step hold the same values. Putting live steps first would also break the chart order, which the recorded steps give us.
There was a problem hiding this comment.
Fair enough, the write-once invariant makes the dedup safe and ordering matters more here.
The Fine-tune tab: pick a project, then run a gradient census or a training run, and watch it. Second of the three changes for this tab, stacked on #57 (base model download); sweeps come next.
What changed
App, so it survives switching tabs, the sidebar shows a dot, and a reloaded webview reattaches. The Mac is kept awake for the length of a run with an activity assertion.RunProgress::Failedheld a bare string inside an internally tagged enum, which serde cannot serialize. Every failure message would have been lost on the way to the app. It is nowFailed { message }, and a test serializes every variant.mlx.metallibintoContents/MacOS, and fail the build if it is missing. Without it MLX falls back to the CPU quietly.find-mlx-metallib.shtakes a profile and honoursCARGO_TARGET_DIR, and its existing callers behave as before.tauri devbuilds dependencies with optimizations. A debug build took about 7 minutes to fine-tune and export a 1.7B model on 12 rows. The optimized one takes 47 seconds. The first build is slower, about 12 minutes here.Testing
-D warnings,cargo test --lockedand the no-default-features check pass for the CLI and the desktop crate (42 tests). The power assertion test checkspmset -g assertionswhile the guard is held and after it drops. 14 JS tests cover the census verdict and job logic (pnpm test).shellcheckpasses.run.json, adapter and charts matched;cancelled, no adapter);~/.onde/base.mlx.metallibin a signed release build, since that needs the signing profiles and a universal build;Notes
find-mlx-metallib.shneeds a target triple.prebuild_mlxbuildsaarch64-apple-darwinand the bundle uses that build's kernels. MLX is compiled only for Apple Silicon (MLX_AVAILABLEinfinetune.rs), so the Intel half of the universal binary trains on the CPU either way. I did not run the universal build.