Skip to content

DiLoCo: token-budget progress bar + rolling-rate ETA (webui + CLI) - #234

Merged
jdinalt merged 2 commits into
devfrom
feature/diloco-token-budget-progress
Jun 14, 2026
Merged

jdinalt merged 2 commits into
devfrom
feature/diloco-token-budget-progress

Conversation

@jdinalt

@jdinalt jdinalt commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

Better at-a-glance diagnostics for token-budgeted DiLoCo runs. The motivating
incident: a run was taking far longer than it should and nothing surfaced it —
a live progress/ETA would have caught it early.

  • Server (server.py): each heartbeat that advances the aggregate appends a
    (monotonic, total_tokens) sample to an in-memory ring (only when a budget is
    set). _token_progress() reports tokens_completed, token_budget, clamped
    fraction, a rolling tokens_per_second over a recent window, and
    eta_seconds. Exposed in /status as token_progress (a live gauge — not
    persisted, resets on restart). The window is ~5 min on purpose: heartbeats
    are ~30 s apart, so a short window would see one or two samples and jitter; a
    wide window stays stable while still reflecting a sustained slowdown within a
    few minutes (rolling-recent-rate basis, so a slowdown shows as a falling rate /
    rising ETA).
  • CLI (forgather diloco status): a TQDM-ish ASCII line under the budget
    field —
      Token budget:  [##########--------------]  41.0%
                     820.00M / 2.00B  ·  1.20M/s  ·  ETA 16m23s
    
  • webui (DiLoCo server view): a fill bar under the dashboard header with
    completed/total + rate + ETA to the right. Always offered when a budget is set
    (an older server without token_progress falls back to the plain count).

Tests

TestTokenProgress in test_token_budget.py: no-budget no-op, fields/fraction,
clamp-at-1, rolling rate + ETA math, recent-window baseline selection. Full
tests/unit/ml/diloco/ + tests/unit/cli/ green (864). black/isort clean,
webui tsc --noEmit clean.

Docs

docs/trainers/diloco-cli.md (status progress line), diloco-architecture.md
(the sampling/rate gauge).

🤖 Generated with Claude Code

jdinalt and others added 2 commits June 14, 2026 21:35
Surface how far an open-ended (token-budgeted) run has got and roughly how long
is left, so a run that's silently going much slower than it should is obvious at
a glance instead of only after the fact.

Server: each heartbeat that advances the aggregate appends a (monotonic,
total_tokens) sample to an in-memory ring (only when a budget is set).
_token_progress() reports completed/budget, a clamped fraction, a rolling
tokens/sec over a recent window (~5 min — wide because heartbeats are ~30s
apart, so a short window would see one or two samples and jitter), and an ETA.
Exposed in /status as token_progress (a live gauge, not persisted).

CLI (forgather diloco status): a TQDM-ish ASCII line under the existing budget
field — bar + percent, then completed/total, rate, and ETA.

webui (DiLoCo server view): a fill bar under the dashboard header when a budget
is set, with completed/total + rate + ETA to the right. Always offered now;
falls back to the plain budget count against a server without token_progress.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- _rolling_token_rate: after a long stall the only in-window sample could be the
  tail itself (baseline collapses onto now -> dt=0 -> None), blanking the
  rate/ETA exactly during the slowdown it exists to surface. Fall back to the
  previous sample so a stall reads as ~0 tok/s. (+ regression test)
- Show 0/s for a genuine stall (rate is not None) instead of '—/s' (which reads
  as 'unknown') in both the CLI and the webui bar.
- Reword the _record_token_sample thread-safety note: heartbeats race across
  workers here (not serial-per-worker); the dt<=0 / dtok<0 guards absorb any
  cross-worker append jitter.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jdinalt
jdinalt merged commit b6b44aa into dev Jun 14, 2026
1 check passed
@jdinalt
jdinalt deleted the feature/diloco-token-budget-progress branch June 14, 2026 21:39
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