@@ -1568,8 +1568,7 @@ def set_state(self, f, state, envs_idx=None, *, partial: bool = False) -> None:
15681568 mass_dst [envs_idx ] = state .mass_shift [envs_idx ]
15691569 if self .n_geoms :
15701570 fric_dst [envs_idx ] = state .friction_ratio [envs_idx ]
1571- if gs .backend == gs .metal :
1572- torch .mps .synchronize ()
1571+
15731572 else :
15741573 envs_idx = self ._scene ._sanitize_envs_idx (envs_idx )
15751574 kernel_set_zero (envs_idx , self ._errno )
@@ -1696,8 +1695,7 @@ def set_base_links_pos(self, pos, links_idx=None, envs_idx=None, *, relative=Fal
16961695 target = data [:, link .q_start : link .q_start + 3 ]
16971696 pos = broadcast_tensor (pos , gs .tc_float , target .shape )
16981697 torch .where (envs_idx [:, None ], pos , target , out = target )
1699- if gs .backend == gs .metal :
1700- torch .mps .synchronize ()
1698+
17011699 else :
17021700 pos , links_idx , envs_idx = self ._sanitize_io_variables (
17031701 pos , links_idx , self .n_links , "links_idx" , envs_idx , (3 ,), skip_allocation = True
@@ -1795,8 +1793,7 @@ def set_base_links_quat(self, quat, links_idx=None, envs_idx=None, *, relative=F
17951793 target = data [:, link .q_start + 3 : link .q_start + 7 ]
17961794 quat = broadcast_tensor (quat , gs .tc_float , target .shape )
17971795 torch .where (envs_idx [:, None ], quat , target , out = target )
1798- if gs .backend == gs .metal :
1799- torch .mps .synchronize ()
1796+
18001797 else :
18011798 quat , links_idx , envs_idx = self ._sanitize_io_variables (
18021799 quat , links_idx , self .n_links , "links_idx" , envs_idx , (4 ,), skip_allocation = True
@@ -1915,8 +1912,7 @@ def set_links_inertia(self, ratio, links_idx=None, envs_idx=None):
19151912 assign_indexed_tensor (mass_data , mask , mass_data [mask ] * ratio_t )
19161913 assign_indexed_tensor (inertial_i_data , mask , inertial_i_data [mask ] * ratio_t [..., None , None ])
19171914 assign_indexed_tensor (invweight_data , mask , invweight_data [mask ] / ratio_t [..., None ])
1918- if gs .backend == gs .metal :
1919- torch .mps .synchronize ()
1915+
19201916 return
19211917
19221918 ratio , links_idx , envs_idx = self ._sanitize_io_variables (
@@ -1971,8 +1967,7 @@ def set_qpos(self, qpos, qs_idx=None, envs_idx=None, *, skip_forward=False):
19711967 errno [envs_idx ] = 0
19721968 if mask and isinstance (mask [0 ], torch .Tensor ):
19731969 envs_idx = mask [0 ].reshape ((- 1 ,))
1974- if gs .backend == gs .metal :
1975- torch .mps .synchronize ()
1970+
19761971 else :
19771972 qpos , qs_idx , envs_idx = self ._sanitize_io_variables (
19781973 qpos , qs_idx , self .n_qs , "qs_idx" , envs_idx , skip_allocation = True
@@ -2116,8 +2111,7 @@ def _set_dofs_info(self, tensor_list, dofs_idx, name, envs_idx=None):
21162111 num_values = len (tensor_list )
21172112 for j , mask_j in enumerate (((* mask , ..., j ) for j in range (num_values )) if num_values > 1 else (mask ,)):
21182113 assign_indexed_tensor (data , mask_j , tensor_list [j ])
2119- if gs .backend == gs .metal :
2120- torch .mps .synchronize ()
2114+
21212115 return
21222116
21232117 tensor_list = list (tensor_list )
@@ -2219,8 +2213,7 @@ def set_dofs_position(self, position, dofs_idx=None, envs_idx=None):
22192213 if gs .use_zerocopy :
22202214 errno = qd_to_torch (self ._errno , copy = False )
22212215 errno [envs_idx ] = 0
2222- if gs .backend == gs .metal :
2223- torch .mps .synchronize ()
2216+
22242217 else :
22252218 kernel_set_zero (envs_idx , self ._errno )
22262219
@@ -2248,8 +2241,7 @@ def control_dofs_force(self, force, dofs_idx=None, envs_idx=None):
22482241 ctrl_mode [mask ] = gs .CTRL_MODE .FORCE
22492242 ctrl_force = qd_to_torch (self .dofs_state .ctrl_force , transpose = True , copy = False )
22502243 assign_indexed_tensor (ctrl_force , mask , force )
2251- if gs .backend == gs .metal :
2252- torch .mps .synchronize ()
2244+
22532245 return
22542246
22552247 force , dofs_idx , envs_idx = self ._sanitize_io_variables (
@@ -2269,8 +2261,7 @@ def control_dofs_velocity(self, velocity, dofs_idx=None, envs_idx=None):
22692261 ctrl_pos [mask ] = 0.0
22702262 ctrl_vel = qd_to_torch (self .dofs_state .ctrl_vel , transpose = True , copy = False )
22712263 assign_indexed_tensor (ctrl_vel , mask , velocity )
2272- if gs .backend == gs .metal :
2273- torch .mps .synchronize ()
2264+
22742265 return
22752266
22762267 velocity , dofs_idx , envs_idx = self ._sanitize_io_variables (
@@ -2290,8 +2281,7 @@ def control_dofs_position(self, position, dofs_idx=None, envs_idx=None):
22902281 assign_indexed_tensor (ctrl_pos , mask , position )
22912282 ctrl_vel = qd_to_torch (self .dofs_state .ctrl_vel , transpose = True , copy = False )
22922283 ctrl_vel [mask ] = 0.0
2293- if gs .backend == gs .metal :
2294- torch .mps .synchronize ()
2284+
22952285 return
22962286
22972287 position , dofs_idx , envs_idx = self ._sanitize_io_variables (
@@ -2311,8 +2301,7 @@ def control_dofs_position_velocity(self, position, velocity, dofs_idx=None, envs
23112301 assign_indexed_tensor (ctrl_pos , mask , position )
23122302 ctrl_vel = qd_to_torch (self .dofs_state .ctrl_vel , transpose = True , copy = False )
23132303 assign_indexed_tensor (ctrl_vel , mask , velocity )
2314- if gs .backend == gs .metal :
2315- torch .mps .synchronize ()
2304+
23162305 return
23172306
23182307 position , dofs_idx , _ = self ._sanitize_io_variables (
@@ -2648,8 +2637,7 @@ def clear_external_force(self):
26482637 for tensor in (self .links_state .cfrc_applied_ang , self .links_state .cfrc_applied_vel ):
26492638 out = qd_to_torch (tensor , copy = False )
26502639 out .zero_ ()
2651- if gs .backend == gs .metal :
2652- torch .mps .synchronize ()
2640+
26532641 return
26542642
26552643 kernel_clear_external_force (self .links_state , self ._rigid_global_info , self ._static_rigid_sim_config )
0 commit comments