Skip to content

Browser and WASM

Mike Wright edited this page Aug 1, 2026 · 1 revision

Browser and WASM

The browser playground is MLPL's best introduction: the interpreter, tutorials, demos, glossary, documentation, and visualization UI run locally via WebAssembly.

Open the hosted playground.

What works well

  • Core syntax, array operations, model construction, autograd, optimizers, and short training loops.
  • Built-in datasets and corpora via load_preloaded.
  • Tokenizers, experiment logic in memory, semantic tags, introspection, and feasibility calculations.
  • Worked demos and structured learning paths.
  • Inline SVG/HTML/3-D visualization and interactive educational UI.
  • A connected mode that uses the same browser client while evaluation occurs on mlpl-serve.

Browser-only execution flow

sequenceDiagram
    participant U as User
    participant UI as Web REPL
    participant W as WASM evaluator
    participant V as Browser renderer
    U->>UI: Enter program or select demo
    UI->>W: Evaluate in browser memory
    W-->>UI: Value, trace, or visualization
    UI->>V: Render transcript and artifact
    V-->>U: Interactive result
Loading

Limits of the sandbox

  • No arbitrary local filesystem reads. Use preloaded data or a native/connected evaluator.
  • No host process spawning.
  • No direct MLX, Metal, CUDA, or native library linkage from WASM.
  • Long single-threaded work can make a tab appear unresponsive; tutorial demos are deliberately small.
  • Direct calls to localhost services are blocked or intentionally avoided because of browser security and CORS.
  • Disk trace export and persistent experiment storage require a native server.

Connected browser mode

A connected browser keeps the web interface but moves evaluation to a native server. The web evaluator validates the connection, probes /v1/devices, streams training events over SSE, retrieves stored visualizations, and gates GPU demos according to the peer's reported devices.

Use connected mode when you want browser ergonomics plus native files, persistent sessions, CPU throughput, MLX, or CUDA. See Server and Remote Execution.

Source references: web architecture, worker-thread discussion, and the components/web workspace.

Clone this wiki locally