Metadata-Version: 2.5
Name: loglog-ml
Version: 0.1.1
Summary: Lightweight, local-first W&B drop-in & TensorBoard alternative for deep learning and LLM research.
Project-URL: Homepage, https://github.com/errantdata/loglog
Project-URL: Repository, https://github.com/errantdata/loglog
Project-URL: Issues, https://github.com/errantdata/loglog/issues
Author-email: "Sean A. Cantrell, PhD" <sean.a.cantrell@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Sean A. Cantrell, PhD
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: deep-learning,experiment-tracking,machine-learning,scaling-laws,tensorboard,wandb
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: fastapi>=0.115.0
Requires-Dist: uvicorn[standard]>=0.30.0
Provides-Extra: all
Requires-Dist: httpx>=0.27.0; extra == 'all'
Requires-Dist: nvidia-ml-py>=12.0.0; extra == 'all'
Requires-Dist: psutil>=5.9.0; extra == 'all'
Requires-Dist: pyarrow>=15.0.0; extra == 'all'
Requires-Dist: pytest>=8.0.0; extra == 'all'
Requires-Dist: ruff>=0.6.0; extra == 'all'
Provides-Extra: dev
Requires-Dist: httpx>=0.27.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.6.0; extra == 'dev'
Provides-Extra: parquet
Requires-Dist: pyarrow>=15.0.0; extra == 'parquet'
Provides-Extra: telemetry
Requires-Dist: nvidia-ml-py>=12.0.0; extra == 'telemetry'
Requires-Dist: psutil>=5.9.0; extra == 'telemetry'
Description-Content-Type: text/markdown

# LogLog

[![PyPI version](https://img.shields.io/pypi/v/loglog-ml.svg)](https://pypi.org/project/loglog-ml/)
[![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)

**Lightweight, local-first Weights & Biases drop-in and TensorBoard alternative built for deep learning and LLM scaling research.**

Zero API keys. Zero accounts. Zero Docker, Postgres, or TensorFlow dependencies. LogLog writes plain, `rsync`-able files on disk with **<10 µs** logging overhead, ingests existing TensorBoard `tfevents` side-by-side without conversion, and serves a fast interactive `uPlot` dashboard built for log-log scaling laws, matched-X `Δ` comparisons, and single-file offline `.html` reports.

![LogLog live scaling dashboard showing side-by-side TensorBoard and LogLog runs, KPI cards, synced crosshairs, and matched-X delta curves](docs/screenshots/dashboard-live.png)

*Live dashboard comparing a streaming TensorBoard run (`tb · live`) alongside native LogLog runs (`ll`) on log-log token axes, with pinned `Δ` baseline (`1b-adamw`), exact synced crosshairs across all panels, and an interpolated Matched-X Eval Loss Delta chart.*

---

## Why LogLog?

| Capability | LogLog | Weights & Biases | TensorBoard |
| :--- | :--- | :--- | :--- |
| **Setup & Auth** | `pip install loglog-ml` — zero keys, zero accounts | Cloud account / API key (or heavy self-hosted stack) | Local, pulls TensorFlow/protobuf stack |
| **Logging Hot Path** | **<10 µs** median (non-blocking background writer) | Local agent + network sync daemon | Synchronous TFRecord event writer |
| **Log-Log Scaling & Matched-X `Δ`** | 1-click `X: Log` / `Y: Log`, Tokens X-axis, interpolated `run − baseline` | Manual custom charts / limited baseline diffs | Linear/log Y only; no matched-X delta |
| **TensorBoard `tfevents`** | Built-in pure-Python incremental reader (zero TF deps), side-by-side with LogLog runs | Requires sync/import step | Native |
| **Storage & Portability** | Plain JSONL / Parquet + SHA-256 blobs + regenerable SQLite cache (`rsync`-friendly) | Cloud database / opaque sync files | Binary `tfevents` protobuf files |
| **Code & Config Diffs** | Auto `git` commit, dirty `code.patch`, `env.txt`, diff-only hyperparameter table | Cloud UI | Not built-in |
| **Shareable Reports** | Single self-contained offline `.html` file + local `/r/<hash>` permalink | Hosted cloud link | Static image export only |

---

## Installation

```bash
pip install loglog-ml
```

> **Package vs. Import Name:** Install **`loglog-ml`** from PyPI; the Python import (`import loglog`) and CLI command (`loglog`) are **`loglog`**.

Optional extras:

```bash
# Background GPU/CPU telemetry (NVML + psutil)
pip install "loglog-ml[telemetry]"

# Optional Parquet compaction on run.finish() (pyarrow; enable via LOGLOG_PARQUET=1)
pip install "loglog-ml[parquet]"

# Both
pip install "loglog-ml[telemetry,parquet]"
```

Or install directly from GitHub:

```bash
pip install "loglog-ml @ git+https://github.com/errantdata/loglog.git"
```

---

## Quickstart

### Option 1 — One-Line Drop-In Replacement (`import loglog as wandb`)

Swap your import and keep your existing W&B training loop:

```python
import loglog as wandb

run = wandb.init(
    project="scale-1b",
    name="1b-muon-qk",
    config={"optimizer": "muon", "lr": 1.5e-3, "qk_norm": True, "d_model": 2048},
)
run.define_metric("eval/*", step_metric="progress/tokens_billions")

for step in range(1, 401):
    wandb.log(
        {
            "progress/tokens_billions": step * 0.025,
            "train/step_loss": train_loss,
            "eval/loss": eval_loss,
            "eval/accuracy": eval_acc,
            "train/lr": lr,
        },
        step=step,
    )

run.finish()
```

### Option 2 — Zero Code Changes (`--shim-wandb`)

Run existing PyTorch, Hugging Face `Trainer`, Accelerate, or Lightning scripts verbatim without modifying a single line or setting `WANDB_API_KEY`:

```bash
loglog run --shim-wandb --project scale-1b -- python train.py
```

`loglog run --shim-wandb` injects a temporary `wandb` shim onto `PYTHONPATH` so every `import wandb` routes transparently to LogLog.

### Option 3 — Launch the Dashboard (LogLog + TensorBoard Side-by-Side)

Point `loglog serve` at one or more `.loglog/` directories, TensorBoard `tfevents` directories, or both together:

```bash
# Serve local ./.loglog automatically
loglog serve --open

# Combine native LogLog runs and existing TensorBoard logs side-by-side
loglog serve ./.loglog ./tb_logs --port 6060 --open
```

---

## Interactive Dashboard

### Scaling Curves, Synced Crosshairs & Customizable Layout

- **Resizable & Foldable Sidebar:** Drag the sidebar edge (`228–560 px`), double-click the divider to reset, snap-collapse to a compact icon rail, or fold individual sections (**Chart Defaults**, **Runs**, **Quick Add Metric**, **Layout Views**). State persists automatically in `localStorage`.
- **Customizable Run KPI Strip:** Displays a single-row ribbon for one run or top-accented comparison cards for multiple runs, complete with completion progress bars, live `tb · live` streaming badges, inline color pickers, double-click run renaming, **`★ Pin Δ`** baseline selection, and a **Customize KPIs** editor.
- **Exact Synced Crosshairs & Interactive Legends:** Every chart displays a top-docked legend with solid/dashed line swatches and a toggleable **`Stats`** table (Latest, Min, Max, Points). Hover a legend pill to isolate a curve, click to toggle visibility, or Shift+Click / double-click to solo. Moving the cursor over any plot draws a synchronized vertical hairline and exact pixel-segment intersection dots across *all* charts at the matching X value.
- **Clean Per-Panel Popover Controls:** Each card exposes compact **`Axes`**, **`Smooth`**, **`Export`** (PNG + publication-ready vector SVG), and **`Panel`** (Edit, Full / ½ / ⅓ width, Reorder, Duplicate, Remove) popovers.
- **Saved Views & Themes:** Save dashboard layouts to the local SQLite store, export/import views as JSON, and switch between **Dark**, **Light**, and **Paper** themes.

### Custom Panels, Per-Panel Axes & Derived Math Expressions

Click **+ Add Chart Panel** (or any metric in **Quick Add Metric**) to build custom visualizations with independent controls per panel:

![Add Chart Panel modal with explicit Y-axis, X-axis, math formula, and per-panel smoothing controls](docs/screenshots/panel-editor.png)

- **Three Panel Modes:**
  1. **Scalar Line:** Plot one or more Y metrics on the same panel with distinct dash styles.
  2. **Matched-X `Δ` (`run − baseline`):** Linearly interpolates each run against your pinned baseline at matched X values (tokens, step, wall hours, or any scalar metric) with a `y = 0` reference line.
  3. **Math Formula:** Plot live derived expressions such as `exp(eval/loss)`, `eval/loss - train/step_loss`, `log10(train/grad_norm)`, or `eval/accuracy / 100`.
- **Independent Y & X Axes:** Override any panel's Y scale (`Global`, `Linear`, `Log-10`), Y unit format (`nats`, `pct`, `kps`, `delta`, `auto`), explicit Y min/max bounds, X-axis source (`Step`, `Tokens`, `Wall Hours`, or any specific scalar metric), and independent EMA smoothing + raw ghost overlay.

### Diff-Only Hyperparameter Comparison

Switch to **Config Diff** to compare hyperparameters across selected runs. **Diff Only: ON** automatically hides identical parameters and highlights only what changed:

![Hyperparameter Comparison table filtering identical keys and highlighting differences](docs/screenshots/config-diff.png)

### Code Diffs, 2-Tier Artifacts, Tables & Environment

Switch to **Code & Artifacts** (or click **Inspect** on any run card) to verify exact reproducibility without leaving the dashboard:

![Code and Artifacts Inspector showing syntax-highlighted git patch diff, artifacts, tables, and environment](docs/screenshots/code-artifacts.png)

- **Automatic Code & Env Capture:** Every LogLog run automatically records its `git` commit, branch, remote, dirty working-tree `code.patch`, host/GPU metadata, and `env.txt` package freeze. View a single run's patch or diff two runs against each other.
- **2-Tier Artifacts (No Weight Bloat):** Small files and directories (`≤ 50 MiB` by default, configurable via `LOGLOG_BLOB_MAX_MB`) are content-addressed and deduplicated into `.loglog/blobs/sha256/`. Large checkpoints and datasets are stored as lightweight immutable manifests (paths, sizes, hashes, metadata) or `file://` references so multi-GB weights are never copied.
- **Tables & Media:** Inspect logged `wandb.Table`, `wandb.plot.bar` / `line` / `scatter`, `wandb.Histogram`, `wandb.Image`, and `wandb.Html` payloads directly in the browser.

---

## Frozen Shareable Snapshot Reports

Freeze any experiment comparison into an immutable snapshot — either from the **Frozen Reports** tab in the UI or via `loglog freeze` on the CLI:

![Frozen offline LogLog report in Light theme with Markdown narrative, KPI cards, and interactive uPlot chart](docs/screenshots/frozen-report.png)

Each frozen report produces:
1. A **single self-contained offline `.html` file** containing the interactive `uPlot` viewer, Markdown narrative, KPI cards, config diff table, and frozen metric data. Open it directly from disk, attach it to a GitHub PR, email it, or drop it in Slack — no server or internet connection required, while keeping full interactive pan/zoom, smoothing, log/linear toggles, theme switching, and SVG export.
2. A content-hashed **local permalink** (`/r/<hash>`) served automatically by `loglog serve`.

```bash
loglog freeze ./.loglog ./tb_logs \
  --title "1.2B Optimizer & Attention Scaling Study (10B Tokens)" \
  --description "Muon + QK-Norm vs Sliding-Window Attention (tfevents) vs AdamW" \
  --markdown-file notes/scaling_summary.md \
  --baseline scale-1b/adamw001 \
  --x-mode tokens \
  --max-step 400 \
  -o reports/scale-1b-report.html
```

---

## W&B Drop-In SDK Reference

### Supported APIs

| Feature | API | Behavior in LogLog |
| :--- | :--- | :--- |
| **Lifecycle** | `init()`, `finish()`, `run`, `with loglog.init(...) as run:` | Local run creation, `atexit` + `SIGINT`/`SIGTERM` flush, resume (`must`/`allow`/`never`) |
| **Disabled / Rank>0 Stub** | `mode="disabled"` or `WANDB_DISABLED=1` | Returns zero-overhead `DisabledRun` no-op stub |
| **Auth** | `login(...)` | Silent no-op returning `True` (no API key needed) |
| **Scalars & Media** | `log(data, step=..., commit=...)`, `define_metric(...)` | `<10 µs` bounded async queue; handles Python/NumPy/PyTorch/JAX scalars & nested dicts |
| **Config & Summary** | `config`, `summary` (`run.config` & module proxies) | Dot/dict access, `.update()`, `allow_val_change`, atomic `config.json` & `summary.json` |
| **Alerts & Files** | `alert(title, text, level=AlertLevel.INFO)`, `save()`, `log_code()` | Persisted to `alerts.jsonl` (shown as chart markers) and `files/` |
| **2-Tier Artifacts** | `Artifact`, `run.log_artifact()`, `run.use_artifact()`, `artifact.download()` | SHA-256 deduplicated blobs (`≤ 50 MiB`) or lightweight manifests/references |
| **Tables & Plots** | `Table`, `Image`, `Html`, `Histogram`, `plot.{bar,line,scatter,histogram}` | Persisted under `media/` and rendered in the Inspector tab |
| **Programmatic Query** | `loglog.Api()` | Read-only local query client (`api.runs()`, `api.run()`, `scan_history()`, `history()`) |
| **Runtime Shim** | `loglog.shim_wandb()` | Registers `loglog` as `sys.modules["wandb"]` in-process |

### Querying Runs Programmatically (`loglog.Api`)

```python
import loglog

api = loglog.Api(root_dir="./.loglog")
for run in api.runs("scale-1b"):
    print(run.name, run.state, run.summary.get("eval/loss"))
    df = run.history(keys=["progress/tokens_billions", "eval/loss"], pandas=True)
    artifacts = run.logged_artifacts()
```

### Environment Variables

LogLog honors both `LOGLOG_*` and standard `WANDB_*` environment variables (`LOGLOG_*` takes precedence):

| Variable | Fallback | Purpose |
| :--- | :--- | :--- |
| `LOGLOG_DIR` | `WANDB_DIR` | Base directory for `.loglog/` (default: `./.loglog`) |
| `LOGLOG_PROJECT` | `WANDB_PROJECT` | Default project name |
| `LOGLOG_NAME` | `WANDB_NAME` | Run display name |
| `LOGLOG_RUN_GROUP` | `WANDB_RUN_GROUP` | Run group identifier |
| `LOGLOG_RUN_ID` | `WANDB_RUN_ID` | Explicit run ID (for resuming) |
| `LOGLOG_MODE` | `WANDB_MODE` / `WANDB_DISABLED` | `local` (default), `offline`, or `disabled` |
| `LOGLOG_TELEMETRY` | — | Set to `1` (or interval in seconds) to enable background GPU/CPU telemetry |
| `LOGLOG_SAVE_UNTRACKED` | — | Set to `1` to include untracked source files in `code.patch` |
| `LOGLOG_PARQUET` | — | Set to `1` to compact `metrics.jsonl` into `metrics.parquet` on `finish()` (requires `loglog-ml[parquet]`) |
| `LOGLOG_BLOB_MAX_MB` | — | Size threshold for 2-tier artifact blobs vs. manifests (default: `50`) |

---

## CLI Reference

```bash
# Start the local web dashboard (supports multiple .loglog and tfevents roots)
loglog serve [PATHS...] [--host 127.0.0.1] [-p 6060] [--state-dir DIR] [--open] [-q]

# Launch a training command with LogLog env vars and optional `import wandb` shim
loglog run [--shim-wandb] [--project P] [--name N] [--group G] [--dir D] [--telemetry] [--save-untracked] -- <COMMAND...>

# Freeze an immutable snapshot report + standalone offline .html file
loglog freeze [PATHS...] --title TITLE [--description TEXT] [--markdown TEXT | --markdown-file FILE] \
  [--runs KEYS] [--baseline KEY] [--max-step N] [--x-mode step|tokens|wall|metric] [--x-metric NAME] [-o OUT.html]

# List discovered LogLog and TensorBoard runs from the terminal
loglog ls [PATHS...] [--state-dir DIR] [--json]
```

---

## On-Disk Storage Layout

Every file inside `.loglog/` is plain, inspectable, and safe to `rsync` between GPU clusters and your laptop. Delete `index.sqlite` at any time — LogLog regenerates it cleanly on startup.

```text
.loglog/
├── index.sqlite                  # Regenerable SQLite cache (runs, metrics, saved views)
├── blobs/
│   └── sha256/                   # Content-addressed deduplicated small artifacts (≤ 50 MiB)
├── reports/
│   └── <hash>/
│       ├── report.json           # Immutable frozen report payload
│       └── report.html           # Self-contained offline interactive HTML report
└── <project>/
    └── <run_id>/
        ├── meta.json             # Run metadata, git commit/branch, host & GPU info
        ├── config.json           # Hyperparameters (atomic JSON)
        ├── summary.json          # Latest & min/max metric summary
        ├── metrics.jsonl         # Append-only scalar log (live-tailed while running)
        ├── metrics.parquet       # Optional compacted Parquet (with `loglog-ml[parquet]`)
        ├── alerts.jsonl          # Logged alert markers
        ├── artifacts.json        # 2-tier artifact & checkpoint manifests
        ├── code.patch            # Dirty git diff captured at run start
        ├── env.txt               # Python package freeze
        └── media/                # Tables, custom charts, images, histograms, HTML
```

---

## Development

```bash
git clone https://github.com/errantdata/loglog.git
cd loglog

# Create virtualenv and install editable package with dev tools
uv venv && source .venv/bin/activate
uv pip install -e ".[dev,parquet]"

# Run tests and linter
pytest -v
ruff check src tests
```

To rebuild the frontend bundle (Preact + Vite + uPlot + single-file report template):

```bash
cd web
npm install
npm run build   # Outputs compiled SPA + report_template.html into src/loglog/server/static/
```

---

## Explicit Non-Goals

LogLog stays intentionally fast, small, and dependency-light by **not** attempting to be:

- A hosted SaaS platform or multi-tenant cloud service with RBAC/SSO.
- A distributed hyperparameter sweep orchestrator or GPU cluster job scheduler.
- A binary checkpoint weight storage server (checkpoints are indexed by manifest/reference, never duplicated).

---

## License

MIT — see [LICENSE](LICENSE).
