Skip to content

fix(tui): smooth noisy chart curves (EMA) + scale to the live run - #122

Merged
vxfemboy merged 3 commits into
mainfrom
fix-tui-chart-scale
Jul 30, 2026
Merged

fix(tui): smooth noisy chart curves (EMA) + scale to the live run#122
vxfemboy merged 3 commits into
mainfrom
fix-tui-chart-scale

Conversation

@vxfemboy

@vxfemboy vxfemboy commented Jul 30, 2026

Copy link
Copy Markdown
Member

Bug

TUI loss/val_loss charts render as scattered confetti (or invisible), not a readable line — worse with a --compare baseline.

Root cause (reproduced from the user's real run over SSH)

Two issues, in priority order:

  1. Noise (primary). Per-step training loss is genuinely noisy — it oscillates across its full range every step (1.44, 0.65, 1.12, 0.86, 0.71…). The chart plotted every raw point via a spike-preserving min/max band, so the noise filled the whole panel as confetti.
  2. Scale (secondary). The y-axis was the union of the live curve and the baseline; a wide-range baseline (prior loss 0.001–5.5 vs live 0.6–2.0) crushed the live curve.

Fix

  • Smooth the displayed curve with an EMA trend line (adaptive span ≈ 8% of visible points, clamped 3–64), like wandb/tensorboard. Baseline smoothed the same way for a like-for-like overlay. (ema_smooth, adaptive_ema_span + tests.)
  • Scale to the live curve, drawing the baseline only where it overlaps (off-scale hidden, title notes it). (chart_yscale + tests.)

Verified locally against the actual run data: raw = confetti (matches the report), EMA = clean descending line. Full rust gate green (fmt, clippy, tests, ≥90% coverage).

vxfemboy added 2 commits July 30, 2026 00:17
The chart set its y-axis to the union of the live curve and the
--compare baseline. A baseline with a much larger range (e.g. prior-run
loss 0.001..5.5 vs a current run at 0.6..2.0) crushed the live curve into
a thin band and filled the panel with the baseline's noise — the live
line looked broken/scattered, and sparse series (val_loss, 4 pts) became
invisible.

Now the y-axis scales to the live curve's own range; the baseline is
drawn only where it overlaps that range (off-scale points hidden, not
clamped to the border), and the title says 'baseline off-scale' when the
whole baseline is out of range. Adds chart_yscale + unit tests using the
real-world value shapes.
The real cause of the 'broken' chart: per-step training loss is very
noisy (oscillates across its full range every step), and the chart
plotted every raw point via a spike-preserving min/max band, so it
rendered as confetti filling the panel. Verified against the user's
actual run (loss bounces 0.6..2.0 step-to-step).

Now the displayed curve is an EMA trend line (adaptive span ~8% of the
visible points, clamped 3..64) — like wandb/tensorboard. Baseline is
smoothed the same way for a like-for-like overlay. Adds ema_smooth +
adaptive_ema_span with tests.

Combined with the prior commit (scale to the live curve, hide off-scale
baseline), the loss/val_loss charts render as clean lines again.
@vxfemboy vxfemboy changed the title fix(tui): scale chart to the live curve, not the baseline union fix(tui): smooth noisy chart curves (EMA) + scale to the live run Jul 30, 2026
The real cause of the 'confetti' chart: the renderer placed each column's
point independently (min/max per step-column + flat carry-forward) and
never joined consecutive points. At low panel heights adjacent points
land close so it looked connected; at tall heights the step-to-step
wiggle spreads points across many rows -> disconnected dots = confetti.
Reproduced from the user's real run rendered at 150x40 (live curve alone
was already confetti, so it was neither the baseline nor the y-scale).

Now render_braille_steps_scaled interpolates a value at each dot column
and bridges it to the previous column's row, drawing a continuous line
(interp_at helper). Verified against the real data at 150x40: a connected
descending curve instead of scatter. Smoothing (EMA) still applies on top.
@vxfemboy
vxfemboy merged commit 40a046d into main Jul 30, 2026
@vxfemboy
vxfemboy deleted the fix-tui-chart-scale branch July 30, 2026 19:06
@vxfemboy
vxfemboy restored the fix-tui-chart-scale branch July 30, 2026 19:43
vxfemboy added a commit that referenced this pull request Jul 30, 2026
Curriculum runs cycle through phases with different loss scales, so one
shared y-axis makes a healthy run look like it diverges at each phase
transition. Now the chart splits the x-axis at checkpoint steps (which
mark phase boundaries) and scales each segment to its OWN range, drawn as
connected sub-curves with a labeled title (labels from the checkpoint
path, e.g. 'reasoning | knowledge | current').

- chart::render_braille_segments + Segment (per-segment scale, breaks the
  line at boundaries for a visual divider).
- ui: Checkpoint{step,label} (was bare step) + checkpoint_label() +
  build_segments(); render_chart segments when checkpoints split the
  window, else the single-scale path. Baseline overlay omitted in
  segmented mode (can't share per-segment scales).

Verified against the real kitby-v2 run at 150x40: reasoning|knowledge|
current segments each render as their own readable curve. Builds on the
connected-line renderer (#122) and the events.jsonl tailer.
@vxfemboy
vxfemboy deleted the fix-tui-chart-scale branch July 30, 2026 22:31
vxfemboy added a commit that referenced this pull request Aug 1, 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