How goabiaryan/relayserve works
RelayServe is an adaptive LLM inference server. The principal workflow is an OpenAI-compatible chat request entering the HTTP server, being handled by the application’s queued request processor, routed to a configured backend or through device selection to local/llama.cpp execution, and returned as a response. The application also tracks metrics, plans layer placement, and manages KV-prefix bookkeeping. README documents streaming, request IDs, and multi-backend use; HTTP-server internals and several runtime modules were not excerpted, so their links rely on the source index or README rather than direct inspection.
Main entry points: app.py Request application · router.py Backend router · http_server.py HTTP API · registry.py Device registry
Components 21
API and startup
- CLI startup
relayserve/cli.py - Runtime settings
relayserve/internal/config/settings.py - HTTP API
relayserve/internal/server/http_server.py
Request orchestration
- Request application
relayserve/internal/server/app.py - Request queue
relayserve/internal/queue/queue.py - KV cache manager
relayserve/internal/kv/manager.py - Metrics collector
relayserve/internal/metrics/collector.py
Device adaptation
- Device scheduler
relayserve/internal/scheduler/scheduler.py - Device probe
relayserve/internal/profile/probe.py - Device registry
relayserve/internal/device/registry.py - Shard planner
relayserve/internal/shard/plan.py
Inference backends
- Backend router
router.py - Backend interface
backends/backend_interface.py - Local backend
backends/local_backend.py - Modal backend
backends/modal_backend.py - vLLM backend
backends/vllm_backend.py - llama.cpp client
relayserve/internal/runner/runner.py - Device runner
relayserve/internal/runner/runner.py
Other components
- Client
- Configured inference services
- llama.cpp endpoints
Connections 30
- Client → HTTP API: sends chat
README.md - CLI startup → Runtime settings: loads settings
relayserve/cli.py - CLI startup → Request application: builds app
relayserve/cli.py - CLI startup → HTTP API: starts server
relayserve/cli.py - HTTP API → Request application: dispatches requests
relayserve/internal/server/http_server.py - Request application → Runtime settings: uses configuration
relayserve/internal/server/app.py - Request application → Request queue: enqueues requests
relayserve/internal/server/app.py - Request application → Device scheduler: selects device
relayserve/internal/server/app.py - Request application → Device probe: probes devices
relayserve/internal/server/app.py - Request application → Device registry: lists devices
relayserve/internal/server/app.py - Device probe → Device registry: creates devices
relayserve/internal/profile/probe.py - Device scheduler → Device registry: reads devices
relayserve/internal/scheduler/scheduler.py - Request application → Shard planner: plans placement
relayserve/internal/server/app.py - Shard planner → Device registry: reads devices
relayserve/internal/shard/plan.py - Request application → KV cache manager: tracks KV prefixes
relayserve/internal/server/app.py - Request application → Metrics collector: records metrics
relayserve/internal/server/app.py - Request application → Backend router: selects backend
relayserve/internal/server/app.py - Backend router → Local backend: builds backend
router.py - Backend router → Modal backend: builds backend
router.py - Backend router → vLLM backend: builds backend
router.py - Local backend → Backend interface: implements
backends/local_backend.py - Modal backend → Backend interface: implements
backends/modal_backend.py - vLLM backend → Backend interface: implements
backends/vllm_backend.py - Local backend → Configured inference services: sends inference
backends/local_backend.py - Modal backend → Configured inference services: sends inference
backends/modal_backend.py - vLLM backend → Configured inference services: sends inference
backends/vllm_backend.py - Request application → llama.cpp client: requests completion
relayserve/internal/server/app.py - Request application → Device runner: runs fallback
relayserve/internal/server/app.py - llama.cpp client → llama.cpp endpoints: sends completion
relayserve/internal/runner/runner.py - HTTP API → Client: returns response
README.md