Skip to content

app: run gradient censuses and training runs with live charts - #58

Merged
setoelkahfi merged 3 commits into
developmentfrom
feature/app-jobs
Nov 18, 2026
Merged

setoelkahfi merged 3 commits into
developmentfrom
feature/app-jobs

Conversation

@setoelkahfi

@setoelkahfi setoelkahfi commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • Census: one epoch at a learning rate of 0. It trains nothing and shows whether the backward pass is sane. The verdict follows the rule I worked out earlier: norms of 10 to 100 are healthy, 1e6 or more means a broken backward pass, and skipped steps are a warning.
  • Training run: train, merge into the base model, export a GGUF. Name, learning rate, epochs, export type and LoRA settings are on the form.
  • While it runs: the stage (train, merge, export), the backend (a CPU fallback is called out with the reason), a progress bar, time left, live loss and gradient-norm charts, skipped steps, and Cancel. Cancel stops after the current step and leaves no adapter. A merge or export that has begun finishes first, and the screen says so.
  • Rows the trainer left out because they are longer than the max sequence length are reported. The trainer only logs this, and in my test run it dropped 8 of 12 rows without saying so.
  • One job at a time. The job lives in 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.
  • A bug in onde-cli: run fine-tune, merge and export as one pipeline #50's progress events: RunProgress::Failed held 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 now Failed { message }, and a test serializes every variant.
  • MLX in the bundle: the release scripts now build the MLX kernels, copy mlx.metallib into Contents/MacOS, 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, and its existing callers behave as before.
  • tauri dev builds 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

  • fmt, clippy with -D warnings, cargo test --locked and the no-default-features check pass for the CLI and the desktop crate (42 tests). The power assertion test checks pmset -g assertions while the guard is held and after it drops. 14 JS tests cover the census verdict and job logic (pnpm test). shellcheck passes.
  • In the running app, on a throwaway 12-row project with Qwen3-1.7B on MLX:
    • a census (4 steps, "gradients look healthy");
    • a full run to a 1.19 GB GGUF, whose run.json, adapter and charts matched;
    • Cancel mid-run (status cancelled, no adapter);
    • the Projects page then showing all three runs, and the base model resolved from ~/.onde/base.
  • Not tested:
    • the bundled mlx.metallib in a signed release build, since that needs the signing profiles and a universal build;
    • a CPU fallback run;
    • reloading the webview in the middle of a job;
    • starting a job from a project whose dataset has errors (unit tests cover the refusal, not the screen).

Notes

find-mlx-metallib.sh needs a target triple. prebuild_mlx builds aarch64-apple-darwin and the bundle uses that build's kernels. MLX is compiled only for Apple Silicon (MLX_AVAILABLE in finetune.rs), so the Intel half of the universal binary trains on the CPU either way. I did not run the universal build.

@setoelkahfi setoelkahfi self-assigned this Nov 18, 2026
@setoelkahfi
setoelkahfi requested a review from paydii November 18, 2026 08:40

@sigit-code-review sigit-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@sigit-code-review

Copy link
Copy Markdown

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

Base automatically changed from feature/app-new-project to development November 18, 2026 09:44
setoelkahfi and others added 2 commits November 18, 2026 10:44
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>

@sigit-code-review sigit-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

@sigit-code-review sigit-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}`))];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, the write-once invariant makes the dedup safe and ordering matters more here.

@sigit-code-review sigit-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@setoelkahfi
setoelkahfi merged commit 4516090 into development Nov 18, 2026
7 checks passed
@setoelkahfi
setoelkahfi deleted the feature/app-jobs branch November 18, 2026 19:26
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.

2 participants