Skip to content

gensyn-ai/dei

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GossipSub + DRQ

Distributed Red Queen (DRQ) optimization with peer-to-peer gossip networking. Each node runs DRQ autonomously, and at the end of every round broadcasts its champion to the network via GossipSub over axl. Peers receive champions from the network and can use them as seeds for future rounds.

Architecture

┌─────────────────────────────────────────┐
│  Node                                   │
│                                         │
│  ┌───────────┐     ┌────────────────┐   │
│  │    axl    │◄───►│   gossipsub    │   │
│  │   node    │     │  (embedded in  │   │
│  │ :9002     │     │    drq.py)     │   │
│  └───────────┘     └───────┬────────┘   │
│                            │            │
│                    ┌───────▼────────┐   │
│                    │     DRQ        │   │
│                    │  optimization  │   │
│                    └───────┬────────┘   │
│                            │            │
│                    ┌───────▼────────┐   │
│                    │  LLM inference │   │
│                    │  (vLLM / MLX   │   │
│                    │   or remote)   │   │
│                    └────────────────┘   │
└─────────────────────────────────────────┘

Each node:

  1. Runs axl for encrypted P2P transport
  2. Runs DRQ with embedded GossipSub for round champion broadcast/receive
  3. Runs an LLM (local vLLM/MLX, or remote API) for warrior generation/mutation

Prep

  1. Clone axl: git clone git@github.com:gensyn-ai/axl.git axl
  2. Generate private key: openssl genpkey -algorithm ed25519 -out axl/private.pem
  3. Edit axl/node-config.json with the public nodes you want to peer with

Docker (Linux)

Build

docker build -f runtime/docker/Dockerfile -t drq-gossip .

Run — Remote inference (API model)

docker run \
  -p 9001:9001 \
  -e MODEL="claude-opus-4-6" \
  -e MODEL_URL="https://api.anthropic.com" \
  -e OPENAI_API_KEY=<api-key> \
  -e DRQ_SAVE_DIR=/outputs \
  -v $(pwd)/outputs:/outputs \
  -v $(pwd)/axl/node-config.json:/opt/axl/node-config.json:ro \
  -v $(pwd)/axl/private.pem:/opt/axl/private.pem:ro \
  drq-gossip

Run — Local inference (vLLM, requires NVIDIA GPU)

docker run --gpus all \
  -p 9001:9001 \
  -e DRQ_SAVE_DIR=/outputs \
  -v $(pwd)/outputs:/outputs \
  -v $(pwd)/inference/vllm/config.yaml:/config/vllm_config.yaml:ro \
  -v $(pwd)/axl/node-config.json:/opt/axl/node-config.json:ro \
  -v $(pwd)/axl/private.pem:/opt/axl/private.pem:ro \
  -v ~/.cache/huggingface:/root/.cache/huggingface \
  drq-gossip

The HuggingFace cache mount persists downloaded models across container restarts.

Extra DRQ arguments

docker run -e DRQ_ARGS="--n_rounds=20 --n_iters=250 --seed=42" ...

macOS (Apple Silicon)

Prerequisites

brew install go supervisor uv

Run — Remote inference (API model)

MODEL="claude-opus-4-6" \
MODEL_URL="https://api.anthropic.com" \
OPENAI_API_KEY=<api-key> \
./runtime/macos/start.sh

Run — Local inference (mlx-lm)

Edit inference/mlx/config.yaml to set your model, then:

./runtime/macos/start.sh

Extra DRQ arguments

DRQ_ARGS="--n_rounds=20 --n_iters=250 --seed=42" ./runtime/macos/start.sh

How gossip works

GossipSub is a publish/subscribe mesh protocol. Each node maintains a small mesh of peers (D=3) and uses a combination of eager push and lazy pull to propagate messages efficiently:

  • On publish: eagerly send to all mesh peers
  • On forward: eagerly send to 1 mesh peer, IHAVE (lazy announce) to the rest
  • IWANT deduplication: each message is only requested from one peer, preventing redundant fetches
  • Heartbeat: periodic mesh maintenance (graft/prune) and IHAVE gossip to non-mesh peers

This achieves ~1.05x redundancy (near theoretical minimum) with 100% delivery reliability.

DRQ integration

Round N completes
  → write round_N_champion.red to save_dir/
  → gossip.publish(champion_code) to network

Round N+1 starts
  → gossip.tick() drains incoming messages
  → received champions written to save_dir/received_champions/
      peer_<node_id>_round_<R>.red

Gossip is enabled with --gossip_enabled (on by default in both runtimes). If axl is not running, gossip disables itself gracefully and DRQ continues in local-only mode.

Running without gossip

# Docker
docker run -e DRQ_ARGS="--gossip_enabled=False" ...

# macOS
DRQ_ARGS="--gossip_enabled=False" ./runtime/macos/start.sh

Project structure

gossipsub.py              GossipSub protocol implementation
drq/
  src/drq.py              DRQ optimization driver (with embedded gossip)
  src/llm_corewar.py      LLM warrior generation and mutation
  src/corewar_util.py     Core War simulation utilities
  corewar/                Core War engine
  human_warriors/         Seed warriors
runtime/
  docker/                 Linux container (vLLM + axl + DRQ)
  macos/                  macOS supervisord (MLX + axl + DRQ)
inference/
  vllm/                   vLLM config (Linux/GPU)
  mlx/                    MLX config (macOS/Apple Silicon)
axl/                      P2P transport layer (Go binary)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors