From 16b915ede5af7c808d8588eefd1ee7dde7419b67 Mon Sep 17 00:00:00 2001 From: Martino Russi Date: Thu, 30 Jul 2026 11:49:48 +0200 Subject: [PATCH] refactor(unitree_g1): drop make_ort_session_options from SONIC branch The ORT SessionOptions helper (thread-pool cap) is being split into its own "ORT fix" PR. SONIC only needs quiet logs, so inline a minimal SessionOptions in the decoder instead of depending on the shared helper. --- .../unitree_g1/controllers/sonic_whole_body.py | 4 ++-- src/lerobot/robots/unitree_g1/g1_utils.py | 18 ------------------ 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/src/lerobot/robots/unitree_g1/controllers/sonic_whole_body.py b/src/lerobot/robots/unitree_g1/controllers/sonic_whole_body.py index 968456f03..d539ff350 100644 --- a/src/lerobot/robots/unitree_g1/controllers/sonic_whole_body.py +++ b/src/lerobot/robots/unitree_g1/controllers/sonic_whole_body.py @@ -45,7 +45,6 @@ from ..g1_utils import ( compute_pd_gains, get_gravity_orientation, lowstate_to_obs, - make_ort_session_options, ) logger = logging.getLogger(__name__) @@ -296,7 +295,8 @@ class SonicRuntime: def __init__(self): decoder_path = hf_hub_download(repo_id="nvidia/GEAR-SONIC", filename="model_decoder.onnx") - so = make_ort_session_options() + so = ort.SessionOptions() + so.log_severity_level = 3 # quiet ORT logs decoder_sess = ort.InferenceSession(decoder_path, sess_options=so) self.kp, self.kd = compute_kp_kd() diff --git a/src/lerobot/robots/unitree_g1/g1_utils.py b/src/lerobot/robots/unitree_g1/g1_utils.py index 414cdf416..138a52b47 100644 --- a/src/lerobot/robots/unitree_g1/g1_utils.py +++ b/src/lerobot/robots/unitree_g1/g1_utils.py @@ -143,24 +143,6 @@ def compute_pd_gains(motor_models, double_indices=()) -> tuple[np.ndarray, np.nd return kp, kd -def make_ort_session_options(intra_op_num_threads: int | None = None, inter_op_num_threads: int | None = None): - """Build quiet ONNX Runtime SessionOptions, optionally capping the CPU thread pool. - - These tiny MLP policies are latency-bound, not throughput-bound, so letting ORT grab - every core starves the real-time control loop / torch policy and causes stutter. Pass - 1 intra + 1 inter thread for lowest-latency per-step inference. - """ - import onnxruntime as ort - - so = ort.SessionOptions() - so.log_severity_level = 3 - if intra_op_num_threads is not None: - so.intra_op_num_threads = intra_op_num_threads - if inter_op_num_threads is not None: - so.inter_op_num_threads = inter_op_num_threads - return so - - class G1_29_JointArmIndex(IntEnum): # Left arm kLeftShoulderPitch = 15