Pedro Mariano / portfolio

Grid Protocol

An AI model that does not fit on one consumer graphics card, running across several ordinary PCs. A control plane in Go decides which machine may join, checks that it stays honest, and places parts of the model on each one. Then I measured whether the network kills the idea.

~0.5–1 msper network hop between two PCs on wired Gigabit
10.4 GBmodel served from an 8 GB card plus a second PC
6 checksbefore any machine is admitted, failing closed
~12k linesof hand-written Go, tests included, all suites passing

The problem

Good models outgrow the graphics cards people own.

Open models worth using are often larger than the 8–12 GB of memory on a consumer GPU, while many PCs sit idle. The idea: split one model across several home machines, so their combined memory serves it.

Two constraints shape everything. Home PCs sit behind routers that refuse incoming connections (often symmetric NAT), so the coordinator can never call a machine; the machine has to call in. And any machine could lie, crash or be impersonated, so nothing is trusted until it proves who it is, and it keeps proving it.

Verifying the machines

Every machine earns its place, and keeps earning it.

  1. Machine dials outEach node opens one persistent, bidirectional gRPC stream to the Go orchestrator. All control traffic travels over it, which works behind home routers.
  2. Server speaks firstThe orchestrator sends a single-use 32-byte random challenge. The node signs a fixed-length transcript bound to that challenge with its ed25519 key, so a recorded handshake can never be replayed.
  3. Six checks, fail closedRate limit per IP, a deadline for the reply (against slow-connection attacks), minimum protocol version, field structure, clock skew and finally the signature. Only a node that passes all six is registered.
  4. Live registryAdmitted nodes go into Redis with a time-to-live and an index of the models they can serve. Heartbeats refresh the record through a compare-and-set script, so if the same node connects twice the newest session wins and the old one is fenced off. A silent node simply expires.
  5. Verified model filesModel shards are content-addressed: a node refuses any file without a pre-agreed SHA-256 digest, rejects mismatches, and caps the decompressed size against compression bombs.
  6. Secret-shopper checksA small share of jobs (2% by default) is replaced by a question with a known answer. A node that gets it wrong is flagged, without knowing which jobs were tests.

Splitting the model

A router that knows how far it can stretch.

The router in Go assigns model shards to live nodes with consistent hashing (virtual nodes, filtered by which model each node can serve, and grouped by local network). When a node leaves, only its shards move.

Adding machines is not free: every extra node adds a network hop per generated token. So admission follows a measured rule rather than "more is better":

max nodes ≈ (1 / target tokens per second − compute per token) / per-hop latency + 1

Nodes are grouped in tiers by usable graphics memory, and the per-hop latency comes from the measurements below, not from a guess.

Measured results

The network was not the bottleneck.

Two PCs on the same wired Gigabit network: the main machine with an RTX 5060 (8 GB), and a laptop whose GPU could not run the build, used as a CPU-only worker. Latency was timed over TCP with a loopback baseline subtracted, 300 paced samples over 60 seconds.

Network, head to worker (July 2026)Result
Measurement overhead (loopback median)0.33 ms
Warm connection, minimum0.60 ms
Paced: median / p95 / p991.64 / 4.3 / 7.2 ms
Estimated real round trip per hop~0.5–1 ms
Drift across the minutenone
Running models across both PCsSpeed
OLMoE 1B-7B, main GPU only164 tokens/s
OLMoE split: main GPU + laptop CPU51 tokens/s
DeepSeek-V2-Lite 10.4 GB, short warm replies~16 tokens/s
Same model, long 14-turn chatfalls to 2–4 tokens/s

The split ran end to end with coherent answers and no crashes across a 14-turn stress test.

What the numbers mean

  • The slowdown is compute, not network. Per token, the laptop CPU took about 15 ms for its layers against 3–6 ms of network. A GPU worker removes the straggler.
  • Long conversations hurt CPU workers. Attention grows with the context, and a CPU is poor at it. Weak machines add capacity; the fast path needs GPUs, so the scheduler has to tier nodes.
  • A free win: loading without memory-mapping cut the main machine's model process from 10.94 GB to 0.54 GB of RAM, with no loss of speed.
  • Setup matters: wired Ethernet only, and a high-performance power plan. Idle power states added 6–10 ms spikes.

How it was built

Specification first, then a review against it.

The handshake has a byte-level specification that the Go verifier and the Rust node must match exactly. After the first build I ran an internal security review and fixed every finding that touched the control plane: fail-closed defaults for public binds, mutual TLS between orchestrators, size caps and mandatory digests on downloads, and owner-only permissions on the node's key file. Both Go modules pass their test suites, including the race detector.

Still open: these are LAN results. Performance across the internet, between homes, is a separate question I have not measured yet.

Built with

  • Go
  • gRPC / Protocol Buffers
  • Redis (Lua scripts)
  • ed25519
  • Rust
  • llama.cpp (RPC)
  • Docker

The code is private for now; I am happy to walk through it in an interview.