Skip to main content

Overview

Introduction

Sedaro's Simulator is responsible for the high-performance execution of Sedaro Models in the cloud and at the edge. It consists of two major pieces of technology:

  • Simulation Compiler: Consumes models and produces execution artifacts
  • Simulation Runtime: Consumes execution artifacts and produces output streams

Input models, execution artifacts, and output streams are all stored in the Artifact Service.

Both the Simulation Compiler and Runtime can be invoked from the Workflow Service.

Simulation Compiler

The simulation compiler consumes as inputs:

  • SedaroML models
  • SedaroTS type annotations
  • Libraries of Rust and Python state propagators annotated with SedaroQL queries
  • Resource constraints
  • Simulator-specific configuration

The simulation compiler performs various validation checks to ensure that models are consistent, types and units are aligned, queries align with models, and simulation is feasible.

What is produced depends on the configuration provided, but may include any of:

  • Generated Rust crates and compiled dylibs/executables
  • Bytecode for generated IRs
  • Kubernetes manifests and architecture description files
  • Initial state files

Ad hoc compilation is crucial for enabling peak simulation performance. It lets us invoke compiled state propagators, reduces simulator overhead, and efficiently serialize data for network communication. The Artifact Service is leveraged to cache and reuse expensive buildtime operations. The generated code invokes the provided state propagators defined in both native Rust and Python via a Foreign Function Interface (FFI).

The simulation compiler is also capable of exporting portable executables such as EDS's (edge deployable simulators). This mode uses longer build times to produce more highly optimized executables.

Simulation Runtime

The Simulator maintains two major runtimes:

  • Cloud: For large-scale distributed execution
  • Edge: For centralized execution on resource-constrained hardware

Both runtimes produce equivalent simulation results (up to ISA discrepancies) which enables users to iterate and experiment rapidly in the cloud and then export portable edge simulators without surprises.

Execution Semantics

SedaroML models split a simulation into many asynchronous "engines", each with its own internal clock. Each engine is responsible for:

  • Initializing its internal state some initial values
  • Iteratively updating its state from some time to a future time and computing an output frame
  • Terminating once some condition is met

Asynchronous engines in a simulation usually must exchange state in order to progress. The simulator ensures that despite these highly asynchronous semantics, all simulations are deterministic: running a simulator multiple times will always produce the same results. Even a failed simulation will always raise the same exception back to the user. Distributed garbage collection enables long-running simulations without exhausting memory limits.

Features

The simulator provides some additional features, discussed briefly here:

  • Co-Simulation: Simulations can be configured to exchange state with external "co-simulators", enabling custom simulation logic, human-in-the-loop, and software/hardware-in-the-loop use cases.
  • Targets: Selected simulation outputs may be egressed as output streams via several different formats/handlers.
  • Realtime/Synctime Modes: In addition to full-speed execution, simulations may be configured to run at some fixed multiple of real time or exactly synced to real time.
  • PRNG: A given run of a simulation may be seeded for deterministic pseudorandom execution. This is especially useful when running large studies of many reproducible simulations.
  • Interpolation: State may be configured to utilize interpolation when exchanged between engines, allowing for higher simulation accuracy and/or larger time steps.