Skip to content

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MORPHIC CANVAS

The page is the model. Your cursor is the gradient.

A zero-dependency, self-improving WebGPU substrate: one storage buffer is the model, the memory, the world, and the render target. One compute pass does forward projection, the analytical gradient step, EMA momentum, and a per-cell Lamport clock. One fragment pass draws the same buffer. No backend, no framework, no separate training loop.

Open index.html, move your mouse, watch the field learn you.

The irreducible kernel

Each cell holds four floats — ctx (active parameter), tgt (EMA shadow, stop-gradient), res (quantization residual), clk (Lamport clock). Every pass:

field = (L + R + U + D) * 0.25          # neighbor consensus
touch = exp(-dist²(mouse) * 60) * 2.5   # your cursor is the input
grad  = (ctx - tgt) * (field + touch)   # the error IS the gradient
ctx   = clamp(ctx - lr*grad + diffusion*(field - ctx), -127, 0)
tgt   = momentum*tgt + (1-momentum)*ctx # EMA tracking, no optimizer state
clk   = clk + 1
pixel = f(ctx, tgt)                     # the fragment shader reads the model

Because tgt is a low-pass shadow of ctx, the prediction error is the exact analytical gradient — no chain rule, no backward graph. That's the whole engine.

The three things this file demonstrates

  1. The training loop has no code. Forward, loss, gradient, update, momentum, clock — four lines inside the compute shader.
  2. The renderer and the model are the same buffer. The fragment shader reads the exact addresses the compute pass just wrote. No readback, no upload, no intermediate representation.
  3. The clock is data. Cells merge by the causal join-semilattice rule from the substrate spec: remote wins on a higher per-cell Lamport clock, or on a tie with a higher node id. Associative, commutative, idempotent — converges with no server, no protocol, and the winner is always one writer's ACTUAL state (no synthetic blends). Equal clocks alone merge nothing; see tests/test_substrate.js.

Files

path what
index.html the page (HUD + canvas)
src/substrate.js the spec: CPU reference implementation, runnable anywhere
src/driver.js WebGPU driver (fused pass) + honest 2D-canvas CPU fallback
tests/test_substrate.js headless law tests — node tests/test_substrate.js

substrate.js is the spec; the WGSL in driver.js is its projection onto the GPU. Where they disagree, substrate.js wins — it's the one we can execute and assert against. Reference tests (5/5): determinism, clamp invariant, clock monotonicity, commutative merge, learning-is-real (treated vs control divergence localizes at the signal).

Regime map — node experiments/reynolds.js

Measured answer to "where is the laminar→turbulent boundary?": there isn't one in the control parameter. The diffusion sweep is smooth everywhere. The boundary is in time: every run passes through a pattern-rich transient (15–24 distinguishable levels at instrument resolution 1e-3, the burn imprint + germination noise) and forgets it by t≈300 at every diffusion setting — saturated class count is 1.

What survives is the mutual orbit: mean|ctx−tgt| is pumped by the sign-flipped far field (anti-damping ≈ lr·|field|, measured growth matches theory) and pinned at e* ≈ 0.258–0.259 across a 20× range of diffusion. Two values iterating off one another at a constant, resolvable separation. Laminar in x-y space, turbulent in the Φ–Θ plane — which regime you report depends on which instrument you point at the field. tests/test_reynolds.js pins all five laws.

Honest limits (we don't claim)

  • Not a halting-problem solution; the clock is a divergence detector.
  • Not cryptography; signatures are checksums for anomaly filters.
  • The CPU fallback is the same law at smaller scale, labeled as such.
  • The EMA-shadow gradient is exact for this loss shape, not a universal backprop replacement.

Roadmap (per the crux)

  • V0 — this file. Pointer trains. Field morphs. Sub-ms GPU step.
  • V1 — agent bridge. window.morphic.getState()/inject() + MCP tools probe_substrate / inject_perturbation.
  • V2 — mesh. BroadcastChannel/WebRTC sync of 128-byte signatures; two tabs converge.
  • V3+ — skins & silicon. ASCII raymarch, sand/water, sonar; Verilog cell as a separate track. Ports, not the product.

Origin

Distilled from the fleet's jepa4 synthesis ("the irreducible crux") and built as the executable reference: the idea only counts if the law runs headless and the claims survive their own tests.

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages