Skip to main content

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.

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.2.tar.gz (12.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.2-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: reactor_realtime_engine-0.1.2.tar.gz
  • Upload date:
  • Size: 12.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.2.tar.gz
Algorithm Hash digest
SHA256 a528a626405c20807da0029f3af5b9cf848d80bda648b4353cd0cbb5c5ab1732
MD5 75911039d56398d6f414f595ddffaa13
BLAKE2b-256 c5bbe0f44bf8efc9b6a52e8347aaaef9b4614a6882dbd4c9fe7d72374357a6fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for reactor_realtime_engine-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d8d070294bb77d16d545285b339e6f61e1b4f5034ecb8392958eb5c6c550f182
MD5 291245b80c632a4bb845b7b77dda906c
BLAKE2b-256 387ecc6c328f3d5c402d0b35b1132c139126ee310915765c47d560aec9eb2e4e

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.1

2 files

0.2.0

2 files

This release

0.1.2 This release

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page