Training
Fine-tuning job monitor with a fixed-axis train and validation loss curve, segmented epoch progress bar, keyboard sample inspection, sliding event log, pause and two-step cancel controls, checkpoint retry, and deploy-to-endpoint flow.
import { TrainingRun } from '@uthereal/ui/training-run'Training run playground
support-classifier-v4
- Step
- 0 / 1,200
- Train loss
- —
- Val loss
- —
- Learning rate
- 0
- Elapsed
- 0s
- ETA
- About 18m 40s
- Evals and checkpoints show here
Overview
TrainingRun monitors a fine-tuning or model training job inside one 640px card. A live Train (raw + EMA smoothed) and Validation loss curve draws rightward across a fixed totalSteps axis that doubles as a segmented per-epoch progress bar so the chart never rescales mid-run. Below the curve sit live telemetry stats (Step, Train loss, Val loss, Learning rate, Elapsed, ETA), a sliding three-row event log of evals and checkpoints, and lifecycle actions (Pause, Resume, two-step Cancel, Retry from checkpoint, Run again, and Deploy ending in a copyable endpoint).
Use TrainingRun on fine-tuning job detail pages, distillation monitors, and custom model onboarding flows. For a generic multi-series trend chart without job controls, use Line chart.
Usage
'use client'
import { TrainingRun } from '@uthereal/ui/training-run'
export function FineTuneMonitor({ job }: { job: Job }) {
return (
<TrainingRun
status={job.status}
name={job.outputName}
modelName={job.baseModel}
modelBrand="qwen"
details={['LoRA r16', '8× H200']}
dataset={{ name: job.datasetName, examples: job.examples }}
step={job.step}
totalSteps={job.totalSteps}
epochs={job.epochs}
loss={job.loss}
learningRate={job.learningRate}
elapsed={job.elapsedSeconds}
eta={job.etaSeconds}
events={job.events}
error={job.error}
onPause={() =>
void fetch(`/api/jobs/${job.id}/pause`, { method: 'POST' })
}
onResume={() =>
void fetch(`/api/jobs/${job.id}/resume`, { method: 'POST' })
}
onCancel={() =>
void fetch(`/api/jobs/${job.id}/cancel`, { method: 'POST' })
}
onRetry={() =>
void fetch(`/api/jobs/${job.id}/retry`, { method: 'POST' })
}
onDeploy={async (signal) => {
const res = await fetch(`/api/jobs/${job.id}/deploy`, {
method: 'POST',
signal,
})
if (!res.ok) throw new Error('Deployment failed')
return res.json()
}}
/>
)
}Omit status to play the built-in simulated LoRA run of Qwen3.8 Max (pauses automatically while off screen; nothing is sent over the network). Each footer button appears only when its matching callback is provided, so passing data props alone renders a read-only monitor.
Examples
Out-of-memory failure and checkpoint retry
Set scenario="oom" on the built-in simulation to reproduce a GPU out-of-memory failure at step 940, showing the danger badge, error footer, event entry, and Retry from checkpoint recovery back to the epoch 2 checkpoint.
billing-triage-v3
- Step
- 0 / 1,200
- Train loss
- —
- Val loss
- —
- Learning rate
- 0
- Elapsed
- 0s
- ETA
- About 18m 40s
- Evals and checkpoints show here
Completed run with final metrics
Pass status="completed", loss, events, and custom four-cell metrics to render the finished state where the four-column results grid replaces live telemetry.
support-classifier-v4
- Validation loss
- 0.442from 2.08
- Train loss
- 0.411EMA
- Duration
- 42m 20s3 epochs
- Eval F1
- 94.6%+6.2 pts
- Weights merged and verified for deploymentStep 1,200
- Validation loss reached 0.442Step 1,200
- Checkpoint saved · epoch 2Step 800
Lifecycle and controls
Job states
| Status | Badge tone & icon | Chart & stats behavior | Footer actions (when callbacks are wired) |
|---|---|---|---|
queued | Quiet clock | Shimmering activity overlay over empty plot; ETA reads "About …". | Cancel (two-step) |
running | Live spinner (Starting / Training) | Live EMA train + validation curve and eased epoch segments; 6 live telemetry cells. | Cancel (two-step), Pause |
paused | Quiet pause | Head dot dims to muted; ETA reads "On hold". | Cancel (two-step), Resume |
failed | Danger circle-alert | Head dot turns danger; footer replaces dataset with error text. | Run again, Retry from checkpoint |
cancelled | Quiet circle-dashed | Curve and epoch bars rest muted; ETA reads "Stopped". | Run again |
completed | Success circle-check | Stats crossfade to 4-column metrics summary. | Run again, Deploy |
| Deployed | Success sparkles | Footer reveals monospace endpoint with an icon-only Copy endpoint button. | Run again |
Two-step cancel & deploy lifecycle
- Pressing Cancel morphs the button into a danger Confirm cancel state for
3seconds; pressing again confirms and invokesonCancel, preventing accidental termination of a long run. - Pressing Deploy enters a loading state while
onDeploy(signal)settles, aborts automatically on unmount or status change, and displays either the copyableendpointor an inline error with Retry deploy.
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
status | queued | running | paused | completed | failed | cancelled— | Where the job is. Leave it out to play the built-in simulated run; running with no loss samples reads as starting up. |
name | stringDefault: "support-classifier-v4" | The job or output model name, "support-classifier-v4". |
modelName | stringDefault: "Qwen3.8 Max" | The base model being fine-tuned, shown beside the mark. |
modelBrand | anthropic | openai | google | qwen | meta | mistral | customDefault: "qwen" | Base model mark shown beside the name; renderModelMark overrides it in React. |
details | string[]Default: ["LoRA r16","8× H200"] | Short facts after the model name, such as LoRA rank and GPUs. Defaults to LoRA r16 on 8× H200. |
dataset | object— | The training data, shown in the footer with its example count. Hidden while a run failed with an error. |
step | integerDefault: 0 | Optimizer steps done, out of totalSteps. |
totalSteps | integerDefault: 1200 | Steps in the whole run. Fixes the x axis so the curve never rescales mid-run. |
epochs | integerDefault: 3 | Number of epochs. The step axis splits into one band and one progress segment per epoch. |
loss | TrainingLossPoint[]Default: [] | Loss samples, oldest first. Train is drawn raw (faint) and smoothed; validation joins its own samples. The line eases toward each new point. |
learningRate | number— | The current learning rate, formatted as 1.84e-4. Reads "Not set" when omitted. |
elapsed | number— | Seconds of training so far, excluding pauses. |
eta | number— | Estimated seconds left. While queued it reads as the expected duration, "About 18m 40s". |
events | TrainingEvent[]Default: [] | The run's event log, oldest first. The newest three show; kinds are start, checkpoint, eval, epoch, warning, error and done. |
metrics | TrainingMetric[]— | Up to four results that replace the live stats on completion. Defaults to final train loss, validation loss, steps and duration. |
activity | string— | A short line over the empty chart while queued or starting, "Waiting for 8× H200 · 2nd in queue". |
error | string— | Why the run failed, shown in the footer in place of the dataset. |
scenario | healthy | oomDefault: "healthy" | Demo only, used when status is left out: "oom" fails once at step 940 so the retry path can be seen. |
pauseAction | string— | Registered host action requested when Pause is pressed. |
resumeAction | string— | Registered host action requested when Resume is pressed. |
cancelAction | string— | Registered host action requested when Cancel is confirmed with a second press. |
retryAction | string— | Registered host action requested when Retry from checkpoint is pressed. |
restartAction | string— | Registered host action requested when Run again is pressed. |
deployAction | string— | Registered host action requested when Deploy is pressed; the React onDeploy callback drives the loading and endpoint states. |
locale | string— | BCP 47 locale for number formatting; inherited from the page when omitted. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes preserve interaction behavior. |
theme | TrainingRunThemeDefault: {} | Color mode, accent, and typed semantic token overrides. |
motion | none | subtle | expressiveDefault: "subtle" | Animation preset. System reduced-motion preferences take precedence. |
motionOptions | TrainingRunMotionOptionsDefault: {} | Crossfade, event slide, and curve easing timing overrides in milliseconds. |
dir | ltr | rtl— | Reading direction; inherited from the page when omitted. |
TrainingLossPointaccepts{ step, train?, val? }ordered oldest first (step0..1,000,000).TrainingEventaccepts{ id, kind, label, step? }with unique IDs (kind:'start' | 'checkpoint' | 'eval' | 'epoch' | 'warning' | 'error' | 'done').TrainingMetricaccepts{ label, value, hint? }(up to4cells shown on completion).
React integration
| Prop | Purpose |
|---|---|
onPause / onResume | Pause a running job or resume a paused job. |
onCancel | Called after the reader confirms the two-step Confirm cancel prompt within 3 seconds. |
onRetry / onRestart | Retry a failed job from its last checkpoint or restart a finished, failed, or cancelled job from step 0. |
onDeploy(signal) | Async deploy handler resolving to { endpoint?: string } | void; rejections display an error message and Retry deploy. |
onAction(action) | Called with the matching registered action ref (pauseAction, resumeAction, cancelAction, retryAction, restartAction, deployAction). |
notice | One-off announcement appended to the polite screen-reader live region. |
renderModelMark({ brand }) | Replaces the 24px base-model mark in the header. Keep returned elements decorative. |
renderDatasetMark() | Replaces the 14px dataset mark in the footer. Keep returned elements decorative. |
preset | Application defaults overridden by explicit instance arguments. |
tokens | CSS variables applied after the typed theme, forwarded to the root card and footer buttons. |
ref, className, style | Applied to the root <section> element. |
| Native attributes | id, aria-*, data-*, and remaining <section> props forwarded to the root element. |
Keyboard & accessibility
| Key | Action |
|---|---|
Tab | Moves through the loss chart, Copy endpoint (when deployed), and footer action buttons. |
ArrowLeft / ArrowRight | On the focused chart, steps backward or forward across loss samples and updates the legend. |
Shift+ArrowLeft / Right | Jumps ten samples along the loss curve. |
Home / End | Jumps inspection to the first or latest loss sample. |
Escape | Clears the inspected step and returns the legend to live values. |
Enter / Space | Activates focused footer buttons (Cancel requires a second press on Confirm cancel). |
- The chart exposes
role="group"with a dynamicaria-labelcarrying current step, train loss, and validation loss; numeric step axis staysdir="ltr"while surrounding card chrome mirrors cleanly in RTL. - A pre-mounted polite
role="status"live region announces status transitions, errors, confirm-cancel prompts, and hostnoticestrings without spamming every training step. - Container queries adapt the card below
440px: padding drops to16px, the legend shortens Validation to Val, live and completed stats wrap to two columns, and the footer stacks context above actions.
Motion & theming
Curve paths and epoch fill bars write directly to the DOM on an exponential smoothing clock (120ms time constant) so bursty updates glide smoothly without React re-renders, while checkpoint rollbacks jump immediately. New event rows slide down on the snappy spring (0.26s), and status badges, stats grids, and footer lines crossfade inside single-cell grid slots so the card height never jumps.
Under prefers-reduced-motion: reduce, the curve jumps straight to each sample, the event slide travel drops, the spinner and waiting shimmer stop, and swaps stay as 120ms opacity crossfades. Setting motion="none" makes every swap immediate (0ms) and stops the spinner.
theme accepts mode, accent, and typed tokens across these groups:
| Token group | CSS custom properties |
|---|---|
core | --ui-surface, --ui-surface-raised, --ui-text, --ui-text-secondary, --ui-muted, --ui-border, --ui-highlight, --ui-accent, --ui-accent-foreground, --ui-danger, --ui-focus-ring, --ui-radius, --ui-border-width, --ui-font, --ui-font-size, --ui-font-weight |
extended | --ui-surface-sunken, --ui-border-strong, --ui-border-subtle, --ui-track, --ui-info, --ui-success, --ui-warning, --ui-tone-foreground, --ui-overlay, --ui-tint-strength |
shape | --ui-radius-sm, --ui-popup-radius, --ui-surface-radius |
accentTones | --ui-accent-strong, --ui-accent-subtle |
type | --ui-font-mono, --ui-font-display |
include | --ui-series-1 (train loss), --ui-series-2 (validation loss) |
component | --ui-training-run-plot-height (156px default plot height) |
An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, TrainingRun is a leaf block. Configure status, job metadata (name, modelName, modelBrand, details, dataset), totalSteps, epochs, loss, events, and registered lifecycle actions. See Building with agents.
{
"type": "TrainingRun",
"props": {
"status": "running",
"name": "support-classifier-v4",
"modelName": "Qwen3.8 Max",
"modelBrand": "qwen",
"details": ["LoRA r16", "8× H200"],
"totalSteps": 1200,
"epochs": 3,
"pauseAction": "pause_training_run",
"cancelAction": "cancel_training_run",
"deployAction": "deploy_trained_model"
},
"children": []
}