wandb/wandb

The AI developer platform. Use Weights & Biases to train and fine-tune models, and manage models from experimentation to production.

11,013 stars Python 10 components

13 hidden assumptions · 6-stage pipeline · 10 components

Like any codebase, this ml training makes assumptions it never checks — most are routine. The ones worth your attention are below.

Records, visualizes, and manages ML experiments with cloud sync and hyperparameter tracking

When users call wandb.init(), the Python SDK spawns a Go core daemon and establishes IPC communication. As training progresses, wandb.log() calls create History objects that get serialized to protobuf RunRecord messages and sent to the core service. The core service batches these records, writes them to local files, and asynchronously syncs to the W&B backend via HTTP APIs with retries. Artifacts follow a similar path but involve file uploads with checksum verification and deduplication.

Under the hood, the system uses 4 feedback loops, 4 data pools, 5 control points to manage its runtime behavior.

A 10-component ml training. 1489 files analyzed. Data flows through 6 distinct pipeline stages.

Hidden Assumptions

Most of what this code assumes is routine. These 3 are the ones most likely to cause trouble here. The rest are minor; they're under "Show everything".

Worth your attention first

If the PID belongs to a different process or the process has already exited, the core service may shut down unexpectedly or fail to detect when it should terminate

Worth your attention first

With default parameters, creating 100 workers each with 1000 history elements could consume gigabytes of memory and cause OOM kills without warning

Worth your attention first

The program will panic or fail silently if the wandb-core binary is missing, has wrong permissions, or is in a different location than expected

Show everything (10 more)
Resource

The embedded coreBinary data represents a valid executable for the current platform and architecture

If this fails: If the embedded binary was built for a different OS/architecture or is corrupted, the session will fail to start with cryptic exec errors

experimental/go-sdk/cmd/examples/embed/main.go
Scale

The rate limiting constants (minRequestsPerSecond=0.1, maxRequestsPerSecond=65536, maxBurst=10) are appropriate for all W&B backend deployments

If this fails: Self-hosted W&B instances with different capacity limits could be overwhelmed by the default 65K requests/second limit, or starved by the 0.1 minimum rate

core/internal/api/api.go
Temporal

A 10-minute idle timeout (defaultDetachedIdleTimeout) is sufficient for all detached mode use cases

If this fails: Long-running ML experiments with sparse logging intervals could have their core service shut down mid-training, causing data loss

core/cmd/wandb-core/main.go
Environment

Environment variables WANDB_TAGS, WANDB_NOTES, etc. are properly formatted and don't contain characters that could break the parsing logic

If this fails: Malformed environment variables could cause silent config corruption or unexpected behavior in the W&B session initialization

experimental/go-sdk/cmd/examples/exec/main.go:main
Contract

The wandb_init function always returns 0 on success and that wandb_finish can be called without checking the run state

If this fails: If wandb_init fails but returns a non-zero code other than what's expected, the assert will crash the program instead of gracefully handling the error

experimental/go-sdk/bindings/c/examples/train.c:main
Ordering

Environment variables must be set before wandb.Setup() is called, and defer statements execute in the correct order

If this fails: If Setup() is called before environment variables are set, the configuration will use defaults instead of intended values; incorrect defer ordering could cause resource leaks

experimental/go-sdk/cmd/examples/exec/main.go:main
Scale

Creating history entries with string keys like 'loss_0', 'loss_1', etc. won't exceed internal limits on key name length or count

If this fails: With numHistoryElements set to very large values, the system could hit undocumented limits on metric name lengths or total number of metrics per run

experimental/go-sdk/cmd/benchmark/main.go:Worker
Environment

The current working directory is writable for creating the port file specified by --port-filename

If this fails: If the directory is read-only or doesn't exist, the service will fail to start but may not provide a clear error message about file permissions

core/cmd/wandb-core/main.go:serviceMain
Contract

The wandb.Init() call in Worker() will always succeed or panic, and that concurrent calls to wandb.Init() are safe

If this fails: If Init() returns an error instead of panicking, workers will continue without proper W&B initialization; concurrent Init() calls could cause race conditions

experimental/go-sdk/cmd/benchmark/main.go:RunWorkers
Resource

The system has enough temporary disk space to extract and execute the embedded binary

If this fails: On systems with full /tmp directories or restricted temp space, the embedded binary extraction could fail silently or with confusing errors

experimental/go-sdk/cmd/examples/embed/main.go

Open the standalone hidden-assumptions report for wandb →

How Data Flows Through the System

When users call wandb.init(), the Python SDK spawns a Go core daemon and establishes IPC communication. As training progresses, wandb.log() calls create History objects that get serialized to protobuf RunRecord messages and sent to the core service. The core service batches these records, writes them to local files, and asynchronously syncs to the W&B backend via HTTP APIs with retries. Artifacts follow a similar path but involve file uploads with checksum verification and deduplication.

  1. Initialize run context — wandb.init() creates a Run object, starts the core daemon process if needed, and establishes gRPC communication channel [Settings → Run]
  2. Capture metrics — wandb.log() calls convert Python dicts to History objects with type validation and step tracking [Python dict → History]
  3. Serialize to protobuf — InterfaceQueue converts History and Config objects into RunRecord protobuf messages for cross-process communication [History → RunRecord]
  4. Process in core service — CoreService receives protobuf messages, validates them, and writes to local JSON lines files while queuing for backend sync [RunRecord → Local file storage]
  5. Sync to backend — RetryableClient sends HTTP requests to W&B API with exponential backoff, handling rate limits and transient failures [Local file storage → Backend API calls]
  6. Upload artifacts — FileSync handles multipart uploads of model files and datasets with checksum verification and progress tracking [Artifact → Cloud storage URLs]

Data Models

The data structures that flow between stages — the contracts that hold the system together.

Run wandb/sdk/wandb_run.py
Object with id: str, project: str, config: dict, summary: dict, history: list[dict], tags: list[str], notes: str, plus methods for log(), save(), finish()
Created by wandb.init(), accumulates metrics via log(), persisted locally and synced to cloud on finish()
History wandb/sdk/wandb_history.py
Dict-like object mapping metric names to numeric values, with optional _step key for x-axis ordering
Built incrementally via wandb.log() calls, serialized to protobuf messages, stored as JSON lines files locally
Config wandb/sdk/wandb_config.py
Dict-like object storing hyperparameters and experiment settings, supports nested structures and type preservation
Set during wandb.init() or via config updates, immutable once run starts, persisted to backend for experiment comparison
Artifact wandb/sdk/artifacts/artifact.py
Container with name: str, type: str, description: str, metadata: dict, plus files/directories and version tracking
Created via wandb.Artifact(), populated with add_file()/add_dir(), logged to run, versioned and stored in cloud
Settings wandb/sdk/wandb_settings.py
Configuration object with api_key: str, base_url: str, project: str, mode: str, plus environment-specific overrides
Constructed from env vars, config files, and explicit parameters during wandb.init(), passed to core service
RunRecord wandb/proto/wandb_internal.proto
Protobuf message containing run metadata, history entries, config updates, and file operations for core service communication
Generated by Python SDK operations, serialized over internal interface to core service, processed and synced to backend

System Behavior

How the system operates at runtime — where data accumulates, what loops, what waits, and what controls what.

Data Pools

Local run directory (file-store)
Stores run metadata, config, logs, and media files in local filesystem before cloud sync
Backend run database (database)
Cloud storage for all run data, accessible via web dashboard and API
Artifact registry (registry)
Version-controlled storage for model files, datasets, and other artifacts with deduplication
Message queue (queue)
IPC buffer between Python SDK and core service for asynchronous message delivery

Feedback Loops

Delays

Control Points

Technology Stack

Protocol Buffers (serialization)
Defines IPC schema between Python SDK and Go core service
gRPC (framework)
Inter-process communication transport layer
GraphQL (framework)
Backend API query language with type-safe client generation
Pydantic (library)
Python data validation and serialization for configuration management
Click (library)
Python CLI framework for wandb command-line interface
Go (runtime)
High-performance core service for data persistence and network I/O
Rust (runtime)
Efficient parquet file processing with C FFI bindings
Sentry (infra)
Error tracking and performance monitoring for SDK telemetry

Key Components

Package Structure

wandb (app)
Main Python SDK that users import to track experiments, log metrics, save artifacts, and sync data to W&B cloud
core (app)
High-performance Go daemon that handles data serialization, network sync, and backend communication
experimental-go-sdk (library)
Go SDK for experiment tracking with bindings to the core service
experimental-rust-sdk (library)
Rust SDK for experiment tracking
parquet-rust-wrapper (library)
Rust library for efficient parquet file reading with C FFI bindings

Explore the interactive analysis

See the full architecture map, data flow, and code patterns visualization.

Analyze on CodeSea

Related Ml Training Repositories

Frequently Asked Questions

What is wandb used for?

Records, visualizes, and manages ML experiments with cloud sync and hyperparameter tracking wandb/wandb is a 10-component ml training written in Python. Data flows through 6 distinct pipeline stages. The codebase contains 1489 files.

How is wandb architected?

wandb is organized into 4 architecture layers: Client SDKs, Core Service, Protocol Layer, Storage & Sync. Data flows through 6 distinct pipeline stages. This layered structure keeps concerns separated and modules independent.

How does data flow through wandb?

Data moves through 6 stages: Initialize run context → Capture metrics → Serialize to protobuf → Process in core service → Sync to backend → .... When users call wandb.init(), the Python SDK spawns a Go core daemon and establishes IPC communication. As training progresses, wandb.log() calls create History objects that get serialized to protobuf RunRecord messages and sent to the core service. The core service batches these records, writes them to local files, and asynchronously syncs to the W&B backend via HTTP APIs with retries. Artifacts follow a similar path but involve file uploads with checksum verification and deduplication. This pipeline design reflects a complex multi-stage processing system.

What technologies does wandb use?

The core stack includes Protocol Buffers (Defines IPC schema between Python SDK and Go core service), gRPC (Inter-process communication transport layer), GraphQL (Backend API query language with type-safe client generation), Pydantic (Python data validation and serialization for configuration management), Click (Python CLI framework for wandb command-line interface), Go (High-performance core service for data persistence and network I/O), and 2 more. A focused set of dependencies that keeps the build manageable.

What system dynamics does wandb have?

wandb exhibits 4 data pools (Local run directory, Backend run database), 4 feedback loops, 5 control points, 4 delays. The feedback loops handle retry and training-loop. These runtime behaviors shape how the system responds to load, failures, and configuration changes.

What design patterns does wandb use?

6 design patterns detected: Multi-process architecture, Protocol buffer communication, Async with eventual consistency, Plugin architecture, Retry with exponential backoff, and 1 more.

Analyzed on April 20, 2026 by CodeSea. Written by .