Files
kernbench2/docs/adr/ADR-0007-runtime-api-boundaries.md
T
2026-03-18 11:47:48 -07:00

2.3 KiB

ADR-0007: Runtime API and Simulation Engine Boundaries

Status

Accepted

Context

The simulator consists of multiple layers with distinct responsibilities:

  • a host-facing API layer used by benchmarks and user code,
  • a discrete-event simulation engine that executes requests,
  • device components that model hardware behavior.

Without strict boundaries, orchestration logic can leak into components, or simulation internals can become entangled with user-facing APIs.

This ADR defines clear responsibility boundaries between:

  • runtime API,
  • simulation engine (sim_engine),
  • hardware components.

Decision

D1. Runtime API is host-facing orchestration only

The runtime API represents host/driver-level behavior and MUST:

  • expose high-level operations (tensor deployment, kernel launch),
  • submit requests only to endpoint components (e.g., IO_CPU),
  • await completion via futures/handles,
  • own and persist host-side metadata (tensor allocation maps, kernel bindings).

The runtime API MUST NOT:

  • hardcode hop-by-hop routing or fan-out,
  • directly invoke internal components (M_CPU, PE_CPU, engines),
  • embed topology- or routing-specific assumptions.

D2. Simulation engine executes and schedules requests

The simulation engine (sim_engine) MUST:

  • inject requests into the compiled topology graph,
  • schedule and execute events using a discrete-event model,
  • manage correlation ids and completion tracking,
  • decompose operations into low-level requests when required (e.g., MemoryWrite events).

The simulation engine MUST NOT:

  • define tensor semantics,
  • define kernel execution policies,
  • expose internal graph details to the runtime API.

D3. Components own fan-out and aggregation

Device-side components MUST:

  • fan-out requests to downstream domains (IO_CPU → M_CPU → PE_CPU → schedulers/engines),
  • aggregate completion and failure signals,
  • propagate results deterministically upstream.

Neither the runtime API nor the simulation engine may orchestrate component-level fan-out explicitly.


Consequences

  • Runtime APIs remain stable as topology and routing evolve.
  • Simulation internals can change without affecting user-facing code.
  • Component implementations remain swappable via DI.

  • SPEC R4, R7, R8
  • ADR-0008 (Tensor deployment)
  • ADR-0009 (Kernel execution)