Real-time mode¶
Real-time mode paces a simulation against the wall clock instead of running as fast as possible. It is the tool for hardware-in-the-loop and human-in-the- loop scenarios, or any demo where simulated time should track real time.
rt.run¶
rt.run is a drop-in replacement for sim.run that
synchronizes stepping on time.monotonic():
from llmsim import rt
sim = llmsim.Sim(seed=0)
# ...build the model...
rt.run(sim, until=100.0, factor=0.1) # 1 sim unit = 0.1 real seconds
factorscales simulated time to real time:factor=1.0means one simulated unit per real second;factor=0.1runs ten simulated units per real second.strict(defaultTrue) — if the run cannot keep up (an event falls more than onefactorunit of wall time behind schedule), it raisesRealtimeDriftError. Withstrict=False, bursts are allowed to hurry to catch up.
Pacing overhead itself is negligible (~0.1 µs per event); drift comes from event density above the platform's sleep granularity, overlong offload payloads, or interpreter pauses. The measured overhead and drift regimes are in the Performance overview.
Determinism is preserved¶
Real-time mode changes when events are dispatched in wall-clock terms, never
which events fire or in what order. The simulated event sequence — and its
trace — is identical to a plain sim.run; only the pacing differs. Combined
with strict compute offload, a paced run can drive real hardware
whose responses arrive within each event's real-time budget.