From e0b50303aaffa7eefb732a518658e6109694c91a Mon Sep 17 00:00:00 2001 From: Maxime Ellerbach Date: Wed, 22 Jul 2026 16:40:19 +0000 Subject: [PATCH] rtc: exclude cold-start inference from latency tracker --- src/lerobot/rollout/inference/rtc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lerobot/rollout/inference/rtc.py b/src/lerobot/rollout/inference/rtc.py index 0eef62cef..3429e64d3 100644 --- a/src/lerobot/rollout/inference/rtc.py +++ b/src/lerobot/rollout/inference/rtc.py @@ -252,6 +252,8 @@ class RTCInferenceEngine(InferenceEngine): policy_device = torch.device(self._device) warmup_required = max(1, self._compile_warmup_inferences) if self._use_torch_compile else 0 + # exclude the first N inferences from the latency tracker to avoid cold-start spikes + latency_warmup_required = max(1, warmup_required) inference_count = 0 consecutive_errors = 0 @@ -316,7 +318,8 @@ class RTCInferenceEngine(InferenceEngine): inference_count += 1 consecutive_errors = 0 is_warmup = self._use_torch_compile and inference_count <= warmup_required - if is_warmup: + # Ignore the first N inferences for latency tracking to avoid cold-start spikes + if inference_count <= latency_warmup_required: latency_tracker.reset() else: latency_tracker.add(new_latency)