Skip to main content

Standalone realtime inference engine: the RealtimeInterface contract, default scheduling loop, and a CPU reference engine, with no runtime dependency

Project description

realtime_engine — the engine, built in isolation

A standalone realtime inference engine with zero reactor_runtime dependency. It's driven entirely through inbox/outbox queues, so any caller matching the contract can run it — the Reactor runtime is wired in later as one such caller.

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 (no runtime) 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.0.tar.gz (10.6 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.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for reactor_realtime_engine-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d0803ed6f7565a9ac5b14c77f909926dea970625356210bdca2cd99bdeb65b3e
MD5 2025312e60a78b056d32ea47d0e55021
BLAKE2b-256 d66ac4a0369ab4a9b49e99b0b03b1a28d8b489fb5c0ccc587121f878b6b1f588

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for reactor_realtime_engine-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae7f54ca1d5a54d49ab43f071fbfa4cabf78e3b7526f9055d2436801e1d86699
MD5 6428c0ea1292759dd38858a49bf25842
BLAKE2b-256 8ce40f202abe27a8536da049ea049f2a8c3d8cb8a7e0159deda2657e5191b093

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