Skip to content

[beta] Decentralized sharded WebGPU compute pool - #4

Open
ThyFriendlyFox wants to merge 3 commits into
mainfrom
cursor/webgpu-compute-pool-beta-b76d
Open

[beta] Decentralized sharded WebGPU compute pool#4
ThyFriendlyFox wants to merge 3 commits into
mainfrom
cursor/webgpu-compute-pool-beta-b76d

Conversation

@ThyFriendlyFox

Copy link
Copy Markdown
Collaborator

Summary

A beta scaffold for a decentralized, sharded WebGPU compute pool: many browser GPUs cooperating to run inference-style workloads, contributed voluntarily to form a shared pool. Off by default behind a feature flag and fully isolated from the existing app.

How it works

Large-model inference is dominated by big matrix multiplies (the core transformer-layer op). The pool splits each matmul into row-block shards and spreads them across every participating GPU, then reassembles the result. Each node is both a worker (computes shards for others) and a requester (dispatches its own jobs).

coordinator (signaling/membership only — never sees shard data)
        ▲                          ▲
   join/SDP/ICE                join/SDP/ICE
   Node A  ◀──── shards over WebRTC datachannel ────▶  Node B
   ComputePool: webgpu · ShardScheduler · PeerLink

What's included (src/compute/)

File Role
webgpu.ts Real WGSL matmul kernel, GPU capability probe, benchmark
ShardScheduler.ts Pure split / build / merge + weighted work-stealing
signaling.ts WebSocket client to the coordinator
peer.ts PeerLink — a peer as a remote Worker over RTCDataChannel
ComputePool.ts Orchestrates GPU + peers; runSharded() / runDemo()
ComputePoolView.ts Beta control panel (status, demo run, per-shard log)
types.ts Task/result/signaling/peer protocol types

Plus compute-coordinator/ — a tiny reference signaling/membership broker (relays WebRTC handshakes only; shard payloads go peer-to-peer).

Enabling

VITE_ENABLE_COMPUTE_POOL=true
VITE_COMPUTE_COORDINATOR_URL=ws://localhost:8787   # optional; omit for solo
VITE_COMPUTE_POOL_ID=mouse-public-beta

A ⚡ launcher then opens the panel. With no coordinator the pool runs as a single node ("solo") and still demonstrates the full shard → compute → merge pipeline on one GPU.

Testing

  • npm run build (tsc + vite) passes; the compute module is isolated and the app is unchanged when the flag is off.
  • Verified the reference coordinator end-to-end over WebSockets: join, peer list, peer_joined, signal relay, and peer_left all pass.
  • The WebGPU kernel and peer datachannel paths require a real browser GPU / ≥2 nodes to exercise live; the solo shard pipeline is the tested-by-construction path.

Beta limitations (see src/compute/README.md)

  • Job primitive is a dense f32 matmul; mapping real model weights/layers on top is future work.
  • Non-tiled kernel (correct, not yet throughput-tuned).
  • No peer result verification/reputation, weight encryption, or anti-abuse — all required before any real public "free inference" deployment.

Note: native iOS sim build (npm run cap:ios:sim) not run here (no Xcode on this Linux VM). WebGPU/WebRTC availability also varies by platform/WebView.

Open in Web Open in Cursor 

cursoragent and others added 3 commits June 23, 2026 21:43
…, pool + beta panel

Co-authored-by: ThyFriendlyFox <thyfriendlyfox@gmail.com>
Co-authored-by: ThyFriendlyFox <thyfriendlyfox@gmail.com>
Co-authored-by: ThyFriendlyFox <thyfriendlyfox@gmail.com>
@ThyFriendlyFox
ThyFriendlyFox marked this pull request as ready for review June 23, 2026 22:06
ThyFriendlyFox added a commit that referenced this pull request Jul 31, 2026
AGENTS.md requires mirroring iOS feature work into kotlin/ or recording why
not. Phases T (terminal screen), F (package manager) and G (the Node layer)
are iOS-only, and until now that was a silent gap in the contract.

Measured rather than guessed, so the record is decision-shaped:

- T and F are portable work, not blocked work: TerminalScreen (27 KB) and
  PackageManager (32 KB) are pure logic over Foundation, HTTP and zlib, all
  of which Android has, and the pyte/pnpm/semver corpora transfer as the
  Android harness.
- G splits 72 % engine-agnostic JS bootstrap (165 KB, ports verbatim) to
  28 % host bridge (65 KB of Swift). Android has no public JavaScriptCore,
  but @JavascriptInterface gives JS synchronous calls into Kotlin — the
  direction require()/readFileSync/execSync need — so parity is feasible
  without a third-party engine and without breaking invariant #4. The
  reverse direction is async, which only reshapes the event loop.

Android build re-verified green (gradlew assembleDebug).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

2 participants