mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-24 18:26:11 +00:00
avoid cold first spike
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -273,7 +275,7 @@ class RTCInferenceEngine(InferenceEngine):
|
||||
idx_before = queue.get_action_index()
|
||||
prev_actions = queue.get_left_over()
|
||||
|
||||
latency = latency_tracker.max()
|
||||
latency = latency_tracker.p95()
|
||||
delay = math.ceil(latency / time_per_chunk) if latency else 0
|
||||
|
||||
obs_batch = build_dataset_frame(self._hw_features, obs, prefix="observation")
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user