mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-30 13:09:40 +00:00
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.
This commit is contained in:
@@ -45,7 +45,6 @@ from ..g1_utils import (
|
|||||||
compute_pd_gains,
|
compute_pd_gains,
|
||||||
get_gravity_orientation,
|
get_gravity_orientation,
|
||||||
lowstate_to_obs,
|
lowstate_to_obs,
|
||||||
make_ort_session_options,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -296,7 +295,8 @@ class SonicRuntime:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
decoder_path = hf_hub_download(repo_id="nvidia/GEAR-SONIC", filename="model_decoder.onnx")
|
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)
|
decoder_sess = ort.InferenceSession(decoder_path, sess_options=so)
|
||||||
|
|
||||||
self.kp, self.kd = compute_kp_kd()
|
self.kp, self.kd = compute_kp_kd()
|
||||||
|
|||||||
@@ -143,24 +143,6 @@ def compute_pd_gains(motor_models, double_indices=()) -> tuple[np.ndarray, np.nd
|
|||||||
return kp, kd
|
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):
|
class G1_29_JointArmIndex(IntEnum):
|
||||||
# Left arm
|
# Left arm
|
||||||
kLeftShoulderPitch = 15
|
kLeftShoulderPitch = 15
|
||||||
|
|||||||
Reference in New Issue
Block a user