Skip to main content

Standalone realtime inference engine: the RealtimeInterface contract, a default scheduling loop, and a CPU reference engine — driven entirely through inbox/outbox queues

Project description

realtime_engine — a standalone realtime inference engine

A standalone realtime inference engine, driven entirely through inbox/outbox queues — so any caller matching the contract can run it.

This follows the design's build order: prove the engine on its own first (the queue boundary gives isolation now, and a path to a process/IPC split later without a process boundary today). Full design write-up lives in Notion.

Layout

Standard src/ layout: src/realtime_engine/ (package) + tests/ + pyproject.toml.

module what
contract.py RealtimeInterface (Protocol) + EngineManifest / SessionInit / StepResult / AdmissionError — Level 1: manifest/attach/step/finalize/detach
queues.py the boundary: inbox msgs (Attach/Detach/Reset/Action) + Chunk; Inbox/Outbox (asyncio.Queue wrappers)
serve.py default_serve — the Level-2 loop a Level-1 engine reuses (drain → batched step → outbox → finalize → tick; generate-from-default); run_engine picks an engine's own serve if it has one
cpu_reference.py CpuReferenceEngine — numpy-only deterministic fake (no GPU/ML); proves admission, batching, invariance, distinctness
tests/test_engine.py standalone tests that feed the inbox and drain the outbox

Develop & test

cd backend/realtime_engine
pip install -e ".[dev]"
ruff check src tests && black --check src tests && isort --check-only src tests && mypy src/realtime_engine
pytest -q

Tests cover: distinctness (co-resident sessions differ), invariance (a session is identical solo vs batched), admission (over-capacity attach raises AdmissionError), finalize, and output shape — all with the engine running standalone. Lint/type/test also run in CI (.buildkite/pipeline.yml).

Contract recap

  • Level 1 (every engine): manifest / attach / step(due) -> [StepResult] / finalize / detach. step is batched (one StepResult per due session).
  • Level 2 (the loop): optional serve(inbox, outbox). Omit it → default_serve. Implement it → own loop (e.g. an sglang-style scheduler).
  • Conditioning arriving via Action is action-class (already client→action-translated by the caller); the engine stays ignorant of client semantics.

Next (not built yet)

  • A real GPU engine impl behind the same contract (Waypoint stages on a ComposedEngine).
  • The runtime caller: a ReactorModel that pumps the inbox (state → Action) and routes the outbox into streaming.
  • Open validation item (flagged in review): measure whether the outbox queue adds latency vs a direct callback.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reactor_realtime_engine-0.1.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reactor_realtime_engine-0.1.1-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file reactor_realtime_engine-0.1.1.tar.gz.

File metadata

  • Download URL: reactor_realtime_engine-0.1.1.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for reactor_realtime_engine-0.1.1.tar.gz
Algorithm Hash digest
SHA256 401db9981b0fba9ca3278e0a552b54ea8d199a058ab9f212a39f0f88dfb69285
MD5 36ac41d5fe076df7726c3a187085a75a
BLAKE2b-256 0e5e44c6b3ffbd22b2ec933ea6b325d21947b0616f7a3312dede0cb9b7708903

See more details on using hashes here.

File details

Details for the file reactor_realtime_engine-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for reactor_realtime_engine-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d378449baa0b62037b98bde8bd20130aa900c2ed2379d3d8a3da45fd814a8467
MD5 b728c2743409dc5efdcedcfff238b5c9
BLAKE2b-256 54e351bfe1e98ebce8fe408222cf5a80430a624ecc8da81b37a57c116dbb97e3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page