Computation Placement¶
Research question¶
Where should inference run — on the vehicle (edge), in a roadside unit, or in the cloud — and how does placement affect latency and energy under different network conditions?
Layers involved¶
Data Source — any source (CARLA, replay, synthetic)
Processing Core — model registry;
deviceassignment per nodeNetWaggle — link between client and server
Analysis — frame latency, queue depth (
metrics.collectors: [queue])
What to configure¶
Assign a device to each node. The model registry maps logical model names to per-device artifact paths. The braking experiment shows the full structure:
examples/braking/flat/atspeed_braking.yaml¶# At-speed emergency-braking experiment.
#
# What this is: the ego is spawned already below the speed-kick gate (the
# scenario places it at y=85) so it is travelling when the obstacle comes into
# view, which is the case the open-loop config cannot produce. A static obstacle
# sits ahead; the ego streams camera frames to the detection server and brakes on
# command. Used to compare link backends on an identical closed-loop scenario.
#
# How to use (the backend is chosen per run, the experiment is not):
# cadet run examples/braking/flat/atspeed_braking.yaml --app-module examples.braking.flat.app \
# --set links.0.network.mode=delay --model-dir <DIR>
# cadet emulate examples/braking/flat/atspeed_braking.yaml --app-module examples.braking.flat.app \
# --set links.0.network.mode=netwaggle --model-dir <DIR>
#
# No simulator address to pass: this config launches its own server and reaches
# it on the loopback. CADET_SCENARIO_RUNNER_DIR and CADET_CARLA_PYTHONAPI_DIR
# say where this machine keeps the two trees the scenario container mounts.
#
# The simulator address is reached off-link (over each emulated host's bypass
# interface under netwaggle), so it is passed at run time and never committed.
extends: ../../../configs/base.yaml
experiment:
name: atspeed_braking
app: braking
repetitions: 3 # the parity convention for this scenario
seed: 0
# What ends a run, stated rather than left to whichever process exits first.
#
# client_report is what the original orchestrator did, and its code says so
# plainly: it launched the client with wait=True (in the foreground), printed
# the final client report the moment the client returned, and only then sent
# ScenarioRunner a SIGTERM. It never waited on the scenario process at all.
# Measured here too - ScenarioRunner is still running when the client
# finishes, and the "All scenario tests were passed successfully!" line in its
# log is printed while it handles that teardown signal, not because the
# behaviour tree completed.
#
# Ending on the sim hook would also cut this scenario short: the behaviour
# tree finishes when the ego has driven 100 m, while the run's point is the
# braking that happens well before then.
end_on: client_report
# The two phase limits. Stated here because this is the example where they
# differ most: the server spends about ten seconds loading yolo11x before the
# client sends its first frame, so one limit over both phases would mostly be
# a limit on that load, and would mean something different on other hardware.
max_startup_s: 240.0 # 60 s for the server's listening line + 180 s for the
# scenario's readiness marker; the same as the default
# sum, written out so it is visible.
max_active_s: 120.0 # the streaming-and-braking phase
# The simulator side this experiment owns. Declaring the pieces together is the
# point: a CARLA server, the client egg that talks to it and a ScenarioRunner
# tree have to match, and a mismatch never announces itself as one - it arrives
# as an import error, or as a scenario that loads and behaves differently.
# Preflight refuses the run on any disagreement.
#
# The paths are the deployment image's own conventions, not a machine's: the
# image mounts the CARLA PythonAPI at /opt/carla and ScenarioRunner at
# /opt/scenario_runner.
source:
kind: carla
fps: 10
camera:
# Matches the open-loop client: 800x600 sensor at 60 deg FOV.
width: 800
height: 600
fov: 60.0
scenario:
map: Town05 # AtSpeed.xml declares Town05
# What the scenario driver is told to run. Naming it here is what lets the
# framework build the original'"'"'s scenario command itself (--reloadWorld,
# --timeout 10000, --output, and the simulator address) instead of taking
# the whole command from the environment; see cadet.sim.scenario_command.
name: AtSpeedBraking_1
definition: examples/braking/flat/scenarios/at_speed_braking_scenario.py
config_file: examples/braking/flat/scenarios/AtSpeed.xml
# The braking app has a tuned brake controller per ego; audi.tt is the one
# the open-loop matrix uses as its first axis value. The scenario spawns the
# ego the sim hook names, so the XML's own model attribute is not used.
ego_vehicle: audi.tt
target_object: car
# Default = the original's 40mph (1:1 rule). The original client's throttle
# targets 40mph and overrides the scenario's KeepVelocity(10 m/s), so the ego
# approaches at ~36 mph. Override to 36kph to instead agree with KeepVelocity
ego_speed: 40mph
runner:
path: /opt/scenario_runner
# The scenario driver runs in a container from this image, which
# carries ScenarioRunner's pinned dependencies; the tree above is
# mounted into it. Built by docker/Dockerfile (INSTALL_SIM=1).
image: cadet:dev
source_digest: 27dae4b3e9d3aff5
weather: clear
carla:
image: carlasim/carla:0.9.10.1
gpu_index: 1 # the simulator owns GPU 1; the detector has GPU 0
quality: Low
offscreen: true
client_egg:
name: carla-0.9.10-py3.7-linux-x86_64.egg
port: 2000
timeout: 10
models:
# The original braking scripts ran without model warm-up; set true to warm
# the model.
warmup: false
detector: yolo
tracker: sort
predictor: linear
model: yolo11x
registry:
yolo11x:
per_device:
gpu: yolo11x.pt
edge: yolo11x.engine
hailo: yolo11x.hef
coco_labels:
per_device:
gpu: coco.names
edge: coco.names
hailo: coco.names
nodes:
- name: client
host: localhost
launcher: local
role: client
device: cpu
- name: server
host: localhost
port: 10100
launcher: local
role: server
device: gpu
gpu_index: 0 # detector on GPU 0; the simulator owns GPU 1
# The original server's fixed per-request cost. Compute, not network.
extra_processing_ms: 13.0
channels:
- name: frames
from: client
to: server
max_queue: 2
send_meta: false
stop_on_brake: true
links:
# A real network path: p50 30 ms, p99 100 ms. Log-normal is the family that
# fits a latency - strictly positive with a long tail - and its parameters
# here are those percentiles as the link states them: p50_ms is the median
# and p99_ms is the tail, from which sigma = ln(p99/p50) / 2.3263 = 0.5176.
#
# Only `mode: delay` reproduces this exactly; it samples the distribution per
# message. The kernel backends (netem, netwaggle) delay packets with a single
# netem, whose jitter is a *uniform* half-width about the delay, so they
# cannot render a spread this wide - a p99 of 100 ms on a 30 ms p50 would need
# a jitter larger than the delay, whose low side netem clamps to zero and
# moves the p50. They refuse it and say so. To run this scenario under a
# kernel backend, override the link with a spread it can hold, e.g.
# --set links.0.network.distribution.p99_ms=55.0 # a shorter tail
# --set links.0.network.bandwidth_mbps=100
# A bandwidth is required for any jittered kernel link: it is what serialises
# netem's output and keeps the flow in order.
- name: frames_link
from: client
to: server
direction: forward
network:
mode: delay # overridden per run on the command line
distribution:
kind: lognormal
p50_ms: 30.0 # the median
p99_ms: 100.0 # the tail; sigma = ln(p99/p50) / 2.3263 = 0.5176
loss: 0.0
app:
plugin: braking
# outputs / transport / metrics inherited from configs/base.yaml.
Key fields:
nodes[*].device— device type (cpu,edge,gpu)nodes[*].gpu_index— explicit CUDA device indexmodels.registry.<key>.per_device.<device>— path to the artifact for each device type (e.g..ptfor gpu,.enginefor edge)
To sweep over link delay values:
docs/snippets/sweep-link-delay.yaml¶# Sweep example: constant delay values. Generates 4 run configs.
# Use as a template; replace with lognormal or netem fields as needed.
# Passes cadet validate.
extends: ../../configs/base.yaml
experiment: {name: snippet_sweep_delay, app: reference, repetitions: 1}
source: {kind: synthetic, count: 8, width: 64, height: 48}
nodes:
- {name: client, host: localhost, role: client, device: cpu}
- {name: server, host: 127.0.0.1, port: 15016, role: server, device: cpu}
links:
- name: inference_link
from: client
to: server
network:
mode: delay
distribution:
kind: constant
value_ms: 20.0
loss: 0.0
sweep:
axes:
links[0].network.distribution.value_ms: [10, 20, 40, 80]
app: {plugin: reference, params: {model_kind: stub}}
How to run¶
cadet run examples/braking/flat/atspeed_braking.yaml \
--set source.carla.host=$(hostname -I | awk '{print $1}') \
--app-module examples.braking.flat.app
For a sweep:
cadet sweep examples/braking/flat/atspeed_braking.yaml \
--set source.carla.host=$(hostname -I | awk '{print $1}') \
--app-module examples.braking.flat.app
Docker node isolation: set launcher: docker on a node to run it in its
own container on a per-run network. The ssh_docker launcher extends this
to a remote host.
Where results land¶
outputs/{experiment}/{app}/{run_id}/:
{run_id}_latency_location_log.csv— per-frame latency; thelocationcolumn records which node executed inferencerun.json— includes the resolved node and model configQueue collector output (if
metrics.collectors: [queue]is set)
How to extend¶
Add a second processing tier: add a node, wire a link from the first server to the second, and route frames in your app plugin.
Enable the queue collector: add
metrics.collectors: [queue]to your experiment config.
See also¶
Tutorial 4: Multi-Device Deployment — multi-device setup
Register per-device model artifacts — wiring model artifacts
Processing Core Layer — pipeline architecture
Analysis Layer — orchestrator and metrics